[
  {
    "path": ".gitattributes",
    "content": "# Auto detect text files and perform LF normalization\n* text=auto\n\n# Custom for Visual Studio\n*.cs     diff=csharp\n\n# Standard to msysgit\n*.doc    diff=astextplain\n*.DOC    diff=astextplain\n*.docx   diff=astextplain\n*.DOCX   diff=astextplain\n*.dot    diff=astextplain\n*.DOT    diff=astextplain\n*.pdf    diff=astextplain\n*.PDF    diff=astextplain\n*.rtf    diff=astextplain\n*.RTF    diff=astextplain\n"
  },
  {
    "path": ".gitignore",
    "content": "# Windows thumbnail cache files\nThumbs.db\nehthumbs.db\nehthumbs_vista.db\n\n# Folder config file\nDesktop.ini\n\n# Recycle Bin used on file shares\n$RECYCLE.BIN/\n\n# Windows Installer files\n*.cab\n*.msi\n*.msm\n*.msp\n\n# Windows shortcuts\n*.lnk\n\n# IDE files\n.vscode/\n*.code-workspace\nrun.bat\n"
  },
  {
    "path": "1-source-files/README.md",
    "content": "# Source files for the BBC Micro cassette version of Elite\n\nThis folder contains the source files for the BBC Micro cassette version of Elite.\n\n* [basic-programs](basic-programs) contains any BASIC programs to be included on the final game disc\n\n* [boot-files](boot-files) contains any !BOOT files to be included on the final game disc\n\n* [images](images) contains the image binaries for the title screen and dashboard\n\n* [main-sources](main-sources) contains the annotated source code\n\n* [original-sources](original-sources) contains the original source code from Ian Bell's personal website\n\n---\n\nRight on, Commanders!\n\n_Mark Moxon_"
  },
  {
    "path": "1-source-files/basic-programs/README.md",
    "content": "# BASIC programs for the BBC Micro cassette version of Elite\n\nThis folder contains the BASIC programs from the original sources for the BBC Micro cassette version of Elite on Ian Bell's personal website.\n\n* [$.ELITE.bin]($.ELITE.bin) is the mode 7 loader program for the version that loads from disc, with an added command to insert a key into the keyboard buffer, so the Elite loader doesn't wait for a key press\n\n* [$.ELITE-cassette.bin]($.ELITE-cassette.bin) is the mode 7 loader program for the original cassette version\n\n* [$.ELITE-disc.bin]($.ELITE-disc.bin) is the mode 7 loader program for the version that loads from disc\n\n---\n\nRight on, Commanders!\n\n_Mark Moxon_"
  },
  {
    "path": "1-source-files/boot-files/README.md",
    "content": "# Boot files for the BBC Micro cassette version of Elite\n\nThis folder contains the boot file from the original sources for the BBC Micro cassette version of Elite on Ian Bell's personal website.\n\n* [$.!BOOT.bin]($.!BOOT.bin) is the original boot file from the game disc\n\n---\n\nRight on, Commanders!\n\n_Mark Moxon_"
  },
  {
    "path": "1-source-files/images/README.md",
    "content": "# Image binaries for the BBC Micro cassette version of Elite\n\nThis folder contains the image binaries from the original sources for the BBC Micro cassette version of Elite on Ian Bell's personal website.\n\n* [P.(C)ASFT.bin](P.(C)ASFT.bin) is the \"(c) ACORNSOFT 1984\" image for the bottom of the title screen\n\n* [P.A-SOFT.bin](P.A-SOFT.bin) is the \"ACORNSOFT\" image for the very top of the title screen\n\n* [P.DIALS.bin](P.DIALS2P.bin) is the dashboard image\n\n* [P.ELITE.bin](P.ELITE.bin) is the \"ELITE\" image for the title screen\n\n---\n\nRight on, Commanders!\n\n_Mark Moxon_"
  },
  {
    "path": "1-source-files/main-sources/README.md",
    "content": "# Annotated source code for the BBC Micro cassette version of Elite\n\nThis folder contains the annotated source code for the BBC Micro cassette version of Elite.\n\n* Main source files:\n\n  * [elite-source.asm](elite-source.asm) contains the main source for the game\n\n  * [elite-bcfs.asm](elite-bcfs.asm) contains the Big Code File source, which concatenates individually assembled binaries into the final game binary\n\n* Other source files:\n\n  * [elite-loader.asm](elite-loader.asm) contains the source for the loader\n\n  * [elite-disc.asm](elite-disc.asm) builds the SSD disc image from the assembled binaries and other source files\n\n  * [elite-readme.asm](elite-readme.asm) generates a README file for inclusion on the SSD disc image\n\n* Files that are generated during the build process:\n\n  * [elite-build-options.asm](elite-build-options.asm) stores the make options in BeebAsm format so they can be included in the assembly process\n\n---\n\nRight on, Commanders!\n\n_Mark Moxon_"
  },
  {
    "path": "1-source-files/main-sources/elite-bcfs.asm",
    "content": "\\ ******************************************************************************\n\\\n\\ BBC MICRO CASSETTE ELITE BIG CODE FILE SOURCE\n\\\n\\ BBC Micro cassette Elite was written by Ian Bell and David Braben and is\n\\ copyright Acornsoft 1984\n\\\n\\ The code in this file is identical to the source discs released on Ian Bell's\n\\ personal website at http://www.elitehomepage.org/ (it's just been reformatted\n\\ to be more readable)\n\\\n\\ The commentary is copyright Mark Moxon, and any misunderstandings or mistakes\n\\ in the documentation are entirely my fault\n\\\n\\ The terminology and notations used in this commentary are explained at\n\\ https://elite.bbcelite.com/terminology\n\\\n\\ The deep dive articles referred to in this commentary can be found at\n\\ https://elite.bbcelite.com/deep_dives\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This source file contains code to produce the Big Code File for BBC Micro\n\\ cassette Elite. The Big Code File comprises the game code and the ship\n\\ blueprints.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This source file produces the following binary files:\n\\\n\\   * ELTcode.unprot.bin\n\\   * ELThead.bin\n\\\n\\ after reading in the following files:\n\\\n\\   * ELTA.bin\n\\   * ELTB.bin\n\\   * ELTC.bin\n\\   * ELTD.bin\n\\   * ELTE.bin\n\\   * ELTF.bin\n\\   * ELTG.bin\n\\   * SHIPS.bin\n\\\n\\ ******************************************************************************\n\n INCLUDE \"1-source-files/main-sources/elite-build-options.asm\"\n\n _SOURCE_DISC           = (_VARIANT = 1)\n _TEXT_SOURCES          = (_VARIANT = 2)\n _STH_CASSETTE          = (_VARIANT = 3)\n\n GUARD &8000            \\ Guard against assembling over MOS memory\n\n\\ ******************************************************************************\n\\\n\\ Configuration variables\n\\\n\\ ******************************************************************************\n\n CODE% = &0F40          \\ CODE% is set to the location that the main game code\n                        \\ gets moved to after it is loaded\n\n LOAD% = &1128          \\ LOAD% points to the start of the actual game code,\n                        \\ after the &28 bytes of header code that are inserted\n                        \\ below\n\n\\ ******************************************************************************\n\\\n\\       Name: ZP\n\\       Type: Workspace\n\\    Address: &0070 to &0071\n\\   Category: Workspaces\n\\    Summary: Important variables used by the loader\n\\\n\\ ******************************************************************************\n\n ORG &0070              \\ Set the assembly address to &0070\n\n.ZP\n\n SKIP 2                 \\ Stores addresses used for moving content around\n\n\\ ******************************************************************************\n\\\n\\ Load the compiled binaries to create the Big Code File\n\\\n\\ ******************************************************************************\n\n ORG &1100              \\ The load address of the main game code file (\"ELTcode\"\n                        \\ for loading from disc, \"ELITEcode\" for loading from\n                        \\ tape)\n\n\\ ******************************************************************************\n\\\n\\       Name: LBL\n\\       Type: Subroutine\n\\   Category: Copy protection\n\\    Summary: Checksum the two pages of code that were copied from UU% to LE%\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine is called at LBL+1 from the CHECKER routine in the loader code in\n\\ elite-loader.asm. It calculates the checksum of the first two pages of the\n\\ loader code that was copied from UU% to LE% by part 3 of the loader, and\n\\ checks the result against the result in the first byte of the LE% block,\n\\ CHECKbyt, at address &0B00.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   LBL+2               Contains an RTS\n\\\n\\ ******************************************************************************\n\n.LBL\n\n EQUB &6C               \\ This value is decremented by the tape loading routine\n                        \\ in the loader, in IRQ1. During loading this value gets\n                        \\ decremented down to &6C, and this new value is then\n                        \\ included in the checksum calculation for the MAINSUM\n                        \\ checksum in the CHECKER routine (the value is set to\n                        \\ &6C here as the tape protection is disabled)\n\n LDX #&60               \\ Set X = &60. This value of X isn't used, it's just a\n                        \\ set up for the RTS call below, where we jump to LBL+2\n                        \\ to perform an RTS, as the opcode for RTS is &60\n\n                        \\ We now run a checksum on the block of memory from\n                        \\ &0B01 to &0CFF, which is the UU% routine from the\n                        \\ loader\n\n LDA #&B                \\ Set ZP(1 0) = &0B00, to point to the start of the code\n STA ZP+1               \\ we want to checksum\n\n LDY #0                 \\ Set Y = 0 to count through each byte within each page\n STY ZP\n\n TYA                    \\ Set A = 0 for building the checksum\n\n INY                    \\ Increment Y to 1\n\n.CHK3\n\n CLC                    \\ Add the Y-th byte of the game code to A\n ADC (ZP),Y\n\n INY                    \\ Increment the counter to point to the next byte\n\n BNE CHK3               \\ Loop back for the next byte until we have finished\n                        \\ adding up this page\n\n INC ZP+1               \\ Increment the high byte of ZP(1 0) to point to the\n                        \\ next page\n\n.CHK4\n\n CLC                    \\ Add the Y-th byte of this page to the checksum in A\n ADC (ZP),Y\n\n INY                    \\ Increment the counter for this page\n\n BPL CHK4               \\ Loop back for the next byte until we have finished\n                        \\ adding up this second page\n\n CMP &0B00              \\ Compare the result to the contents of CHECKbyt in the\n                        \\ loader code at elite-loader.asm. This value gets set\n                        \\ by elite-checksum.py\n\n BEQ LBL+2              \\ If the checksums match, jump to LBL+2, which contains\n                        \\ an RTS\n\n                        \\ Otherwise the checksum just failed, so we reset the\n                        \\ machine\n\n LDA #%01111111         \\ Set 6522 System VIA interrupt enable register IER\n STA &FE4E              \\ (SHEILA &4E) bits 0-6 (i.e. disable all hardware\n                        \\ interrupts from the System VIA)\n\n JMP (&FFFC)            \\ Jump to the address in &FFFC to reset the machine\n\n.elitea\n\n PRINT \"elitea = \", ~P%\n INCBIN \"3-assembled-output/ELTA.bin\"\n\n.eliteb\n\n PRINT \"eliteb = \", ~P%\n INCBIN \"3-assembled-output/ELTB.bin\"\n\n.elitec\n\n PRINT \"elitec = \", ~P%\n INCBIN \"3-assembled-output/ELTC.bin\"\n\n.elited\n\n PRINT \"elited = \", ~P%\n INCBIN \"3-assembled-output/ELTD.bin\"\n\n.elitee\n\n PRINT \"elitee = \", ~P%\n INCBIN \"3-assembled-output/ELTE.bin\"\n\n.elitef\n\n PRINT \"elitef = \", ~P%\n INCBIN \"3-assembled-output/ELTF.bin\"\n\n.eliteg\n\n PRINT \"eliteg = \", ~P%\n INCBIN \"3-assembled-output/ELTG.bin\"\n\n.checksum0\n\n PRINT \"checksum0 = \", ~P%\n\nIF _SOURCE_DISC OR _TEXT_SOURCES\n\n SKIP 1                 \\ We skip this byte so we can insert the checksum later\n                        \\ in elite-checksum.py\n\nELIF _STH_CASSETTE\n\n EQUB &20               \\ We skip this byte so we can insert the checksum later\n                        \\ in elite-checksum.py; it contains workspace noise in\n                        \\ the Stairway to Hell variant\n\nENDIF\n\n.ships\n\n PRINT \"ships = \", ~P%\n INCBIN \"3-assembled-output/SHIPS.bin\"\n\n.end\n\n\\ ******************************************************************************\n\\\n\\ Save ELTcode.unprot.bin and ELThead.bin\n\\\n\\ ******************************************************************************\n\n PRINT \"P% = \", ~P%\n PRINT \"S.ELTcode 1100 \", ~(LOAD% + &6000 - CODE%), \" \", ~LOAD%, \" \", ~LOAD%\n SAVE \"3-assembled-output/ELTcode.unprot.bin\", &1100, (LOAD% + &6000 - CODE%), LOAD%\n SAVE \"3-assembled-output/ELThead.bin\", &1100, elitea, &1100\n"
  },
  {
    "path": "1-source-files/main-sources/elite-build-options.asm",
    "content": "_VERSION=1\n_VARIANT=3\n_REMOVE_CHECKSUMS=FALSE\n_MAX_COMMANDER=FALSE\n_DISC=TRUE\n_PROT=FALSE\n"
  },
  {
    "path": "1-source-files/main-sources/elite-disc.asm",
    "content": "\\ ******************************************************************************\n\\\n\\ BBC MICRO CASSETTE ELITE DISC IMAGE SCRIPT\n\\\n\\ BBC Micro cassette Elite was written by Ian Bell and David Braben and is\n\\ copyright Acornsoft 1984\n\\\n\\ The code in this file is identical to the source discs released on Ian Bell's\n\\ personal website at http://www.elitehomepage.org/ (it's just been reformatted\n\\ to be more readable)\n\\\n\\ The commentary is copyright Mark Moxon, and any misunderstandings or mistakes\n\\ in the documentation are entirely my fault\n\\\n\\ The terminology and notations used in this commentary are explained at\n\\ https://elite.bbcelite.com/terminology\n\\\n\\ The deep dive articles referred to in this commentary can be found at\n\\ https://elite.bbcelite.com/deep_dives\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This source file produces an SSD disc image for BBC Micro cassette Elite.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This source file produces one of the following SSD disc images, depending on\n\\ which release is being built:\n\\\n\\   * elite-cassette-sth.ssd\n\\   * elite-cassette-from-source-disc.ssd\n\\   * elite-cassette-from-text-sources.ssd\n\\\n\\ This can be loaded into an emulator or a real BBC Micro.\n\\\n\\ ******************************************************************************\n\n INCLUDE \"1-source-files/main-sources/elite-build-options.asm\"\n\n _SOURCE_DISC           = (_VARIANT = 1)\n _TEXT_SOURCES          = (_VARIANT = 2)\n _STH_CASSETTE          = (_VARIANT = 3)\n\nIF _DISC\n\n PUTFILE \"1-source-files/boot-files/$.!BOOT.bin\", \"!BOOT\", &FFFFFF, &FFFFFF\n PUTFILE \"1-source-files/basic-programs/$.ELITE.bin\", \"ELITE\", &FF1900, &FF8023\n PUTFILE \"3-assembled-output/ELITE.bin\", \"ELTdata\", &FF1100, &FF2000\n PUTFILE \"3-assembled-output/ELTcode.bin\", \"ELTcode\", &FF1128, &FF1128\n\nELSE\n\n PUTFILE \"1-source-files/boot-files/$.!BOOT.bin\", \"!BOOT\", &FFFFFF, &FFFFFF\n PUTFILE \"1-source-files/basic-programs/$.ELITE-cassette.bin\", \"ELITE\", &FF1900, &FF8023\n\\PUTFILE \"3-assembled-output/ELITE.bin\", \"ELITEdata\", &FF0E00, &FF1D00\n\\PUTFILE \"3-assembled-output/ELTcode.bin\", \"ELITEcode\", &000E00, &000132\n PUTFILE \"3-assembled-output/ELITE.bin\", \"ELITEda\", &FF0E00, &FF1D00\n PUTFILE \"3-assembled-output/ELTcode.bin\", \"ELITEco\", &000E00, &000132\n\nENDIF\n\n PUTFILE \"3-assembled-output/README.txt\", \"README\", &FFFFFF, &FFFFFF\n"
  },
  {
    "path": "1-source-files/main-sources/elite-loader.asm",
    "content": "\\ ******************************************************************************\n\\\n\\ BBC MICRO CASSETTE ELITE GAME LOADER SOURCE\n\\\n\\ BBC Micro cassette Elite was written by Ian Bell and David Braben and is\n\\ copyright Acornsoft 1984\n\\\n\\ The code in this file is identical to the source discs released on Ian Bell's\n\\ personal website at http://www.elitehomepage.org/ (it's just been reformatted\n\\ to be more readable)\n\\\n\\ The commentary is copyright Mark Moxon, and any misunderstandings or mistakes\n\\ in the documentation are entirely my fault\n\\\n\\ The terminology and notations used in this commentary are explained at\n\\ https://elite.bbcelite.com/terminology\n\\\n\\ The deep dive articles referred to in this commentary can be found at\n\\ https://elite.bbcelite.com/deep_dives\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This source file contains the game loader for BBC Micro cassette Elite.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This source file produces the following binary file:\n\\\n\\   * ELITE.unprot.bin\n\\\n\\ after reading in the following files:\n\\\n\\   * P.A-SOFT.bin\n\\   * P.(C)ASFT.bin\n\\   * DIALS.bin\n\\   * P.ELITE.bin\n\\   * PYTHON.bin\n\\   * WORDS9.bin\n\\\n\\ ******************************************************************************\n\n INCLUDE \"1-source-files/main-sources/elite-build-options.asm\"\n\n _SOURCE_DISC           = (_VARIANT = 1)\n _TEXT_SOURCES          = (_VARIANT = 2)\n _STH_CASSETTE          = (_VARIANT = 3)\n\n GUARD &6000            \\ Guard against assembling over screen memory\n\n\\ ******************************************************************************\n\\\n\\ Configuration variables\n\\\n\\ ******************************************************************************\n\n DISC = _DISC           \\ Set to TRUE to load the code above DFS and relocate\n                        \\ down, so we can load the cassette version from disc,\n                        \\ or set to FALSE to load the code as if it were from a\n                        \\ cassette\n\n PROT = _PROT           \\ Set to TRUE to enable the tape protection code, or set\n                        \\ to FALSE to disable the code (for TRUE, the file must\n                        \\ be saved to tape with the block data corrupted, so you\n                        \\ probably want to leave this as FALSE)\n\nIF DISC\n\n CODE% = &1100          \\ CODE% is set to the assembly address of the loader\n                        \\ code file that we assemble in this file (\"ELITE\"),\n                        \\ which is at the lowest DFS page value of &1100 for the\n                        \\ version that loads from disc\n\n LOAD% = &1100          \\ LOAD% is the load address of the main game code file\n                        \\ (\"ELTcode\" for loading from disc, \"ELITEcode\" for\n                        \\ loading from tape)\n\n L% = &1128             \\ L% points to the start of the actual game code from\n                        \\ elite-source.asm, after the &28 bytes of header code\n                        \\ that are inserted by elite-bcfs.asm\n\nELSE\n\n CODE% = &0E00          \\ CODE% is set to the assembly address of the loader\n                        \\ code file that we assemble in this file (\"ELITE\"),\n                        \\ which is at the standard &0E00 address for the version\n                        \\ that loads from cassette\n\n LOAD% = &0F1F          \\ LOAD% is the load address of the main game code file\n                        \\ (\"ELTcode\" for loading from disc, \"ELITEcode\" for\n                        \\ loading from tape)\n\n L% = &0F47             \\ L% points to the start of the actual game code from\n                        \\ elite-source.asm, after the &28 bytes of header code\n                        \\ that are inserted by elite-bcfs.asm\n\nENDIF\n\n LEN1 = 15              \\ Size of the BEGIN% routine that gets pushed onto the\n                        \\ stack and executed there\n\n LEN2 = 18              \\ Size of the MVDL routine that gets pushed onto the\n                        \\ stack and executed there\n\n LEN = LEN1 + LEN2      \\ Total number of bytes that get pushed on the stack for\n                        \\ execution there (33)\n\n VSCAN = 57-1           \\ Defines the split position in the split-screen mode\n\n LE% = &0B00            \\ LE% is the address to which the code from UU% onwards\n                        \\ is copied in part 3. It contains:\n                        \\\n                        \\   * ENTRY2, the entry point for the second block of\n                        \\     loader code\n                        \\\n                        \\   * IRQ1, the interrupt routine for the split-screen\n                        \\     mode\n                        \\\n                        \\   * BLOCK, which by this point has already been put\n                        \\     on the stack by this point\n                        \\\n                        \\   * The variables used by the above\n\n NETV = &0224           \\ The NETV vector that we intercept as part of the copy\n                        \\ protection\n\n IRQ1V = &0204          \\ The IRQ1V vector that we intercept to implement the\n                        \\ split-screen mode\n\n OSPRNT = &0234         \\ The address for the OSPRNT vector\n\n C% = &0F40             \\ C% is set to the location that the main game code gets\n                        \\ moved to after it is loaded\n\n S% = C%                \\ S% points to the entry point for the main game code\n\nIF _SOURCE_DISC\n\n D% = &563A             \\ D% is set to the address of the byte after the end of\n                        \\ the code, i.e. the byte after checksum0 at XX21\n\nELIF _TEXT_SOURCES\n\n D% = &5638             \\ D% is set to the address of the byte after the end of\n                        \\ the code, i.e. the byte after checksum0 at XX21\n\nELIF _STH_CASSETTE\n\n D% = &563A             \\ D% is set to the address of the byte after the end of\n                        \\ the code, i.e. the byte after checksum0 at XX21\n\nENDIF\n\n LC% = &6000 - C%       \\ LC% is set to the maximum size of the main game code\n                        \\ (as the code starts at C% and screen memory starts\n                        \\ at &6000)\n\n N% = 67                \\ N% is set to the number of bytes in the VDU table, so\n                        \\ we can loop through them in part 2 below\n\n SVN = &7FFD            \\ SVN is where we store the \"saving in progress\" flag,\n                        \\ and it matches the location in elite-source.asm\n\n VEC = &7FFE            \\ VEC is where we store the original value of the IRQ1\n                        \\ vector, and it matches the value in elite-source.asm\n\n VIA = &FE00            \\ Memory-mapped space for accessing internal hardware,\n                        \\ such as the video ULA, 6845 CRTC and 6522 VIAs (also\n                        \\ known as SHEILA)\n\n OSWRCH = &FFEE         \\ The address for the OSWRCH routine\n\n OSBYTE = &FFF4         \\ The address for the OSBYTE routine\n\n OSWORD = &FFF1         \\ The address for the OSWORD routine\n\n\\ ******************************************************************************\n\\\n\\       Name: ZP\n\\       Type: Workspace\n\\    Address: &0004 to &0005 and &0070 to &0086\n\\   Category: Workspaces\n\\    Summary: Important variables used by the loader\n\\\n\\ ******************************************************************************\n\n ORG &0004              \\ Set the assembly address to &0004\n\n.TRTB%\n\n SKIP 2                 \\ Contains the address of the keyboard translation\n                        \\ table, which is used to translate internal key\n                        \\ numbers to ASCII\n\n ORG &0070              \\ Set the assembly address to &0070\n\n.ZP\n\n SKIP 2                 \\ Stores addresses used for moving content around\n\n.P\n\n SKIP 1                 \\ Temporary storage, used in a number of places\n\n.Q\n\n SKIP 1                 \\ Temporary storage, used in a number of places\n\n.YY\n\n SKIP 1                 \\ Temporary storage, used in a number of places\n\n.T\n\n SKIP 1                 \\ Temporary storage, used in a number of places\n\n.SC\n\n SKIP 1                 \\ Screen address (low byte)\n                        \\\n                        \\ Elite draws on-screen by poking bytes directly into\n                        \\ screen memory, and SC(1 0) is typically set to the\n                        \\ address of the character block containing the pixel\n                        \\ we want to draw\n\n.SCH\n\n SKIP 1                 \\ Screen address (high byte)\n\n.BLPTR\n\n SKIP 2                 \\ Gets set to &03CA as part of the obfuscation code\n\n.V219\n\n SKIP 2                 \\ Gets set to &0218 as part of the obfuscation code\n\n SKIP 4                 \\ These bytes appear to be unused\n\n.K3\n\n SKIP 1                 \\ Temporary storage, used in a number of places\n\n.BLCNT\n\n SKIP 2                 \\ Stores the tape loader block count as part of the copy\n                        \\ protection code in IRQ1\n\n.BLN\n\n SKIP 2                 \\ Gets set to &03C6 as part of the obfuscation code\n\n.EXCN\n\n SKIP 2                 \\ Gets set to &03C2 as part of the obfuscation code\n\n\\ ******************************************************************************\n\\\n\\ ELITE LOADER\n\\\n\\ ******************************************************************************\n\n ORG CODE%              \\ Set the assembly address to CODE%\n\n\\ ******************************************************************************\n\\\n\\       Name: Elite loader (Part 1 of 6)\n\\       Type: Subroutine\n\\   Category: Loader\n\\    Summary: Include binaries for recursive tokens, Python blueprint and images\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The loader bundles a number of binary files in with the loader code, and moves\n\\ them to their correct memory locations in part 3 below.\n\\\n\\ There are two files containing code:\n\\\n\\   * WORDS9.bin contains the recursive token table, which is moved to &0400\n\\     before the main game is loaded\n\\\n\\   * PYTHON.bin contains the Python ship blueprint, which gets moved to &7F00\n\\     before the main game is loaded\n\\\n\\ and four files containing images, which are all moved into screen memory by\n\\ the loader:\n\\\n\\   * P.A-SOFT.bin contains the \"ACORNSOFT\" title across the top of the loading\n\\     screen, which gets moved to screen address &6100, on the second character\n\\     row of the monochrome mode 4 screen\n\\\n\\   * P.ELITE.bin contains the \"ELITE\" title across the top of the loading\n\\     screen, which gets moved to screen address &6300, on the fourth character\n\\     row of the monochrome mode 4 screen\n\\\n\\   * P.(C)ASFT.bin contains the \"(C) Acornsoft 1984\" title across the bottom\n\\     of the loading screen, which gets moved to screen address &7600, the\n\\     penultimate character row of the monochrome mode 4 screen, just above the\n\\     dashboard\n\\\n\\   * P.DIALS.bin contains the dashboard, which gets moved to screen address\n\\     &7800, which is the starting point of the four-colour mode 5 portion at\n\\     the bottom of the split screen\n\\\n\\ The routine ends with a jump to the start of the loader code at ENTRY.\n\\\n\\ ******************************************************************************\n\n PRINT \"WORDS9 = \", ~P%\n INCBIN \"3-assembled-output/WORDS9.bin\"\n\n ALIGN 256\n\n PRINT \"P.DIALS = \", ~P%\n INCBIN \"1-source-files/images/P.DIALS.bin\"\n\n PRINT \"PYTHON = \", ~P%\n INCBIN \"3-assembled-output/PYTHON.bin\"\n\n PRINT \"P.ELITE = \", ~P%\n INCBIN \"1-source-files/images/P.ELITE.bin\"\n\n PRINT \"P.A-SOFT = \", ~P%\n INCBIN \"1-source-files/images/P.A-SOFT.bin\"\n\n PRINT \"P.(C)ASFT = \", ~P%\n INCBIN \"1-source-files/images/P.(C)ASFT.bin\"\n\n.run\n\n JMP ENTRY              \\ Jump to ENTRY to start the loading process\n\n\\ ******************************************************************************\n\\\n\\       Name: B%\n\\       Type: Variable\n\\   Category: Drawing the screen\n\\    Summary: VDU commands for setting the square mode 4 screen\n\\  Deep dive: The split-screen mode in BBC Micro Elite\n\\             Drawing monochrome pixels on the BBC Micro\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This block contains the bytes that get written by OSWRCH to set up the screen\n\\ mode (this is equivalent to using the VDU statement in BASIC).\n\\\n\\ It defines the whole screen using a square, monochrome mode 4 configuration;\n\\ the mode 5 part for the dashboard is implemented in the IRQ1 routine.\n\\\n\\ The top part of Elite's screen mode is based on mode 4 but with the following\n\\ differences:\n\\\n\\   * 32 columns, 31 rows (256 x 248 pixels) rather than 40, 32\n\\\n\\   * The horizontal sync position is at character 45 rather than 49, which\n\\     pushes the screen to the right (which centres it as it's not as wide as\n\\     the normal screen modes)\n\\\n\\   * Screen memory goes from &6000 to &7EFF, which leaves another whole page\n\\     for code (i.e. 256 bytes) after the end of the screen. This is where the\n\\     Python ship blueprint slots in\n\\\n\\   * The text window is 1 row high and 13 columns wide, and is at (2, 16)\n\\\n\\   * The cursor is disabled\n\\\n\\ This almost-square mode 4 variant makes life a lot easier when drawing to the\n\\ screen, as there are 256 pixels on each row (or, to put it in screen memory\n\\ terms, there's one page of memory per row of pixels).\n\\\n\\ There is also an interrupt-driven routine that switches the bytes-per-pixel\n\\ setting from that of mode 4 to that of mode 5, when the raster reaches the\n\\ split between the space view and the dashboard.\n\\\n\\ ******************************************************************************\n\n.B%\n\n EQUB 22, 4             \\ Switch to screen mode 4\n\n EQUB 28                \\ Define a text window as follows:\n EQUB 2, 17, 15, 16     \\\n                        \\   * Left = 2\n                        \\   * Right = 15\n                        \\   * Top = 16\n                        \\   * Bottom = 17\n                        \\\n                        \\ i.e. 1 row high, 13 columns wide at (2, 16)\n\n EQUB 23, 0, 6, 31      \\ Set 6845 register R6 = 31\n EQUB 0, 0, 0           \\\n EQUB 0, 0, 0           \\ This is the \"vertical displayed\" register, and sets\n                        \\ the number of displayed character rows to 31. For\n                        \\ comparison, this value is 32 for standard modes 4 and\n                        \\ 5, but we claw back the last row for storing code just\n                        \\ above the end of screen memory\n\n EQUB 23, 0, 12, &0C    \\ Set 6845 register R12 = &0C and R13 = &00\n EQUB 0, 0, 0           \\\n EQUB 0, 0, 0           \\ This sets 6845 registers (R12 R13) = &0C00 to point\n EQUB 23, 0, 13, &00    \\ to the start of screen memory in terms of character\n EQUB 0, 0, 0           \\ rows. There are 8 pixel lines in each character row,\n EQUB 0, 0, 0           \\ so to get the actual address of the start of screen\n                        \\ memory, we multiply by 8:\n                        \\\n                        \\   &0C00 * 8 = &6000\n                        \\\n                        \\ So this sets the start of screen memory to &6000\n\n EQUB 23, 0, 1, 32      \\ Set 6845 register R1 = 32\n EQUB 0, 0, 0           \\\n EQUB 0, 0, 0           \\ This is the \"horizontal displayed\" register, which\n                        \\ defines the number of character blocks per horizontal\n                        \\ character row. For comparison, this value is 40 for\n                        \\ modes 4 and 5, but our custom screen is not as wide at\n                        \\ only 32 character blocks across\n\n EQUB 23, 0, 2, 45      \\ Set 6845 register R2 = 45\n EQUB 0, 0, 0           \\\n EQUB 0, 0, 0           \\ This is the \"horizontal sync position\" register, which\n                        \\ defines the position of the horizontal sync pulse on\n                        \\ the horizontal line in terms of character widths from\n                        \\ the left-hand side of the screen. For comparison this\n                        \\ is 49 for modes 4 and 5, but needs to be adjusted for\n                        \\ our custom screen's width\n\n EQUB 23, 0, 10, 32     \\ Set 6845 register R10 = %00100000 = 32\n EQUB 0, 0, 0           \\\n EQUB 0, 0, 0           \\ This is the \"cursor start\" register, and bits 5 and 6\n                        \\ define the \"cursor display mode\", as follows:\n                        \\\n                        \\   * %00 = steady, non-blinking cursor\n                        \\\n                        \\   * %01 = do not display a cursor\n                        \\\n                        \\   * %10 = fast blinking cursor (blink at 1/16 of the\n                        \\           field rate)\n                        \\\n                        \\   * %11 = slow blinking cursor (blink at 1/32 of the\n                        \\           field rate)\n                        \\\n                        \\ We can therefore turn off the cursor completely by\n                        \\ setting cursor display mode %01, with bit 6 of R10\n                        \\ clear and bit 5 of R10 set\n\n\\ ******************************************************************************\n\\\n\\       Name: E%\n\\       Type: Variable\n\\   Category: Sound\n\\    Summary: Sound envelope definitions\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This table contains the sound envelope data, which is passed to OSWORD by the\n\\ FNE macro to create the four sound envelopes used in-game. Refer to chapter 30\n\\ of the \"BBC Microcomputer User Guide\" by John Coll for details of sound\n\\ envelopes and what all the parameters mean.\n\\\n\\ The envelopes are as follows:\n\\\n\\   * Envelope 1 is the sound of our own laser firing\n\\\n\\   * Envelope 2 is the sound of lasers hitting us, or hyperspace\n\\\n\\   * Envelope 3 is the first sound in the two-part sound of us dying, or the\n\\     second sound in the two-part sound of us hitting or killing an enemy ship\n\\\n\\   * Envelope 4 is the sound of E.C.M. firing\n\\\n\\ ******************************************************************************\n\n.E%\n\n EQUB 1, 1, 0, 111, -8, 4, 1, 8, 8, -2, 0, -1, 112, 44\n EQUB 2, 1, 14, -18, -1, 44, 32, 50, 6, 1, 0, -2, 120, 126\n EQUB 3, 1, 1, -1, -3, 17, 32, 128, 1, 0, 0, -1, 1, 1\n EQUB 4, 1, 4, -8, 44, 4, 6, 8, 22, 0, 0, -127, 126, 0\n\n\\ ******************************************************************************\n\\\n\\       Name: swine\n\\       Type: Subroutine\n\\   Category: Copy protection\n\\    Summary: Resets the machine if the copy protection detects a problem\n\\\n\\ ******************************************************************************\n\n.swine\n\n LDA #%01111111         \\ Set 6522 System VIA interrupt enable register IER\n STA &FE4E              \\ (SHEILA &4E) bits 0-6 (i.e. disable all hardware\n                        \\ interrupts from the System VIA)\n\n JMP (&FFFC)            \\ Jump to the address in &FFFC to reset the machine\n\n\\ ******************************************************************************\n\\\n\\       Name: OSB\n\\       Type: Subroutine\n\\   Category: Utility routines\n\\    Summary: A convenience routine for calling OSBYTE with Y = 0\n\\\n\\ ******************************************************************************\n\n.OSB\n\n LDY #0                 \\ Call OSBYTE with Y = 0, returning from the subroutine\n JMP OSBYTE             \\ using a tail call (so we can call OSB to call OSBYTE\n                        \\ for when we know we want Y set to 0)\n\n\\ ******************************************************************************\n\\\n\\       Name: Authors' names\n\\       Type: Variable\n\\   Category: Copy protection\n\\    Summary: The authors' names, buried in the code\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Contains the authors' names, plus an unused OS command string that would\n\\ *RUN the main game code, which isn't what actually happens (so presumably\n\\ this is to throw the crackers off the scent).\n\\\n\\ ******************************************************************************\n\n EQUS \"R.ELITEcode\"     \\ This is short for \"*RUN ELITEcode\"\n EQUB 13\n\n EQUS \"By D.Braben/I.Bell\"\n EQUB 13\n\n EQUB &B0\n\n\\ ******************************************************************************\n\\\n\\       Name: oscliv\n\\       Type: Variable\n\\   Category: Utility routines\n\\    Summary: Contains the address of OSCLIV, for executing OS commands\n\\\n\\ ******************************************************************************\n\n.oscliv\n\n EQUW &FFF7             \\ Address of OSCLIV, for executing OS commands\n                        \\ (specifically the *LOAD that loads the main game code)\n\n\\ ******************************************************************************\n\\\n\\       Name: David9\n\\       Type: Variable\n\\   Category: Copy protection\n\\    Summary: Address used as part of the stack-based decryption loop\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This address is used in the decryption loop starting at David2 in part 4, and\n\\ is used to jump back into the loop at David5.\n\\\n\\ ******************************************************************************\n\n.David9\n\n EQUW David5            \\ The address of David5\n\n CLD                    \\ This instruction is not used\n\n\\ ******************************************************************************\n\\\n\\       Name: David23\n\\       Type: Variable\n\\   Category: Copy protection\n\\    Summary: Address pointer to the start of the 6502 stack\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This two-byte address points to the start of the 6502 stack, which descends\n\\ from the end of page 2, less LEN bytes, which comes out as &01DF. So when we\n\\ push 33 bytes onto the stack (LEN being 33), this address will point to the\n\\ start of those bytes, which means we can push executable code onto the stack\n\\ and run it by calling this address with a JMP (David23) instruction. Sneaky\n\\ stuff!\n\\\n\\ ******************************************************************************\n\n.David23\n\n EQUW (512-LEN)         \\ The address of LEN bytes before the start of the stack\n\n\\ ******************************************************************************\n\\\n\\       Name: doPROT1\n\\       Type: Subroutine\n\\   Category: Copy protection\n\\    Summary: Routine to self-modify the loader code\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine modifies various bits of code in-place as part of the copy\n\\ protection mechanism. It is called with A = &48 and X = 255.\n\\\n\\ ******************************************************************************\n\n.doPROT1\n\n LDY #&DB               \\ Store &EFDB in TRTB%(1 0) to point to the keyboard\n STY TRTB%              \\ translation table for OS 0.1 (which we will overwrite\n LDY #&EF               \\ with a call to OSBYTE later)\n STY TRTB%+1\n\n LDY #2                 \\ Set the high byte of V219(1 0) to 2\n STY V219+1\n\n STA PROT1-255,X        \\ Poke &48 into PROT1, which changes the instruction\n                        \\ there to a PHA\n\n LDY #&18               \\ Set the low byte of V219(1 0) to &18 (as X = 255), so\n STY V219+1,X           \\ V219(1 0) now contains &0218\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: MHCA\n\\       Type: Variable\n\\   Category: Copy protection\n\\    Summary: Used to set one of the vectors in the copy protection code\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This value is used to set the low byte of BLPTR(1 0), when it's set in PLL1\n\\ as part of the copy protection.\n\\\n\\ ******************************************************************************\n\n.MHCA\n\n EQUB &CA               \\ The low byte of BLPTR(1 0)\n\n\\ ******************************************************************************\n\\\n\\       Name: David7\n\\       Type: Subroutine\n\\   Category: Copy protection\n\\    Summary: Part of the multi-jump obfuscation code in PROT1\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This instruction is part of the multi-jump obfuscation in PROT1 (see part 2 of\n\\ the loader), which does the following jumps:\n\\\n\\   David8 -> FRED1 -> David7 -> Ian1 -> David3\n\\\n\\ ******************************************************************************\n\n.David7\n\n BCC Ian1               \\ This instruction is part of the multi-jump obfuscation\n                        \\ in PROT1\n\n\\ ******************************************************************************\n\\\n\\       Name: FNE\n\\       Type: Macro\n\\   Category: Sound\n\\    Summary: Macro definition for defining a sound envelope\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The following macro is used to define the four sound envelopes used in the\n\\ game. It uses OSWORD 8 to create an envelope using the 14 parameters in the\n\\ I%-th block of 14 bytes at location E%. This OSWORD call is the same as BBC\n\\ BASIC's ENVELOPE command.\n\\\n\\ See variable E% for more details of the envelopes themselves.\n\\\n\\ ******************************************************************************\n\nMACRO FNE I%\n\n LDX #LO(E%+I%*14)      \\ Set (Y X) to point to the I%-th set of envelope data\n LDY #HI(E%+I%*14)      \\ in E%\n\n LDA #8                 \\ Call OSWORD with A = 8 to set up sound envelope I%\n JSR OSWORD\n\nENDMACRO\n\n\\ ******************************************************************************\n\\\n\\       Name: Elite loader (Part 2 of 6)\n\\       Type: Subroutine\n\\   Category: Loader\n\\    Summary: Perform a number of OS calls, set up sound, push routines on stack\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This part of the loader does a number of calls to OS routines, sets up the\n\\ sound envelopes, pushes 33 bytes onto the stack that will be used later, and\n\\ sends us on a wild goose chase, just for kicks.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   Ian1                Re-entry point following the wild goose chase\n\\                       obfuscation\n\\\n\\ ******************************************************************************\n\n.ENTRY\n\n SEI                    \\ Disable all interrupts\n\n CLD                    \\ Clear the decimal flag, so we're not in decimal mode\n\nIF NOT(DISC)\n\n LDA #0                 \\ Call OSBYTE with A = 0 and X = 255 to fetch the\n LDX #255               \\ operating system version into X\n JSR OSBYTE\n\n TXA                    \\ If X = 0 then this is OS 1.00, so jump down to OS100\n BEQ OS100              \\ to skip the following\n\n LDY &FFB6              \\ Otherwise this is OS 1.20, so set Y to the contents of\n                        \\ &FFB6, which contains the length of the default vector\n                        \\ table\n\n LDA &FFB7              \\ Set ZP(1 0) to the location stored in &FFB7-&FFB8,\n STA ZP                 \\ which contains the address of the default vector table\n LDA &FFB8\n STA ZP+1\n\n DEY                    \\ Decrement Y so we can use it as an index for setting\n                        \\ all the vectors to their default states\n\n.ABCDEFG\n\n LDA (ZP),Y             \\ Copy the Y-th byte from the default vector table into\n STA &0200,Y            \\ the vector table in &0200\n\n DEY                    \\ Decrement the loop counter\n\n BPL ABCDEFG            \\ Loop back for the next vector until we have done them\n                        \\ all\n\n.OS100\n\nENDIF\n\n LDA #%01111111         \\ Set 6522 System VIA interrupt enable register IER\n STA &FE4E              \\ (SHEILA &4E) bits 0-6 (i.e. disable all hardware\n                        \\ interrupts from the System VIA)\n\n STA &FE6E              \\ Set 6522 User VIA interrupt enable register IER\n                        \\ (SHEILA &6E) bits 0-6 (i.e. disable all hardware\n                        \\ interrupts from the User VIA)\n\n LDA &FFFC              \\ Fetch the low byte of the reset address in &FFFC,\n                        \\ which will reset the machine if called\n\n STA &0200              \\ Set the low bytes of USERV, BRKV, IRQ2V and EVENTV\n STA &0202\n STA &0206\n STA &0220\n\n LDA &FFFD              \\ Fetch the high byte of the reset address in &FFFD,\n                        \\ which will reset the machine if called\n\n STA &0201              \\ Set the high bytes of USERV, BRKV, IRQ2V and EVENTV\n STA &0203\n STA &0207\n STA &0221\n\n LDX #&2F-2             \\ We now step through all the vectors from &0204 to\n                        \\ &022F and OR their high bytes with &C0, so they all\n                        \\ point into the MOS ROM space (which is from &C000 and\n                        \\ upwards), so we set a counter in X to count through\n                        \\ them\n\n.purge\n\n LDA &0202,X            \\ Set the high byte of the vector in &0202+X so it\n ORA #&C0               \\ points to the MOS ROM\n STA &0202,X\n\n DEX                    \\ Increment the counter to point to the next high byte\n DEX\n\n BPL purge              \\ Loop back until we have done all the vectors\n\n LDA #&60               \\ Store an RTS instruction in location &0232\n STA &0232\n\n LDA #&2                \\ Point the NETV vector to &0232, which we just filled\n STA NETV+1             \\ with an RTS\n LDA #&32\n STA NETV\n\n LDA #&20               \\ Set A to the op code for a JSR call with absolute\n                        \\ addressing\n\n EQUB &2C               \\ Skip the next instruction by turning it into\n                        \\ &2C &D0 &66, or BIT &66D0, which does nothing apart\n                        \\ from affect the flags\n\n.Ian1\n\n BNE David3             \\ This instruction is skipped if we came from above,\n                        \\ otherwise this is part of the multi-jump obfuscation\n                        \\ in PROT1\n\n STA David2             \\ Store &20 in location David2, which modifies the\n                        \\ instruction there (see David2 for details)\n\n LSR A                  \\ Set A = 16\n\n LDX #3                 \\ Set the high bytes of BLPTR(1 0), BLN(1 0) and\n STX BLPTR+1            \\ EXCN(1 0) to &3. We will fill in the high bytes in\n STX BLN+1              \\ the PLL1 routine, and will then use these values in\n STX EXCN+1             \\ the IRQ1 handler\n\n DEX                    \\ Set X = 2\n\n JSR OSBYTE             \\ Call OSBYTE with A = 16 and X = 2 to set the ADC to\n                        \\ sample 2 channels from the joystick\n\n EQUB &2C               \\ Skip the next instruction by turning it into\n                        \\ &2C &D0 &A1, or BIT &A1D0, which does nothing apart\n                        \\ from affect the flags\n\n.FRED1\n\n BNE David7             \\ This instruction is skipped if we came from above,\n                        \\ otherwise this is part of the multi-jump obfuscation\n                        \\ in PROT1\n\n LDX #255               \\ Call doPROT1 to change an instruction in the PROT1\n LDA #&48               \\ routine and set up another couple of variables\n JSR doPROT1\n\n LDA #144               \\ Call OSBYTE with A = 144, X = 255 and Y = 0 to move\n JSR OSB                \\ the screen down one line and turn screen interlace on\n\n LDA #247               \\ Call OSBYTE with A = 247 and X = Y = 0 to disable the\n LDX #0                 \\ BREAK intercept code by poking 0 into the first value\n JSR OSB\n\n\\LDA #129               \\ These instructions are commented out in the original\n\\LDY #255               \\ source, along with the comment \"Damn 0.1\", so\n\\LDX #1                 \\ presumably MOS version 0.1 was a bit of a pain to\n\\JSR OSBYTE             \\ support - which is probably why Elite doesn't bother\n\\                       \\ and only supports 1.0 and 1.2\n\\TXA\n\\\n\\BPL OS01\n\\\n\\Damn 0.1\n\n LDA #190               \\ Call OSBYTE with A = 190, X = 8 and Y = 0 to set the\n LDX #8                 \\ ADC conversion type to 8 bits, for the joystick\n JSR OSB\n\n EQUB &2C               \\ Skip the next instruction by turning it into\n                        \\ &2C &D0 &E1, or BIT &E1D0, which does nothing apart\n                        \\ from affect the flags\n\n.David8\n\n BNE FRED1              \\ This instruction is skipped if we came from above,\n                        \\ otherwise this is part of the multi-jump obfuscation\n                        \\ in PROT1\n\n LDA #143               \\ Call OSBYTE 143 to issue a paged ROM service call of\n LDX #&C                \\ type &C with argument &FF, which is the \"NMI claim\"\n LDY #&FF               \\ service call that asks the current user of the NMI\n JSR OSBYTE             \\ space to clear it out\n\n LDA #13                \\ Set A = 13 for the next OSBYTE call\n\n.abrk\n\n LDX #0                 \\ Call OSBYTE with A = 13, X = 0 and Y = 0 to disable\n JSR OSB                \\ the \"output buffer empty\" event\n\n LDA #225               \\ Call OSBYTE with A = 225, X = 128 and Y = 0 to set\n LDX #128               \\ the function keys to return ASCII codes for SHIFT-fn\n JSR OSB                \\ keys (i.e. add 128)\n\n LDA #172               \\ Call OSBYTE 172 to read the address of the MOS\n LDX #0                 \\ keyboard translation table into (Y X)\n LDY #255\n JSR OSBYTE\n\n STX TRTB%              \\ Store the address of the keyboard translation table in\n STY TRTB%+1            \\ TRTB%(1 0)\n\n LDA #200               \\ Call OSBYTE with A = 200, X = 3 and Y = 0 to disable\n LDX #3                 \\ the ESCAPE key and clear memory if the BREAK key is\n JSR OSB                \\ pressed\n\nIF PROT AND NOT(DISC)\n\n CPX #3                 \\ If the previous value of X from the call to OSBYTE 200\n BNE abrk+1             \\ was not 3 (ESCAPE disabled, clear memory), jump to\n                        \\ abrk+1, which contains a BRK instruction which will\n                        \\ reset the computer (as we set BRKV to point to the\n                        \\ reset address above)\n\nENDIF\n\n LDA #13                \\ Call OSBYTE with A = 13, X = 2 and Y = 0 to disable\n LDX #2                 \\ the \"character entering keyboard buffer\" event\n JSR OSB\n\n.OS01\n\n LDX #&FF               \\ Set the stack pointer to &01FF, which is the standard\n TXS                    \\ location for the 6502 stack, so this instruction\n                        \\ effectively resets the stack\n\n INX                    \\ Set X = 0, to use as a counter in the following loop\n\n.David3\n\n LDA BEGIN%,X           \\ This routine pushes 33 bytes from BEGIN% onto the\n                        \\ stack, so fetch the X-th byte from BEGIN%\n\n.PROT1\n\n INY                    \\ This instruction gets changed to a PHA instruction by\n                        \\ the doPROT1 routine that's called above, so by the\n                        \\ time we get here, this instruction actually pushes the\n                        \\ X-th byte from BEGIN% onto the stack\n\n INX                    \\ Increment the loop counter\n\n CPX #LEN               \\ If X < #LEN (which is 33), loop back for the next one.\n BNE David8             \\ This branch actually takes us on a wild goose chase\n                        \\ through the following locations, where each BNE is\n                        \\ prefaced by an EQUB &2C that disables the branch\n                        \\ instruction during the normal instruction flow:\n                        \\\n                        \\   David8 -> FRED1 -> David7 -> Ian1 -> David3\n                        \\\n                        \\ so in the end this just loops back to push the next\n                        \\ byte onto the stack, but in a really sneaky way\n\n LDA #LO(B%)            \\ Set the low byte of ZP(1 0) to point to the VDU code\n STA ZP                 \\ table at B%\n\n LDA #&C8               \\ Poke &C8 into PROT1 to change the instruction that we\n STA PROT1              \\ modified back to an INY instruction, rather than a PHA\n\n LDA #HI(B%)            \\ Set the high byte of ZP(1 0) to point to the VDU code\n STA ZP+1               \\ table at B%\n\n LDY #0                 \\ We are now going to send the N% VDU bytes in the table\n                        \\ at B% to OSWRCH to set up the special mode 4 screen\n                        \\ that forms the basis for the split-screen mode\n\n.LOOP\n\n LDA (ZP),Y             \\ Pass the Y-th byte of the B% table to OSWRCH\n JSR OSWRCH\n\n INY                    \\ Increment the loop counter\n\n CPY #N%                \\ Loop back for the next byte until we have done them\n BNE LOOP               \\ all (the number of bytes was set in N% above)\n\n LDA #1                 \\ In doPROT1 above we set V219(1 0) = &0218, so this\n TAX                    \\ code sets the contents of &0219 (the high byte of\n TAY                    \\ BPUTV) to 1. We will see why this later, at the start\n STA (V219),Y           \\ of part 4\n\n LDA #4                 \\ Call OSBYTE with A = 4, X = 1 and Y = 0 to disable\n JSR OSB                \\ cursor editing, so the cursor keys return ASCII values\n                        \\ and can therefore be used in-game\n\n LDA #9                 \\ Call OSBYTE with A = 9, X = 0 and Y = 0 to disable\n LDX #0                 \\ flashing colours\n JSR OSB\n\n LDA #&6C               \\ Poke &6C into crunchit after EOR'ing it first (which\n EOR crunchit           \\ has no effect as crunchit contains a BRK instruction\n STA crunchit           \\ with opcode 0), to change crunchit to an indirect JMP\n\n FNE 0                  \\ Set up sound envelopes 0-3 using the FNE macro\n FNE 1\n FNE 2\n FNE 3\n\n\\ ******************************************************************************\n\\\n\\       Name: Elite loader (Part 3 of 6)\n\\       Type: Subroutine\n\\   Category: Loader\n\\    Summary: Move and decrypt recursive tokens, Python blueprint and images\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Move and decrypt the following memory blocks:\n\\\n\\   * WORDS9: move 4 pages (1024 bytes) from CODE% to &0400\n\\\n\\   * P.ELITE: move 1 page (256 bytes) from CODE% + &0C00 to &6300\n\\\n\\   * P.A-SOFT: move 1 page (256 bytes) from CODE% + &0D00 to &6100\n\\\n\\   * P.(C)ASFT: move 1 page (256 bytes) from CODE% + &0E00 to &7600\n\\\n\\   * P.DIALS and PYTHON: move 8 pages (2048 bytes) from CODE% + &0400 to &7800\n\\\n\\   * Move 2 pages (512 bytes) from UU% to &0B00-&0CFF\n\\\n\\ and call the routine to draw Saturn between P.(C)ASFT and P.DIALS.\n\\\n\\ See part 1 above for more details on the above files and the locations that\n\\ they are moved to.\n\\\n\\ The code at UU% (see below) forms part of the loader code and is moved before\n\\ being run, so it's tucked away safely while the main game code is loaded and\n\\ decrypted.\n\\\n\\ ******************************************************************************\n\n LDX #4                 \\ Set the following:\n STX P+1                \\\n LDA #HI(CODE%)         \\   P(1 0) = &0400\n STA ZP+1               \\   ZP(1 0) = CODE%\n LDY #0                 \\   (X Y) = &400 = 1024\n LDA #256-LEN1          \\\n STA (V219-4,X)         \\ In doPROT1 above we set V219(1 0) = &0218, so this\n STY ZP                 \\ also sets the contents of &0218 (the low byte of\n STY P                  \\ BPUTV) to 256 - LEN1, or &F1. We set the low byte to\n                        \\ 1 above, so BPUTV now contains &01F1, which we will\n                        \\ use at the start of part 4\n\n JSR crunchit           \\ Call crunchit, which has now been modified to call the\n                        \\ MVDL routine on the stack, to move and decrypt &400\n                        \\ bytes from CODE% to &0400. We loaded WORDS9.bin to\n                        \\ CODE% in part 1, so this moves WORDS9\n\n LDX #1                 \\ Set the following:\n LDA #(HI(CODE%)+&C)    \\\n STA ZP+1               \\   P(1 0) = &6300\n LDA #&63               \\   ZP(1 0) = CODE% + &C\n STA P+1                \\   (X Y) = &100 = 256\n LDY #0\n\n JSR crunchit           \\ Call crunchit to move and decrypt &100 bytes from\n                        \\ CODE% + &C to &6300, so this moves P.ELITE\n\n LDX #1                 \\ Set the following:\n LDA #(HI(CODE%)+&D)    \\\n STA ZP+1               \\   P(1 0) = &6100\n LDA #&61               \\   ZP(1 0) = CODE% + &D\n STA P+1                \\   (X Y) = &100 = 256\n LDY #0\n\n JSR crunchit           \\ Call crunchit to move and decrypt &100 bytes from\n                        \\ CODE% + &D to &6100, so this moves P.A-SOFT\n\n LDX #1                 \\ Set the following:\n LDA #(HI(CODE%)+&E)    \\\n STA ZP+1               \\   P(1 0) = &7600\n LDA #&76               \\   ZP(1 0) = CODE% + &E\n STA P+1                \\   (X Y) = &100 = 256\n LDY #0\n\n JSR crunchit           \\ Call crunchit to move and decrypt &100 bytes from\n                        \\ CODE% + &E to &7600, so this moves P.(C)ASFT\n\n JSR PLL1               \\ Call PLL1 to draw Saturn\n\n LDX #8                 \\ Set the following:\n LDA #(HI(CODE%)+4)     \\\n STA ZP+1               \\   P(1 0) = &7800\n LDA #&78               \\   ZP(1 0) = CODE% + &4\n STA P+1                \\   (X Y) = &800 = 2048\n LDY #0                 \\\n STY ZP                 \\ Also set BLCNT = 0\n STY BLCNT\n STY P\n\n JSR crunchit           \\ Call crunchit to move and decrypt &800 bytes from\n                        \\ CODE% + &4 to &7800, so this moves P.DIALS and PYTHON\n\nIF DISC\n\n LDX #2                 \\ Set the following:\n LDA #HI(UU%)           \\\n STA ZP+1               \\   P(1 0) = LE%\n LDA #LO(UU%)           \\   ZP(1 0) = UU%\n STA ZP                 \\   (X Y) = &200 = 512 (as we are building for disc)\n LDA #HI(LE%)\n STA P+1\n LDY #0\n STY P\n\nELSE\n\n LDX #3                 \\ Set the following:\n LDA #HI(UU%)           \\\n STA ZP+1               \\   P(1 0) = LE%\n LDA #LO(UU%)           \\   ZP(1 0) = UU%\n STA ZP                 \\   (X Y) = &300 = 768 (as we are building for tape)\n LDA #HI(LE%)\n STA P+1\n LDY #0\n STY P\n\nENDIF\n\n JSR crunchit           \\ Call crunchit to move and decrypt either &200 or &300\n                        \\ bytes from UU% to LE%, leaving X = 0\n\n\\ ******************************************************************************\n\\\n\\       Name: Elite loader (Part 4 of 6)\n\\       Type: Subroutine\n\\   Category: Loader\n\\    Summary: Copy more code onto stack, decrypt TUT block, set up IRQ1 handler\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This part copies more code onto the stack (from BLOCK to ENDBLOCK), decrypts\n\\ the code from TUT onwards, and sets up the IRQ1 handler for the split-screen\n\\ mode.\n\\\n\\ ******************************************************************************\n\n STY David3-2           \\ Y was set to 0 above, so this modifies the OS01\n                        \\ routine above by changing the TXS instruction to BRK,\n                        \\ so calls to OS01 will now do this:\n                        \\\n                        \\   LDX #&FF\n                        \\   BRK\n                        \\\n                        \\ This is presumably just to confuse any cracker, as we\n                        \\ don't call OS01 again\n\n                        \\ We now enter a loop that starts with the counter in Y\n                        \\ (initially set to 0). It calls JSR &01F1 on the stack,\n                        \\ which pushes the Y-th byte of BLOCK on the stack\n                        \\ before encrypting the Y-th byte of BLOCK in-place. It\n                        \\ then jumps back to David5 below, where we increment Y\n                        \\ until it reaches a value of ENDBLOCK - BLOCK. So this\n                        \\ loop basically decrypts the code from TUT onwards, and\n                        \\ at the same time it pushes the code between BLOCK and\n                        \\ ENDBLOCK onto the stack, so it's there ready to be run\n                        \\ (at address &0163)\n\n.David2\n\n EQUB &AC               \\ This byte was changed to &20 by part 2, so by the time\n EQUW &FFD4             \\ we get here, these three bytes together become JSR\n                        \\ &FFD4, or JSR OSBPUT. Amongst all the code above,\n                        \\ we've also managed to set BPUTV to &01F1, and as BPUTV\n                        \\ is the vector that OSBPUT goes through, these three\n                        \\ bytes are actually doing JSR &01F1\n                        \\\n                        \\ That address is in the stack, and is the address of\n                        \\ the BEGIN% routine, which we pushed onto the stack in\n                        \\ the modified PROT1 routine. That routine doesn't\n                        \\ return with an RTS, but instead it removes the return\n                        \\ address from the stack and jumps to David5 below after\n                        \\ pushing the Y-th byte of BLOCK onto the stack and\n                        \\ EOR'ing the Y-th byte of TUT with the Y-th byte of\n                        \\ BLOCK\n                        \\\n                        \\ This obfuscation probably kept the crackers busy for a\n                        \\ while - it's difficult enough to work out when you\n                        \\ have the source code in front of you!\n\n.LBLa\n\n                        \\ If, for some reason, the above JSR doesn't call the\n                        \\ routine on the stack and returns normally, which might\n                        \\ happen if crackers manage to unpick the BPUTV\n                        \\ redirection, then we end up here. We now obfuscate the\n                        \\ first 255 bytes of the location where the main game\n                        \\ gets loaded (which is set in C%), just to make things\n                        \\ hard, and then we reset the machine... all in a\n                        \\ completely twisted manner, of course\n\n LDA C%,X               \\ Obfuscate the X-th byte of C% by EOR'ing with &A5\n EOR #&A5\n STA C%,X\n\n DEX                    \\ Decrement the loop counter\n\n BNE LBLa               \\ Loop back until X wraps around, after EOR'ing a whole\n                        \\ page\n\n JMP (C%+&CF)           \\ C%+&CF is &100F, which in the main game code contains\n                        \\ an LDA KY17 instruction (it's in the main loader in\n                        \\ the MA76 section). This has opcode &A5 &4E, and the\n                        \\ EOR above changes the first of these to &00, so this\n                        \\ jump goes to a BRK instruction, which in turn goes to\n                        \\ BRKV, which in turn resets the computer (as we set\n                        \\ BRKV to point to the reset address in part 2)\n\n.swine2\n\n JMP swine              \\ Jump to swine to reset the machine\n\n EQUW &4CFF             \\ This data doesn't appear to be used\n\n.crunchit\n\n BRK                    \\ This instruction gets changed to an indirect JMP at\n EQUW David23           \\ the end of part 2, so this does JMP (David23). David23\n                        \\ contains &01DF, so these bytes are actually doing JMP\n                        \\ &01DF. That address is in the stack, and is the\n                        \\ address of the MVDL routine, which we pushed onto the\n                        \\ stack in the modified PROT1 routine... so this\n                        \\ actually does the following:\n                        \\\n                        \\   JMP MVDL\n                        \\\n                        \\ meaning that this instruction:\n                        \\\n                        \\   JSR crunchit\n                        \\\n                        \\ actually does this, because it's a tail call:\n                        \\\n                        \\   JSR MVDL\n                        \\\n                        \\ It's yet another impressive bit of obfuscation and\n                        \\ misdirection\n\n.RAND\n\n EQUD &6C785349         \\ The random number seed used for drawing Saturn\n\n.David5\n\n INY                    \\ Increment the loop counter\n\n CPY #(ENDBLOCK-BLOCK)  \\ Loop back to copy the next byte until we have copied\n BNE David2             \\ all the bytes between BLOCK and ENDBLOCK\n\n SEI                    \\ Disable interrupts while we set up our interrupt\n                        \\ handler to support the split-screen mode\n\n LDA #%11000010         \\ Clear 6522 System VIA interrupt enable register IER\n STA VIA+&4E            \\ (SHEILA &4E) bits 1 and 7 (i.e. enable CA1 and TIMER1\n                        \\ interrupts from the System VIA, which enable vertical\n                        \\ sync and the 1 MHz timer, which we need enabled for\n                        \\ the split-screen interrupt code to work)\n\n LDA #%01111111         \\ Set 6522 User VIA interrupt enable register IER\n STA &FE6E              \\ (SHEILA &6E) bits 0-7 (i.e. disable all hardware\n                        \\ interrupts from the User VIA)\n\n LDA IRQ1V              \\ Store the low byte of the current IRQ1V vector in VEC\n STA VEC\n\n LDA IRQ1V+1            \\ If the current high byte of the IRQ1V vector is less\n BPL swine2             \\ than &80, which means it points to user RAM rather\n                        \\ the MOS ROM, then something is probably afoot, so jump\n                        \\ to swine2 to reset the machine\n\n STA VEC+1              \\ Otherwise all is well, so store the high byte of the\n                        \\ current IRQ1V vector in VEC+1, so VEC(1 0) now\n                        \\ contains the original address of the IRQ1 handler\n\n LDA #HI(IRQ1)          \\ Set the IRQ1V vector to IRQ1, so IRQ1 is now the\n STA IRQ1V+1            \\ interrupt handler\n LDA #LO(IRQ1)\n STA IRQ1V\n\n LDA #VSCAN             \\ Set 6522 System VIA T1C-L timer 1 high-order counter\n STA VIA+&45            \\ (SHEILA &45) to VSCAN (56) to start the T1 counter\n                        \\ counting down from 14080 at a rate of 1 MHz (this is\n                        \\ a different value to the main game code)\n\n CLI                    \\ Re-enable interrupts\n\nIF DISC\n\n LDA #%10000001         \\ Clear 6522 System VIA interrupt enable register IER\n STA &FE4E              \\ (SHEILA &4E) bit 1 (i.e. enable the CA2 interrupt,\n                        \\ which comes from the keyboard)\n\n LDY #20                \\ Set Y = 20 for the following OSBYTE call\n\nIF _REMOVE_CHECKSUMS\n\n NOP                    \\ If we have disabled checksums, skip the OSBYTE call\n NOP\n NOP\n\nELSE\n\n JSR OSBYTE             \\ A was set to 129 above, so this calls OSBYTE with\n                        \\ A = 129 and Y = 20, as well as a value of X = 0,\n                        \\ which was set by the call to crunchit at the end of\n                        \\ part 3\n                        \\\n                        \\ This reads the keyboard with a time limit of (Y X)\n                        \\ centiseconds, or 20 * 256 = 5120 centiseconds, or\n                        \\ 51.2 seconds\n\nENDIF\n\n LDA #%00000001         \\ Set 6522 System VIA interrupt enable register IER\n STA &FE4E              \\ (SHEILA &4E) bit 1 (i.e. disable the CA2 interrupt,\n                        \\ which comes from the keyboard)\n\nENDIF\n\n RTS                    \\ This RTS actually does a jump to ENTRY2, to the next\n                        \\ step of the loader in part 5. See the documentation\n                        \\ for the stack routine at BEGIN% for more details\n\n\\ ******************************************************************************\n\\\n\\       Name: PLL1 (Part 1 of 3)\n\\       Type: Subroutine\n\\   Category: Drawing planets\n\\    Summary: Draw Saturn on the loading screen (draw the planet)\n\\  Deep dive: Drawing Saturn on the loading screen\n\\\n\\ ******************************************************************************\n\n.PLL1\n\n                        \\ The following loop iterates CNT(1 0) times, i.e. &500\n                        \\ or 1280 times, and draws the planet part of the\n                        \\ loading screen's Saturn\n\n LDA VIA+&44            \\ Read the 6522 System VIA T1C-L timer 1 low-order\n STA RAND+1             \\ counter (SHEILA &44), which decrements one million\n                        \\ times a second and will therefore be pretty random,\n                        \\ and store it in location RAND+1, which is among the\n                        \\ main game code's random seeds in RAND (so this seeds\n                        \\ the random number generator)\n\n JSR DORND              \\ Set A and X to signed random numbers between -128 and\n                        \\ 127, so let's say A = r1\n\n JSR SQUA2              \\ Set (A P) = A * A\n                        \\           = r1^2\n\n STA ZP+1               \\ Set ZP(1 0) = (A P)\n LDA P                  \\             = r1^2\n STA ZP\n\n JSR DORND              \\ Set A and X to signed random numbers between -128 and\n                        \\ 127, so let's say A = r2\n\n STA YY                 \\ Set YY = A\n                        \\        = r2\n\n JSR SQUA2              \\ Set (A P) = A * A\n                        \\           = r2^2\n\n TAX                    \\ Set (X P) = (A P)\n                        \\           = r2^2\n\n LDA P                  \\ Set (A ZP) = (X P) + ZP(1 0)\n ADC ZP                 \\\n STA ZP                 \\ first adding the low bytes\n\n TXA                    \\ And then adding the high bytes\n ADC ZP+1\n\n BCS PLC1               \\ If the addition overflowed, jump down to PLC1 to skip\n                        \\ to the next pixel\n\n STA ZP+1               \\ Set ZP(1 0) = (A ZP)\n                        \\             = r1^2 + r2^2\n\n LDA #1                 \\ Set ZP(1 0) = &4001 - ZP(1 0) - (1 - C)\n SBC ZP                 \\             = 128^2 - ZP(1 0)\n STA ZP                 \\\n                        \\ (as the C flag is clear), first subtracting the low\n                        \\ bytes\n\n LDA #&40               \\ And then subtracting the high bytes\n SBC ZP+1\n STA ZP+1\n\n BCC PLC1               \\ If the subtraction underflowed, jump down to PLC1 to\n                        \\ skip to the next pixel\n\n                        \\ If we get here, then both calculations fitted into\n                        \\ 16 bits, and we have:\n                        \\\n                        \\   ZP(1 0) = 128^2 - (r1^2 + r2^2)\n                        \\\n                        \\ where ZP(1 0) >= 0\n\n JSR ROOT               \\ Set ZP = SQRT(ZP(1 0))\n\n LDA ZP                 \\ Set X = ZP >> 1\n LSR A                  \\       = SQRT(128^2 - (a^2 + b^2)) / 2\n TAX\n\n LDA YY                 \\ Set A = YY\n                        \\       = r2\n\n CMP #128               \\ If YY >= 128, set the C flag (so the C flag is now set\n                        \\ to bit 7 of A)\n\n ROR A                  \\ Rotate A and set the sign bit to the C flag, so A is\n                        \\ halved while retaining its sign\n                        \\\n                        \\ A is still a signed number from -128 to 127\n\n JSR PIX                \\ Draw a pixel at screen coordinate (X + 128, A + 128),\n                        \\ where:\n                        \\\n                        \\   X = ZP / 2\n                        \\   A = r2 / 2\n                        \\   ZP = SQRT(128^2 - (r1^2 + r2^2))\n                        \\\n                        \\ So this is the same as plotting at (x, y) where:\n                        \\\n                        \\   r1 = random number from -128 to 127\n                        \\   r2 = random number from -128 to 127\n                        \\\n                        \\   (r1^2 + r2^2) < 128^2\n                        \\\n                        \\   x = (SQRT(128^2 - (r1^2 + r2^2)) / 2) + 128\n                        \\   y = (r2 / 2) + 128\n                        \\\n                        \\ which is what we want\n\n.PLC1\n\n DEC CNT                \\ Decrement the counter in CNT (the low byte)\n\n BNE PLL1               \\ Loop back to PLL1 until CNT = 0\n\n DEC CNT+1              \\ Decrement the counter in CNT+1 (the high byte)\n\n BNE PLL1               \\ Loop back to PLL1 until CNT+1 = 0\n\n LDX #&C2               \\ Set the low byte of EXCN(1 0) to &C2, so we now have\n STX EXCN               \\ EXCN(1 0) = &03C2, which we will use in the IRQ1\n                        \\ handler (this has nothing to do with drawing Saturn,\n                        \\ it's all part of the copy protection)\n\n\\ ******************************************************************************\n\\\n\\       Name: PLL1 (Part 2 of 3)\n\\       Type: Subroutine\n\\   Category: Drawing planets\n\\    Summary: Draw Saturn on the loading screen (draw the stars)\n\\  Deep dive: Drawing Saturn on the loading screen\n\\\n\\ ******************************************************************************\n\n                        \\ The following loop iterates CNT2(1 0) times, i.e. &1DD\n                        \\ or 477 times, and draws the background stars on the\n                        \\ loading screen\n\n.PLL2\n\n JSR DORND              \\ Set A and X to signed random numbers between -128 and\n                        \\ 127, so let's say A = r3\n\n TAX                    \\ Set X = A\n                        \\       = r3\n\n JSR SQUA2              \\ Set (A P) = A * A\n                        \\           = r3^2\n\n STA ZP+1               \\ Set ZP+1 = A\n                        \\          = r3^2 / 256\n\n JSR DORND              \\ Set A and X to signed random numbers between -128 and\n                        \\ 127, so let's say A = r4\n\n STA YY                 \\ Set YY = r4\n\n JSR SQUA2              \\ Set (A P) = A * A\n                        \\           = r4^2\n\n ADC ZP+1               \\ Set A = A + r3^2 / 256\n                        \\       = r4^2 / 256 + r3^2 / 256\n                        \\       = (r3^2 + r4^2) / 256\n\n CMP #&11               \\ If A < 17, jump down to PLC2 to skip to the next pixel\n BCC PLC2\n\n LDA YY                 \\ Set A = r4\n\n JSR PIX                \\ Draw a pixel at screen coordinate (X + 128, A + 128),\n                        \\ where:\n                        \\\n                        \\   X = r3\n                        \\   A = r4\n                        \\\n                        \\ So this is the same as plotting at (x, y) where:\n                        \\\n                        \\   r3 = random number from -128 to 127\n                        \\   r4 = random number from -128 to 127\n                        \\\n                        \\   (r3^2 + r4^2) / 256 >= 17\n                        \\\n                        \\   x = r3\n                        \\   y = r4\n                        \\\n                        \\ which is what we want\n\n.PLC2\n\n DEC CNT2               \\ Decrement the counter in CNT2 (the low byte)\n\n BNE PLL2               \\ Loop back to PLL2 until CNT2 = 0\n\n DEC CNT2+1             \\ Decrement the counter in CNT2+1 (the high byte)\n\n BNE PLL2               \\ Loop back to PLL2 until CNT2+1 = 0\n\n LDX MHCA               \\ Set the low byte of BLPTR(1 0) to the contents of MHCA\n STX BLPTR              \\ (which is &CA), so we now have BLPTR(1 0) = &03CA,\n                        \\ which we will use in the IRQ1 handler (this has\n                        \\ nothing to do with drawing Saturn, it's all part of\n                        \\ the copy protection)\n\n LDX #&C6               \\ Set the low byte of BLN(1 0) to &C6, so we now have\n STX BLN                \\ BLN(1 0) = &03C6, which we will use in the IRQ1\n                        \\ handler (this has nothing to do with drawing Saturn,\n                        \\ it's all part of the copy protection)\n\n\\ ******************************************************************************\n\\\n\\       Name: PLL1 (Part 3 of 3)\n\\       Type: Subroutine\n\\   Category: Drawing planets\n\\    Summary: Draw Saturn on the loading screen (draw the rings)\n\\  Deep dive: Drawing Saturn on the loading screen\n\\\n\\ ******************************************************************************\n\n                        \\ The following loop iterates CNT3(1 0) times, i.e. &500\n                        \\ or 1280 times, and draws the rings around the loading\n                        \\ screen's Saturn\n\n.PLL3\n\n JSR DORND              \\ Set A and X to signed random numbers between -128 and\n                        \\ 127, so let's say A = r5\n\n STA ZP                 \\ Set ZP = r5\n\n JSR SQUA2              \\ Set (A P) = A * A\n                        \\           = r5^2\n\n STA ZP+1               \\ Set ZP+1 = A\n                        \\          = r5^2 / 256\n\n JSR DORND              \\ Set A and X to signed random numbers between -128 and\n                        \\ 127, so let's say A = r6\n\n STA YY                 \\ Set YY = r6\n\n JSR SQUA2              \\ Set (A P) = A * A\n                        \\           = r6^2\n\n STA T                  \\ Set T = A\n                        \\       = r6^2 / 256\n\n ADC ZP+1               \\ Set ZP+1 = A + r5^2 / 256\n STA ZP+1               \\          = r6^2 / 256 + r5^2 / 256\n                        \\          = (r5^2 + r6^2) / 256\n\n LDA ZP                 \\ Set A = ZP\n                        \\       = r5\n\n CMP #128               \\ If A >= 128, set the C flag (so the C flag is now set\n                        \\ to bit 7 of ZP, i.e. bit 7 of A)\n\n ROR A                  \\ Rotate A and set the sign bit to the C flag, so bits\n                        \\ 6 and 7 are now the same\n\n CMP #128               \\ If A >= 128, set the C flag (so again, the C flag is\n                        \\ set to bit 7 of A)\n\n ROR A                  \\ Rotate A and set the sign bit to the C flag, so bits\n                        \\ 5-7 are now the same, i.e. A is a random number in one\n                        \\ of these ranges:\n                        \\\n                        \\   %00000000 - %00011111  = 0-31\n                        \\   %11100000 - %11111111  = 224-255\n                        \\\n                        \\ In terms of signed 8-bit integers, this is a random\n                        \\ number from -32 to 31. Let's call it r7\n\n ADC YY                 \\ Set A = A + YY\n                        \\       = r7 + r6\n\n TAX                    \\ Set X = A\n                        \\       = r6 + r7\n\n JSR SQUA2              \\ Set (A P) = A * A\n                        \\           = (r6 + r7)^2\n\n TAY                    \\ Set Y = A\n                        \\       = (r6 + r7)^2 / 256\n\n ADC ZP+1               \\ Set A = A + ZP+1\n                        \\       = (r6 + r7)^2 / 256 + (r5^2 + r6^2) / 256\n                        \\       = ((r6 + r7)^2 + r5^2 + r6^2) / 256\n\n BCS PLC3               \\ If the addition overflowed, jump down to PLC3 to skip\n                        \\ to the next pixel\n\n CMP #80                \\ If A >= 80, jump down to PLC3 to skip to the next\n BCS PLC3               \\ pixel\n\n CMP #32                \\ If A < 32, jump down to PLC3 to skip to the next pixel\n BCC PLC3\n\n TYA                    \\ Set A = Y + T\n ADC T                  \\       = (r6 + r7)^2 / 256 + r6^2 / 256\n                        \\       = ((r6 + r7)^2 + r6^2) / 256\n\n CMP #16                \\ If A >= 16, skip to PL1 to plot the pixel\n BCS PL1\n\n LDA ZP                 \\ If ZP is positive (i.e. r5 < 128), jump down to PLC3\n BPL PLC3               \\ to skip to the next pixel\n\n.PL1\n\n                        \\ If we get here then the following is true:\n                        \\\n                        \\   32 <= ((r6 + r7)^2 + r5^2 + r6^2) / 256 < 80\n                        \\\n                        \\ and either this is true:\n                        \\\n                        \\   ((r6 + r7)^2 + r6^2) / 256 >= 16\n                        \\\n                        \\ or both these are true:\n                        \\\n                        \\   ((r6 + r7)^2 + r6^2) / 256 < 16\n                        \\   r5 >= 128\n\n LDA YY                 \\ Set A = YY\n                        \\       = r6\n\n JSR PIX                \\ Draw a pixel at screen coordinate (X + 128, A + 128),\n                        \\ where:\n                        \\\n                        \\   X = (random -32 to 31) + r6\n                        \\   A = r6\n                        \\\n                        \\ So this is the same as plotting at (x, y) where:\n                        \\\n                        \\   r5 = random number from -128 to 127\n                        \\   r6 = random number from -128 to 127\n                        \\   r7 = r5, squashed into -32 to 31\n                        \\\n                        \\   32 <= ((r6 + r7)^2 + r5^2 + r6^2) / 256 < 80\n                        \\\n                        \\   Either: ((r6 + r7)^2 + r6^2) / 256 >= 16\n                        \\\n                        \\   Or:     ((r6 + r7)^2 + r6^2) / 256 <  16\n                        \\           r5 >= 128\n                        \\\n                        \\   x = r6 + r7 + 128\n                        \\   y = r6 + 128\n                        \\\n                        \\ which is what we want\n\n.PLC3\n\n DEC CNT3               \\ Decrement the counter in CNT3 (the low byte)\n\n BNE PLL3               \\ Loop back to PLL3 until CNT3 = 0\n\n DEC CNT3+1             \\ Decrement the counter in CNT3+1 (the high byte)\n\n BNE PLL3               \\ Loop back to PLL3 until CNT3+1 = 0\n\n\\ ******************************************************************************\n\\\n\\       Name: DORND\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Generate random numbers\n\\  Deep dive: Generating random numbers\n\\             Fixing ship positions\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Set A and X to random numbers (though note that X is set to the random number\n\\ that was returned in A the last time DORND was called).\n\\\n\\ The C and V flags are also set randomly.\n\\\n\\ This is a simplified version of the DORND routine in the main game code. It\n\\ swaps the two calculations around and omits the ROL A instruction, but is\n\\ otherwise very similar. See the DORND routine in the main game code for more\n\\ details.\n\\\n\\ ******************************************************************************\n\n.DORND\n\n LDA RAND+1             \\ r1´ = r1 + r3 + C\n TAX                    \\ r3´ = r1\n ADC RAND+3\n STA RAND+1\n STX RAND+3\n\n LDA RAND               \\ X = r2´ = r0\n TAX                    \\ A = r0´ = r0 + r2\n ADC RAND+2\n STA RAND\n STX RAND+2\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: SQUA2\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate (A P) = A * A\n\\  Deep dive: Shift-and-add multiplication\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Do the following multiplication of signed 8-bit numbers:\n\\\n\\   (A P) = A * A\n\\\n\\ This uses a similar approach to routine SQUA2 in the main game code, which\n\\ itself uses the MU11 routine to do the multiplication. However, this version\n\\ first ensures that A is positive, so it can support signed numbers.\n\\\n\\ ******************************************************************************\n\n.SQUA2\n\n BPL SQUA               \\ If A > 0, jump to SQUA\n\n EOR #&FF               \\ Otherwise we need to negate A for the SQUA algorithm\n CLC                    \\ to work, so we do this using two's complement, by\n ADC #1                 \\ setting A = ~A + 1\n\n.SQUA\n\n STA Q                  \\ Set Q = A and P = A\n\n STA P                  \\ Set P = A\n\n LDA #0                 \\ Set A = 0 so we can start building the answer in A\n\n LDY #8                 \\ Set up a counter in Y to count the 8 bits in P\n\n LSR P                  \\ Set P = P >> 1\n                        \\ and C flag = bit 0 of P\n\n.SQL1\n\n BCC SQ1                \\ If C (i.e. the next bit from P) is set, do the\n CLC                    \\ addition for this bit of P:\n ADC Q                  \\\n                        \\   A = A + Q\n\n.SQ1\n\n ROR A                  \\ Shift A right to catch the next digit of our result,\n                        \\ which the next ROR sticks into the left end of P while\n                        \\ also extracting the next bit of P\n\n ROR P                  \\ Add the overspill from shifting A to the right onto\n                        \\ the start of P, and shift P right to fetch the next\n                        \\ bit for the calculation into the C flag\n\n DEY                    \\ Decrement the loop counter\n\n BNE SQL1               \\ Loop back for the next bit until P has been rotated\n                        \\ all the way\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: PIX\n\\       Type: Subroutine\n\\   Category: Drawing pixels\n\\    Summary: Draw a single pixel at a specific coordinate\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Draw a pixel at screen coordinate (X + 128, A + 128). The routine uses the\n\\ same approach as the PIXEL routine in the main game code, except it plots a\n\\ single pixel from TWOS instead of a two pixel dash from TWOS2. This applies\n\\ to the top part of the screen (the monochrome mode 4 space view).\n\\\n\\ See the PIXEL routine in the main game code for more details.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   The signed screen x-coordinate of the pixel to draw,\n\\                       from -128 to 127, to be plotted relative to the origin\n\\                       at (128, 128)\n\\\n\\   A                   The signed screen y-coordinate of the pixel to draw,\n\\                       from -128 to 127, to be plotted relative to the origin\n\\                       at (128, 128)\n\\\n\\ ******************************************************************************\n\n.PIX\n\n TAY                    \\ Copy A into Y, for use later\n\n EOR #%10000000         \\ Add 128 to A and treat this as an unsigned number from\n                        \\ now on\n\n LSR A                  \\ Set ZP+1 = &60 + A >> 3\n LSR A\n LSR A\n ORA #&60\n STA ZP+1\n\n TXA                    \\ Set A = X + 128 and treat this as an unsigned number\n EOR #%10000000         \\ from now on\n\n AND #%11111000         \\ Set ZP = (A >> 3) * 8\n STA ZP\n\n TYA                    \\ Set Y = Y mod 8, which is the pixel row within the\n AND #7                 \\ character block at which we want to draw our pixel\n TAY                    \\ (as each character block has 8 rows)\n\n TXA                    \\ Set X = X mod 8, which is the horizontal pixel number\n AND #7                 \\ within the character block where the pixel lies (as\n TAX                    \\ each pixel line in the character block is 8 pixels\n                        \\ wide)\n\n LDA TWOS,X             \\ Fetch a pixel from TWOS and OR it into ZP+Y\n ORA (ZP),Y\n STA (ZP),Y\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: TWOS\n\\       Type: Variable\n\\   Category: Drawing pixels\n\\    Summary: Ready-made single-pixel character row bytes for mode 4\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Ready-made bytes for plotting one-pixel points in mode 4 (the top part of the\n\\ split screen). See the PIX routine for details.\n\\\n\\ ******************************************************************************\n\n.TWOS\n\n EQUB %10000000\n EQUB %01000000\n EQUB %00100000\n EQUB %00010000\n EQUB %00001000\n EQUB %00000100\n EQUB %00000010\n EQUB %00000001\n\n\\ ******************************************************************************\n\\\n\\       Name: CNT\n\\       Type: Variable\n\\   Category: Drawing planets\n\\    Summary: A counter for use in drawing Saturn's planetary body\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Defines the number of iterations of the PLL1 loop, which draws the planet part\n\\ of the loading screen's Saturn.\n\\\n\\ ******************************************************************************\n\n.CNT\n\n EQUW &0500             \\ The number of iterations of the PLL1 loop (1280)\n\n\\ ******************************************************************************\n\\\n\\       Name: CNT2\n\\       Type: Variable\n\\   Category: Drawing planets\n\\    Summary: A counter for use in drawing Saturn's background stars\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Defines the number of iterations of the PLL2 loop, which draws the background\n\\ stars on the loading screen.\n\\\n\\ ******************************************************************************\n\n.CNT2\n\n EQUW &01DD             \\ The number of iterations of the PLL2 loop (477)\n\n\\ ******************************************************************************\n\\\n\\       Name: CNT3\n\\       Type: Variable\n\\   Category: Drawing planets\n\\    Summary: A counter for use in drawing Saturn's rings\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Defines the number of iterations of the PLL3 loop, which draws the rings\n\\ around the loading screen's Saturn.\n\\\n\\ ******************************************************************************\n\n.CNT3\n\n EQUW &0500             \\ The number of iterations of the PLL3 loop (1280)\n\n\\ ******************************************************************************\n\\\n\\       Name: ROOT\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate ZP = SQRT(ZP(1 0))\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following square root:\n\\\n\\   ZP = SQRT(ZP(1 0))\n\\\n\\ This routine is identical to LL5 in the main game code - it even has the same\n\\ label names. The only difference is that LL5 calculates Q = SQRT(R Q), but\n\\ apart from the variables used, the instructions are identical, so see the LL5\n\\ routine in the main game code for more details on the algorithm used here.\n\\\n\\ ******************************************************************************\n\n.ROOT\n\n LDY ZP+1               \\ Set (Y Q) = ZP(1 0)\n LDA ZP\n STA Q\n\n                        \\ So now to calculate ZP = SQRT(Y Q)\n\n LDX #0                 \\ Set X = 0, to hold the remainder\n\n STX ZP                 \\ Set ZP = 0, to hold the result\n\n LDA #8                 \\ Set P = 8, to use as a loop counter\n STA P\n\n.LL6\n\n CPX ZP                 \\ If X < ZP, jump to LL7\n BCC LL7\n\n BNE LL8                \\ If X > ZP, jump to LL8\n\n CPY #64                \\ If Y < 64, jump to LL7 with the C flag clear,\n BCC LL7                \\ otherwise fall through into LL8 with the C flag set\n\n.LL8\n\n TYA                    \\ Set Y = Y - 64\n SBC #64                \\\n TAY                    \\ This subtraction will work as we know C is set from\n                        \\ the BCC above, and the result will not underflow as we\n                        \\ already checked that Y >= 64, so the C flag is also\n                        \\ set for the next subtraction\n\n TXA                    \\ Set X = X - ZP\n SBC ZP\n TAX\n\n.LL7\n\n ROL ZP                 \\ Shift the result in Q to the left, shifting the C flag\n                        \\ into bit 0 and bit 7 into the C flag\n\n ASL Q                  \\ Shift the dividend in (Y S) to the left, inserting\n TYA                    \\ bit 7 from above into bit 0\n ROL A\n TAY\n\n TXA                    \\ Shift the remainder in X to the left\n ROL A\n TAX\n\n ASL Q                  \\ Shift the dividend in (Y S) to the left\n TYA\n ROL A\n TAY\n\n TXA                    \\ Shift the remainder in X to the left\n ROL A\n TAX\n\n DEC P                  \\ Decrement the loop counter\n\n BNE LL6                \\ Loop back to LL6 until we have done 8 loops\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: BEGIN%\n\\       Type: Subroutine\n\\   Category: Copy protection\n\\    Summary: Single-byte decryption and copying routine, run on the stack\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine is copied to the stack at &01F1. It pushes BLOCK to ENDBLOCK onto\n\\ the stack, and decrypts the code from TUT onwards.\n\\\n\\ The 15 instructions for this routine are pushed onto the stack and executed\n\\ there. The instructions are pushed onto the stack in reverse (as the stack\n\\ grows downwards in memory), so first the JMP gets pushed, then the STA, and\n\\ so on.\n\\\n\\ This is the code that is pushed onto the stack. It gets run by a JMP call to\n\\ David2, which then calls the routine on the stack with JSR &01F1.\n\\\n\\    01F1 : PLA             \\ Remove the return address from the stack that was\n\\    01F2 : PLA             \\ put here by the JSR that called this routine\n\\\n\\    01F3 : LDA BLOCK,Y     \\ Set A = the Y-th byte of BLOCK\n\\\n\\    01F6 : PHA             \\ Push A onto the stack\n\\\n\\    01F7 : EOR TUT,Y       \\ EOR the Y-th byte of TUT with A\n\\    01FA : STA TUT,Y\n\\\n\\    01FD : JMP (David9)    \\ Jump to the address in David9\n\\\n\\ The routine is called inside a loop with Y as the counter. It counts from 0 to\n\\ ENDBLOCK - BLOCK, so the routine eventually pushes every byte between BLOCK\n\\ and ENDBLOCK onto the stack, as well as EOR'ing each byte from TUT onwards to\n\\ decrypt that section.\n\\\n\\ The elite-checksums.py script reverses the order of the bytes between BLOCK\n\\ and ENDBLOCK in the final file, so pushing them onto the stack (which is a\n\\ descending stack) realigns them in memory as assembled below. Not only that,\n\\ but the last two bytes pushed on the stack are the ones that are at the start\n\\ of the block at BLOCK, and these contain the address of ENTRY2. This is why\n\\ the RTS at the end of part 4 above actually jumps to ENTRY2 in part 5.\n\\\n\\ ******************************************************************************\n\n.BEGIN%\n\n EQUB HI(David9)        \\ JMP (David9)\n EQUB LO(David9)\n EQUB &6C\n\n EQUB HI(TUT)           \\ STA TUT,Y\n EQUB LO(TUT)\n EQUB &99\n\nIF _REMOVE_CHECKSUMS\n\n EQUB HI(TUT)           \\ If we have disabled checksums, then just load the Y-th\n EQUB LO(TUT)           \\ byte of TUT with LDA TUT,Y\n EQUB &B9\n\nELSE\n\n EQUB HI(TUT)           \\ EOR TUT,Y\n EQUB LO(TUT)\n EQUB &59\n\nENDIF\n\n PHA                    \\ PHA\n\n EQUB HI(BLOCK)         \\ LDA BLOCK,Y\n EQUB LO(BLOCK)\n EQUB &B9\n\n PLA                    \\ PLA\n\n PLA                    \\ PLA\n\n\\ ******************************************************************************\n\\\n\\       Name: DOMOVE\n\\       Type: Subroutine\n\\   Category: Copy protection\n\\    Summary: Multi-byte decryption and copying routine, run on the stack\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine is copied to the stack at &01DF. It moves and decrypts a block of\n\\ memory. The original source refers to the stack routine as MVDL.\n\\\n\\ The 18 instructions for this routine are pushed onto the stack and executed\n\\ there. The instructions are pushed onto the stack in reverse (as the stack\n\\ grows downwards in memory), so first the RTS gets pushed, then the BNE, and\n\\ so on.\n\\\n\\ This is the code that is pushed onto the stack. It gets run by a JMP call to\n\\ crunchit, which then calls the routine on the stack at MVDL, or &01DF. The\n\\ label MVDL comes from a comment in the original source file ELITES.\n\\\n\\    01DF : .MVDL\n\\\n\\    01DF : LDA (ZP),Y      \\ Set A = the Y-th byte from the block whose address\n\\                           \\ is in ZP(1 0)\n\\\n\\    01E1 : EOR OSB,Y       \\ EOR A with the Y-th byte on from OSB\n\\\n\\    01E4 : STA (P),Y       \\ Store A in the Y-th byte of the block whose\n\\                           \\ address is in P(1 0)\n\\\n\\    01E6 : DEY             \\ Decrement the loop counter\n\\\n\\    01E7 : BNE MVDL        \\ Loop back to copy and EOR the next byte until we\n\\                           \\ have copied an entire page (256 bytes)\n\\\n\\    01E9 : INC P+1         \\ Increment the high byte of P(1 0) so it points to\n\\                           \\ the next page of 256 bytes\n\\\n\\    01EB : INC ZP+1        \\ Increment ZP(1 0) so it points to the next page of\n\\                           \\ 256 bytes\n\\\n\\    01ED : DEX             \\ Decrement X\n\\\n\\    01EE : BNE MVDL        \\ Loop back to copy the next page\n\\\n\\    01F0 : RTS             \\ Return from the subroutine, which takes us back\n\\                           \\ to the caller of the crunchit routine using a\n\\                           \\ tail call, as we called this with JMP crunchit\n\\\n\\ We call MVDL with the following arguments:\n\\\n\\   (X Y)               The number of bytes to copy\n\\\n\\   ZP(1 0)             The source address\n\\\n\\   P(1 0)              The destination address\n\\\n\\ The routine moves and decrypts a block of memory, and is used in part 3 to\n\\ move blocks of code and images that are embedded within the loader binary,\n\\ either into low memory locations below PAGE (for the recursive token table and\n\\ page at UU%), or into screen memory (for the loading screen and dashboard\n\\ images).\n\\\n\\ If checksums are disabled in the build, we don't do the EOR instruction, so\n\\ the routine just moves and doesn't decrypt.\n\\\n\\ ******************************************************************************\n\n.DOMOVE\n\n RTS                    \\ RTS\n\n EQUW &D0EF             \\ BNE MVDL\n\n DEX                    \\ DEX\n\n EQUB ZP+1              \\ INC ZP+1\n INC P+1                \\ INC P+1\n EQUB &E6\n\n EQUW &D0F6             \\ BNE MVDL\n\n DEY                    \\ DEY\n\n EQUB P                 \\ STA(P),Y\n EQUB &91\n\nIF _REMOVE_CHECKSUMS\n\n NOP                    \\ If we have disabled checksums, skip the EOR so the\n NOP                    \\ routine just does the copying part\n NOP\n\nELSE\n\n EQUB HI(OSB)           \\ EOR OSB,Y\n EQUB LO(OSB)\n EQUB &59\n\nENDIF\n\n EQUB ZP                \\ LDA(ZP),Y\n EQUB &B1\n\n\\ ******************************************************************************\n\\\n\\       Name: UU%\n\\       Type: Workspace\n\\    Address: &0B00\n\\   Category: Workspaces\n\\    Summary: Marker for a block that is moved as part of the obfuscation\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The code from here to the end of the file gets copied to &0B00 (LE%) by part\n\\ 3. It is called from the end of part 4, via ENTRY2 in part 5 below.\n\\\n\\ ******************************************************************************\n\n.UU%\n\n Q% = P% - LE%\n\n ORG LE%                \\ Set the assembly address to LE%\n\n\\ ******************************************************************************\n\\\n\\       Name: CHECKbyt\n\\       Type: Variable\n\\   Category: Copy protection\n\\    Summary: Checksum for the validity of the UU% workspace\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ We calculate the value of the CHECKbyt checksum in elite-checksum.py, so this\n\\ just reserves a byte. It checks the validity of the first two pages of the UU%\n\\ workspace, which gets copied to LE%.\n\\\n\\ ******************************************************************************\n\n.CHECKbyt\n\n BRK                    \\ This could be an EQUB 0 directive instead of a BRK,\n                        \\ but this is what's in the source code\n\n\\ ******************************************************************************\n\\\n\\       Name: MAINSUM\n\\       Type: Variable\n\\   Category: Copy protection\n\\    Summary: Two checksums for the decryption header and text token table\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Contains two checksum values, one for the header code at LBL, and the other\n\\ for the recursive token table from &0400 to &07FF.\n\\\n\\ ******************************************************************************\n\n.MAINSUM\n\n EQUB &CB               \\ This is the checksum value of the decryption header\n                        \\ code (from LBL to elitea) that gets prepended to the\n                        \\ main game code by elite-bcfs.asm and saved as\n                        \\ ELThead.bin\n\n EQUB 0                 \\ This is the checksum value for the recursive token\n                        \\ table from &0400 to &07FF. We calculate the value in\n                        \\ elite-checksum.py, so this just reserves a byte\n\n\\ ******************************************************************************\n\\\n\\       Name: FOOLV\n\\       Type: Variable\n\\   Category: Copy protection\n\\    Summary: Part of the AFOOL roundabout obfuscation routine\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ FOOLV contains the address of FOOL. This is part of the JSR AFOOL obfuscation\n\\ routine, which calls AFOOL, which then jumps to the address in FOOLV, which\n\\ contains the address of FOOL, which contains an RTS instruction... so overall\n\\ it does nothing, but in a rather roundabout fashion.\n\\\n\\ ******************************************************************************\n\n.FOOLV\n\n EQUW FOOL              \\ The address of FOOL, which contains an RTS\n\n\\ ******************************************************************************\n\\\n\\       Name: CHECKV\n\\       Type: Variable\n\\   Category: Copy protection\n\\    Summary: The address of the LBL routine in the decryption header\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ CHECKV contains the address of the LBL routine at the very start of the main\n\\ game code file, in the decryption header code that gets prepended to the main\n\\ game code by elite-bcfs.asm and saved as ELThead.bin\n\\\n\\ ******************************************************************************\n\n.CHECKV\n\n EQUW LOAD%+1           \\ The address of the LBL routine\n\n\\ ******************************************************************************\n\\\n\\       Name: block1\n\\       Type: Variable\n\\   Category: Drawing the screen\n\\    Summary: Palette data for the two dashboard colour scheme\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Palette bytes for use with the split-screen mode 5. See TVT1 in the main game\n\\ code for an explanation.\n\\\n\\ ******************************************************************************\n\n.block1\n\n EQUB &F5, &E5\n EQUB &B5, &A5\n EQUB &76, &66\n EQUB &36, &26\n EQUB &D4, &C4\n EQUB &94, &84\n\n\\ ******************************************************************************\n\\\n\\       Name: block2\n\\       Type: Variable\n\\   Category: Drawing the screen\n\\    Summary: Palette data for the space part of the screen\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Palette bytes for use with the split-screen mode 4. See TVT1 in the main game\n\\ code for an explanation.\n\\\n\\ ******************************************************************************\n\n.block2\n\n EQUB &D0, &C0\n EQUB &B0, &A0\n EQUB &F0, &E0\n EQUB &90, &80\n EQUB &77, &67\n EQUB &37, &27\n\n\\ ******************************************************************************\n\\\n\\       Name: TT26\n\\       Type: Subroutine\n\\   Category: Text\n\\    Summary: Print a character at the text cursor (WRCHV points here)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine prints a character at the text cursor (XC, YC). It is very\n\\ similar to the routine of the same name in the main game code, so refer to\n\\ that routine for a more detailed description.\n\\\n\\ This routine, however, only works within a small 14x14 character text window,\n\\ which we use for the tape loading messages, so there is extra code for fitting\n\\ the text into the window (and it also reverses the effect of line feeds and\n\\ carriage returns).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The character to be printed\n\\\n\\   XC                  Contains the text column to print at (the x-coordinate)\n\\\n\\   YC                  Contains the line number to print on (the y-coordinate)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   A                   A is preserved\n\\\n\\   X                   X is preserved\n\\\n\\   Y                   Y is preserved\n\\\n\\ ******************************************************************************\n\n.TT26\n\n STA K3                 \\ Store the A, X and Y registers (in K3 for A, and on\n TYA                    \\ the stack for the others), so we can restore them at\n PHA                    \\ the end (so they don't get changed by this routine)\n TXA\n PHA\n\n.rr\n\n LDA K3                 \\ Set A = the character to be printed\n\n CMP #7                 \\ If this is a beep character (A = 7), jump to R5,\n BEQ R5                 \\ which will emit the beep, restore the registers and\n                        \\ return from the subroutine\n\n CMP #32                \\ If this is an ASCII character (A >= 32), jump to RR1\n BCS RR1                \\ below, which will print the character, restore the\n                        \\ registers and return from the subroutine\n\n CMP #13                \\ If this is control code 13 (carriage return) then jump\n BEQ RRX1               \\ to RRX1, which will move along on character, restore\n                        \\ the registers and return from the subroutine (as we\n                        \\ don't have room in the text window for new lines)\n\n INC YC                 \\ If we get here, then this is control code 10, a line\n                        \\ feed, so move down one line and fall through into RRX1\n                        \\ to move the cursor to the start of the line\n\n.RRX1\n\n LDX #7                 \\ Set the column number (x-coordinate) of the text\n STX XC                 \\ to 7\n\n BNE RR4                \\ Jump to RR4 to restore the registers and return from\n                        \\ the subroutine (this BNE is effectively a JMP as Y\n                        \\ will never be zero)\n\n.RR1\n\n LDX #&BF               \\ Set X to point to the first font page in ROM minus 1,\n                        \\ which is &C0 - 1, or &BF\n\n ASL A                  \\ If bit 6 of the character is clear (A is 32-63)\n ASL A                  \\ then skip the following instruction\n BCC P%+4\n\n LDX #&C1               \\ A is 64-126, so set X to point to page &C1\n\n ASL A                  \\ If bit 5 of the character is clear (A is 64-95)\n BCC P%+3               \\ then skip the following instruction\n\n INX                    \\ Increment X, so X now contains the high byte\n                        \\ (the page) of the address of the definition that we\n                        \\ want, while A contains the low byte (the offset into\n                        \\ the page) of the address\n\n STA P                  \\ Store the address of this character's definition in\n STX P+1                \\ P(1 0)\n\n LDA XC                 \\ If the column number (x-coordinate) of the text is\n CMP #20                \\ less than 20, skip to NOLF\n BCC NOLF\n\n LDA #7                 \\ Otherwise we just reached the end of the line, so\n STA XC                 \\ move the text cursor to column 7, and down onto the\n INC YC                 \\ next line\n\n.NOLF\n\n ASL A                  \\ Multiply the x-coordinate (column) of the text by 8\n ASL A                  \\ and store in ZP, to get the low byte of the screen\n ASL A                  \\ address for the character we want to print\n STA ZP\n\n INC XC                 \\ Once we print the character, we want to move the text\n                        \\ cursor to the right, so we do this by incrementing XC\n\n LDA YC                 \\ If the row number (y-coordinate) of the text is less\n CMP #19                \\ than 19, skip to RR3\n BCC RR3\n\n                        \\ Otherwise we just reached the bottom of the screen,\n                        \\ which is a small 14x14 character text window we use\n                        \\ for showing the tape loading messages, so now we need\n                        \\ to clear that window and move the cursor to the top\n\n LDA #7                 \\ Move the text cursor to column 7\n STA XC\n\n LDA #&65               \\ Set the high byte of the SC(1 0) to &65, for character\n STA SC+1               \\ row 5 of the screen\n\n LDY #7*8               \\ Set Y = 7 * 8, for column 7 (as there are 8 bytes per\n                        \\ character block)\n\n LDX #14                \\ Set X = 14, to count the number of character rows we\n                        \\ need to clear\n\n STY SC                 \\ Set the low byte of SC(1 0) to 7*8, so SC(1 0) now\n                        \\ points to the character block at row 5, column 7, at\n                        \\ the top-left corner of the small text window\n\n LDA #0                 \\ Set A = 0 for use in clearing the screen (which we do\n                        \\ by setting the screen memory to 0)\n\n TAY                    \\ Set Y = 0\n\n.David1\n\n STA (SC),Y             \\ Clear the Y-th byte of the block pointed to by SC(1 0)\n\n INY                    \\ Increment the counter in Y\n\n CPY #14*8              \\ Loop back to clear the next byte until we have done 14\n BCC David1             \\ lots of 8 bytes (i.e. 14 characters, the width of the\n                        \\ small text window)\n\n TAY                    \\ Set Y = 0, ready for the next row\n\n INC SC+1               \\ Point SC(1 0) to the next page in memory, i.e. the\n                        \\ next character row\n\n DEX                    \\ Decrement the counter in X\n\n BPL David1             \\ Loop back to David1 until we have done 14 character\n                        \\ rows (the height of the small text window)\n\n LDA #5                 \\ Move the text cursor to row 5\n STA YC\n\n BNE rr                 \\ Jump to rr to print the character we were about to\n                        \\ print when we ran out of space (this BNE is\n                        \\ effectively a JMP as A will never be zero)\n\n.RR3\n\n ORA #&60               \\ Add &60 to YC, giving us the page number that we want\n\n STA ZP+1               \\ Store the page number of the destination screen\n                        \\ location in ZP+1, so ZP now points to the full screen\n                        \\ location where this character should go\n\n LDY #7                 \\ We want to print the 8 bytes of character data to the\n                        \\ screen (one byte per row), so set up a counter in Y\n                        \\ to count these bytes\n\n.RRL1\n\n LDA (P),Y              \\ The character definition is at P(1 0) - we set this up\n                        \\ above -  so load the Y-th byte from P(1 0)\n\n STA (ZP),Y             \\ Store the Y-th byte at the screen address for this\n                        \\ character location\n\n DEY                    \\ Decrement the loop counter\n\n BPL RRL1               \\ Loop back for the next byte to print to the screen\n\n.RR4\n\n PLA                    \\ We're done printing, so restore the values of the\n TAX                    \\ A, X and Y registers that we saved above, loading them\n PLA                    \\ from K3 (for A) and the stack (for X and Y)\n TAY\n LDA K3\n\n.FOOL\n\n RTS                    \\ Return from the subroutine\n\n.R5\n\n LDA #7                 \\ Control code 7 makes a beep, so load this into A\n\n JSR osprint            \\ Call OSPRINT to \"print\" the beep character\n\n JMP RR4                \\ Jump to RR4 to restore the registers and return from\n                        \\ the subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: osprint\n\\       Type: Subroutine\n\\   Category: Utility routines\n\\    Summary: Print a character\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The character to print\n\\\n\\ ******************************************************************************\n\n.TUT\n\n.osprint\n\n JMP (OSPRNT)           \\ Jump to the address in OSPRNT and return using a\n                        \\ tail call\n\n EQUB &6C               \\ This byte appears to be unused\n\n\\ ******************************************************************************\n\\\n\\       Name: command\n\\       Type: Subroutine\n\\   Category: Utility routines\n\\    Summary: Execute an OS command\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   (Y X)               The address of the OS command string to execute\n\\\n\\ ******************************************************************************\n\n.command\n\n JMP (oscliv)           \\ Jump to &FFF7 to execute the OS command pointed to\n                        \\ by (Y X) and return using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: MESS1\n\\       Type: Variable\n\\   Category: Utility routines\n\\    Summary: Contains an OS command string for loading the main game code\n\\\n\\ ******************************************************************************\n\n.MESS1\n\nIF DISC\n\n EQUS \"L.ELTcode 1100\"  \\ This is short for \"*LOAD ELTcode 1100\"\n\nELSE\n\n EQUS \"L.ELITEcode F1F\" \\ This is short for \"*LOAD ELITEcode F1F\"\n\nENDIF\n\n EQUB 13\n\n\\ ******************************************************************************\n\\\n\\       Name: Elite loader (Part 5 of 6)\n\\       Type: Subroutine\n\\   Category: Loader\n\\    Summary: Load main game code, decrypt it, move it to the correct location\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This part loads the main game code, decrypts it and moves it to the correct\n\\ location for it to run.\n\\\n\\ The code in this part is encrypted by elite-checksum.py and is decrypted in\n\\ part 4 by the same routine that moves part 6 onto the stack.\n\\\n\\ ******************************************************************************\n\n.ENTRY2\n\n                        \\ We start this part of the loader by setting the\n                        \\ following:\n                        \\\n                        \\   OSPRNT(1 0) = WRCHV\n                        \\   WRCHV(1 0) = TT26\n                        \\   (Y X) = MESS1(1 0)\n                        \\\n                        \\ so any character printing will use the TT26 routine\n\n LDA &020E              \\ Copy the low byte of WRCHV to the low byte of OSPRNT\n STA OSPRNT\n\n LDA #LO(TT26)          \\ Set the low byte of WRCHV to the low byte of TT26\n STA &020E\n\n LDX #LO(MESS1)         \\ Set X to the low byte of MESS1\n\n LDA &020F              \\ Copy the high byte of WRCHV to the high byte of OSPRNT\n STA OSPRNT+1\n\n LDA #HI(TT26)          \\ Set the high byte of WRCHV to the high byte of TT26\n LDY #HI(MESS1)         \\ and set Y to the high byte of MESS1\n STA &020F\n\n JSR AFOOL              \\ This calls AFOOL, which jumps to the address in FOOLV,\n                        \\ which contains the address of FOOL, which contains an\n                        \\ RTS instruction... so overall this does nothing, but\n                        \\ in a rather roundabout fashion\n\n JSR command            \\ Call command to execute the OSCLI command pointed to\n                        \\ by (Y X) in MESS1, which starts loading the main game\n                        \\ code\n\n JSR 512-LEN+CHECKER-ENDBLOCK \\ Call the CHECKER routine in its new location on\n                              \\ the stack, to run a number of checksums on the\n                              \\ code (this routine, along with the whole of part\n                              \\ 6, was pushed onto the stack in part 4)\n\n JSR AFOOL              \\ Another call to the round-the-houses routine to try\n                        \\ and distract the crackers, presumably\n\nIF DISC\n\n LDA #140               \\ Call OSBYTE with A = 140 and X = 12 to select the\n LDX #12                \\ tape filing system (i.e. do a *TAPE command)\n JSR OSBYTE\n\nENDIF\n\n LDA #0                 \\ Set SVN to 0, as the main game code checks the value\n STA SVN                \\ of this location in its IRQ1 routine, so it needs to\n                        \\ be set to 0 so it can work properly once it takes over\n                        \\ when the game itself runs\n\n                        \\ We now decrypt and move the main game code from &1128\n                        \\ to &0F40\n\n LDX #HI(LC%)           \\ Set X = high byte of LC%, the maximum size of the main\n                        \\ game code, so if we move this number of pages, we will\n                        \\ have definitely moved all the game code down\n\n LDA #LO(L%)            \\ Set ZP(1 0) = L% (the start of the game code)\n STA ZP\n LDA #HI(L%)\n STA ZP+1\n\n LDA #LO(C%)            \\ Set P(1 0) = C% = &0F40\n STA P\n LDA #HI(C%)\n STA P+1\n\n LDY #0                 \\ Set Y as a counter for working our way through every\n                        \\ byte of the game code. We EOR the counter with the\n                        \\ current byte to decrypt it\n\n.ML1\n\n TYA                    \\ Copy the counter into A\n\nIF _REMOVE_CHECKSUMS\n\n LDA (ZP),Y             \\ If we have disabled checksums, just fetch the byte to\n                        \\ copy from the Y-th block pointed to by ZP(1 0)\n\nELSE\n\n EOR (ZP),Y             \\ Fetch the byte and EOR it with the counter\n\nENDIF\n\n STA (P),Y              \\ Store the copied (and decrypted) byte in the Y-th byte\n                        \\ of the block pointed to by P(1 0)\n\n INY                    \\ Increment the loop counter\n\n BNE ML1                \\ Loop back for the next byte until we have finished the\n                        \\ first 256 bytes\n\n INC ZP+1               \\ Increment the high bytes of both ZP(1 0) and P(1 0) to\n INC P+1                \\ point to the next 256 bytes\n\n DEX                    \\ Decrement the number of pages we need to copy in X\n\n BPL ML1                \\ Loop back to copy and decrypt the next page of bytes\n                        \\ until we have done them all\n\n                        \\ S% points to the entry point for the main game code,\n                        \\ so the following copies the addresses from the start\n                        \\ of the main code (see the S% label in the main game\n                        \\ code for the vector values)\n\n LDA S%+6               \\ Set BRKV to point to the BR1 routine in the main game\n STA &0202              \\ code\n LDA S%+7\n STA &0203\n\n LDA S%+2               \\ Set WRCHV to point to the TT26 routine in the main\n STA &020E              \\ game code\n LDA S%+3\n STA &020F\n\n RTS                    \\ This RTS actually does a jump to the first instruction\n                        \\ in BLOCK, after the two EQUW operatives, which is now\n                        \\ on the stack. This takes us to the next and final\n                        \\ step of the loader in part 6. See the documentation\n                        \\ for the stack routine at BEGIN% for more details\n\n.AFOOL\n\n JMP (FOOLV)            \\ This jumps to the address in FOOLV as part of the\n                        \\ JSR AFOOL instruction above, which does nothing except\n                        \\ take us on wild goose chase\n\n\\ ******************************************************************************\n\\\n\\       Name: M2\n\\       Type: Variable\n\\   Category: Utility routines\n\\    Summary: Used for testing the 6522 System VIA status byte in IRQ1\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Used for testing bit 1 of the 6522 System VIA status byte in the IRQ1 routine,\n\\ as well as bit 1 of the block flag.\n\\\n\\ ******************************************************************************\n\n.M2\n\n EQUB %00000010         \\ Bit 1 is set\n\n\\ ******************************************************************************\n\\\n\\       Name: IRQ1\n\\       Type: Subroutine\n\\   Category: Drawing the screen\n\\    Summary: The loader's screen-mode interrupt handler (IRQ1V points here)\n\\  Deep dive: The split-screen mode in BBC Micro Elite\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The main interrupt handler, which implements Elite's split-screen mode.\n\\\n\\ This routine is similar to the main IRQ1 routine in the main game code, except\n\\ it's a bit simpler (it doesn't need to support the mode-flashing effect of\n\\ hyperspace, for example).\n\\\n\\ It also sets Timer 1 to a different value, 14386 instead of 14622. The split\n\\ in the split-screen mode does overlap more in the loader than in the game, so\n\\ it's interesting that they didn't fine-tune this version as much.\n\\\n\\ For more details on how the following works, see the IRQ1 routine in the main\n\\ game code.\n\\\n\\ ******************************************************************************\n\n.VIA2\n\n LDA #%00000100         \\ Set the Video ULA control register (SHEILA &20) to\n STA &FE20              \\ %00000100, which is the same as switching to mode 5,\n                        \\ (i.e. the bottom part of the screen) but with no\n                        \\ cursor\n\n LDY #11                \\ We now apply the palette bytes from block1 to the\n                        \\ mode 5 screen, so set a counter in Y for 12 bytes\n\n.inlp1\n\n LDA block1,Y           \\ Copy the Y-th palette byte from block1 to SHEILA &21\n STA &FE21              \\ to map logical to actual colours for the bottom part\n                        \\ of the screen (i.e. the dashboard)\n\n DEY                    \\ Decrement the palette byte counter\n\n BPL inlp1              \\ Loop back to the inlp1 until we have copied all the\n                        \\ palette bytes\n\n PLA                    \\ Restore Y from the stack\n TAY\n\n JMP (VEC)              \\ Jump to the address in VEC, which was set to the\n                        \\ original IRQ1V vector in part 4, so this instruction\n                        \\ passes control to the next interrupt handler\n\n.IRQ1\n\n TYA                    \\ Store Y on the stack\n PHA\n\nIF PROT AND NOT(DISC)\n\n                        \\ By this point, we have set up the following in\n                        \\ various places throughout the loader code (such as\n                        \\ part 2 and PLL1):\n                        \\\n                        \\   BLPTR(1 0) = &03CA\n                        \\   BLN(1 0)   = &03C6\n                        \\   EXCN(1 0)  = &03C2\n                        \\\n                        \\ BLPTR (&03CA) is a byte in the MOS workspace that\n                        \\ stores the block flag of the most recent block loaded\n                        \\ from tape\n                        \\\n                        \\ BLN (&03C6) is the low byte of the number of the last\n                        \\ block loaded from tape\n                        \\\n                        \\ EXCN (&03C2) is the low byte of the execution address\n                        \\ of the file being loaded\n\n LDY #0                 \\ Set A to the block flag of the most recent block\n LDA (BLPTR),Y          \\ loaded from tape\n\n BIT M2                 \\ If bit 1 of the block flag is set, jump to itdone\n BNE itdone\n\n EOR #%10000011         \\ Otherwise flip bits 0, 1 and 7 of A. This has two\n                        \\ main effects:\n                        \\\n                        \\   * Bit 0 of the block flag gets cleared. Most\n                        \\     cassette versions of Acornsoft games are saved to\n                        \\     tape with locked blocks, so you can't just load\n                        \\     the game into memory (you'll get a \"Locked\" error\n                        \\     for each block). Locked blocks have bit 0 set, so\n                        \\     this clears the locked status, so when the MOS\n                        \\     gets round to checking whether the block is\n                        \\     locked, we've already cleared it and updated it in\n                        \\     memory (which we do below), so the block loads\n                        \\     without throwing an error\n                        \\\n                        \\   * Bit 1 of the block flag gets set, so we won't\n                        \\     increment BLCNT again until the next block starts\n                        \\     loading (so in this way we count the number of\n                        \\     blocks loaded in BLCNT)\n\n INC BLCNT              \\ Increment BLCNT, which was initialised to 0 in part 3\n\n BNE ZQK                \\ If BLCNT is non-zero, skip the next instruction\n\n DEC BLCNT              \\ If incrementing BLCNT set it to zero, decrement it, so\n                        \\ this sets a maximum of 255 on BLCNT\n\n.ZQK\n\n STA (BLPTR),Y          \\ Store the updated value of A in the block flag, so the\n                        \\ block gets unlocked\n\n LDA #35                \\ If the block number in BLN is 35, skip the next\n CMP (BLN),Y            \\ instruction, leaving A = 32 = &23\n BEQ P%+4\n\n EOR #17                \\ Set A = 35 EOR 17 = 50 = &32\n\n CMP (EXCN),Y           \\ If the low byte of the execution address of the file\n BEQ itdone             \\ we are loading is equal to A (which is either &23 or\n                        \\ &32), skip to itdone\n\n DEC LOAD%              \\ Otherwise decrement LOAD%, which is the address of the\n                        \\ first byte of the main game code file (i.e. the load\n                        \\ address of \"ELTcode\"), so this decrements the first\n                        \\ byte of the file we are loading, i.e. the LBL variable\n                        \\ added by the Big Code File source\n\n.itdone\n\nENDIF\n\n LDA VIA+&4D            \\ Read the 6522 System VIA status byte bit 1 (SHEILA\n BIT M2                 \\ &4D), which is set if vertical sync has occurred on\n                        \\ the video system\n\n BNE LINSCN             \\ If we are on the vertical sync pulse, jump to LINSCN\n                        \\ to set up the timers to enable us to switch the\n                        \\ screen mode between the space view and dashboard\n\n AND #%01000000         \\ If the 6522 System VIA status byte bit 6 is set, which\n BNE VIA2               \\ means timer 1 has timed out, jump to VIA2\n\n PLA                    \\ Restore Y from the stack\n TAY\n\n JMP (VEC)              \\ Jump to the address in VEC, which was set to the\n                        \\ original IRQ1V vector in part 4, so this instruction\n                        \\ passes control to the next interrupt handler\n\n.LINSCN\n\n LDA #50                \\ Set 6522 System VIA T1C-L timer 1 low-order counter\n STA VIA+&44            \\ (SHEILA &44) to 50\n\n LDA #VSCAN             \\ Set 6522 System VIA T1C-L timer 1 high-order counter\n STA VIA+&45            \\ (SHEILA &45) to VSCAN (56) to start the T1 counter\n                        \\ counting down from 14386 at a rate of 1 MHz\n\n LDA #8                 \\ Set the Video ULA control register (SHEILA &20) to\n STA &FE20              \\ %00001000, which is the same as switching to mode 4\n                        \\ (i.e. the top part of the screen) but with no cursor\n\n LDY #11                \\ We now apply the palette bytes from block2 to the\n                        \\ mode 4 screen, so set a counter in Y for 12 bytes\n\n.inlp2\n\n LDA block2,Y           \\ Copy the Y-th palette byte from block2 to SHEILA &21\n STA &FE21              \\ to map logical to actual colours for the top part of\n                        \\ the screen (i.e. the space view)\n\n DEY                    \\ Decrement the palette byte counter\n\n BPL inlp2              \\ Loop back to the inlp1 until we have copied all the\n                        \\ palette bytes\n\n PLA                    \\ Restore Y from the stack\n TAY\n\n JMP (VEC)              \\ Jump to the address in VEC, which was set to the\n                        \\ original IRQ1V vector in part 4, so this instruction\n                        \\ passes control to the next interrupt handler\n\n\\ ******************************************************************************\n\\\n\\       Name: BLOCK\n\\       Type: Variable\n\\   Category: Copy protection\n\\    Summary: Addresses for the obfuscated jumps that use RTS not JMP\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ These two addresses get pushed onto the stack in part 4. The first EQUW is the\n\\ address of ENTRY2, while the second is the address of the first instruction in\n\\ part 6, after it is pushed onto the stack.\n\\\n\\ This entire section from BLOCK to ENDBLOCK gets copied into the stack at\n\\ location &015E by part 4, so by the time we call the routine at the second\n\\ EQUW address at the start, the entry point is on the stack at &0163.\n\\\n\\ This means that the RTS instructions at the end of parts 4 and 5 jump to\n\\ ENTRY2 and the start of part 6 respectively. See part 4 for details.\n\\\n\\ ******************************************************************************\n\n.BLOCK\n\n EQUW ENTRY2-1\n\n EQUW 512-LEN+BLOCK-ENDBLOCK+3\n\n\\ ******************************************************************************\n\\\n\\       Name: Elite loader (Part 6 of 6)\n\\       Type: Subroutine\n\\   Category: Loader\n\\    Summary: Set up interrupt vectors, calculate checksums, run main game code\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This is the final part of the loader. It sets up some of the main game's\n\\ interrupt vectors and calculates various checksums, before finally handing\n\\ over to the main game.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   nononono            Reset the machine\n\\\n\\ ******************************************************************************\n\n LDA VIA+&44            \\ Read the 6522 System VIA T1C-L timer 1 low-order\n STA &0001              \\ counter (SHEILA &44), which decrements one million\n                        \\ times a second and will therefore be pretty random,\n                        \\ and store it in location &0001, which is among the\n                        \\ main game code's random seeds (so this seeds the\n                        \\ random number generator for the main game)\n\n SEI                    \\ Disable all interrupts\n\n LDA #%00111001         \\ Set 6522 System VIA interrupt enable register IER\n STA VIA+&4E            \\ (SHEILA &4E) bits 0 and 3-5 (i.e. disable the Timer1,\n                        \\ CB1, CB2 and CA2 interrupts from the System VIA)\n\n\\LDA #&7F               \\ These instructions are commented out in the original\n\\STA &FE6E              \\ source with the comment \"already done\", which they\n\\LDA IRQ1V              \\ were, in part 4\n\\STA VEC\n\\LDA IRQ1V+1\n\\STA VEC+1\n\n LDA S%+4               \\ S% points to the entry point for the main game code,\n STA IRQ1V              \\ so this copies the address of the main game's IRQ1\n LDA S%+5               \\ routine from the start of the main code into IRQ1V\n STA IRQ1V+1\n\n LDA #VSCAN             \\ Set 6522 System VIA T1C-L timer 1 high-order counter\n STA VIA+&45            \\ (SHEILA &45) to VSCAN (56) to start the T1 counter\n                        \\ counting down from 14080 at a rate of 1 MHz (this is\n                        \\ a different value to the main game code)\n\n CLI                    \\ Re-enable interrupts\n\n\\LDA #129               \\ These instructions are commented out in the original\n\\LDY #&FF               \\ source. They call OSBYTE with A = 129, X = 1 and\n\\LDX #1                 \\ Y = &FF, which returns the machine type in X, so\n\\JSR OSBYTE             \\ this code would detect the MOS version\n\\\n\\TXA\n\\EOR #&FF\n\\STA MOS\n\\\n\\BMI BLAST\n\n LDY #0                 \\ Call OSBYTE with A = 200, X = 3 and Y = 0 to disable\n LDA #200               \\ the ESCAPE key and clear memory if the BREAK key is\n LDX #3                 \\ pressed\n JSR OSBYTE\n\n                        \\ The rest of the routine calculates various checksums\n                        \\ and makes sure they are correct before proceeding, to\n                        \\ prevent code tampering. We start by calculating the\n                        \\ checksum for the main game code from &0F40 to &5540,\n                        \\ which just adds up every byte and checks it against\n                        \\ the checksum stored at the end of the main game code\n\n.BLAST\n\n LDA #HI(S%)            \\ Set ZP(1 0) = S%\n STA ZP+1               \\\n LDA #LO(S%)            \\ so ZP(1 0) points to the start of the main game code\n STA ZP\n\n LDX #&45               \\ We are going to checksum &45 pages from &0F40 to &5540\n                        \\ so set a page counter in X\n\n LDY #0                 \\ Set Y to count through each byte within each page\n\n TYA                    \\ Set A = 0 for building the checksum\n\n.CHK\n\n CLC                    \\ Add the Y-th byte of this page of the game code to A\n ADC (ZP),Y\n\n INY                    \\ Increment the counter for this page\n\n BNE CHK                \\ Loop back for the next byte until we have finished\n                        \\ adding up this page\n\n INC ZP+1               \\ Increment the high byte of ZP(1 0) to point to the\n                        \\ next page\n\n DEX                    \\ Decrement the page counter we set in X\n\n BPL CHK                \\ Loop back to add up the next page until we have done\n                        \\ them all\n\nIF _REMOVE_CHECKSUMS\n\n LDA #0                 \\ If we have disabled checksums, just set A to 0 so the\n NOP                    \\ BEQ below jumps to itsOK\n\nELSE\n\n CMP D%-1               \\ D% is set to the address of the byte after the end of\n                        \\ the code, so this compares the result to the last byte\n                        \\ in the main game code at location checksum0\n\nENDIF\n\n BEQ itsOK              \\ If the checksum we just calculated matches the value\n                        \\ in location checksum0, jump to itsOK\n\n.nononono\n\n STA S%+1               \\ If we get here then the checksum was wrong, so first\n                        \\ we store the incorrect checksum value in the low byte\n                        \\ of the address stored at the start of the main game\n                        \\ code, which contains the address of TT170, the entry\n                        \\ point for the main game (so this hides this address\n                        \\ from prying eyes)\n\n LDA #%01111111         \\ Set 6522 System VIA interrupt enable register IER\n STA &FE4E              \\ (SHEILA &4E) bits 0-6 (i.e. disable all hardware\n                        \\ interrupts from the System VIA)\n\n JMP (&FFFC)            \\ Jump to the address in &FFFC to reset the machine\n\n.itsOK\n\n JMP (S%)               \\ The checksum was correct, so we call the address held\n                        \\ in the first two bytes of the main game code, which\n                        \\ point to TT170, the entry point for the main game\n                        \\ code, so this, finally, is where we hand over to the\n                        \\ game itself\n\n\\ ******************************************************************************\n\\\n\\       Name: CHECKER\n\\       Type: Subroutine\n\\   Category: Copy protection\n\\    Summary: Run checksum checks on tokens, loader and tape block count\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine runs checksum checks on the recursive token table and the loader\n\\ code at the start of the main game code file, to prevent tampering with these\n\\ areas of memory. It also runs a check on the tape loading block count.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   ENDBLOCK            Denotes the end of the encrypted code that starts at\n\\                       BLOCK\n\\\n\\ ******************************************************************************\n\n.CHECKER\n\n                        \\ First we check the MAINSUM+1 checksum for the\n                        \\ recursive token table from &0400 to &07FF\n\n LDY #0                 \\ Set Y = 0 to count through each byte within each page\n\n LDX #4                 \\ We are going to checksum 4 pages from &0400 to &07FF\n                        \\ so set a page counter in X\n\n STX ZP+1               \\ Set ZP(1 0) = &0400, to point to the start of the code\n STY ZP                 \\ we want to checksum\n\n TYA                    \\ Set A = 0 for building the checksum\n\n.CHKq\n\n CLC                    \\ Add the Y-th byte of this page of the token table to A\n ADC (ZP),Y\n\n INY                    \\ Increment the counter for this page\n\n BNE CHKq               \\ Loop back for the next byte until we have finished\n                        \\ adding up this page\n\n INC ZP+1               \\ Increment the high byte of ZP(1 0) to point to the\n                        \\ next page\n\n DEX                    \\ Decrement the page counter we set in X\n\n BNE CHKq               \\ Loop back to add up the next page until we have done\n                        \\ them all\n\n CMP MAINSUM+1          \\ Compare the result to the contents of MAINSUM+1, which\n                        \\ contains the checksum for the table (this gets set by\n                        \\ elite-checksum.py)\n\nIF _REMOVE_CHECKSUMS\n\n NOP                    \\ If we have disabled checksums, do nothing\n NOP\n\nELSE\n\n BNE nononono           \\ If the checksum we just calculated does not match the\n                        \\ contents of MAINSUM+1, jump to nononono to reset the\n                        \\ machine\n\nENDIF\n\n                        \\ Next, we check the LBL routine in the header that's\n                        \\ appended to the main game code in elite-bcfs.asm, and\n                        \\ which is currently loaded at LOAD% (which contains the\n                        \\ load address of the main game code file)\n\n TYA                    \\ Set A = 0 for building the checksum (as Y is still 0\n                        \\ from the above checksum loop)\n\n.CHKb\n\n CLC                    \\ Add the Y-th byte of LOAD% to A\n ADC LOAD%,Y\n\n INY                    \\ Increment the counter\n\n CPY #40                \\ There are 40 bytes in the loader, so loop back until\n BNE CHKb               \\ we have added them all\n\n CMP MAINSUM            \\ Compare the result to the contents of MAINSUM, which\n                        \\ contains the checksum for loader code\n\nIF _REMOVE_CHECKSUMS\n\n NOP                    \\ If we have disabled checksums, do nothing\n NOP\n\nELSE\n\n BNE nononono           \\ If the checksum we just calculated does not match the\n                        \\ contents of MAINSUM, jump to nononono to reset the\n                        \\ machine\n\nENDIF\n\n                        \\ Finally, we check the block count from the tape\n                        \\ loading code in the IRQ1 routine, which counts the\n                        \\ number of blocks in the main game code\n\nIF PROT AND NOT(DISC)\n\n LDA BLCNT              \\ If the tape protection is enabled and we are loading\n CMP #&4F               \\ from tape (as opposed to disc), check that the block\n BCC nononono           \\ count in BLCNT is &4F, and if it isn't, jump to\n                        \\ nononono to reset the machine\n\nENDIF\n\nIF _REMOVE_CHECKSUMS\n\n RTS                    \\ If we have disabled checksums, return from the\n NOP                    \\ subroutine\n NOP\n\nELSE\n\n JMP (CHECKV)           \\ Call the LBL routine in the header (whose address is\n                        \\ in CHECKV). This routine is inserted before the main\n                        \\ game code by elite-bcfs.asm, and it checks the\n                        \\ validity of the first two pages of the UU% routine,\n                        \\ which was copied to LE% above, and which contains a\n                        \\ checksum byte in CHECKbyt. We then return from the\n                        \\ subroutine using a tail call\n\nENDIF\n\n.ENDBLOCK\n\n\\ ******************************************************************************\n\\\n\\       Name: XC\n\\       Type: Variable\n\\   Category: Text\n\\    Summary: The x-coordinate of the text cursor\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Contains the x-coordinate of the text cursor (i.e. the text column) with an\n\\ initial value of column 7, at the top-left corner of the 14x14 text window\n\\ where we show the tape loading messages (see TT26 for details).\n\\\n\\ ******************************************************************************\n\n.XC\n\n EQUB 7\n\n\\ ******************************************************************************\n\\\n\\       Name: YC\n\\       Type: Variable\n\\   Category: Text\n\\    Summary: The y-coordinate of the text cursor\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Contains the y-coordinate of the text cursor (i.e. the text row) with an\n\\ initial value of row 6, at the top-left corner of the 14x14 text window where\n\\ we show the tape loading messages (see TT26 for details).\n\\\n\\ ******************************************************************************\n\n.YC\n\n EQUB 6\n\n\\ ******************************************************************************\n\\\n\\ Save ELITE.unprot.bin\n\\\n\\ ******************************************************************************\n\n COPYBLOCK LE%, P%, UU%         \\ Copy the block that we assembled at LE% to\n                                \\ UU%, which is where it will actually run\n\n PRINT \"Addresses for the scramble routines in elite-checksum.py\"\n PRINT \"BLOCK_offset = \", ~(BLOCK - LE%) + (UU% - CODE%)\n PRINT \"ENDBLOCK_offset = \", ~(ENDBLOCK - LE%) + (UU% - CODE%)\n PRINT \"MAINSUM_offset = \", ~(MAINSUM - LE%) + (UU% - CODE%)\n PRINT \"TUT_offset = \", ~(TUT - LE%) + (UU% - CODE%)\n PRINT \"CHECKbyt_offset = \", ~(CHECKbyt - LE%) + (UU% - CODE%)\n PRINT \"CODE_offset = \", ~(OSB - CODE%)\n PRINT \"UU% = \", ~UU%\n PRINT \"Q% = \", ~Q%\n PRINT \"OSB = \", ~OSB\n\n PRINT \"Memory usage: \", ~LE%, \" - \", ~P%\n PRINT \"Stack: \",LEN + ENDBLOCK - BLOCK\n\n PRINT \"S. ELITE \", ~CODE%, \" \", ~UU% + (P% - LE%), \" \", ~run, \" \", ~CODE%\n SAVE \"3-assembled-output/ELITE.unprot.bin\", CODE%, UU% + (P% - LE%), run, CODE%\n"
  },
  {
    "path": "1-source-files/main-sources/elite-readme.asm",
    "content": "\\ ******************************************************************************\n\\\n\\ BBC MICRO CASSETTE ELITE README SOURCE\n\\\n\\ BBC Micro cassette Elite was written by Ian Bell and David Braben and is\n\\ copyright Acornsoft 1984\n\\\n\\ The code in this file is identical to the source discs released on Ian Bell's\n\\ personal website at http://www.elitehomepage.org/ (it's just been reformatted\n\\ to be more readable)\n\\\n\\ The commentary is copyright Mark Moxon, and any misunderstandings or mistakes\n\\ in the documentation are entirely my fault\n\\\n\\ The terminology and notations used in this commentary are explained at\n\\ https://elite.bbcelite.com/terminology\n\\\n\\ The deep dive articles referred to in this commentary can be found at\n\\ https://elite.bbcelite.com/deep_dives\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This source file produces a README file for BBC Micro cassette Elite.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This source file produces the following binary file:\n\\\n\\   * README.txt\n\\\n\\ ******************************************************************************\n\n INCLUDE \"1-source-files/main-sources/elite-build-options.asm\"\n\n _SOURCE_DISC           = (_VARIANT = 1)\n _TEXT_SOURCES          = (_VARIANT = 2)\n _STH_CASSETTE          = (_VARIANT = 3)\n\n.readme\n\n EQUB 10, 13\n EQUS \"---------------------------------------\"\n EQUB 10, 13\n EQUS \"Acornsoft Elite\"\n EQUB 10, 13\n EQUB 10, 13\n EQUS \"Version: BBC Micro cassette\"\n EQUB 10, 13\n\nIF _SOURCE_DISC\n\n EQUS \"Variant: Ian Bell's source disc\"\n EQUB 10, 13\n\nELIF _TEXT_SOURCES\n\n EQUS \"Variant: Ian Bell's text sources\"\n EQUB 10, 13\n\nELIF _STH_CASSETTE\n\n EQUS \"Variant: Stairway to Hell cassette\"\n EQUB 10, 13\n EQUS \"Product: Acornsoft SBG38\"\n EQUB 10, 13\n\nENDIF\n\n EQUB 10, 13\n EQUS \"See www.bbcelite.com for details\"\n EQUB 10, 13\n EQUS \"---------------------------------------\"\n EQUB 10, 13\n\n SAVE \"3-assembled-output/README.txt\", readme, P%\n\n"
  },
  {
    "path": "1-source-files/main-sources/elite-source.asm",
    "content": "\\ ******************************************************************************\n\\\n\\ BBC MICRO CASSETTE ELITE MAIN GAME SOURCE\n\\\n\\ BBC Micro cassette Elite was written by Ian Bell and David Braben and is\n\\ copyright Acornsoft 1984\n\\\n\\ The code in this file is identical to the source discs released on Ian Bell's\n\\ personal website at http://www.elitehomepage.org/ (it's just been reformatted\n\\ to be more readable)\n\\\n\\ The commentary is copyright Mark Moxon, and any misunderstandings or mistakes\n\\ in the documentation are entirely my fault\n\\\n\\ The terminology and notations used in this commentary are explained at\n\\ https://elite.bbcelite.com/terminology\n\\\n\\ The deep dive articles referred to in this commentary can be found at\n\\ https://elite.bbcelite.com/deep_dives\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This source file contains the main game code for BBC Micro cassette Elite. It\n\\ also contains the ship blueprints and game text.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This source file produces the following binary files:\n\\\n\\   * ELTA.bin\n\\   * ELTB.bin\n\\   * ELTC.bin\n\\   * ELTD.bin\n\\   * ELTE.bin\n\\   * ELTF.bin\n\\   * ELTG.bin\n\\   * PYTHON.bin\n\\   * SHIPS.bin\n\\   * WORDS9.bin\n\\\n\\ ******************************************************************************\n\n INCLUDE \"1-source-files/main-sources/elite-build-options.asm\"\n\n _SOURCE_DISC           = (_VARIANT = 1)\n _TEXT_SOURCES          = (_VARIANT = 2)\n _STH_CASSETTE          = (_VARIANT = 3)\n\n GUARD &6000            \\ Guard against assembling over screen memory\n\n\\ ******************************************************************************\n\\\n\\ Configuration variables\n\\\n\\ ******************************************************************************\n\n CODE% = &0F40          \\ The address where the code will be run\n\n LOAD% = &1128          \\ The address where the code will be loaded\n\n CODE_WORDS% = &0400    \\ The address where the text data will be run\n\n LOAD_WORDS% = &1100    \\ The address where the text data will be loaded\n\n Q% = _MAX_COMMANDER    \\ Set Q% to TRUE to max out the default commander, FALSE\n                        \\ for the standard default commander\n\n NOST = 18              \\ The number of stardust particles in normal space (this\n                        \\ goes down to 3 in witchspace)\n\n NOSH = 12              \\ The maximum number of ships in our local bubble of\n                        \\ universe\n\n NTY = 13               \\ The number of different ship types\n\n COPS = 2               \\ Ship type for a Viper\n\n THG = 6                \\ Ship type for a Thargoid\n\n CYL = 7                \\ Ship type for a Cobra Mk III (trader)\n\n SST = 8                \\ Ship type for the space station\n\n MSL = 9                \\ Ship type for a missile\n\n AST = 10               \\ Ship type for an asteroid\n\n OIL = 11               \\ Ship type for a cargo canister\n\n TGL = 12               \\ Ship type for a Thargon\n\n ESC = 13               \\ Ship type for an escape pod\n\n POW = 15               \\ Pulse laser power\n\n NI% = 36               \\ The number of bytes in each ship's data block (as\n                        \\ stored in INWK and K%)\n\n VSCAN = 57             \\ Defines the split position in the split-screen mode\n\n X = 128                \\ The centre x-coordinate of the 256 x 192 space view\n\n Y = 96                 \\ The centre y-coordinate of the 256 x 192 space view\n\n f0 = &20               \\ Internal key number for red key f0 (Launch, Front)\n\n f1 = &71               \\ Internal key number for red key f1 (Buy Cargo, Rear)\n\n f2 = &72               \\ Internal key number for red key f2 (Sell Cargo, Left)\n\n f3 = &73               \\ Internal key number for red key f3 (Equip Ship, Right)\n\n f4 = &14               \\ Internal key number for red key f4 (Long-range Chart)\n\n f5 = &74               \\ Internal key number for red key f5 (Short-range Chart)\n\n f6 = &75               \\ Internal key number for red key f6 (Data on System)\n\n f7 = &16               \\ Internal key number for red key f7 (Market Price)\n\n f8 = &76               \\ Internal key number for red key f8 (Status Mode)\n\n f9 = &77               \\ Internal key number for red key f9 (Inventory)\n\n RE = &23               \\ The obfuscation byte used to hide the recursive tokens\n                        \\ table from crackers viewing the binary code\n\n VIA = &FE00            \\ Memory-mapped space for accessing internal hardware,\n                        \\ such as the video ULA, 6845 CRTC and 6522 VIAs (also\n                        \\ known as SHEILA)\n\n OSBYTE = &FFF4         \\ The address for the OSBYTE routine, which is used\n                        \\ three times in the main game code\n\n OSWORD = &FFF1         \\ The address for the OSWORD routine, which is used\n                        \\ twice in the main game code\n\n OSFILE = &FFDD         \\ The address for the OSFILE routine, which is used\n                        \\ once in the main game code\n\n\\ ******************************************************************************\n\\\n\\       Name: ZP\n\\       Type: Workspace\n\\    Address: &0000 to &00E1\n\\   Category: Workspaces\n\\    Summary: Lots of important variables are stored in the zero page workspace\n\\             as it is quicker and more space-efficient to access memory here\n\\\n\\ ******************************************************************************\n\n ORG &0000              \\ Set the assembly address to &0000\n\n.ZP\n\n SKIP 0                 \\ The start of the zero page workspace\n\n.RAND\n\n SKIP 4                 \\ Four 8-bit seeds for the random number generation\n                        \\ system implemented in the DORND routine\n\n.TRTB%\n\n SKIP 2                 \\ Contains the address of the keyboard translation\n                        \\ table, which is used to translate internal key\n                        \\ numbers to ASCII\n\n.T1\n\n SKIP 1                 \\ Temporary storage, used in a number of places\n\n.SC\n\n SKIP 1                 \\ Screen address (low byte)\n                        \\\n                        \\ Elite draws on-screen by poking bytes directly into\n                        \\ screen memory, and SC(1 0) is typically set to the\n                        \\ address of the character block containing the pixel\n                        \\ we want to draw\n\n.SCH\n\n SKIP 1                 \\ Screen address (high byte)\n\n.XX16\n\n SKIP 18                \\ Temporary storage for a block of values, used in a\n                        \\ number of places\n\n.P\n\n SKIP 3                 \\ Temporary storage, used in a number of places\n\n.XX0\n\n SKIP 2                 \\ Temporary storage, used to store the address of a ship\n                        \\ blueprint. For example, it is used when we add a new\n                        \\ ship to the local bubble in routine NWSHP, and it\n                        \\ contains the address of the current ship's blueprint\n                        \\ as we loop through all the nearby ships in the main\n                        \\ flight loop\n\n.INF\n\n SKIP 2                 \\ Temporary storage, typically used for storing the\n                        \\ address of a ship's data block, so it can be copied\n                        \\ to and from the internal workspace at INWK\n\n.V\n\n SKIP 2                 \\ Temporary storage, typically used for storing an\n                        \\ address pointer\n\n.XX\n\n SKIP 2                 \\ Temporary storage, typically used for storing a 16-bit\n                        \\ x-coordinate\n\n.YY\n\n SKIP 2                 \\ Temporary storage, typically used for storing a 16-bit\n                        \\ y-coordinate\n\n.SUNX\n\n SKIP 2                 \\ The 16-bit x-coordinate of the vertical centre axis\n                        \\ of the sun (which might be off-screen)\n\n.BETA\n\n SKIP 1                 \\ The current pitch angle beta, which is reduced from\n                        \\ JSTY to a sign-magnitude value between -8 and +8\n                        \\\n                        \\ This describes how fast we are pitching our ship, and\n                        \\ determines how fast the universe pitches around us\n                        \\\n                        \\ The sign bit is also stored in BET2, while the\n                        \\ opposite sign is stored in BET2+1\n\n.BET1\n\n SKIP 1                 \\ The magnitude of the pitch angle beta, i.e. |beta|,\n                        \\ which is a positive value between 0 and 8\n\n.XC\n\n SKIP 1                 \\ The x-coordinate of the text cursor (i.e. the text\n                        \\ column), which can be from 0 to 32\n                        \\\n                        \\ A value of 0 denotes the leftmost column and 32 the\n                        \\ rightmost column, but because the top part of the\n                        \\ screen (the space view) has a border box that\n                        \\ clashes with columns 0 and 32, text is only shown\n                        \\ in columns 1-31\n\n.YC\n\n SKIP 1                 \\ The y-coordinate of the text cursor (i.e. the text\n                        \\ row), which can be from 0 to 23\n                        \\\n                        \\ The screen actually has 31 character rows if you\n                        \\ include the dashboard, but the text printing routines\n                        \\ only work on the top part (the space view), so the\n                        \\ text cursor only goes up to a maximum of 23, the row\n                        \\ just before the screen splits\n                        \\\n                        \\ A value of 0 denotes the top row, but because the\n                        \\ top part of the screen has a border box that clashes\n                        \\ with row 0, text is always shown at row 1 or greater\n\n.QQ22\n\n SKIP 2                 \\ The two hyperspace countdown counters\n                        \\\n                        \\ Before a hyperspace jump, both QQ22 and QQ22+1 are\n                        \\ set to 15\n                        \\\n                        \\ QQ22 is an internal counter that counts down by 1\n                        \\ each time TT102 is called, which happens every\n                        \\ iteration of the main game loop. When it reaches\n                        \\ zero, the on-screen counter in QQ22+1 gets\n                        \\ decremented, and QQ22 gets set to 5 and the countdown\n                        \\ continues (so the first tick of the hyperspace counter\n                        \\ takes 15 iterations to happen, but subsequent ticks\n                        \\ take 5 iterations each)\n                        \\\n                        \\ QQ22+1 contains the number that's shown on-screen\n                        \\ during the countdown. It counts down from 15 to 1, and\n                        \\ when it hits 0, the hyperspace engines kick in\n\n.ECMA\n\n SKIP 1                 \\ The E.C.M. countdown timer, which determines whether\n                        \\ an E.C.M. system is currently operating\n                        \\\n                        \\   * 0 = E.C.M. is off\n                        \\\n                        \\   * Non-zero = E.C.M. is on and is counting down\n                        \\\n                        \\ The counter starts at 32 when an E.C.M. is activated,\n                        \\ either by us or by an opponent, and it decreases by 1\n                        \\ in each iteration of the main flight loop until it\n                        \\ reaches zero, at which point the E.C.M. switches off.\n                        \\ Only one E.C.M. can be active at any one time, so\n                        \\ there is only one counter\n\n.XX15\n\n SKIP 0                 \\ Temporary storage, typically used for storing screen\n                        \\ coordinates in line-drawing routines\n                        \\\n                        \\ There are six bytes of storage, from XX15 TO XX15+5.\n                        \\ The first four bytes have the following aliases:\n                        \\\n                        \\   X1 = XX15\n                        \\   Y1 = XX15+1\n                        \\   X2 = XX15+2\n                        \\   Y2 = XX15+3\n                        \\\n                        \\ These are typically used for describing lines in terms\n                        \\ of screen coordinates, i.e. (X1, Y1) to (X2, Y2)\n                        \\\n                        \\ The last two bytes of XX15 do not have aliases\n\n.X1\n\n SKIP 1                 \\ Temporary storage, typically used for x-coordinates in\n                        \\ the line-drawing routines\n\n.Y1\n\n SKIP 1                 \\ Temporary storage, typically used for y-coordinates in\n                        \\ line-drawing routines\n\n.X2\n\n SKIP 1                 \\ Temporary storage, typically used for x-coordinates in\n                        \\ the line-drawing routines\n\n.Y2\n\n SKIP 1                 \\ Temporary storage, typically used for y-coordinates in\n                        \\ line-drawing routines\n\n SKIP 2                 \\ The last two bytes of the XX15 block\n\n.XX12\n\n SKIP 6                 \\ Temporary storage for a block of values, used in a\n                        \\ number of places\n\n.K\n\n SKIP 4                 \\ Temporary storage, used in a number of places\n\n.KL\n\n SKIP 1                 \\ The following bytes implement a key logger that\n                        \\ enables Elite to scan for concurrent key presses of\n                        \\ the primary flight keys, plus a secondary flight key\n                        \\\n                        \\ If a key is being pressed that is not in the keyboard\n                        \\ table at KYTB, it can be stored here (as seen in\n                        \\ routine DK4, for example)\n\n.KY1\n\n SKIP 1                 \\ \"?\" is being pressed (slow down)\n                        \\\n                        \\   * 0 = no\n                        \\\n                        \\   * Non-zero = yes\n\n.KY2\n\n SKIP 1                 \\ Space is being pressed (speed up)\n                        \\\n                        \\   * 0 = no\n                        \\\n                        \\   * Non-zero = yes\n\n.KY3\n\n SKIP 1                 \\ \"<\" is being pressed (roll left)\n                        \\\n                        \\   * 0 = no\n                        \\\n                        \\   * Non-zero = yes\n\n.KY4\n\n SKIP 1                 \\ \">\" is being pressed (roll right)\n                        \\\n                        \\   * 0 = no\n                        \\\n                        \\   * Non-zero = yes\n\n.KY5\n\n SKIP 1                 \\ \"X\" is being pressed (pull up)\n                        \\\n                        \\   * 0 = no\n                        \\\n                        \\   * Non-zero = yes\n\n.KY6\n\n SKIP 1                 \\ \"S\" is being pressed (pitch down)\n                        \\\n                        \\   * 0 = no\n                        \\\n                        \\   * Non-zero = yes\n\n.KY7\n\n SKIP 1                 \\ \"A\" is being pressed (fire lasers)\n                        \\\n                        \\   * 0 = no\n                        \\\n                        \\   * Non-zero = yes\n                        \\\n                        \\ This is also set when the joystick fire button has\n                        \\ been pressed\n\n.KY12\n\n SKIP 1                 \\ TAB is being pressed (energy bomb)\n                        \\\n                        \\   * 0 = no\n                        \\\n                        \\   * Non-zero = yes\n\n.KY13\n\n SKIP 1                 \\ ESCAPE is being pressed (launch escape pod)\n                        \\\n                        \\   * 0 = no\n                        \\\n                        \\   * Non-zero = yes\n\n.KY14\n\n SKIP 1                 \\ \"T\" is being pressed (target missile)\n                        \\\n                        \\   * 0 = no\n                        \\\n                        \\   * Non-zero = yes\n\n.KY15\n\n SKIP 1                 \\ \"U\" is being pressed (unarm missile)\n                        \\\n                        \\   * 0 = no\n                        \\\n                        \\   * Non-zero = yes\n\n.KY16\n\n SKIP 1                 \\ \"M\" is being pressed (fire missile)\n                        \\\n                        \\   * 0 = no\n                        \\\n                        \\   * Non-zero = yes\n\n.KY17\n\n SKIP 1                 \\ \"E\" is being pressed (activate E.C.M.)\n                        \\\n                        \\   * 0 = no\n                        \\\n                        \\   * Non-zero = yes\n\n.KY18\n\n SKIP 1                 \\ \"J\" is being pressed (in-system jump)\n                        \\\n                        \\   * 0 = no\n                        \\\n                        \\   * Non-zero = yes\n\n.KY19\n\n SKIP 1                 \\ \"C\" is being pressed (activate docking computer)\n                        \\\n                        \\   * 0 = no\n                        \\\n                        \\   * Non-zero = yes\n\n.LAS\n\n SKIP 1                 \\ Contains the laser power of the laser fitted to the\n                        \\ current space view (or 0 if there is no laser fitted\n                        \\ to the current view)\n                        \\\n                        \\ This gets set to bits 0-6 of the laser power byte from\n                        \\ the commander data block, which contains the laser's\n                        \\ power (bit 7 doesn't denote laser power, just whether\n                        \\ or not the laser pulses, so that is not stored here)\n\n.MSTG\n\n SKIP 1                 \\ The current missile lock target\n                        \\\n                        \\   * &FF = no target\n                        \\\n                        \\   * 1-12 = the slot number of the ship that our\n                        \\            missile is locked onto\n\n.XX1\n\n SKIP 0                 \\ This is an alias for INWK that is used in the main\n                        \\ ship-drawing routine at LL9\n\n.INWK\n\n SKIP 33                \\ The zero-page internal workspace for the current ship\n                        \\ data block\n                        \\\n                        \\ As operations on zero page locations are faster and\n                        \\ have smaller opcodes than operations on the rest of\n                        \\ the addressable memory, Elite tends to store oft-used\n                        \\ data here. A lot of the routines in Elite need to\n                        \\ access and manipulate ship data, so to make this an\n                        \\ efficient exercise, the ship data is first copied from\n                        \\ the ship data blocks at K% into INWK (or, when new\n                        \\ ships are spawned, from the blueprints at XX21)\n\n.XX19\n\n SKIP NI% - 33          \\ XX19(1 0) shares its location with INWK(34 33), which\n                        \\ contains the address of the ship line heap\n\n.LSP\n\n SKIP 1                 \\ The ball line heap pointer, which contains the number\n                        \\ of the first free byte after the end of the LSX2 and\n                        \\ LSY2 heaps\n\n.QQ15\n\n SKIP 6                 \\ The three 16-bit seeds for the selected system, i.e.\n                        \\ the one in the crosshairs in the Short-range Chart\n\n.K5\n\n SKIP 0                 \\ Temporary storage used to store segment coordinates\n                        \\ across successive calls to BLINE, the ball line\n                        \\ routine\n\n.XX18\n\n SKIP 0                 \\ Temporary storage used to store coordinates in the\n                        \\ LL9 ship-drawing routine\n\n.QQ17\n\n SKIP 1                 \\ Contains a number of flags that affect how text tokens\n                        \\ are printed, particularly capitalisation\n                        \\\n                        \\   * If all bits are set (255) then text printing is\n                        \\     disabled\n                        \\\n                        \\   * Bit 7: 0 = ALL CAPS\n                        \\            1 = Sentence Case, bit 6 determines the\n                        \\                case of the next letter to print\n                        \\\n                        \\   * Bit 6: 0 = print the next letter in upper case\n                        \\            1 = print the next letter in lower case\n                        \\\n                        \\   * Bits 0-5: If any of bits 0-5 are set, print in\n                        \\               lower case\n                        \\\n                        \\ So:\n                        \\\n                        \\   * QQ17 = 0 means case is set to ALL CAPS\n                        \\\n                        \\   * QQ17 = %10000000 means Sentence Case, currently\n                        \\            printing upper case\n                        \\\n                        \\   * QQ17 = %11000000 means Sentence Case, currently\n                        \\            printing lower case\n                        \\\n                        \\   * QQ17 = %11111111 means printing is disabled\n\n.QQ19\n\n SKIP 3                 \\ Temporary storage, used in a number of places\n\n.K6\n\n SKIP 5                 \\ Temporary storage, typically used for storing\n                        \\ coordinates during vector calculations\n\n.ALP1\n\n SKIP 1                 \\ Magnitude of the roll angle alpha, i.e. |alpha|,\n                        \\ which is a positive value between 0 and 31\n\n.ALP2\n\n SKIP 2                 \\ Bit 7 of ALP2 = sign of the roll angle in ALPHA\n                        \\\n                        \\ Bit 7 of ALP2+1 = opposite sign to ALP2 and ALPHA\n\n.BET2\n\n SKIP 2                 \\ Bit 7 of BET2 = sign of the pitch angle in BETA\n                        \\\n                        \\ Bit 7 of BET2+1 = opposite sign to BET2 and BETA\n\n.DELTA\n\n SKIP 1                 \\ Our current speed, in the range 1-40\n\n.DELT4\n\n SKIP 2                 \\ Our current speed * 64 as a 16-bit value\n                        \\\n                        \\ This is stored as DELT4(1 0), so the high byte in\n                        \\ DELT4+1 therefore contains our current speed / 4\n\n.U\n\n SKIP 1                 \\ Temporary storage, used in a number of places\n\n.Q\n\n SKIP 1                 \\ Temporary storage, used in a number of places\n\n.R\n\n SKIP 1                 \\ Temporary storage, used in a number of places\n\n.S\n\n SKIP 1                 \\ Temporary storage, used in a number of places\n\n.XSAV\n\n SKIP 1                 \\ Temporary storage for saving the value of the X\n                        \\ register, used in a number of places\n\n.YSAV\n\n SKIP 1                 \\ Temporary storage for saving the value of the Y\n                        \\ register, used in a number of places\n\n.XX17\n\n SKIP 1                 \\ Temporary storage, used in BPRNT to store the number\n                        \\ of characters to print, and as the edge counter in the\n                        \\ main ship-drawing routine\n\n.QQ11\n\n SKIP 1                 \\ The type of the current view:\n                        \\\n                        \\   0   = Space view\n                        \\   1   = Data on System screen (red key f6)\n                        \\         Get commander name (\"@\", save/load commander)\n                        \\         In-system jump just arrived (\"J\")\n                        \\         Title screen\n                        \\         Buy Cargo screen (red key f1)\n                        \\         Mis-jump just arrived (witchspace)\n                        \\   4   = Sell Cargo screen (red key f2)\n                        \\   6   = Death screen\n                        \\   8   = Status Mode screen (red key f8)\n                        \\         Inventory screen (red key f9)\n                        \\   16  = Market Price screen (red key f7)\n                        \\   32  = Equip Ship screen (red key f3)\n                        \\   64  = Long-range Chart (red key f4)\n                        \\   128 = Short-range Chart (red key f5)\n                        \\\n                        \\ This value is typically set by calling routine TT66\n\n.ZZ\n\n SKIP 1                 \\ Temporary storage, typically used for distance values\n\n.XX13\n\n SKIP 1                 \\ Temporary storage, typically used in the line-drawing\n                        \\ routines\n\n.MCNT\n\n SKIP 1                 \\ The main loop counter\n                        \\\n                        \\ This counter determines how often certain actions are\n                        \\ performed within the main loop\n\n.DL\n\n SKIP 1                 \\ Vertical sync flag\n                        \\\n                        \\ DL gets set to 30 every time we reach vertical sync on\n                        \\ the video system, which happens 50 times a second\n                        \\ (50Hz). The WSCAN routine uses this to pause until the\n                        \\ vertical sync, by setting DL to 0 and then monitoring\n                        \\ its value until it changes to 30\n\n.TYPE\n\n SKIP 1                 \\ The current ship type\n                        \\\n                        \\ This is where we store the current ship type for when\n                        \\ we are iterating through the ships in the local bubble\n                        \\ as part of the main flight loop. See the table at XX21\n                        \\ for information about ship types\n\n.JSTX\n\n SKIP 1                 \\ Our current roll rate\n                        \\\n                        \\ This value is shown in the dashboard's RL indicator,\n                        \\ and determines the rate at which we are rolling\n                        \\\n                        \\ The value ranges from 1 to 255 with 128 as the centre\n                        \\ point, so 1 means roll is decreasing at the maximum\n                        \\ rate, 128 means roll is not changing, and 255 means\n                        \\ roll is increasing at the maximum rate\n                        \\\n                        \\ This value is updated by \"<\" and \">\" key presses, or\n                        \\ if joysticks are enabled, from the joystick. If\n                        \\ keyboard damping is enabled (which it is by default),\n                        \\ the value is slowly moved towards the centre value of\n                        \\ 128 (no roll) if there are no key presses or joystick\n                        \\ movement\n\n.JSTY\n\n SKIP 1                 \\ Our current pitch rate\n                        \\\n                        \\ This value is shown in the dashboard's DC indicator,\n                        \\ and determines the rate at which we are pitching\n                        \\\n                        \\ The value ranges from 1 to 255 with 128 as the centre\n                        \\ point, so 1 means pitch is decreasing at the maximum\n                        \\ rate, 128 means pitch is not changing, and 255 means\n                        \\ pitch is increasing at the maximum rate\n                        \\\n                        \\ This value is updated by \"S\" and \"X\" key presses, or\n                        \\ if joysticks are enabled, from the joystick. If\n                        \\ keyboard damping is enabled (which it is by default),\n                        \\ the value is slowly moved towards the centre value of\n                        \\ 128 (no pitch) if there are no key presses or joystick\n                        \\ movement\n\n.ALPHA\n\n SKIP 1                 \\ The current roll angle alpha, which is reduced from\n                        \\ JSTX to a sign-magnitude value between -31 and +31\n                        \\\n                        \\ This describes how fast we are rolling our ship, and\n                        \\ determines how fast the universe rolls around us\n                        \\\n                        \\ The sign bit is also stored in ALP2, while the\n                        \\ opposite sign is stored in ALP2+1\n\n.QQ12\n\n SKIP 1                 \\ Our \"docked\" status\n                        \\\n                        \\   * 0 = we are not docked\n                        \\\n                        \\   * &FF = we are docked\n\n.TGT\n\n SKIP 1                 \\ Temporary storage, typically used as a target value\n                        \\ for counters when drawing explosion clouds and partial\n                        \\ circles\n\n.SWAP\n\n SKIP 1                 \\ Temporary storage, used to store a flag that records\n                        \\ whether or not we had to swap a line's start and end\n                        \\ coordinates around when clipping the line in routine\n                        \\ LL145 (the flag is used in places like BLINE to swap\n                        \\ them back)\n\n.COL\n\n SKIP 1                 \\ Temporary storage, used to store colour information\n                        \\ when drawing pixels in the dashboard\n\n.FLAG\n\n SKIP 1                 \\ A flag that's used to define whether this is the first\n                        \\ call to the ball line routine in BLINE, so it knows\n                        \\ whether to wait for the second call before storing\n                        \\ segment data in the ball line heap\n\n.CNT\n\n SKIP 1                 \\ Temporary storage, typically used for storing the\n                        \\ number of iterations required when looping\n\n.CNT2\n\n SKIP 1                 \\ Temporary storage, used in the planet-drawing routine\n                        \\ to store the segment number where the arc of a partial\n                        \\ circle should start\n\n.STP\n\n SKIP 1                 \\ The step size for drawing circles\n                        \\\n                        \\ Circles in Elite are split up into 64 points, and the\n                        \\ step size determines how many points to skip with each\n                        \\ straight-line segment, so the smaller the step size,\n                        \\ the smoother the circle. The values used are:\n                        \\\n                        \\   * 2 for big planets and the circles on the charts\n                        \\\n                        \\   * 4 for medium planets and the launch tunnel\n                        \\\n                        \\   * 8 for small planets and the hyperspace tunnel\n                        \\\n                        \\ As the step size increases we move from smoother\n                        \\ circles at the top to more polygonal at the bottom.\n                        \\ See the CIRCLE2 routine for more details\n\n.XX4\n\n SKIP 1                 \\ Temporary storage, used in a number of places\n\n.XX20\n\n SKIP 1                 \\ Temporary storage, used in a number of places\n\n.XX14\n\n SKIP 1                 \\ This byte appears to be unused\n\n.RAT\n\n SKIP 1                 \\ Used to store different signs depending on the current\n                        \\ space view, for use in calculating stardust movement\n\n.RAT2\n\n SKIP 1                 \\ Temporary storage, used to store the pitch and roll\n                        \\ signs when moving objects and stardust\n\n.K2\n\n SKIP 4                 \\ Temporary storage, used in a number of places\n\n ORG &00D1              \\ Set the assembly address to &00D1\n\n.T\n\n SKIP 1                 \\ Temporary storage, used in a number of places\n\n.K3\n\n SKIP 0                 \\ Temporary storage, used in a number of places\n\n.XX2\n\n SKIP 14                \\ Temporary storage, used to store the visibility of the\n                        \\ ship's faces during the ship-drawing routine at LL9\n\n.K4\n\n SKIP 2                 \\ Temporary storage, used in a number of places\n\n PRINT \"ZP workspace from \", ~ZP, \"to \", ~P%-1, \"inclusive\"\n\n\\ ******************************************************************************\n\\\n\\       Name: XX3\n\\       Type: Workspace\n\\    Address: &0100 to the top of the descending stack\n\\   Category: Workspaces\n\\    Summary: Temporary storage space for complex calculations\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Used as heap space for storing temporary data during calculations. Shared with\n\\ the descending 6502 stack, which works down from &01FF.\n\\\n\\ ******************************************************************************\n\n ORG &0100              \\ Set the assembly address to &0100\n\n.XX3\n\n SKIP 256               \\ Temporary storage, typically used for storing tables\n                        \\ of values such as screen coordinates or ship data\n\n\\ ******************************************************************************\n\\\n\\       Name: T%\n\\       Type: Workspace\n\\    Address: &0300 to &0371\n\\   Category: Workspaces\n\\    Summary: Current commander data and stardust data blocks\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Contains the current commander data (NT% bytes at location TP), and the\n\\ stardust data blocks (NOST bytes at location SX)\n\\\n\\ ******************************************************************************\n\n ORG &0300              \\ Set the assembly address to &0300\n\n.T%\n\n SKIP 0                 \\ The start of the T% workspace\n\n.TP\n\n SKIP 1                 \\ The current mission status, which is always 0 for the\n                        \\ cassette version of Elite as there are no missions\n\n.QQ0\n\n SKIP 1                 \\ The current system's galactic x-coordinate (0-256)\n\n.QQ1\n\n SKIP 1                 \\ The current system's galactic y-coordinate (0-256)\n\n.QQ21\n\n SKIP 6                 \\ The three 16-bit seeds for the current galaxy\n                        \\\n                        \\ These seeds define system 0 in the current galaxy, so\n                        \\ they can be used as a starting point to generate all\n                        \\ 256 systems in the galaxy\n                        \\\n                        \\ Using a galactic hyperdrive rotates each byte to the\n                        \\ left (rolling each byte within itself) to get the\n                        \\ seeds for the next galaxy, so after eight galactic\n                        \\ jumps, the seeds roll around to the first galaxy again\n\n.CASH\n\n SKIP 4                 \\ Our current cash pot\n                        \\\n                        \\ The cash stash is stored as a 32-bit unsigned integer,\n                        \\ with the most significant byte in CASH and the least\n                        \\ significant in CASH+3. This is big-endian, which is\n                        \\ the opposite way round to most of the numbers used in\n                        \\ Elite - to use our notation for multi-byte numbers,\n                        \\ the amount of cash is CASH(0 1 2 3)\n\n.QQ14\n\n SKIP 1                 \\ Our current fuel level (0-70)\n                        \\\n                        \\ The fuel level is stored as the number of light years\n                        \\ multiplied by 10, so QQ14 = 1 represents 0.1 light\n                        \\ years, and the maximum possible value is 70, for 7.0\n                        \\ light years\n\n.COK\n\n SKIP 1                 \\ Flags used to generate the competition code\n\n.GCNT\n\n SKIP 1                 \\ The number of the current galaxy (0-7)\n                        \\\n                        \\ When this is displayed in-game, 1 is added to the\n                        \\ number, so we start in galaxy 1 in-game, but it's\n                        \\ stored as galaxy 0 internally\n                        \\\n                        \\ The galaxy number increases by one every time a\n                        \\ galactic hyperdrive is used, and wraps back around to\n                        \\ the start after eight galaxies\n\n.LASER\n\n SKIP 4                 \\ The specifications of the lasers fitted to each of the\n                        \\ four space views\n                        \\\n                        \\   * Byte #0 = front view\n                        \\\n                        \\   * Byte #1 = rear view\n                        \\\n                        \\   * Byte #2 = left view\n                        \\\n                        \\   * Byte #3 = right view\n                        \\\n                        \\ The value for each view is as follows:\n                        \\\n                        \\   * 0 = no laser is fitted to this view\n                        \\\n                        \\   * Non-zero = a laser is fitted to this view, with\n                        \\     the following specification:\n                        \\\n                        \\     * Bits 0-6 contain the laser's power\n                        \\\n                        \\     * Bit 7 determines whether or not the laser pulses\n                        \\       (0 = pulse laser) or is always on (1 = beam\n                        \\       laser)\n\n SKIP 2                 \\ These bytes appear to be unused (they were originally\n                        \\ used for up/down lasers, but they were dropped)\n\n.CRGO\n\n SKIP 1                 \\ Our ship's cargo capacity\n                        \\\n                        \\   * 22 = standard cargo bay of 20 tonnes\n                        \\\n                        \\   * 37 = large cargo bay of 35 tonnes\n                        \\\n                        \\ The value is two greater than the actual capacity to\n                        \\ make the maths in tnpr slightly more efficient\n\n.QQ20\n\n SKIP 17                \\ The contents of our cargo hold\n                        \\\n                        \\ The amount of market item X that we have in our hold\n                        \\ can be found in the X-th byte of QQ20. For example:\n                        \\\n                        \\   * QQ20 contains the amount of food (item 0)\n                        \\\n                        \\   * QQ20+7 contains the amount of computers (item 7)\n                        \\\n                        \\ See QQ23 for a list of market item numbers and their\n                        \\ storage units\n\n.ECM\n\n SKIP 1                 \\ E.C.M. system\n                        \\\n                        \\   * 0 = not fitted\n                        \\\n                        \\   * &FF = fitted\n\n.BST\n\n SKIP 1                 \\ Fuel scoops (BST stands for \"barrel status\")\n                        \\\n                        \\   * 0 = not fitted\n                        \\\n                        \\   * &FF = fitted\n\n.BOMB\n\n SKIP 1                 \\ Energy bomb\n                        \\\n                        \\   * 0 = not fitted\n                        \\\n                        \\   * &7F = fitted\n\n.ENGY\n\n SKIP 1                 \\ Energy unit\n                        \\\n                        \\   * 0 = not fitted\n                        \\\n                        \\   * Non-zero = fitted\n                        \\\n                        \\ The actual value determines the refresh rate of our\n                        \\ energy banks, as they refresh by ENGY+1 each time (so\n                        \\ our ship's energy level goes up by 2 each time if we\n                        \\ have an energy unit fitted, otherwise it goes up by 1)\n\n.DKCMP\n\n SKIP 1                 \\ Docking computer\n                        \\\n                        \\   * 0 = not fitted\n                        \\\n                        \\   * &FF = fitted\n\n.GHYP\n\n SKIP 1                 \\ Galactic hyperdrive\n                        \\\n                        \\   * 0 = not fitted\n                        \\\n                        \\   * &FF = fitted\n\n.ESCP\n\n SKIP 1                 \\ Escape pod\n                        \\\n                        \\   * 0 = not fitted\n                        \\\n                        \\   * &FF = fitted\n\n SKIP 4                 \\ These bytes appear to be unused\n\n.NOMSL\n\n SKIP 1                 \\ The number of missiles we have fitted (0-4)\n\n.FIST\n\n SKIP 1                 \\ Our legal status (FIST stands for \"fugitive/innocent\n                        \\ status\")\n                        \\\n                        \\   * 0 = Clean\n                        \\\n                        \\   * 1-49 = Offender\n                        \\\n                        \\   * 50+ = Fugitive\n                        \\\n                        \\ You get 64 points if you kill a cop, so that's a fast\n                        \\ ticket to fugitive status\n\n.AVL\n\n SKIP 17                \\ Market availability in the current system\n                        \\\n                        \\ The available amount of market item X is stored in\n                        \\ the X-th byte of AVL, so for example:\n                        \\\n                        \\   * AVL contains the amount of food (item 0)\n                        \\\n                        \\   * AVL+7 contains the amount of computers (item 7)\n                        \\\n                        \\ See QQ23 for a list of market item numbers and their\n                        \\ storage units\n\n.QQ26\n\n SKIP 1                 \\ A random value used to randomise market data\n                        \\\n                        \\ This value is set to a new random number for each\n                        \\ change of system, so we can add a random factor into\n                        \\ the calculations for market prices\n\n.TALLY\n\n SKIP 2                 \\ Our combat rank\n                        \\\n                        \\ The combat rank is stored as the number of kills, in a\n                        \\ 16-bit number TALLY(1 0) - so the high byte is in\n                        \\ TALLY+1 and the low byte in TALLY\n                        \\\n                        \\ If the high byte in TALLY+1 is 0 then we have between\n                        \\ 0 and 255 kills, so our rank is Harmless, Mostly\n                        \\ Harmless, Poor, Average Above Average or Competent,\n                        \\ according to the value of the low byte in TALLY:\n                        \\\n                        \\   Harmless         %00000000 to %00000111 = 0 to 7\n                        \\   Mostly Harmless  %00001000 to %00001111 = 8 to 15\n                        \\   Poor             %00010000 to %00011111 = 16 to 31\n                        \\   Average          %00100000 to %00111111 = 32 to 63\n                        \\   Above Average    %01000000 to %01111111 = 64 to 127\n                        \\   Competent        %10000000 to %11111111 = 128 to 255\n                        \\\n                        \\ Note that the Competent range also covers kill counts\n                        \\ from 256 to 511, as follows\n                        \\\n                        \\ If the high byte in TALLY+1 is non-zero then we are\n                        \\ Competent, Dangerous, Deadly or Elite, according to\n                        \\ the value of TALLY(1 0):\n                        \\\n                        \\   Competent   (1 0) to (1 255)   = 256 to 511 kills\n                        \\   Dangerous   (2 0) to (9 255)   = 512 to 2559 kills\n                        \\   Deadly      (10 0) to (24 255) = 2560 to 6399 kills\n                        \\   Elite       (25 0) and up      = 6400 kills and up\n                        \\\n                        \\ You can see the rating calculation in the STATUS\n                        \\ subroutine\n\n.SVC\n\n SKIP 1                 \\ The save count\n                        \\\n                        \\ When a new commander is created, the save count gets\n                        \\ set to 128. This value gets halved each time the\n                        \\ commander file is saved, but it is otherwise unused.\n                        \\ It is presumably part of the security system for the\n                        \\ competition, possibly another flag to catch out\n                        \\ entries with manually altered commander files\n\n SKIP 2                 \\ The commander file checksum\n                        \\\n                        \\ These two bytes are reserved for the commander file\n                        \\ checksum, so when the current commander block is\n                        \\ copied from here to the last saved commander block at\n                        \\ NA%, CHK and CHK2 get overwritten\n\n NT% = SVC + 2 - TP     \\ This sets the variable NT% to the size of the current\n                        \\ commander data block, which starts at TP and ends at\n                        \\ SVC+2 (inclusive)\n\n.SX\n\n SKIP NOST + 1          \\ This is where we store the x_hi coordinates for all\n                        \\ the stardust particles\n\n.SXL\n\n SKIP NOST + 1          \\ This is where we store the x_lo coordinates for all\n                        \\ the stardust particles\n\n PRINT \"T% workspace from \", ~T%, \"to \", ~P%-1, \"inclusive\"\n\n\\ ******************************************************************************\n\\\n\\ ELITE RECURSIVE TEXT TOKEN FILE\n\\\n\\ Produces the binary file WORDS9.bin that gets loaded by elite-loader.asm.\n\\\n\\ The recursive token table is loaded at &1100 and is moved down to &0400 as\n\\ part of elite-loader.asm, so it ends up at &0400 to &07FF.\n\\\n\\ ******************************************************************************\n\n ORG CODE_WORDS%        \\ Set the assembly address to CODE_WORDS%\n\n\\ ******************************************************************************\n\\\n\\       Name: CHAR\n\\       Type: Macro\n\\   Category: Text\n\\    Summary: Macro definition for characters in the recursive token table\n\\  Deep dive: Printing text tokens\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The following macro is used when building the recursive token table:\n\\\n\\   CHAR 'x'            Insert ASCII character \"x\"\n\\\n\\ To include an apostrophe, use a backtick character, as in CHAR '`'.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   'x'                 The character to insert into the table\n\\\n\\ ******************************************************************************\n\nMACRO CHAR x\n\n IF x = '`'\n   EQUB 39 EOR RE\n ELSE\n   EQUB x EOR RE\n ENDIF\n\nENDMACRO\n\n\\ ******************************************************************************\n\\\n\\       Name: TWOK\n\\       Type: Macro\n\\   Category: Text\n\\    Summary: Macro definition for two-letter tokens in the token table\n\\  Deep dive: Printing text tokens\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The following macro is used when building the recursive token table:\n\\\n\\   TWOK 'x', 'y'       Insert two-letter token \"xy\"\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   'x'                 The first letter of the two-letter token to insert into\n\\                       the table\n\\\n\\   'y'                 The second letter of the two-letter token to insert into\n\\                       the table\n\\\n\\ ******************************************************************************\n\nMACRO TWOK t, k\n\n IF t = 'A' AND k = 'L'\n  EQUB 128 EOR RE\n ENDIF\n\n IF t = 'L' AND k = 'E'\n  EQUB 129 EOR RE\n ENDIF\n\n IF t = 'X' AND k = 'E'\n  EQUB 130 EOR RE\n ENDIF\n\n IF t = 'G' AND k = 'E'\n  EQUB 131 EOR RE\n ENDIF\n\n IF t = 'Z' AND k = 'A'\n  EQUB 132 EOR RE\n ENDIF\n\n IF t = 'C' AND k = 'E'\n  EQUB 133 EOR RE\n ENDIF\n\n IF t = 'B' AND k = 'I'\n  EQUB 134 EOR RE\n ENDIF\n\n IF t = 'S' AND k = 'O'\n  EQUB 135 EOR RE\n ENDIF\n\n IF t = 'U' AND k = 'S'\n  EQUB 136 EOR RE\n ENDIF\n\n IF t = 'E' AND k = 'S'\n  EQUB 137 EOR RE\n ENDIF\n\n IF t = 'A' AND k = 'R'\n  EQUB 138 EOR RE\n ENDIF\n\n IF t = 'M' AND k = 'A'\n  EQUB 139 EOR RE\n ENDIF\n\n IF t = 'I' AND k = 'N'\n  EQUB 140 EOR RE\n ENDIF\n\n IF t = 'D' AND k = 'I'\n  EQUB 141 EOR RE\n ENDIF\n\n IF t = 'R' AND k = 'E'\n  EQUB 142 EOR RE\n ENDIF\n\n IF t = 'A' AND k = '?'\n  EQUB 143 EOR RE\n ENDIF\n\n IF t = 'E' AND k = 'R'\n  EQUB 144 EOR RE\n ENDIF\n\n IF t = 'A' AND k = 'T'\n  EQUB 145 EOR RE\n ENDIF\n\n IF t = 'E' AND k = 'N'\n  EQUB 146 EOR RE\n ENDIF\n\n IF t = 'B' AND k = 'E'\n  EQUB 147 EOR RE\n ENDIF\n\n IF t = 'R' AND k = 'A'\n  EQUB 148 EOR RE\n ENDIF\n\n IF t = 'L' AND k = 'A'\n  EQUB 149 EOR RE\n ENDIF\n\n IF t = 'V' AND k = 'E'\n  EQUB 150 EOR RE\n ENDIF\n\n IF t = 'T' AND k = 'I'\n  EQUB 151 EOR RE\n ENDIF\n\n IF t = 'E' AND k = 'D'\n  EQUB 152 EOR RE\n ENDIF\n\n IF t = 'O' AND k = 'R'\n  EQUB 153 EOR RE\n ENDIF\n\n IF t = 'Q' AND k = 'U'\n  EQUB 154 EOR RE\n ENDIF\n\n IF t = 'A' AND k = 'N'\n  EQUB 155 EOR RE\n ENDIF\n\n IF t = 'T' AND k = 'E'\n  EQUB 156 EOR RE\n ENDIF\n\n IF t = 'I' AND k = 'S'\n  EQUB 157 EOR RE\n ENDIF\n\n IF t = 'R' AND k = 'I'\n  EQUB 158 EOR RE\n ENDIF\n\n IF t = 'O' AND k = 'N'\n  EQUB 159 EOR RE\n ENDIF\n\nENDMACRO\n\n\\ ******************************************************************************\n\\\n\\       Name: CONT\n\\       Type: Macro\n\\   Category: Text\n\\    Summary: Macro definition for control codes in the recursive token table\n\\  Deep dive: Printing text tokens\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The following macro is used when building the recursive token table:\n\\\n\\   CONT n              Insert control code token {n}\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   n                   The control code to insert into the table\n\\\n\\ ******************************************************************************\n\nMACRO CONT n\n\n EQUB n EOR RE\n\nENDMACRO\n\n\\ ******************************************************************************\n\\\n\\       Name: RTOK\n\\       Type: Macro\n\\   Category: Text\n\\    Summary: Macro definition for recursive tokens in the recursive token table\n\\  Deep dive: Printing text tokens\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The following macro is used when building the recursive token table:\n\\\n\\   RTOK n              Insert recursive token [n]\n\\\n\\                         * Tokens 0-95 get stored as n + 160\n\\\n\\                         * Tokens 128-145 get stored as n - 114\n\\\n\\                         * Tokens 96-127 get stored as n\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   n                   The number of the recursive token to insert into the\n\\                       table, in the range 0 to 145\n\\\n\\ ******************************************************************************\n\nMACRO RTOK n\n\n IF n >= 0 AND n <= 95\n  t = n + 160\n ELIF n >= 128\n  t = n - 114\n ELSE\n  t = n\n ENDIF\n\n EQUB t EOR RE\n\nENDMACRO\n\n\\ ******************************************************************************\n\\\n\\       Name: QQ18\n\\       Type: Variable\n\\   Category: Text\n\\    Summary: The recursive token table for tokens 0-148\n\\  Deep dive: Printing text tokens\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The encodings shown for each recursive text token use the following notation:\n\\\n\\   {n}           Control code              n = 0 to 13\n\\   <n>           Two-letter token          n = 128 to 159\n\\   [n]           Recursive token           n = 0 to 148\n\\\n\\ ******************************************************************************\n\n.QQ18\n\n RTOK 111               \\ Token 0:      \"FUEL SCOOPS ON {beep}\"\n RTOK 131               \\\n CONT 7                 \\ Encoded as:   \"[111][131]{7}\"\n EQUB 0\n\n CHAR ' '               \\ Token 1:      \" CHART\"\n CHAR 'C'               \\\n CHAR 'H'               \\ Encoded as:   \" CH<138>T\"\n TWOK 'A', 'R'\n CHAR 'T'\n EQUB 0\n\n CHAR 'G'               \\ Token 2:      \"GOVERNMENT\"\n CHAR 'O'               \\\n TWOK 'V', 'E'          \\ Encoded as:   \"GO<150>RNM<146>T\"\n CHAR 'R'\n CHAR 'N'\n CHAR 'M'\n TWOK 'E', 'N'\n CHAR 'T'\n EQUB 0\n\n CHAR 'D'               \\ Token 3:      \"DATA ON {selected system name}\"\n TWOK 'A', 'T'          \\\n CHAR 'A'               \\ Encoded as:   \"D<145>A[131]{3}\"\n RTOK 131\n CONT 3\n EQUB 0\n\n TWOK 'I', 'N'          \\ Token 4:      \"INVENTORY{crlf}\n TWOK 'V', 'E'          \\               \"\n CHAR 'N'               \\\n CHAR 'T'               \\ Encoded as:   \"<140><150>NT<153>Y{13}\"\n TWOK 'O', 'R'\n CHAR 'Y'\n CONT 13\n EQUB 0\n\n CHAR 'S'               \\ Token 5:      \"SYSTEM\"\n CHAR 'Y'               \\\n CHAR 'S'               \\ Encoded as:   \"SYS<156>M\"\n TWOK 'T', 'E'\n CHAR 'M'\n EQUB 0\n\n CHAR 'P'               \\ Token 6:      \"PRICE\"\n TWOK 'R', 'I'          \\\n TWOK 'C', 'E'          \\ Encoded as:   \"P<158><133>\"\n EQUB 0\n\n CONT 2                 \\ Token 7:      \"{current system name} MARKET PRICES\"\n CHAR ' '               \\\n TWOK 'M', 'A'          \\ Encoded as:   \"{2} <139>RKET [6]S\"\n CHAR 'R'\n CHAR 'K'\n CHAR 'E'\n CHAR 'T'\n CHAR ' '\n RTOK 6\n CHAR 'S'\n EQUB 0\n\n TWOK 'I', 'N'          \\ Token 8:      \"INDUSTRIAL\"\n CHAR 'D'               \\\n TWOK 'U', 'S'          \\ Encoded as:   \"<140>D<136>T<158><128>\"\n CHAR 'T'\n TWOK 'R', 'I'\n TWOK 'A', 'L'\n EQUB 0\n\n CHAR 'A'               \\ Token 9:      \"AGRICULTURAL\"\n CHAR 'G'               \\\n TWOK 'R', 'I'          \\ Encoded as:   \"AG<158>CULTU<148>L\"\n CHAR 'C'\n CHAR 'U'\n CHAR 'L'\n CHAR 'T'\n CHAR 'U'\n TWOK 'R', 'A'\n CHAR 'L'\n EQUB 0\n\n TWOK 'R', 'I'          \\ Token 10:     \"RICH \"\n CHAR 'C'               \\\n CHAR 'H'               \\ Encoded as:   \"<158>CH \"\n CHAR ' '\n EQUB 0\n\n CHAR 'A'               \\ Token 11:     \"AVERAGE \"\n TWOK 'V', 'E'          \\\n TWOK 'R', 'A'          \\ Encoded as:   \"A<150><148><131> \"\n TWOK 'G', 'E'\n CHAR ' '\n EQUB 0\n\n CHAR 'P'               \\ Token 12:     \"POOR \"\n CHAR 'O'               \\\n TWOK 'O', 'R'          \\ Encoded as:   \"PO<153> \"\n CHAR ' '\n EQUB 0\n\n TWOK 'M', 'A'          \\ Token 13:     \"MAINLY \"\n TWOK 'I', 'N'          \\\n CHAR 'L'               \\ Encoded as:   \"<139><140>LY \"\n CHAR 'Y'\n CHAR ' '\n EQUB 0\n\n CHAR 'U'               \\ Token 14:     \"UNIT\"\n CHAR 'N'               \\\n CHAR 'I'               \\ Encoded as:   \"UNIT\"\n CHAR 'T'\n EQUB 0\n\n CHAR 'V'               \\ Token 15:     \"VIEW \"\n CHAR 'I'               \\\n CHAR 'E'               \\ Encoded as:   \"VIEW \"\n CHAR 'W'\n CHAR ' '\n EQUB 0\n\n TWOK 'Q', 'U'          \\ Token 16:     \"QUANTITY\"\n TWOK 'A', 'N'          \\\n TWOK 'T', 'I'          \\ Encoded as:   \"<154><155><151>TY\"\n CHAR 'T'\n CHAR 'Y'\n EQUB 0\n\n TWOK 'A', 'N'          \\ Token 17:     \"ANARCHY\"\n TWOK 'A', 'R'          \\\n CHAR 'C'               \\ Encoded as:   \"<155><138>CHY\"\n CHAR 'H'\n CHAR 'Y'\n EQUB 0\n\n CHAR 'F'               \\ Token 18:     \"FEUDAL\"\n CHAR 'E'               \\\n CHAR 'U'               \\ Encoded as:   \"FEUD<128>\"\n CHAR 'D'\n TWOK 'A', 'L'\n EQUB 0\n\n CHAR 'M'               \\ Token 19:     \"MULTI-GOVERNMENT\"\n CHAR 'U'               \\\n CHAR 'L'               \\ Encoded as:   \"MUL<151>-[2]\"\n TWOK 'T', 'I'\n CHAR '-'\n RTOK 2\n EQUB 0\n\n TWOK 'D', 'I'          \\ Token 20:     \"DICTATORSHIP\"\n CHAR 'C'               \\\n CHAR 'T'               \\ Encoded as:   \"<141>CT<145><153>[25]\"\n TWOK 'A', 'T'\n TWOK 'O', 'R'\n RTOK 25\n EQUB 0\n\n RTOK 91                \\ Token 21:     \"COMMUNIST\"\n CHAR 'M'               \\\n CHAR 'U'               \\ Encoded as:   \"[91]MUN<157>T\"\n CHAR 'N'\n TWOK 'I', 'S'\n CHAR 'T'\n EQUB 0\n\n CHAR 'C'               \\ Token 22:     \"CONFEDERACY\"\n TWOK 'O', 'N'          \\\n CHAR 'F'               \\ Encoded as:   \"C<159>F<152><144>ACY\"\n TWOK 'E', 'D'\n TWOK 'E', 'R'\n CHAR 'A'\n CHAR 'C'\n CHAR 'Y'\n EQUB 0\n\n CHAR 'D'               \\ Token 23:     \"DEMOCRACY\"\n CHAR 'E'               \\\n CHAR 'M'               \\ Encoded as:   \"DEMOC<148>CY\"\n CHAR 'O'\n CHAR 'C'\n TWOK 'R', 'A'\n CHAR 'C'\n CHAR 'Y'\n EQUB 0\n\n CHAR 'C'               \\ Token 24:     \"CORPORATE STATE\"\n TWOK 'O', 'R'          \\\n CHAR 'P'               \\ Encoded as:   \"C<153>P<153><145>E [43]<145>E\"\n TWOK 'O', 'R'\n TWOK 'A', 'T'\n CHAR 'E'\n CHAR ' '\n RTOK 43\n TWOK 'A', 'T'\n CHAR 'E'\n EQUB 0\n\n CHAR 'S'               \\ Token 25:     \"SHIP\"\n CHAR 'H'               \\\n CHAR 'I'               \\ Encoded as:   \"SHIP\"\n CHAR 'P'\n EQUB 0\n\n CHAR 'P'               \\ Token 26:     \"PRODUCT\"\n CHAR 'R'               \\\n CHAR 'O'               \\ Encoded as:   \"PRODUCT\"\n CHAR 'D'\n CHAR 'U'\n CHAR 'C'\n CHAR 'T'\n EQUB 0\n\n CHAR ' '               \\ Token 27:     \" LASER\"\n TWOK 'L', 'A'          \\\n CHAR 'S'               \\ Encoded as:   \" <149>S<144>\"\n TWOK 'E', 'R'\n EQUB 0\n\n CHAR 'H'               \\ Token 28:     \"HUMAN COLONIAL\"\n CHAR 'U'               \\\n CHAR 'M'               \\ Encoded as:   \"HUM<155> COL<159>I<128>\"\n TWOK 'A', 'N'\n CHAR ' '\n CHAR 'C'\n CHAR 'O'\n CHAR 'L'\n TWOK 'O', 'N'\n CHAR 'I'\n TWOK 'A', 'L'\n EQUB 0\n\n CHAR 'H'               \\ Token 29:     \"HYPERSPACE \"\n CHAR 'Y'               \\\n CHAR 'P'               \\ Encoded as:   \"HYP<144>SPA<133> \"\n TWOK 'E', 'R'\n CHAR 'S'\n CHAR 'P'\n CHAR 'A'\n TWOK 'C', 'E'\n CHAR ' '\n EQUB 0\n\n CHAR 'S'               \\ Token 30:     \"SHORT RANGE CHART\"\n CHAR 'H'               \\\n TWOK 'O', 'R'          \\ Encoded as:   \"SH<153>T [42][1]\"\n CHAR 'T'\n CHAR ' '\n RTOK 42\n RTOK 1\n EQUB 0\n\n TWOK 'D', 'I'          \\ Token 31:     \"DISTANCE\"\n RTOK 43                \\\n TWOK 'A', 'N'          \\ Encoded as:   \"<141>[43]<155><133>\"\n TWOK 'C', 'E'\n EQUB 0\n\n CHAR 'P'               \\ Token 32:     \"POPULATION\"\n CHAR 'O'               \\\n CHAR 'P'               \\ Encoded as:   \"POPUL<145>I<159>\"\n CHAR 'U'\n CHAR 'L'\n TWOK 'A', 'T'\n CHAR 'I'\n TWOK 'O', 'N'\n EQUB 0\n\n CHAR 'G'               \\ Token 33:     \"GROSS PRODUCTIVITY\"\n CHAR 'R'               \\\n CHAR 'O'               \\ Encoded as:   \"GROSS [26]IVITY\"\n CHAR 'S'\n CHAR 'S'\n CHAR ' '\n RTOK 26\n CHAR 'I'\n CHAR 'V'\n CHAR 'I'\n CHAR 'T'\n CHAR 'Y'\n EQUB 0\n\n CHAR 'E'               \\ Token 34:     \"ECONOMY\"\n CHAR 'C'               \\\n TWOK 'O', 'N'          \\ Encoded as:   \"EC<159>OMY\"\n CHAR 'O'\n CHAR 'M'\n CHAR 'Y'\n EQUB 0\n\n CHAR ' '               \\ Token 35:     \" LIGHT YEARS\"\n CHAR 'L'               \\\n CHAR 'I'               \\ Encoded as:   \" LIGHT YE<138>S\"\n CHAR 'G'\n CHAR 'H'\n CHAR 'T'\n CHAR ' '\n CHAR 'Y'\n CHAR 'E'\n TWOK 'A', 'R'\n CHAR 'S'\n EQUB 0\n\n TWOK 'T', 'E'          \\ Token 36:     \"TECH.LEVEL\"\n CHAR 'C'               \\\n CHAR 'H'               \\ Encoded as:   \"<156>CH.<129><150>L\"\n CHAR '.'\n TWOK 'L', 'E'\n TWOK 'V', 'E'\n CHAR 'L'\n EQUB 0\n\n CHAR 'C'               \\ Token 37:     \"CASH\"\n CHAR 'A'               \\\n CHAR 'S'               \\ Encoded as:   \"CASH\"\n CHAR 'H'\n EQUB 0\n\n CHAR ' '               \\ Token 38:     \" BILLION\"\n TWOK 'B', 'I'          \\\n RTOK 118               \\ Encoded as:   \" <134>[118]I<159>\"\n CHAR 'I'\n TWOK 'O', 'N'\n EQUB 0\n\n RTOK 122               \\ Token 39:     \"GALACTIC CHART{galaxy number}\"\n RTOK 1                 \\\n CONT 1                 \\ Encoded as:   \"[122][1]{1}\"\n EQUB 0\n\n CHAR 'T'               \\ Token 40:     \"TARGET LOST\"\n TWOK 'A', 'R'          \\\n TWOK 'G', 'E'          \\ Encoded as:   \"T<138><131>T LO[43]\"\n CHAR 'T'\n CHAR ' '\n CHAR 'L'\n CHAR 'O'\n RTOK 43\n EQUB 0\n\n RTOK 106               \\ Token 41:     \"MISSILE JAMMED\"\n CHAR ' '               \\\n CHAR 'J'               \\ Encoded as:   \"[106] JAMM<152>\"\n CHAR 'A'\n CHAR 'M'\n CHAR 'M'\n TWOK 'E', 'D'\n EQUB 0\n\n CHAR 'R'               \\ Token 42:     \"RANGE\"\n TWOK 'A', 'N'          \\\n TWOK 'G', 'E'          \\ Encoded as:   \"R<155><131>\"\n EQUB 0\n\n CHAR 'S'               \\ Token 43:     \"ST\"\n CHAR 'T'               \\\n EQUB 0                 \\ Encoded as:   \"ST\"\n\n RTOK 16                \\ Token 44:     \"QUANTITY OF \"\n CHAR ' '               \\\n CHAR 'O'               \\ Encoded as:   \"[16] OF \"\n CHAR 'F'\n CHAR ' '\n EQUB 0\n\n CHAR 'S'               \\ Token 45:     \"SELL\"\n CHAR 'E'               \\\n RTOK 118               \\ Encoded as:   \"SE[118]\"\n EQUB 0\n\n CHAR ' '               \\ Token 46:     \" CARGO{sentence case}\"\n CHAR 'C'               \\\n TWOK 'A', 'R'          \\ Encoded as:   \" C<138>GO{6}\"\n CHAR 'G'\n CHAR 'O'\n CONT 6\n EQUB 0\n\n CHAR 'E'               \\ Token 47:     \"EQUIP\"\n TWOK 'Q', 'U'          \\\n CHAR 'I'               \\ Encoded as:   \"E<154>IP\"\n CHAR 'P'\n EQUB 0\n\n CHAR 'F'               \\ Token 48:     \"FOOD\"\n CHAR 'O'               \\\n CHAR 'O'               \\ Encoded as:   \"FOOD\"\n CHAR 'D'\n EQUB 0\n\n TWOK 'T', 'E'          \\ Token 49:     \"TEXTILES\"\n CHAR 'X'               \\\n TWOK 'T', 'I'          \\ Encoded as:   \"<156>X<151>L<137>\"\n CHAR 'L'\n TWOK 'E', 'S'\n EQUB 0\n\n TWOK 'R', 'A'          \\ Token 50:     \"RADIOACTIVES\"\n TWOK 'D', 'I'          \\\n CHAR 'O'               \\ Encoded as:   \"<148><141>OAC<151><150>S\"\n CHAR 'A'\n CHAR 'C'\n TWOK 'T', 'I'\n TWOK 'V', 'E'\n CHAR 'S'\n EQUB 0\n\n CHAR 'S'               \\ Token 51:     \"SLAVES\"\n TWOK 'L', 'A'          \\\n TWOK 'V', 'E'          \\ Encoded as:   \"S<149><150>S\"\n CHAR 'S'\n EQUB 0\n\n CHAR 'L'               \\ Token 52:     \"LIQUOR/WINES\"\n CHAR 'I'               \\\n TWOK 'Q', 'U'          \\ Encoded as:   \"LI<154><153>/W<140><137>\"\n TWOK 'O', 'R'\n CHAR '/'\n CHAR 'W'\n TWOK 'I', 'N'\n TWOK 'E', 'S'\n EQUB 0\n\n CHAR 'L'               \\ Token 53:     \"LUXURIES\"\n CHAR 'U'               \\\n CHAR 'X'               \\ Encoded as:   \"LUXU<158><137>\"\n CHAR 'U'\n TWOK 'R', 'I'\n TWOK 'E', 'S'\n EQUB 0\n\n CHAR 'N'               \\ Token 54:     \"NARCOTICS\"\n TWOK 'A', 'R'          \\\n CHAR 'C'               \\ Encoded as:   \"N<138>CO<151>CS\"\n CHAR 'O'\n TWOK 'T', 'I'\n CHAR 'C'\n CHAR 'S'\n EQUB 0\n\n RTOK 91                \\ Token 55:     \"COMPUTERS\"\n CHAR 'P'               \\\n CHAR 'U'               \\ Encoded as:   \"[91]PUT<144>S\"\n CHAR 'T'\n TWOK 'E', 'R'\n CHAR 'S'\n EQUB 0\n\n TWOK 'M', 'A'          \\ Token 56:     \"MACHINERY\"\n CHAR 'C'               \\\n CHAR 'H'               \\ Encoded as:   \"<139>CH<140><144>Y\"\n TWOK 'I', 'N'\n TWOK 'E', 'R'\n CHAR 'Y'\n EQUB 0\n\n RTOK 117               \\ Token 57:     \"ALLOYS\"\n CHAR 'O'               \\\n CHAR 'Y'               \\ Encoded as:   \"[117]OYS\"\n CHAR 'S'\n EQUB 0\n\n CHAR 'F'               \\ Token 58:     \"FIREARMS\"\n CHAR 'I'               \\\n TWOK 'R', 'E'          \\ Encoded as:   \"FI<142><138>MS\"\n TWOK 'A', 'R'\n CHAR 'M'\n CHAR 'S'\n EQUB 0\n\n CHAR 'F'               \\ Token 59:     \"FURS\"\n CHAR 'U'               \\\n CHAR 'R'               \\ Encoded as:   \"FURS\"\n CHAR 'S'\n EQUB 0\n\n CHAR 'M'               \\ Token 60:     \"MINERALS\"\n TWOK 'I', 'N'          \\\n TWOK 'E', 'R'          \\ Encoded as:   \"M<140><144><128>S\"\n TWOK 'A', 'L'\n CHAR 'S'\n EQUB 0\n\n CHAR 'G'               \\ Token 61:     \"GOLD\"\n CHAR 'O'               \\\n CHAR 'L'               \\ Encoded as:   \"GOLD\"\n CHAR 'D'\n EQUB 0\n\n CHAR 'P'               \\ Token 62:     \"PLATINUM\"\n CHAR 'L'               \\\n TWOK 'A', 'T'          \\ Encoded as:   \"PL<145><140>UM\"\n TWOK 'I', 'N'\n CHAR 'U'\n CHAR 'M'\n EQUB 0\n\n TWOK 'G', 'E'          \\ Token 63:     \"GEM-STONES\"\n CHAR 'M'               \\\n CHAR '-'               \\ Encoded as:   \"<131>M-[43]<159><137>\"\n RTOK 43\n TWOK 'O', 'N'\n TWOK 'E', 'S'\n EQUB 0\n\n TWOK 'A', 'L'          \\ Token 64:     \"ALIEN ITEMS\"\n CHAR 'I'               \\\n TWOK 'E', 'N'          \\ Encoded as:   \"<128>I<146> [127]S\"\n CHAR ' '\n RTOK 127\n CHAR 'S'\n EQUB 0\n\n CHAR '('               \\ Token 65:     \"(Y/N)?\"\n CHAR 'Y'               \\\n CHAR '/'               \\ Encoded as:   \"(Y/N)?\"\n CHAR 'N'\n CHAR ')'\n CHAR '?'\n EQUB 0\n\n CHAR ' '               \\ Token 66:     \" CR\"\n CHAR 'C'               \\\n CHAR 'R'               \\ Encoded as:   \" CR\"\n EQUB 0\n\n CHAR 'L'               \\ Token 67:     \"LARGE\"\n TWOK 'A', 'R'          \\\n TWOK 'G', 'E'          \\ Encoded as:   \"L<138><131>\"\n EQUB 0\n\n CHAR 'F'               \\ Token 68:     \"FIERCE\"\n CHAR 'I'               \\\n TWOK 'E', 'R'          \\ Encoded as:   \"FI<144><133>\"\n TWOK 'C', 'E'\n EQUB 0\n\n CHAR 'S'               \\ Token 69:     \"SMALL\"\n TWOK 'M', 'A'          \\\n RTOK 118               \\ Encoded as:   \"S<139>[118]\"\n EQUB 0\n\n CHAR 'G'               \\ Token 70:     \"GREEN\"\n TWOK 'R', 'E'          \\\n TWOK 'E', 'N'          \\ Encoded as:   \"G<142><146>\"\n EQUB 0\n\n CHAR 'R'               \\ Token 71:     \"RED\"\n TWOK 'E', 'D'          \\\n EQUB 0                 \\ Encoded as:   \"R<152>\"\n\n CHAR 'Y'               \\ Token 72:     \"YELLOW\"\n CHAR 'E'               \\\n RTOK 118               \\ Encoded as:   \"YE[118]OW\"\n CHAR 'O'\n CHAR 'W'\n EQUB 0\n\n CHAR 'B'               \\ Token 73:     \"BLUE\"\n CHAR 'L'               \\\n CHAR 'U'               \\ Encoded as:   \"BLUE\"\n CHAR 'E'\n EQUB 0\n\n CHAR 'B'               \\ Token 74:     \"BLACK\"\n TWOK 'L', 'A'          \\\n CHAR 'C'               \\ Encoded as:   \"B<149>CK\"\n CHAR 'K'\n EQUB 0\n\n RTOK 136               \\ Token 75:     \"HARMLESS\"\n EQUB 0                 \\\n                        \\ Encoded as:   \"[136]\"\n\n CHAR 'S'               \\ Token 76:     \"SLIMY\"\n CHAR 'L'               \\\n CHAR 'I'               \\ Encoded as:   \"SLIMY\"\n CHAR 'M'\n CHAR 'Y'\n EQUB 0\n\n CHAR 'B'               \\ Token 77:     \"BUG-EYED\"\n CHAR 'U'               \\\n CHAR 'G'               \\ Encoded as:   \"BUG-EY<152>\"\n CHAR '-'\n CHAR 'E'\n CHAR 'Y'\n TWOK 'E', 'D'\n EQUB 0\n\n CHAR 'H'               \\ Token 78:     \"HORNED\"\n TWOK 'O', 'R'          \\\n CHAR 'N'               \\ Encoded as:   \"H<153>N<152>\"\n TWOK 'E', 'D'\n EQUB 0\n\n CHAR 'B'               \\ Token 79:     \"BONY\"\n TWOK 'O', 'N'          \\\n CHAR 'Y'               \\ Encoded as:   \"B<159>Y\"\n EQUB 0\n\n CHAR 'F'               \\ Token 80:     \"FAT\"\n TWOK 'A', 'T'          \\\n EQUB 0                 \\ Encoded as:   \"F<145>\"\n\n CHAR 'F'               \\ Token 81:     \"FURRY\"\n CHAR 'U'               \\\n CHAR 'R'               \\ Encoded as:   \"FURRY\"\n CHAR 'R'\n CHAR 'Y'\n EQUB 0\n\n CHAR 'R'               \\ Token 82:     \"RODENT\"\n CHAR 'O'               \\\n CHAR 'D'               \\ Encoded as:   \"ROD<146>T\"\n TWOK 'E', 'N'\n CHAR 'T'\n EQUB 0\n\n CHAR 'F'               \\ Token 83:     \"FROG\"\n CHAR 'R'               \\\n CHAR 'O'               \\ Encoded as:   \"FROG\"\n CHAR 'G'\n EQUB 0\n\n CHAR 'L'               \\ Token 84:     \"LIZARD\"\n CHAR 'I'               \\\n TWOK 'Z', 'A'          \\ Encoded as:   \"LI<132>RD\"\n CHAR 'R'\n CHAR 'D'\n EQUB 0\n\n CHAR 'L'               \\ Token 85:     \"LOBSTER\"\n CHAR 'O'               \\\n CHAR 'B'               \\ Encoded as:   \"LOB[43]<144>\"\n RTOK 43\n TWOK 'E', 'R'\n EQUB 0\n\n TWOK 'B', 'I'          \\ Token 86:     \"BIRD\"\n CHAR 'R'               \\\n CHAR 'D'               \\ Encoded as:   \"<134>RD\"\n EQUB 0\n\n CHAR 'H'               \\ Token 87:     \"HUMANOID\"\n CHAR 'U'               \\\n CHAR 'M'               \\ Encoded as:   \"HUM<155>OID\"\n TWOK 'A', 'N'\n CHAR 'O'\n CHAR 'I'\n CHAR 'D'\n EQUB 0\n\n CHAR 'F'               \\ Token 88:     \"FELINE\"\n CHAR 'E'               \\\n CHAR 'L'               \\ Encoded as:   \"FEL<140>E\"\n TWOK 'I', 'N'\n CHAR 'E'\n EQUB 0\n\n TWOK 'I', 'N'          \\ Token 89:     \"INSECT\"\n CHAR 'S'               \\\n CHAR 'E'               \\ Encoded as:   \"<140>SECT\"\n CHAR 'C'\n CHAR 'T'\n EQUB 0\n\n RTOK 11                \\ Token 90:     \"AVERAGE RADIUS\"\n TWOK 'R', 'A'          \\\n TWOK 'D', 'I'          \\ Encoded as:   \"[11]<148><141><136>\"\n TWOK 'U', 'S'\n EQUB 0\n\n CHAR 'C'               \\ Token 91:     \"COM\"\n CHAR 'O'               \\\n CHAR 'M'               \\ Encoded as:   \"COM\"\n EQUB 0\n\n RTOK 91                \\ Token 92:     \"COMMANDER\"\n CHAR 'M'               \\\n TWOK 'A', 'N'          \\ Encoded as:   \"[91]M<155>D<144>\"\n CHAR 'D'\n TWOK 'E', 'R'\n EQUB 0\n\n CHAR ' '               \\ Token 93:     \" DESTROYED\"\n CHAR 'D'               \\\n TWOK 'E', 'S'          \\ Encoded as:   \" D<137>TROY<152>\"\n CHAR 'T'\n CHAR 'R'\n CHAR 'O'\n CHAR 'Y'\n TWOK 'E', 'D'\n EQUB 0\n\n CHAR 'B'               \\ Token 94:     \"BY D.BRABEN & I.BELL\"\n CHAR 'Y'               \\\n CHAR ' '               \\ Encoded as:   \"BY D.B<148><147>N & I.<147>[118]\"\n CHAR 'D'\n CHAR '.'\n CHAR 'B'\n TWOK 'R', 'A'\n TWOK 'B', 'E'\n CHAR 'N'\n CHAR ' '\n CHAR '&'\n CHAR ' '\n CHAR 'I'\n CHAR '.'\n TWOK 'B', 'E'\n RTOK 118\n EQUB 0\n\n RTOK 14                \\ Token 95:     \"UNIT  QUANTITY{crlf}\n CHAR ' '               \\                 PRODUCT   UNIT PRICE FOR SALE{crlf}\n CHAR ' '               \\                                              {lf}\"\n RTOK 16                \\\n CONT 13                \\ Encoded as:   \"[14]  [16]{13} [26]   [14] [6] F<153>\n CHAR ' '               \\                 SA<129>{13}{10}\"\n RTOK 26\n CHAR ' '\n CHAR ' '\n CHAR ' '\n RTOK 14\n CHAR ' '\n RTOK 6\n CHAR ' '\n CHAR 'F'\n TWOK 'O', 'R'\n CHAR ' '\n CHAR 'S'\n CHAR 'A'\n TWOK 'L', 'E'\n CONT 13\n CONT 10\n EQUB 0\n\n CHAR 'F'               \\ Token 96:     \"FRONT\"\n CHAR 'R'               \\\n TWOK 'O', 'N'          \\ Encoded as:   \"FR<159>T\"\n CHAR 'T'\n EQUB 0\n\n TWOK 'R', 'E'          \\ Token 97:     \"REAR\"\n TWOK 'A', 'R'          \\\n EQUB 0                 \\ Encoded as:   \"<142><138>\"\n\n TWOK 'L', 'E'          \\ Token 98:     \"LEFT\"\n CHAR 'F'               \\\n CHAR 'T'               \\ Encoded as:   \"<129>FT\"\n EQUB 0\n\n TWOK 'R', 'I'          \\ Token 99:     \"RIGHT\"\n CHAR 'G'               \\\n CHAR 'H'               \\ Encoded as:   \"<158>GHT\"\n CHAR 'T'\n EQUB 0\n\n RTOK 121               \\ Token 100:    \"ENERGY LOW{beep}\"\n CHAR 'L'               \\\n CHAR 'O'               \\ Encoded as:   \"[121]LOW{7}\"\n CHAR 'W'\n CONT 7\n EQUB 0\n\n RTOK 99                \\ Token 101:    \"RIGHT ON COMMANDER!\"\n RTOK 131               \\\n RTOK 92                \\ Encoded as:   \"[99][131][92]!\"\n CHAR '!'\n EQUB 0\n\n CHAR 'E'               \\ Token 102:    \"EXTRA \"\n CHAR 'X'               \\\n CHAR 'T'               \\ Encoded as:   \"EXT<148> \"\n TWOK 'R', 'A'\n CHAR ' '\n EQUB 0\n\n CHAR 'P'               \\ Token 103:    \"PULSE LASER\"\n CHAR 'U'               \\\n CHAR 'L'               \\ Encoded as:   \"PULSE[27]\"\n CHAR 'S'\n CHAR 'E'\n RTOK 27\n EQUB 0\n\n TWOK 'B', 'E'          \\ Token 104:    \"BEAM LASER\"\n CHAR 'A'               \\\n CHAR 'M'               \\ Encoded as:   \"<147>AM[27]\"\n RTOK 27\n EQUB 0\n\n CHAR 'F'               \\ Token 105:    \"FUEL\"\n CHAR 'U'               \\\n CHAR 'E'               \\ Encoded as:   \"FUEL\"\n CHAR 'L'\n EQUB 0\n\n CHAR 'M'               \\ Token 106:    \"MISSILE\"\n TWOK 'I', 'S'          \\\n CHAR 'S'               \\ Encoded as:   \"M<157>SI<129>\"\n CHAR 'I'\n TWOK 'L', 'E'\n EQUB 0\n\n RTOK 67                \\ Token 107:    \"LARGE CARGO{sentence case} BAY\"\n RTOK 46                \\\n CHAR ' '               \\ Encoded as:   \"[67][46] BAY\"\n CHAR 'B'\n CHAR 'A'\n CHAR 'Y'\n EQUB 0\n\n CHAR 'E'               \\ Token 108:    \"E.C.M.SYSTEM\"\n CHAR '.'               \\\n CHAR 'C'               \\ Encoded as:   \"E.C.M.[5]\"\n CHAR '.'\n CHAR 'M'\n CHAR '.'\n RTOK 5\n EQUB 0\n\n RTOK 102               \\ Token 109:    \"EXTRA PULSE LASERS\"\n RTOK 103               \\\n CHAR 'S'               \\ Encoded as:   \"[102][103]S\"\n EQUB 0\n\n RTOK 102               \\ Token 110:    \"EXTRA BEAM LASERS\"\n RTOK 104               \\\n CHAR 'S'               \\ Encoded as:   \"[102][104]S\"\n EQUB 0\n\n RTOK 105               \\ Token 111:    \"FUEL SCOOPS\"\n CHAR ' '               \\\n CHAR 'S'               \\ Encoded as:   \"[105] SCOOPS\"\n CHAR 'C'\n CHAR 'O'\n CHAR 'O'\n CHAR 'P'\n CHAR 'S'\n EQUB 0\n\n TWOK 'E', 'S'          \\ Token 112:    \"ESCAPE POD\"\n CHAR 'C'               \\\n CHAR 'A'               \\ Encoded as:   \"<137>CAPE POD\"\n CHAR 'P'\n CHAR 'E'\n CHAR ' '\n CHAR 'P'\n CHAR 'O'\n CHAR 'D'\n EQUB 0\n\n RTOK 121               \\ Token 113:    \"ENERGY BOMB\"\n CHAR 'B'               \\\n CHAR 'O'               \\ Encoded as:   \"[121]BOMB\"\n CHAR 'M'\n CHAR 'B'\n EQUB 0\n\n RTOK 121               \\ Token 114:    \"ENERGY UNIT\"\n RTOK 14                \\\n EQUB 0                 \\ Encoded as:   \"[121][14]\"\n\n RTOK 124               \\ Token 115:    \"DOCKING COMPUTERS\"\n TWOK 'I', 'N'          \\\n CHAR 'G'               \\ Encoded as:   \"[124]<140>G [55]\"\n CHAR ' '\n RTOK 55\n EQUB 0\n\n RTOK 122               \\ Token 116:    \"GALACTIC HYPERSPACE \"\n CHAR ' '               \\\n RTOK 29                \\ Encoded as:   \"[122] [29]\"\n EQUB 0\n\n CHAR 'A'               \\ Token 117:    \"ALL\"\n RTOK 118               \\\n EQUB 0                 \\ Encoded as:   \"A[118]\"\n\n CHAR 'L'               \\ Token 118:    \"LL\"\n CHAR 'L'               \\\n EQUB 0                 \\ Encoded as:   \"LL\"\n\n RTOK 37                \\ Token 119:    \"CASH:{cash} CR{crlf}\n CHAR ':'               \\               \"\n CONT 0                 \\\n EQUB 0                 \\ Encoded as:   \"[37]:{0}\"\n\n TWOK 'I', 'N'          \\ Token 120:    \"INCOMING MISSILE\"\n RTOK 91                \\\n TWOK 'I', 'N'          \\ Encoded as:   \"<140>[91]<140>G [106]\"\n CHAR 'G'\n CHAR ' '\n RTOK 106\n EQUB 0\n\n TWOK 'E', 'N'          \\ Token 121:    \"ENERGY \"\n TWOK 'E', 'R'          \\\n CHAR 'G'               \\ Encoded as:   \"<146><144>GY \"\n CHAR 'Y'\n CHAR ' '\n EQUB 0\n\n CHAR 'G'               \\ Token 122:    \"GALACTIC\"\n CHAR 'A'               \\\n TWOK 'L', 'A'          \\ Encoded as:   \"GA<149>C<151>C\"\n CHAR 'C'\n TWOK 'T', 'I'\n CHAR 'C'\n EQUB 0\n\n CONT 13                \\ Token 123:    \"{crlf}\n RTOK 92                \\                COMMANDER'S NAME? \"\n CHAR '`'               \\\n CHAR 'S'               \\ Encoded as:   \"{13}[92]'S NAME? \"\n CHAR ' '\n CHAR 'N'\n CHAR 'A'\n CHAR 'M'\n CHAR 'E'\n CHAR '?'\n CHAR ' '\n EQUB 0\n\n CHAR 'D'               \\ Token 124:    \"DOCK\"\n CHAR 'O'               \\\n CHAR 'C'               \\ Encoded as:   \"DOCK\"\n CHAR 'K'\n EQUB 0\n\n CONT 5                 \\ Token 125:    \"FUEL: {fuel level} LIGHT YEARS{crlf}\n TWOK 'L', 'E'          \\                CASH:{cash} CR{crlf}\n CHAR 'G'               \\                LEGAL STATUS:\"\n TWOK 'A', 'L'          \\\n CHAR ' '               \\ Encoded as:   \"{5}<129>G<128> [43]<145><136>:\"\n RTOK 43\n TWOK 'A', 'T'\n TWOK 'U', 'S'\n CHAR ':'\n EQUB 0\n\n RTOK 92                \\ Token 126:    \"COMMANDER {commander name}{crlf}\n CHAR ' '               \\                {crlf}\n CONT 4                 \\                {crlf}\n CONT 13                \\                {sentence case}PRESENT SYSTEM{tab to\n CONT 13                \\                column 21}:{current system name}{crlf}\n CONT 13                \\                HYPERSPACE SYSTEM{tab to column 21}:\n CONT 6                 \\                {selected system name}{crlf}\n RTOK 145               \\                CONDITION{tab to column 21}:\"\n CHAR ' '               \\\n RTOK 5                 \\ Encoded as:   \"[92] {4}{13}{13}{13}{6}[145] [5]{9}{2}\n CONT 9                 \\                {13}[29][5]{9}{3}{13}C<159><141><151>\n CONT 2                 \\                <159>{9}\"\n CONT 13\n RTOK 29\n RTOK 5\n CONT 9\n CONT 3\n CONT 13\n CHAR 'C'\n TWOK 'O', 'N'\n TWOK 'D', 'I'\n TWOK 'T', 'I'\n TWOK 'O', 'N'\n CONT 9\n EQUB 0\n\n CHAR 'I'               \\ Token 127:    \"ITEM\"\n TWOK 'T', 'E'          \\\n CHAR 'M'               \\ Encoded as:   \"I<156>M\"\n EQUB 0\n\n CHAR ' '               \\ Token 128:    \"  LOAD NEW COMMANDER (Y/N)?{crlf}\n CHAR ' '               \\                {crlf}\n CHAR 'L'               \\               \"\n CHAR 'O'               \\\n CHAR 'A'               \\ Encoded as:   \"  LOAD NEW [92] [65]{13}{13}\"\n CHAR 'D'\n CHAR ' '\n CHAR 'N'\n CHAR 'E'\n CHAR 'W'\n CHAR ' '\n RTOK 92\n CHAR ' '\n RTOK 65\n CONT 13\n CONT 13\n EQUB 0\n\n CONT 6                 \\ Token 129:    \"{sentence case}DOCKED\"\n RTOK 124               \\\n TWOK 'E', 'D'          \\ Encoded as:   \"{6}[124]<152>\"\n EQUB 0\n\n TWOK 'R', 'A'          \\ Token 130:    \"RATING:\"\n TWOK 'T', 'I'          \\\n CHAR 'N'               \\ Encoded as:   \"<148><151>NG:\"\n CHAR 'G'\n CHAR ':'\n EQUB 0\n\n CHAR ' '               \\ Token 131:    \" ON \"\n TWOK 'O', 'N'          \\\n CHAR ' '               \\ Encoded as:   \" <159> \"\n EQUB 0\n\n CONT 13                \\ Token 132:    \"{crlf}\n CONT 8                 \\                {all caps}EQUIPMENT: {sentence case}\"\n RTOK 47                \\\n CHAR 'M'               \\ Encoded as:   \"{13}{8}[47]M<146>T:{6}\"\n TWOK 'E', 'N'\n CHAR 'T'\n CHAR ':'\n CONT 6\n EQUB 0\n\n CHAR 'C'               \\ Token 133:    \"CLEAN\"\n TWOK 'L', 'E'          \\\n TWOK 'A', 'N'          \\ Encoded as:   \"C<129><155>\"\n EQUB 0\n\n CHAR 'O'               \\ Token 134:    \"OFFENDER\"\n CHAR 'F'               \\\n CHAR 'F'               \\ Encoded as:   \"OFF<146>D<144>\"\n TWOK 'E', 'N'\n CHAR 'D'\n TWOK 'E', 'R'\n EQUB 0\n\n CHAR 'F'               \\ Token 135:    \"FUGITIVE\"\n CHAR 'U'               \\\n CHAR 'G'               \\ Encoded as:   \"FUGI<151><150>\"\n CHAR 'I'\n TWOK 'T', 'I'\n TWOK 'V', 'E'\n EQUB 0\n\n CHAR 'H'               \\ Token 136:    \"HARMLESS\"\n TWOK 'A', 'R'          \\\n CHAR 'M'               \\ Encoded as:   \"H<138>M<129>SS\"\n TWOK 'L', 'E'\n CHAR 'S'\n CHAR 'S'\n EQUB 0\n\n CHAR 'M'               \\ Token 137:    \"MOSTLY HARMLESS\"\n CHAR 'O'               \\\n RTOK 43                \\ Encoded as:   \"MO[43]LY [136]\"\n CHAR 'L'\n CHAR 'Y'\n CHAR ' '\n RTOK 136\n EQUB 0\n\n RTOK 12                \\ Token 138:    \"POOR \"\n EQUB 0                 \\\n                        \\ Encoded as:   \"[12]\"\n\n RTOK 11                \\ Token 139:    \"AVERAGE \"\n EQUB 0                 \\\n                        \\ Encoded as:   \"[11]\"\n\n CHAR 'A'               \\ Token 140:    \"ABOVE AVERAGE \"\n CHAR 'B'               \\\n CHAR 'O'               \\ Encoded as:   \"ABO<150> [11]\"\n TWOK 'V', 'E'\n CHAR ' '\n RTOK 11\n EQUB 0\n\n RTOK 91                \\ Token 141:    \"COMPETENT\"\n CHAR 'P'               \\\n CHAR 'E'               \\ Encoded as:   \"[91]PET<146>T\"\n CHAR 'T'\n TWOK 'E', 'N'\n CHAR 'T'\n EQUB 0\n\n CHAR 'D'               \\ Token 142:    \"DANGEROUS\"\n TWOK 'A', 'N'          \\\n TWOK 'G', 'E'          \\ Encoded as:   \"D<155><131>RO<136>\"\n CHAR 'R'\n CHAR 'O'\n TWOK 'U', 'S'\n EQUB 0\n\n CHAR 'D'               \\ Token 143:    \"DEADLY\"\n CHAR 'E'               \\\n CHAR 'A'               \\ Encoded as:   \"DEADLY\"\n CHAR 'D'\n CHAR 'L'\n CHAR 'Y'\n EQUB 0\n\n CHAR '-'               \\ Token 144:    \"---- E L I T E ----\"\n CHAR '-'               \\\n CHAR '-'               \\ Encoded as:   \"---- E L I T E ----\"\n CHAR '-'\n CHAR ' '\n CHAR 'E'\n CHAR ' '\n CHAR 'L'\n CHAR ' '\n CHAR 'I'\n CHAR ' '\n CHAR 'T'\n CHAR ' '\n CHAR 'E'\n CHAR ' '\n CHAR '-'\n CHAR '-'\n CHAR '-'\n CHAR '-'\n EQUB 0\n\n CHAR 'P'               \\ Token 145:    \"PRESENT\"\n TWOK 'R', 'E'          \\\n CHAR 'S'               \\ Encoded as:   \"P<142>S<146>T\"\n TWOK 'E', 'N'\n CHAR 'T'\n EQUB 0\n\n CONT 8                 \\ Token 146:    \"{all caps}GAME OVER\"\n CHAR 'G'               \\\n CHAR 'A'               \\ Encoded as:   \"{8}GAME O<150>R\"\n CHAR 'M'\n CHAR 'E'\n CHAR ' '\n CHAR 'O'\n TWOK 'V', 'E'\n CHAR 'R'\n EQUB 0\n\n CHAR 'P'               \\ Token 147:    \"PRESS FIRE OR SPACE,COMMANDER.{crlf}\n CHAR 'R'               \\                {crlf}\n TWOK 'E', 'S'          \\               \"\n CHAR 'S'               \\\n CHAR ' '               \\ Encoded as:   \"PR<137>S FI<142> <153> SPA<133>,[92].\n CHAR 'F'               \\                {13}{13}\"\n CHAR 'I'\n TWOK 'R', 'E'\n CHAR ' '\n TWOK 'O', 'R'\n CHAR ' '\n CHAR 'S'\n CHAR 'P'\n CHAR 'A'\n TWOK 'C', 'E'\n CHAR ','\n RTOK 92\n CHAR '.'\n CONT 13\n CONT 13\n EQUB 0\n\n CHAR '('               \\ Token 148:    \"(C) ACORNSOFT 1984\"\n CHAR 'C'               \\\n CHAR ')'               \\ Encoded as:   \"(C) AC<153>N<135>FT 1984\"\n CHAR ' '\n CHAR 'A'\n CHAR 'C'\n TWOK 'O', 'R'\n CHAR 'N'\n TWOK 'S', 'O'\n CHAR 'F'\n CHAR 'T'\n CHAR ' '\n CHAR '1'\n CHAR '9'\n CHAR '8'\n CHAR '4'\n EQUB 0\n\n\\ ******************************************************************************\n\\\n\\ Save WORDS9.bin\n\\\n\\ ******************************************************************************\n\n PRINT \"WORDS9\"\n PRINT \"Assembled at \", ~CODE_WORDS%\n PRINT \"Ends at \", ~P%\n PRINT \"Code size is \", ~(P% - CODE_WORDS%)\n PRINT \"Execute at \", ~LOAD_WORDS%\n PRINT \"Reload at \", ~LOAD_WORDS%\n\n PRINT \"S.WORDS9 \", ~CODE_WORDS%, \" \", ~P%, \" \", ~LOAD_WORDS%, \" \", ~LOAD_WORDS%\n SAVE \"3-assembled-output/WORDS9.bin\", CODE_WORDS%, P%, LOAD_WORDS%\n\n\\ ******************************************************************************\n\\\n\\       Name: K%\n\\       Type: Workspace\n\\    Address: &0900 to &0AAF\n\\   Category: Workspaces\n\\    Summary: Ship data blocks and ship line heaps\n\\  Deep dive: Ship data blocks\n\\             The local bubble of universe\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Contains ship data for all the ships, planets, suns and space stations in our\n\\ local bubble of universe, along with their corresponding ship line heaps.\n\\\n\\ The blocks are pointed to by the lookup table at location UNIV. The first 432\n\\ bytes of the K% workspace hold ship data on up to 12 ships, with 36 (NI%)\n\\ bytes per ship, and the ship line heap grows downwards from WP at the end of\n\\ the K% workspace.\n\\\n\\ ******************************************************************************\n\n ORG &0900              \\ Set the assembly address to &0900\n\n.K%\n\n SKIP NOSH * NI%        \\ Ship data blocks and ship line heap\n\n PRINT \"K% workspace from \", ~K%, \"to \", ~P%-1, \"inclusive\"\n\n\\ ******************************************************************************\n\\\n\\       Name: WP\n\\       Type: Workspace\n\\    Address: &0D40 to &0F33\n\\   Category: Workspaces\n\\    Summary: Ship slots, variables\n\\\n\\ ******************************************************************************\n\n ORG &0D40              \\ Set the assembly address to &0D40\n\n.WP\n\n SKIP 0                 \\ The start of the WP workspace\n\n.FRIN\n\n SKIP NOSH + 1          \\ Slots for the ships in the local bubble of universe\n                        \\\n                        \\ There are #NOSH + 1 slots, but the ship-spawning\n                        \\ routine at NWSHP only populates #NOSH of them, so\n                        \\ there are 13 slots but only 12 are used for ships\n                        \\ (the last slot is effectively used as a null\n                        \\ terminator when shuffling the slots down in the\n                        \\ KILLSHP routine)\n\n.CABTMP\n\n SKIP 0                 \\ Cabin temperature\n                        \\\n                        \\ The ambient cabin temperature in deep space is 30,\n                        \\ which is displayed as one notch on the dashboard bar\n                        \\\n                        \\ We get higher temperatures closer to the sun\n                        \\\n                        \\ CABTMP shares a location with MANY, but that's OK as\n                        \\ MANY+0 would contain the number of ships of type 0,\n                        \\ and as there is no ship type 0 (they start at 1), the\n                        \\ byte at MANY+0 is not used for storing a ship type\n                        \\ and can be used for the cabin temperature instead\n\n.MANY\n\n SKIP SST               \\ The number of ships of each type in the local bubble\n                        \\ of universe\n                        \\\n                        \\ The number of ships of type X in the local bubble is\n                        \\ stored at MANY+X\n\n.SSPR\n\n SKIP NTY + 1 - SST     \\ \"Space station present\" flag\n                        \\\n                        \\   * Non-zero if we are inside the space station's safe\n                        \\     zone\n                        \\\n                        \\   * 0 if we aren't (in which case we can show the sun)\n                        \\\n                        \\ This flag is at MANY+SST, which is no coincidence, as\n                        \\ MANY+SST is a count of how many space stations there\n                        \\ are in our local bubble, which is the same as saying\n                        \\ \"space station present\"\n\n.ECMP\n\n SKIP 1                 \\ Our E.C.M. status\n                        \\\n                        \\   * 0 = E.C.M. is off\n                        \\\n                        \\   * Non-zero = E.C.M. is on\n\n.MJ\n\n SKIP 1                 \\ Are we in witchspace (i.e. have we mis-jumped)?\n                        \\\n                        \\   * 0 = no, we are in normal space\n                        \\\n                        \\   * &FF = yes, we are in witchspace\n\n.LAS2\n\n SKIP 1                 \\ Laser power for the current laser\n                        \\\n                        \\   * Bits 0-6 contain the laser power of the current\n                        \\     space view\n                        \\\n                        \\   * Bit 7 denotes whether or not the laser pulses:\n                        \\\n                        \\     * 0 = pulsing laser\n                        \\\n                        \\     * 1 = beam laser (i.e. always on)\n\n.MSAR\n\n SKIP 1                 \\ The targeting state of our leftmost missile\n                        \\\n                        \\   * 0 = missile is not looking for a target, or it\n                        \\     already has a target lock (indicator is not\n                        \\     yellow/white)\n                        \\\n                        \\   * Non-zero = missile is currently looking for a\n                        \\     target (indicator is yellow/white)\n\n.VIEW\n\n SKIP 1                 \\ The number of the current space view\n                        \\\n                        \\   * 0 = front\n                        \\   * 1 = rear\n                        \\   * 2 = left\n                        \\   * 3 = right\n\n.LASCT\n\n SKIP 1                 \\ The laser pulse count for the current laser\n                        \\\n                        \\ This is a counter that defines the gap between the\n                        \\ pulses of a pulse laser. It is set as follows:\n                        \\\n                        \\   * 0 for a beam laser\n                        \\\n                        \\   * 10 for a pulse laser\n                        \\\n                        \\ It gets decremented every vertical sync (in the LINSCN\n                        \\ routine, which is called 50 times a second) and is set\n                        \\ to a non-zero value for pulse lasers only\n                        \\\n                        \\ The laser only fires when the value of LASCT hits\n                        \\ zero, so for pulse lasers with a value of 10, that\n                        \\ means the laser fires once every 10 vertical syncs (or\n                        \\ 5 times a second)\n                        \\\n                        \\ In comparison, beam lasers fire continuously as the\n                        \\ value of LASCT is always 0\n\n.GNTMP\n\n SKIP 1                 \\ Laser temperature (or \"gun temperature\")\n                        \\\n                        \\ If the laser temperature exceeds 242 then the laser\n                        \\ overheats and cannot be fired again until it has\n                        \\ cooled down\n\n.HFX\n\n SKIP 1                 \\ A flag that toggles the hyperspace colour effect\n                        \\\n                        \\   * 0 = no colour effect\n                        \\\n                        \\   * Non-zero = hyperspace colour effect enabled\n                        \\\n                        \\ When HFX is set to 1, the mode 4 screen that makes\n                        \\ up the top part of the display is temporarily switched\n                        \\ to mode 5 (the same screen mode as the dashboard),\n                        \\ which has the effect of blurring and colouring the\n                        \\ hyperspace rings in the top part of the screen. The\n                        \\ code to do this is in the LINSCN routine, which is\n                        \\ called as part of the screen mode routine at IRQ1.\n                        \\ It's in LINSCN that HFX is checked, and if it is\n                        \\ non-zero, the top part of the screen is not switched\n                        \\ to mode 4, thus leaving the top part of the screen in\n                        \\ the more colourful mode 5\n\n.EV\n\n SKIP 1                 \\ The \"extra vessels\" spawning counter\n                        \\\n                        \\ This counter is set to 0 on arrival in a system and\n                        \\ following an in-system jump, and is bumped up when we\n                        \\ spawn bounty hunters or pirates (i.e. \"extra vessels\")\n                        \\\n                        \\ It decreases by 1 each time we consider spawning more\n                        \\ \"extra vessels\" in part 4 of the main game loop, so\n                        \\ increasing the value of EV has the effect of delaying\n                        \\ the spawning of more vessels\n                        \\\n                        \\ In other words, this counter stops bounty hunters and\n                        \\ pirates from continually appearing, and ensures that\n                        \\ there's a delay between spawnings\n\n.DLY\n\n SKIP 1                 \\ In-flight message delay\n                        \\\n                        \\ This counter is used to keep an in-flight message up\n                        \\ for a specified time before it gets removed. The value\n                        \\ in DLY is decremented each time we start another\n                        \\ iteration of the main game loop at TT100\n\n.de\n\n SKIP 1                 \\ Equipment destruction flag\n                        \\\n                        \\   * Bit 1 denotes whether or not the in-flight message\n                        \\     about to be shown by the MESS routine is about\n                        \\     destroyed equipment:\n                        \\\n                        \\     * 0 = the message is shown normally\n                        \\\n                        \\     * 1 = the string \" DESTROYED\" gets added to the\n                        \\       end of the message\n\n.LSX\n\n SKIP 0                 \\ LSX is an alias that points to the first byte of the\n                        \\ sun line heap at LSO\n                        \\\n                        \\   * &FF indicates the sun line heap is empty\n                        \\\n                        \\   * Otherwise the LSO heap contains the line data for\n                        \\     the sun\n\n.LSO\n\n SKIP 192               \\ The ship line heap for the space station (see NWSPS)\n                        \\ and the sun line heap (see SUN)\n                        \\\n                        \\ The spaces can be shared as our local bubble of\n                        \\ universe can support either the sun or a space\n                        \\ station, but not both\n\n.LSX2\n\n SKIP 78                \\ The ball line heap for storing x-coordinates\n\n.LSY2\n\n SKIP 78                \\ The ball line heap for storing y-coordinates\n\n.SY\n\n SKIP NOST + 1          \\ This is where we store the y_hi coordinates for all\n                        \\ the stardust particles\n\n.SYL\n\n SKIP NOST + 1          \\ This is where we store the y_lo coordinates for all\n                        \\ the stardust particles\n\n.SZ\n\n SKIP NOST + 1          \\ This is where we store the z_hi coordinates for all\n                        \\ the stardust particles\n\n.SZL\n\n SKIP NOST + 1          \\ This is where we store the z_lo coordinates for all\n                        \\ the stardust particles\n\n.XSAV2\n\n SKIP 1                 \\ Temporary storage, used for storing the value of the X\n                        \\ register in the TT26 routine\n\n.YSAV2\n\n SKIP 1                 \\ Temporary storage, used for storing the value of the Y\n                        \\ register in the TT26 routine\n\n.MCH\n\n SKIP 1                 \\ The text token number of the in-flight message that is\n                        \\ currently being shown, and which will be removed by\n                        \\ the me2 routine when the counter in DLY reaches zero\n\n.FSH\n\n SKIP 1                 \\ Forward shield status\n                        \\\n                        \\   * 0 = empty\n                        \\\n                        \\   * &FF = full\n\n.ASH\n\n SKIP 1                 \\ Aft shield status\n                        \\\n                        \\   * 0 = empty\n                        \\\n                        \\   * &FF = full\n\n.ENERGY\n\n SKIP 1                 \\ Energy bank status\n                        \\\n                        \\   * 0 = empty\n                        \\\n                        \\   * &FF = full\n\n.LASX\n\n SKIP 1                 \\ The x-coordinate of the tip of the laser line\n\n.LASY\n\n SKIP 1                 \\ The y-coordinate of the tip of the laser line\n\n.COMX\n\n SKIP 1                 \\ The x-coordinate of the compass dot\n\n.COMY\n\n SKIP 1                 \\ The y-coordinate of the compass dot\n\n.QQ24\n\n SKIP 1                 \\ Temporary storage, used to store the current market\n                        \\ item's price in routine TT151\n\n.QQ25\n\n SKIP 1                 \\ Temporary storage, used to store the current market\n                        \\ item's availability in routine TT151\n\n.QQ28\n\n SKIP 1                 \\ The current system's economy (0-7)\n                        \\\n                        \\   * 0 = Rich Industrial\n                        \\   * 1 = Average Industrial\n                        \\   * 2 = Poor Industrial\n                        \\   * 3 = Mainly Industrial\n                        \\   * 4 = Mainly Agricultural\n                        \\   * 5 = Rich Agricultural\n                        \\   * 6 = Average Agricultural\n                        \\   * 7 = Poor Agricultural\n\n.QQ29\n\n SKIP 1                 \\ Temporary storage, used in a number of places\n\n.gov\n\n SKIP 1                 \\ The current system's government type (0-7)\n\n.tek\n\n SKIP 1                 \\ The current system's tech level (0-14)\n\n.SLSP\n\n SKIP 2                 \\ The address of the bottom of the ship line heap\n                        \\\n                        \\ The ship line heap is a descending block of memory\n                        \\ that starts at WP and descends down to SLSP. It can be\n                        \\ extended downwards by the NWSHP routine when adding\n                        \\ new ships (and their associated ship line heaps), in\n                        \\ which case SLSP is lowered to provide more heap space,\n                        \\ assuming there is enough free memory to do so\n\n.XX24\n\n SKIP 1                 \\ This byte appears to be unused\n\n.ALTIT\n\n SKIP 1                 \\ Our altitude above the surface of the planet or sun\n                        \\\n                        \\   * 255 = we are a long way above the surface\n                        \\\n                        \\   * 1-254 = our altitude as the square root of:\n                        \\\n                        \\       x_hi^2 + y_hi^2 + z_hi^2 - 6^2\n                        \\\n                        \\     where our ship is at the origin, the centre of the\n                        \\     planet/sun is at (x_hi, y_hi, z_hi), and the\n                        \\     radius of the planet/sun is 6\n                        \\\n                        \\   * 0 = we have crashed into the surface\n\n.QQ2\n\n SKIP 6                 \\ The three 16-bit seeds for the current system, i.e.\n                        \\ the one we are currently in\n\n.QQ3\n\n SKIP 1                 \\ The selected system's economy (0-7)\n                        \\\n                        \\   * 0 = Rich Industrial\n                        \\   * 1 = Average Industrial\n                        \\   * 2 = Poor Industrial\n                        \\   * 3 = Mainly Industrial\n                        \\   * 4 = Mainly Agricultural\n                        \\   * 5 = Rich Agricultural\n                        \\   * 6 = Average Agricultural\n                        \\   * 7 = Poor Agricultural\n\n.QQ4\n\n SKIP 1                 \\ The selected system's government (0-7)\n\n.QQ5\n\n SKIP 1                 \\ The selected system's tech level (0-14)\n\n.QQ6\n\n SKIP 2                 \\ The selected system's population in billions * 10\n                        \\ (1-71), so the maximum population is 7.1 billion\n\n.QQ7\n\n SKIP 2                 \\ The selected system's productivity in M CR (96-62480)\n\n.QQ8\n\n SKIP 2                 \\ The distance from the current system to the selected\n                        \\ system in light years * 10, stored as a 16-bit number\n                        \\\n                        \\ The distance will be 0 if the selected system is the\n                        \\ current system\n                        \\\n                        \\ The galaxy chart is 102.4 light years wide and 51.2\n                        \\ light years tall (see the intra-system distance\n                        \\ calculations in routine TT111 for details), which\n                        \\ equates to 1024 x 512 in terms of QQ8\n\n.QQ9\n\n SKIP 1                 \\ The galactic x-coordinate of the crosshairs in the\n                        \\ galaxy chart (and, most of the time, the selected\n                        \\ system's galactic x-coordinate)\n\n.QQ10\n\n SKIP 1                 \\ The galactic y-coordinate of the crosshairs in the\n                        \\ galaxy chart (and, most of the time, the selected\n                        \\ system's galactic y-coordinate)\n\n.NOSTM\n\n SKIP 1                 \\ The number of stardust particles shown on screen,\n                        \\ which is 18 (#NOST) for normal space, and 3 for\n                        \\ witchspace\n\n PRINT \"WP workspace from \", ~WP, \"to \", ~P%-1, \"inclusive\"\n\n\\ ******************************************************************************\n\\\n\\ ELITE A FILE\n\\\n\\ Produces the binary file ELTA.bin that gets loaded by elite-bcfs.asm.\n\\\n\\ The main game code (ELITE A through G, plus the ship data) is loaded at &1128\n\\ and is moved down to &0F40 as part of elite-loader.asm.\n\\\n\\ ******************************************************************************\n\n ORG CODE%              \\ Set the assembly address to CODE%\n\n LOAD_A% = LOAD%\n\n\\ ******************************************************************************\n\\\n\\       Name: S%\n\\       Type: Workspace\n\\    Address: &0F40 to &0F50\n\\   Category: Workspaces\n\\    Summary: Vector addresses, compass colour and configuration settings\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Contains addresses that are used by the loader to set up vectors, the current\n\\ compass colour, and the game's configuration settings.\n\\\n\\ ******************************************************************************\n\n.S%\n\n EQUW TT170             \\ The entry point for the main game; once the main code\n                        \\ has been loaded, decrypted and moved to the right\n                        \\ place by elite-loader.asm, the game is started by a\n                        \\ JMP (S%) instruction, which jumps to the main entry\n                        \\ point at TT170 via this location\n\n EQUW TT26              \\ WRCHV is set to the address in these two bytes by\n                        \\ elite-loader.asm, so WRCHV points to TT26\n\n EQUW IRQ1              \\ IRQ1V is set to the address in these two bytes by\n                        \\ elite-loader.asm, so IRQ1V points to IRQ1\n\n EQUW BR1               \\ BRKV is set to the address in these two bytes by\n                        \\ elite-loader.asm, so BRKV points to BR1\n\n.COMC\n\n SKIP 1                 \\ The colour of the dot on the compass\n                        \\\n                        \\   * &F0 = the object in the compass is in front of us,\n                        \\     so the dot is yellow/white\n                        \\\n                        \\   * &FF = the object in the compass is behind us, so\n                        \\     the dot is green/cyan\n\n.DNOIZ\n\n SKIP 1                 \\ Sound on/off configuration setting\n                        \\\n                        \\   * 0 = sound is on (default)\n                        \\\n                        \\   * Non-zero = sound is off\n                        \\\n                        \\ Toggled by pressing \"S\" when paused, see the DK4\n                        \\ routine for details\n\n.DAMP\n\n SKIP 1                 \\ Keyboard damping configuration setting\n                        \\\n                        \\   * 0 = damping is enabled (default)\n                        \\\n                        \\   * &FF = damping is disabled\n                        \\\n                        \\ Toggled by pressing CAPS LOCK when paused, see the\n                        \\ DKS3 routine for details\n\n.DJD\n\n SKIP 1                 \\ Keyboard auto-recentre configuration setting\n                        \\\n                        \\   * 0 = auto-recentre is enabled (default)\n                        \\\n                        \\   * &FF = auto-recentre is disabled\n                        \\\n                        \\ Toggled by pressing \"A\" when paused, see the DKS3\n                        \\ routine for details\n\n.PATG\n\n SKIP 1                 \\ Configuration setting to show the author names on the\n                        \\ start-up screen and enable manual hyperspace mis-jumps\n                        \\\n                        \\   * 0 = no author names or manual mis-jumps (default)\n                        \\\n                        \\   * &FF = show author names and allow manual mis-jumps\n                        \\\n                        \\ Toggled by pressing \"X\" when paused, see the DKS3\n                        \\ routine for details\n                        \\\n                        \\ This needs to be turned on for manual mis-jumps to be\n                        \\ possible. To do a manual mis-jump, first toggle the\n                        \\ author display by pausing the game and pressing \"X\",\n                        \\ and during the next hyperspace, hold down CTRL to\n                        \\ force a mis-jump. See routine ee5 for the \"AND PATG\"\n                        \\ instruction that implements this logic\n\n.FLH\n\n SKIP 1                 \\ Flashing console bars configuration setting\n                        \\\n                        \\   * 0 = static bars (default)\n                        \\\n                        \\   * &FF = flashing bars\n                        \\\n                        \\ Toggled by pressing \"F\" when paused, see the DKS3\n                        \\ routine for details\n\n.JSTGY\n\n SKIP 1                 \\ Reverse joystick Y-channel configuration setting\n                        \\\n                        \\   * 0 = standard Y-channel (default)\n                        \\\n                        \\   * &FF = reversed Y-channel\n                        \\\n                        \\ Toggled by pressing \"Y\" when paused, see the DKS3\n                        \\ routine for details\n\n.JSTE\n\n SKIP 1                 \\ Reverse both joystick channels configuration setting\n                        \\\n                        \\   * 0 = standard channels (default)\n                        \\\n                        \\   * &FF = reversed channels\n                        \\\n                        \\ Toggled by pressing \"J\" when paused, see the DKS3\n                        \\ routine for details\n\n.JSTK\n\n SKIP 1                 \\ Keyboard or joystick configuration setting\n                        \\\n                        \\   * 0 = keyboard (default)\n                        \\\n                        \\   * &FF = joystick\n                        \\\n                        \\ Toggled by pressing \"K\" when paused, see the DKS3\n                        \\ routine for details\n\n PRINT \"S% workspace from \", ~S%, \"to \", ~P%-1, \"inclusive\"\n\n\\ ******************************************************************************\n\\\n\\       Name: Main flight loop (Part 1 of 16)\n\\       Type: Subroutine\n\\   Category: Main loop\n\\    Summary: Seed the random number generator\n\\  Deep dive: Program flow of the main game loop\n\\             Generating random numbers\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The main flight loop covers most of the flight-specific aspects of Elite. This\n\\ section covers the following:\n\\\n\\   * Seed the random number generator\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   M%                  The entry point for the main flight loop\n\\\n\\ ******************************************************************************\n\n.M%\n\n LDA K%                 \\ We want to seed the random number generator with a\n                        \\ pretty random number, so fetch the contents of K%,\n                        \\ which is the x_lo coordinate of the planet. This value\n                        \\ will be fairly unpredictable, so it's a pretty good\n                        \\ candidate\n\n STA RAND               \\ Store the seed in the first byte of the four-byte\n                        \\ random number seed that's stored in RAND\n\n\\ ******************************************************************************\n\\\n\\       Name: Main flight loop (Part 2 of 16)\n\\       Type: Subroutine\n\\   Category: Main loop\n\\    Summary: Calculate the alpha and beta angles from the current pitch and\n\\             roll of our ship\n\\  Deep dive: Program flow of the main game loop\n\\             Pitching and rolling\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The main flight loop covers most of the flight-specific aspects of Elite. This\n\\ section covers the following:\n\\\n\\   * Calculate the alpha and beta angles from the current pitch and roll\n\\\n\\ Here we take the current rate of pitch and roll, as set by the joystick or\n\\ keyboard, and convert them into alpha and beta angles that we can use in the\n\\ matrix functions to rotate space around our ship. The alpha angle covers\n\\ roll, while the beta angle covers pitch (there is no yaw in this version of\n\\ Elite). The angles are in radians, which allows us to use the small angle\n\\ approximation when moving objects in the sky (see the MVEIT routine for more\n\\ on this). Also, the signs of the two angles are stored separately, in both\n\\ the sign and the flipped sign, as this makes calculations easier.\n\\\n\\ ******************************************************************************\n\n LDX JSTX               \\ Set X to the current rate of roll in JSTX\n\n JSR cntr               \\ Apply keyboard damping twice (if enabled) so the roll\n JSR cntr               \\ rate in X creeps towards the centre by 2\n\n                        \\ The roll rate in JSTX increases if we press \">\" (and\n                        \\ the RL indicator on the dashboard goes to the right)\n                        \\\n                        \\ This rolls our ship to the right (clockwise), but we\n                        \\ actually implement this by rolling everything else\n                        \\ to the left (anti-clockwise), so a positive roll rate\n                        \\ in JSTX translates to a negative roll angle alpha\n\n TXA                    \\ Set A and Y to the roll rate but with the sign bit\n EOR #%10000000         \\ flipped (i.e. set them to the sign we want for alpha)\n TAY\n\n AND #%10000000         \\ Extract the flipped sign of the roll rate and store\n STA ALP2               \\ in ALP2 (so ALP2 contains the sign of the roll angle\n                        \\ alpha)\n\n STX JSTX               \\ Update JSTX with the damped value that's still in X\n\n EOR #%10000000         \\ Extract the correct sign of the roll rate and store\n STA ALP2+1             \\ in ALP2+1 (so ALP2+1 contains the flipped sign of the\n                        \\ roll angle alpha)\n\n TYA                    \\ Set A to the roll rate but with the sign bit flipped\n\n BPL P%+7               \\ If the value of A is positive, skip the following\n                        \\ three instructions\n\n EOR #%11111111         \\ A is negative, so change the sign of A using two's\n CLC                    \\ complement so that A is now positive and contains\n ADC #1                 \\ the absolute value of the roll rate, i.e. |JSTX|\n\n LSR A                  \\ Divide the (positive) roll rate in A by 4\n LSR A\n\n CMP #8                 \\ If A >= 8, skip the following two instructions\n BCS P%+4\n\n LSR A                  \\ A < 8, so halve A again\n\n CLC                    \\ This instruction has no effect, as we only get here\n                        \\ if the C flag is clear (if it is set, we skip this\n                        \\ instruction)\n\n STA ALP1               \\ Store A in ALP1, so we now have:\n                        \\\n                        \\   ALP1 = |JSTX| / 8    if |JSTX| < 32\n                        \\\n                        \\   ALP1 = |JSTX| / 4    if |JSTX| >= 32\n                        \\\n                        \\ This means that at lower roll rates, the roll angle is\n                        \\ reduced closer to zero than at higher roll rates,\n                        \\ which gives us finer control over the ship's roll at\n                        \\ lower roll rates\n                        \\\n                        \\ Because JSTX is in the range -127 to +127, ALP1 is\n                        \\ in the range 0 to 31\n\n ORA ALP2               \\ Store A in ALPHA, but with the sign set to ALP2 (so\n STA ALPHA              \\ ALPHA has a different sign to the actual roll rate)\n\n LDX JSTY               \\ Set X to the current rate of pitch in JSTY\n\n JSR cntr               \\ Apply keyboard damping so the pitch rate in X creeps\n                        \\ towards the centre by 1\n\n TXA                    \\ Set A and Y to the pitch rate but with the sign bit\n EOR #%10000000         \\ flipped\n TAY\n\n AND #%10000000         \\ Extract the flipped sign of the pitch rate into A\n\n STX JSTY               \\ Update JSTY with the damped value that's still in X\n\n STA BET2+1             \\ Store the flipped sign of the pitch rate in BET2+1\n\n EOR #%10000000         \\ Extract the correct sign of the pitch rate and store\n STA BET2               \\ it in BET2\n\n TYA                    \\ Set A to the pitch rate but with the sign bit flipped\n\n BPL P%+4               \\ If the value of A is positive, skip the following\n                        \\ instruction\n\n EOR #%11111111         \\ A is negative, so flip the bits\n\n ADC #4                 \\ Add 4 to the (positive) pitch rate, so the maximum\n                        \\ value is now up to 131 (rather than 127)\n\n LSR A                  \\ Divide the (positive) pitch rate in A by 16\n LSR A\n LSR A\n LSR A\n\n CMP #3                 \\ If A >= 3, skip the following instruction\n BCS P%+3\n\n LSR A                  \\ A < 3, so halve A again\n\n STA BET1               \\ Store A in BET1, so we now have:\n                        \\\n                        \\   BET1 = |JSTY| / 32    if |JSTY| < 48\n                        \\\n                        \\   BET1 = |JSTY| / 16    if |JSTY| >= 48\n                        \\\n                        \\ This means that at lower pitch rates, the pitch angle\n                        \\ is reduced closer to zero than at higher pitch rates,\n                        \\ which gives us finer control over the ship's pitch at\n                        \\ lower pitch rates\n                        \\\n                        \\ Because JSTY is in the range -131 to +131, BET1 is in\n                        \\ the range 0 to 8\n\n ORA BET2               \\ Store A in BETA, but with the sign set to BET2 (so\n STA BETA               \\ BETA has the same sign as the actual pitch rate)\n\n\\ ******************************************************************************\n\\\n\\       Name: Main flight loop (Part 3 of 16)\n\\       Type: Subroutine\n\\   Category: Main loop\n\\    Summary: Scan for flight keys and process the results\n\\  Deep dive: Program flow of the main game loop\n\\             The key logger\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The main flight loop covers most of the flight-specific aspects of Elite. This\n\\ section covers the following:\n\\\n\\   * Scan for flight keys and process the results\n\\\n\\ Flight keys are logged in the key logger at location KY1 onwards, with a\n\\ non-zero value in the relevant location indicating a key press.\n\\\n\\ The key presses that are processed are as follows:\n\\\n\\   * Space and \"?\" to speed up and slow down\n\\   * \"U\", \"T\" and \"M\" to disarm, arm and fire missiles\n\\   * TAB to fire an energy bomb\n\\   * ESCAPE to launch an escape pod\n\\   * \"J\" to initiate an in-system jump\n\\   * \"E\" to deploy E.C.M. anti-missile countermeasures\n\\   * \"C\" to use the docking computer\n\\   * \"A\" to fire lasers\n\\\n\\ ******************************************************************************\n\n LDA KY2                \\ If Space is being pressed, keep going, otherwise jump\n BEQ MA17               \\ down to MA17 to skip the following\n\n LDA DELTA              \\ The \"go faster\" key is being pressed, so first we\n CMP #40                \\ fetch the current speed from DELTA into A, and if\n BCS MA17               \\ A >= 40, we are already going at full pelt, so jump\n                        \\ down to MA17 to skip the following\n\n INC DELTA              \\ We can go a bit faster, so increment the speed in\n                        \\ location DELTA\n\n.MA17\n\n LDA KY1                \\ If \"?\" is being pressed, keep going, otherwise jump\n BEQ MA4                \\ down to MA4 to skip the following\n\n DEC DELTA              \\ The \"slow down\" key is being pressed, so we decrement\n                        \\ the current ship speed in DELTA\n\n BNE MA4                \\ If the speed is still greater than zero, jump to MA4\n\n INC DELTA              \\ Otherwise we just braked a little too hard, so bump\n                        \\ the speed back up to the minimum value of 1\n\n.MA4\n\n LDA KY15               \\ If \"U\" is being pressed and the number of missiles\n AND NOMSL              \\ in NOMSL is non-zero, keep going, otherwise jump down\n BEQ MA20               \\ to MA20 to skip the following\n\n LDY #&EE               \\ The \"disarm missiles\" key is being pressed, so call\n JSR ABORT              \\ ABORT to disarm the missile and update the missile\n                        \\ indicators on the dashboard to green/cyan (Y = &EE)\n\n LDA #40                \\ Call the NOISE routine with A = 40 to make a low,\n JSR NOISE              \\ long beep to indicate the missile is now disarmed\n\n.MA31\n\n LDA #0                 \\ Set MSAR to 0 to indicate that no missiles are\n STA MSAR               \\ currently armed\n\n.MA20\n\n LDA MSTG               \\ If MSTG is positive (i.e. it does not have bit 7 set),\n BPL MA25               \\ then it indicates we already have a missile locked on\n                        \\ a target (in which case MSTG contains the ship number\n                        \\ of the target), so jump to MA25 to skip targeting. Or\n                        \\ to put it another way, if MSTG = &FF, which means\n                        \\ there is no current target lock, keep going\n\n LDA KY14               \\ If \"T\" is being pressed, keep going, otherwise jump\n BEQ MA25               \\ down to MA25 to skip the following\n\n LDX NOMSL              \\ If the number of missiles in NOMSL is zero, jump down\n BEQ MA25               \\ to MA25 to skip the following\n\n STA MSAR               \\ The \"target missile\" key is being pressed and we have\n                        \\ at least one missile, so set MSAR = &FF to denote that\n                        \\ our missile is currently armed (we know A has the\n                        \\ value &FF, as we just loaded it from MSTG and checked\n                        \\ that it was negative)\n\n LDY #&E0               \\ Change the leftmost missile indicator to yellow/white\n JSR MSBAR              \\ on the missile bar (this call changes the leftmost\n                        \\ indicator because we set X to the number of missiles\n                        \\ in NOMSL above, and the indicators are numbered from\n                        \\ right to left, so X is the number of the leftmost\n                        \\ indicator)\n\n.MA25\n\n LDA KY16               \\ If \"M\" is being pressed, keep going, otherwise jump\n BEQ MA24               \\ down to MA24 to skip the following\n\n LDA MSTG               \\ If MSTG = &FF then there is no target lock, so jump to\n BMI MA64               \\ MA64 to skip the following (also skipping the checks\n                        \\ for TAB, ESCAPE, \"J\" and \"E\")\n\n JSR FRMIS              \\ The \"fire missile\" key is being pressed and we have\n                        \\ a missile lock, so call the FRMIS routine to fire\n                        \\ the missile\n\n.MA24\n\n LDA KY12               \\ If TAB is being pressed, keep going, otherwise jump\n BEQ MA76               \\ down to MA76 to skip the following\n\n ASL BOMB               \\ The \"energy bomb\" key is being pressed, so double\n                        \\ the value in BOMB. If we have an energy bomb fitted,\n                        \\ BOMB will contain &7F (%01111111) before this shift\n                        \\ and will contain &FE (%11111110) after the shift; if\n                        \\ we don't have an energy bomb fitted, BOMB will still\n                        \\ contain 0. The bomb explosion is dealt with in the\n                        \\ MAL1 routine below - this just registers the fact that\n                        \\ we've set the bomb ticking\n\n.MA76\n\n LDA KY13               \\ If ESCAPE is being pressed and we have an escape pod\n AND ESCP               \\ fitted, keep going, otherwise skip the next\n BEQ P%+5               \\ instruction\n\n JMP ESCAPE             \\ The button is being pressed to launch an escape pod\n                        \\ and we have an escape pod fitted, so jump to ESCAPE to\n                        \\ launch it, and exit the main flight loop using a tail\n                        \\ call\n\n LDA KY18               \\ If \"J\" is being pressed, keep going, otherwise skip\n BEQ P%+5               \\ the next instruction\n\n JSR WARP               \\ Call the WARP routine to do an in-system jump\n\n LDA KY17               \\ If \"E\" is being pressed and we have an E.C.M. fitted,\n AND ECM                \\ keep going, otherwise jump down to MA64 to skip the\n BEQ MA64               \\ following\n\n LDA ECMA               \\ If ECMA is non-zero, that means an E.C.M. is already\n BNE MA64               \\ operating and is counting down (this can be either\n                        \\ our E.C.M. or an opponent's), so jump down to MA64 to\n                        \\ skip the following (as we can't have two E.C.M.\n                        \\ systems operating at the same time)\n\n DEC ECMP               \\ The E.C.M. button is being pressed and nobody else\n                        \\ is operating their E.C.M., so decrease the value of\n                        \\ ECMP to make it non-zero, to denote that our E.C.M.\n                        \\ is now on\n\n JSR ECBLB2             \\ Call ECBLB2 to light up the E.C.M. indicator bulb on\n                        \\ the dashboard, set the E.C.M. countdown timer to 32,\n                        \\ and start making the E.C.M. sound\n\n.MA64\n\n LDA KY19               \\ If \"C\" is being pressed, and we have a docking\n AND DKCMP              \\ computer fitted, and we are inside the space station's\n AND SSPR               \\ safe zone, keep going, otherwise jump down to MA68 to\n BEQ MA68               \\ skip the following\n\n LDA K%+NI%+32          \\ Fetch the AI counter (byte #32) of the second ship\n BMI MA68               \\ from the ship data workspace at K%, which is reserved\n                        \\ for the sun or the space station (in this case it's\n                        \\ the latter as we are in the safe zone). If byte #32 is\n                        \\ negative, meaning the station is hostile, then jump\n                        \\ down to MA68 to skip the following (so we can't use\n                        \\ the docking computer to dock at a station that has\n                        \\ turned against us)\n\n JMP GOIN               \\ The Docking Computer button has been pressed and\n                        \\ we are allowed to dock at the station, so jump to\n                        \\ GOIN to dock (or \"go in\"), and exit the main flight\n                        \\ loop using a tail call\n\n.MA68\n\n LDA #0                 \\ Set LAS = 0, to switch the laser off while we do the\n STA LAS                \\ following logic\n\n STA DELT4              \\ Take the 16-bit value (DELTA 0) - i.e. a two-byte\n LDA DELTA              \\ number with DELTA as the high byte and 0 as the low\n LSR A                  \\ byte - and divide it by 4, storing the 16-bit result\n ROR DELT4              \\ in DELT4(1 0). This has the effect of storing the\n LSR A                  \\ current speed * 64 in the 16-bit location DELT4(1 0)\n ROR DELT4\n STA DELT4+1\n\n LDA LASCT              \\ If LASCT is zero, keep going, otherwise the laser is\n BNE MA3                \\ a pulse laser that is between pulses, so jump down to\n                        \\ MA3 to skip the following\n\n LDA KY7                \\ If \"A\" is being pressed, keep going, otherwise jump\n BEQ MA3                \\ down to MA3 to skip the following\n\n LDA GNTMP              \\ If the laser temperature >= 242 then the laser has\n CMP #242               \\ overheated, so jump down to MA3 to skip the following\n BCS MA3\n\n LDX VIEW               \\ If the current space view has a laser fitted (i.e. the\n LDA LASER,X            \\ laser power for this view is greater than zero), then\n BEQ MA3                \\ keep going, otherwise jump down to MA3 to skip the\n                        \\ following\n\n                        \\ If we get here, then the \"fire\" button is being\n                        \\ pressed, our laser hasn't overheated and isn't already\n                        \\ being fired, and we actually have a laser fitted to\n                        \\ the current space view, so it's time to hit me with\n                        \\ those laser beams\n\n PHA                    \\ Store the current view's laser power on the stack\n\n AND #%01111111         \\ Set LAS and LAS2 to bits 0-6 of the laser power\n STA LAS\n STA LAS2\n\n LDA #0                 \\ Call the NOISE routine with A = 0 to make the sound\n JSR NOISE              \\ of our laser firing\n\n JSR LASLI              \\ Call LASLI to draw the laser lines\n\n PLA                    \\ Restore the current view's laser power into A\n\n BPL ma1                \\ If the laser power has bit 7 set, then it's an \"always\n                        \\ on\" laser rather than a pulsing laser, so keep going,\n                        \\ otherwise jump down to ma1 to skip the following\n                        \\ instruction\n\n LDA #0                 \\ This is an \"always on\" laser (i.e. a beam laser,\n                        \\ as this version of Elite doesn't have military\n                        \\ lasers), so set A = 0, which will be stored in LASCT\n                        \\ to denote that this is not a pulsing laser\n\n.ma1\n\n AND #%11111010         \\ LASCT will be set to 0 for beam lasers, and to the\n STA LASCT              \\ laser power AND %11111010 for pulse lasers, which\n                        \\ comes to 10 (as pulse lasers have a power of 15). See\n                        \\ MA23 in part 16 for more on laser pulsing and LASCT\n\n\\ ******************************************************************************\n\\\n\\       Name: Main flight loop (Part 4 of 16)\n\\       Type: Subroutine\n\\   Category: Main loop\n\\    Summary: For each nearby ship: Copy the ship's data block from K% to the\n\\             zero-page workspace at INWK\n\\  Deep dive: Program flow of the main game loop\n\\             Ship data blocks\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The main flight loop covers most of the flight-specific aspects of Elite. This\n\\ section covers the following:\n\\\n\\   * Start looping through all the ships in the local bubble, and for each\n\\     one:\n\\\n\\     * Copy the ship's data block from K% to INWK\n\\\n\\     * Set XX0 to point to the ship's blueprint (if this is a ship)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   MAL1                Marks the beginning of the ship analysis loop, so we\n\\                       can jump back here from part 12 of the main flight loop\n\\                       to work our way through each ship in the local bubble.\n\\                       We also jump back here when a ship is removed from the\n\\                       bubble, so we can continue processing from the next ship\n\\\n\\ ******************************************************************************\n\n.MA3\n\n LDX #0                 \\ We're about to work our way through all the ships in\n                        \\ our local bubble of universe, so set a counter in X,\n                        \\ starting from 0, to refer to each ship slot in turn\n\n.MAL1\n\n STX XSAV               \\ Store the current slot number in XSAV\n\n LDA FRIN,X             \\ Fetch the contents of this slot into A. If it is 0\n BNE P%+5               \\ then this slot is empty and we have no more ships to\n JMP MA18               \\ process, so jump to MA18 below, otherwise A contains\n                        \\ the type of ship that's in this slot, so skip over the\n                        \\ JMP MA18 instruction and keep going\n\n STA TYPE               \\ Store the ship type in TYPE\n\n JSR GINF               \\ Call GINF to fetch the address of the ship data block\n                        \\ for the ship in slot X and store it in INF. The data\n                        \\ block is in the K% workspace, which is where all the\n                        \\ ship data blocks are stored\n\n                        \\ Next we want to copy the ship data block from INF to\n                        \\ the zero-page workspace at INWK, so we can process it\n                        \\ more efficiently\n\n LDY #NI%-1             \\ There are NI% bytes in each ship data block (and in\n                        \\ the INWK workspace, so we set a counter in Y so we can\n                        \\ loop through them\n\n.MAL2\n\n LDA (INF),Y            \\ Load the Y-th byte of INF and store it in the Y-th\n STA INWK,Y             \\ byte of INWK\n\n DEY                    \\ Decrement the loop counter\n\n BPL MAL2               \\ Loop back for the next byte until we have copied the\n                        \\ last byte from INF to INWK\n\n LDA TYPE               \\ If the ship type is negative then this indicates a\n BMI MA21               \\ planet or sun, so jump down to MA21, as the next bit\n                        \\ sets up a pointer to the ship blueprint, and then\n                        \\ checks for energy bomb damage, and neither of these\n                        \\ apply to planets and suns\n\n ASL A                  \\ Set Y = ship type * 2\n TAY\n\n LDA XX21-2,Y           \\ The ship blueprints at XX21 start with a lookup\n STA XX0                \\ table that points to the individual ship blueprints,\n                        \\ so this fetches the low byte of this particular ship\n                        \\ type's blueprint and stores it in XX0\n\n LDA XX21-1,Y           \\ Fetch the high byte of this particular ship type's\n STA XX0+1              \\ blueprint and store it in XX0+1\n\n\\ ******************************************************************************\n\\\n\\       Name: Main flight loop (Part 5 of 16)\n\\       Type: Subroutine\n\\   Category: Main loop\n\\    Summary: For each nearby ship: If an energy bomb has been set off,\n\\             potentially kill this ship\n\\  Deep dive: Program flow of the main game loop\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The main flight loop covers most of the flight-specific aspects of Elite. This\n\\ section covers the following:\n\\\n\\   * Continue looping through all the ships in the local bubble, and for each\n\\     one:\n\\\n\\     * If an energy bomb has been set off and this ship can be killed, kill it\n\\       and increase the kill tally\n\\\n\\ ******************************************************************************\n\n LDA BOMB               \\ If we set off our energy bomb (see MA24 above), then\n BPL MA21               \\ BOMB is now negative, so this skips to MA21 if our\n                        \\ energy bomb is not going off\n\n CPY #2*SST             \\ If the ship in Y is the space station, jump to BA21\n BEQ MA21               \\ as energy bombs are useless against space stations\n\n LDA INWK+31            \\ If the ship we are checking has bit 5 set in its ship\n AND #%00100000         \\ byte #31, then it is already exploding, so jump to\n BNE MA21               \\ BA21 as ships can't explode more than once\n\n LDA INWK+31            \\ The energy bomb is killing this ship, so set bit 7 of\n ORA #%10000000         \\ the ship byte #31 to indicate that it has now been\n STA INWK+31            \\ killed\n\n JSR EXNO2              \\ Call EXNO2 to process the fact that we have killed a\n                        \\ ship (so increase the kill tally, make an explosion\n                        \\ sound and possibly display \"RIGHT ON COMMANDER!\")\n\n\\ ******************************************************************************\n\\\n\\       Name: Main flight loop (Part 6 of 16)\n\\       Type: Subroutine\n\\   Category: Main loop\n\\    Summary: For each nearby ship: Move the ship in space and copy the updated\n\\             INWK data block back to K%\n\\  Deep dive: Program flow of the main game loop\n\\             Program flow of the ship-moving routine\n\\             Ship data blocks\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The main flight loop covers most of the flight-specific aspects of Elite. This\n\\ section covers the following:\n\\\n\\   * Continue looping through all the ships in the local bubble, and for each\n\\     one:\n\\\n\\     * Move the ship in space\n\\\n\\     * Copy the updated ship's data block from INWK back to K%\n\\\n\\ ******************************************************************************\n\n.MA21\n\n JSR MVEIT              \\ Call MVEIT to move the ship we are processing in space\n\n                        \\ Now that we are done processing this ship, we need to\n                        \\ copy the ship data back from INWK to the correct place\n                        \\ in the K% workspace. We already set INF in part 4 to\n                        \\ point to the ship's data block in K%, so we can simply\n                        \\ do the reverse of the copy we did before, this time\n                        \\ copying from INWK to INF\n\n LDY #NI%-1             \\ Set a counter in Y so we can loop through the NI%\n                        \\ bytes in the ship data block\n\n.MAL3\n\n LDA INWK,Y             \\ Load the Y-th byte of INWK and store it in the Y-th\n STA (INF),Y            \\ byte of INF\n\n DEY                    \\ Decrement the loop counter\n\n BPL MAL3               \\ Loop back for the next byte, until we have copied the\n                        \\ last byte from INWK back to INF\n\n\\ ******************************************************************************\n\\\n\\       Name: Main flight loop (Part 7 of 16)\n\\       Type: Subroutine\n\\   Category: Main loop\n\\    Summary: For each nearby ship: Check whether we are docking, scooping or\n\\             colliding with it\n\\  Deep dive: Program flow of the main game loop\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The main flight loop covers most of the flight-specific aspects of Elite. This\n\\ section covers the following:\n\\\n\\   * Continue looping through all the ships in the local bubble, and for each\n\\     one:\n\\\n\\     * Check how close we are to this ship and work out if we are docking,\n\\       scooping or colliding with it\n\\\n\\ ******************************************************************************\n\n LDA INWK+31            \\ Fetch the status of this ship from bits 5 (is ship\n AND #%10100000         \\ exploding?) and bit 7 (has ship been killed?) from\n                        \\ ship byte #31 into A\n\n JSR MAS4               \\ Or this value with x_hi, y_hi and z_hi\n\n BNE MA65               \\ If this value is non-zero, then either the ship is\n                        \\ far away (i.e. has a non-zero high byte in at least\n                        \\ one of the three axes), or it is already exploding,\n                        \\ or has been flagged as being killed - in which case\n                        \\ jump to MA65 to skip the following, as we can't dock\n                        \\ scoop or collide with it\n\n LDA INWK               \\ Set A = (x_lo OR y_lo OR z_lo), and if bit 7 of the\n ORA INWK+3             \\ result is set, the ship is still a fair distance\n ORA INWK+6             \\ away (further than 127 in at least one axis), so jump\n BMI MA65               \\ to MA65 to skip the following, as it's too far away to\n                        \\ dock, scoop or collide with\n\n LDX TYPE               \\ If the current ship type is negative then it's either\n BMI MA65               \\ a planet or a sun, so jump down to MA65 to skip the\n                        \\ following, as we can't dock with it or scoop it\n\n CPX #SST               \\ If this ship is the space station, jump to ISDK to\n BEQ ISDK               \\ check whether we are docking with it\n\n AND #%11000000         \\ If bit 6 of (x_lo OR y_lo OR z_lo) is set, then the\n BNE MA65               \\ ship is still a reasonable distance away (further than\n                        \\ 63 in at least one axis), so jump to MA65 to skip the\n                        \\ following, as it's too far away to dock, scoop or\n                        \\ collide with\n\n CPX #MSL               \\ If this ship is a missile, jump down to MA65 to skip\n BEQ MA65               \\ the following, as we can't scoop or dock with a\n                        \\ missile, and it has its own dedicated collision\n                        \\ checks in the TACTICS routine\n\n CPX #OIL               \\ If ship type >= OIL (i.e. it's a cargo canister,\n BCS P%+5               \\ Thargon or escape pod), skip the JMP instruction and\n JMP MA58               \\ continue on, otherwise jump to MA58 to process a\n                        \\ potential collision\n\n LDA BST                \\ If we have fuel scoops fitted then BST will be &FF,\n                        \\ otherwise it will be 0\n\n AND INWK+5             \\ Ship byte #5 contains the y_sign of this ship, so a\n                        \\ negative value here means the canister is below us,\n                        \\ which means the result of the AND will be negative if\n                        \\ the canister is below us and we have a fuel scoop\n                        \\ fitted\n\n BPL MA58               \\ If the result is positive, then we either have no\n                        \\ scoop or the canister is above us, and in both cases\n                        \\ this means we can't scoop the item, so jump to MA58\n                        \\ to process a collision\n\n\\ ******************************************************************************\n\\\n\\       Name: Main flight loop (Part 8 of 16)\n\\       Type: Subroutine\n\\   Category: Main loop\n\\    Summary: For each nearby ship: Process us potentially scooping this item\n\\  Deep dive: Program flow of the main game loop\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The main flight loop covers most of the flight-specific aspects of Elite. This\n\\ section covers the following:\n\\\n\\   * Continue looping through all the ships in the local bubble, and for each\n\\     one:\n\\\n\\     * Process us potentially scooping this item\n\\\n\\ ******************************************************************************\n\n LDA #3                 \\ Set A to 3 to denote we may be scooping an escape pod\n\n CPX #TGL               \\ If ship type < Thargon, i.e. it's a canister, jump\n BCC oily               \\ to oily to randomly decide the canister's contents\n\n BNE slvy2              \\ If ship type <> Thargon, i.e. it's an escape pod,\n                        \\ jump to slvy2 with A set to 3, so we scoop up the\n                        \\ escape pod as slaves\n\n LDA #16                \\ Otherwise this is a Thargon, so jump to slvy2 with\n BNE slvy2              \\ A set to 16, so we scoop up the Thargon as alien items\n                        \\ (this BNE is effectively a JMP as A will never be\n                        \\ zero)\n\n.oily\n\n JSR DORND              \\ Set A and X to random numbers and reduce A to a\n AND #7                 \\ random number in the range 0-7\n\n.slvy2\n\n                        \\ By the time we get here, we are scooping, and A\n                        \\ contains the type of item we are scooping (a random\n                        \\ number 0-7 if we are scooping a cargo canister, 3 if\n                        \\ we are scooping an escape pod, or 16 if we are\n                        \\ scooping a Thargon). These numbers correspond to the\n                        \\ relevant market items (see QQ23 for a list), so a\n                        \\ cargo canister can contain anything from food to\n                        \\ computers, while escape pods contain slaves, and\n                        \\ Thargons become alien items when scooped\n\n STA QQ29               \\ Call tnpr with the scooped cargo type stored in QQ29\n LDA #1                 \\ and A set to 1, to work out whether we have room in\n JSR tnpr               \\ the hold for the scooped item (A is preserved by this\n                        \\ call, and the C flag contains the result)\n\n LDY #78                \\ This instruction has no effect, so presumably it used\n                        \\ to do something, but didn't get removed\n\n BCS MA59               \\ If the C flag is set then we have no room in the hold\n                        \\ for the scooped item, so jump down to MA59 make a\n                        \\ sound to indicate failure, before destroying the\n                        \\ canister\n\n LDY QQ29               \\ Scooping was successful, so set Y to the type of\n                        \\ item we just scooped, which we stored in QQ29 above\n\n ADC QQ20,Y             \\ Add A (which we set to 1 above) to the number of items\n STA QQ20,Y             \\ of type Y in the cargo hold, as we just successfully\n                        \\ scooped one canister of type Y\n\n TYA                    \\ Print recursive token 48 + Y as an in-flight token,\n ADC #208               \\ which will be in the range 48 (\"FOOD\") to 64 (\"ALIEN\n JSR MESS               \\ ITEMS\"), so this prints the scooped item's name\n\n JMP MA60               \\ We are done scooping, so jump down to MA60 to set the\n                        \\ kill flag on the canister, as it no longer exists in\n                        \\ the local bubble\n\n.MA65\n\n JMP MA26               \\ If we get here, then the ship we are processing was\n                        \\ too far away to be scooped, docked or collided with,\n                        \\ so jump to MA26 to skip over the collision routines\n                        \\ and move on to missile targeting\n\n\\ ******************************************************************************\n\\\n\\       Name: Main flight loop (Part 9 of 16)\n\\       Type: Subroutine\n\\   Category: Main loop\n\\    Summary: For each nearby ship: If it is a space station, check whether we\n\\             are successfully docking with it\n\\  Deep dive: Program flow of the main game loop\n\\             Docking checks\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The main flight loop covers most of the flight-specific aspects of Elite. This\n\\ section covers the following:\n\\\n\\   * Process docking with a space station\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   GOIN                We jump here from part 3 of the main flight loop if the\n\\                       docking computer is activated by pressing \"C\"\n\\\n\\ ******************************************************************************\n\n.ISDK\n\n LDA K%+NI%+32          \\ 1. Fetch the AI counter (byte #32) of the second ship\n BMI MA62               \\ in the ship data workspace at K%, which is reserved\n                        \\ for the sun or the space station (in this case it's\n                        \\ the latter), and if it's negative, i.e. bit 7 is set,\n                        \\ meaning the station is hostile, jump down to MA62 to\n                        \\ fail docking (so trying to dock at a station that we\n                        \\ have annoyed does not end well)\n\n LDA INWK+14            \\ 2. If nosev_z_hi < 214, jump down to MA62 to fail\n CMP #214               \\ docking, as the angle of approach is greater than 26\n BCC MA62               \\ degrees\n\n JSR SPS4               \\ Call SPS4 to get the vector to the space station\n                        \\ into XX15\n\n LDA XX15+2             \\ 3. Check the sign of the z-axis (bit 7 of XX15+2) and\n BMI MA62               \\ if it is negative, we are facing away from the\n                        \\ station, so jump to MA62 to fail docking\n\n CMP #89                \\ 4. If z-axis < 89, jump to MA62 to fail docking, as\n BCC MA62               \\ we are not in the 22.0 degree safe cone of approach\n\n LDA INWK+16            \\ 5. If |roofv_x_hi| < 80, jump to MA62 to fail docking,\n AND #%01111111         \\ as the slot is more than 36.6 degrees from horizontal\n CMP #80\n BCC MA62\n\n.GOIN\n\n                        \\ If we arrive here, either the docking computer has\n                        \\ been activated, or we just docked successfully\n\n LDA #0                 \\ Set the on-screen hyperspace counter to 0\n STA QQ22+1\n\n LDA #8                 \\ This instruction has no effect, so presumably it used\n                        \\ to do something, and didn't get removed\n\n JSR LAUN               \\ Show the space station launch tunnel\n\n JSR RES4               \\ Reset the shields and energy banks, stardust and INWK\n                        \\ workspace\n\n JMP BAY                \\ Go to the docking bay (i.e. show the Status Mode\n                        \\ screen)\n\n.MA62\n\n                        \\ If we arrive here, docking has just failed\n\n LDA DELTA              \\ If the ship's speed is < 5, jump to MA67 to register\n CMP #5                 \\ some damage, but not a huge amount\n BCC MA67\n\n JMP DEATH              \\ Otherwise we have just crashed into the station, so\n                        \\ process our death\n\n\\ ******************************************************************************\n\\\n\\       Name: Main flight loop (Part 10 of 16)\n\\       Type: Subroutine\n\\   Category: Main loop\n\\    Summary: For each nearby ship: Remove if scooped, or process collisions\n\\  Deep dive: Program flow of the main game loop\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The main flight loop covers most of the flight-specific aspects of Elite. This\n\\ section covers the following:\n\\\n\\   * Continue looping through all the ships in the local bubble, and for each\n\\     one:\n\\\n\\     * Remove scooped item after both successful and failed scooping attempts\n\\\n\\     * Process collisions\n\\\n\\ ******************************************************************************\n\n.MA59\n\n                        \\ If we get here then scooping failed\n\n JSR EXNO3              \\ Make the sound of the cargo canister being destroyed\n                        \\ and fall through into MA60 to remove the canister\n                        \\ from our local bubble\n\n.MA60\n\n                        \\ If we get here then scooping was successful\n\n ASL INWK+31            \\ Set bit 7 of the scooped or destroyed item, to denote\n SEC                    \\ that it has been killed and should be removed from\n ROR INWK+31            \\ the local bubble\n\n.MA61\n\n BNE MA26               \\ Jump to MA26 to skip over the collision routines and\n                        \\ to move on to missile targeting (this BNE is\n                        \\ effectively a JMP as A will never be zero)\n\n.MA67\n\n                        \\ If we get here then we have collided with something,\n                        \\ but not fatally\n\n LDA #1                 \\ Set the speed in DELTA to 1 (i.e. a sudden stop)\n STA DELTA\n\n LDA #5                 \\ Set the amount of damage in A to 5 (a small dent) and\n BNE MA63               \\ jump down to MA63 to process the damage (this BNE is\n                        \\ effectively a JMP as A will never be zero)\n\n.MA58\n\n                        \\ If we get here, we have collided with something in a\n                        \\ potentially fatal way\n\n ASL INWK+31            \\ Set bit 7 of the ship we just collided with, to\n SEC                    \\ denote that it has been killed and should be removed\n ROR INWK+31            \\ from the local bubble\n\n LDA INWK+35            \\ Load A with the energy level of the ship we just hit\n\n SEC                    \\ Set the amount of damage in A to 128 + A / 2, so\n ROR A                  \\ this is quite a big dent, and colliding with higher\n                        \\ energy ships will cause more damage\n\n.MA63\n\n JSR OOPS               \\ The amount of damage is in A, so call OOPS to reduce\n                        \\ our shields, and if the shields are gone, there's a\n                        \\ chance of cargo loss or even death\n\n JSR EXNO3              \\ Make the sound of colliding with the other ship and\n                        \\ fall through into MA26 to try targeting a missile\n\n\\ ******************************************************************************\n\\\n\\       Name: Main flight loop (Part 11 of 16)\n\\       Type: Subroutine\n\\   Category: Main loop\n\\    Summary: For each nearby ship: Process missile lock and firing our laser\n\\  Deep dive: Program flow of the main game loop\n\\             Flipping axes between space views\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The main flight loop covers most of the flight-specific aspects of Elite. This\n\\ section covers the following:\n\\\n\\   * Continue looping through all the ships in the local bubble, and for each\n\\     one:\n\\\n\\     * If this is not the front space view, flip the axes of the ship's\n\\        coordinates in INWK\n\\\n\\     * Process missile lock\n\\\n\\     * Process our laser firing\n\\\n\\ ******************************************************************************\n\n.MA26\n\n LDA QQ11               \\ If this is not a space view, jump to MA15 to skip\n BNE MA15               \\ missile and laser locking\n\n JSR PLUT               \\ Call PLUT to update the geometric axes in INWK to\n                        \\ match the view (front, rear, left, right)\n\n JSR HITCH              \\ Call HITCH to see if this ship is in the crosshairs,\n BCC MA8                \\ in which case the C flag will be set (so if there is\n                        \\ no missile or laser lock, we jump to MA8 to skip the\n                        \\ following)\n\n LDA MSAR               \\ We have missile lock, so check whether the leftmost\n BEQ MA47               \\ missile is currently armed, and if not, jump to MA47\n                        \\ to process laser fire, as we can't lock an unarmed\n                        \\ missile\n\n JSR BEEP               \\ We have missile lock and an armed missile, so call\n                        \\ the BEEP subroutine to make a short, high beep\n\n LDX XSAV               \\ Call ABORT2 to store the details of this missile\n LDY #&0E               \\ lock, with the targeted ship's slot number in X\n JSR ABORT2             \\ (which we stored in XSAV at the start of this ship's\n                        \\ loop at MAL1), and set the colour of the missile\n                        \\ indicator to the colour in Y (red = &0E)\n\n.MA47\n\n                        \\ If we get here then the ship is in our sights, but\n                        \\ we didn't lock a missile, so let's see if we're\n                        \\ firing the laser\n\n LDA LAS                \\ If we are firing the laser then LAS will contain the\n BEQ MA8                \\ laser power (which we set in MA68 above), so if this\n                        \\ is zero, jump down to MA8 to skip the following\n\n LDX #15                \\ We are firing our laser and the ship in INWK is in\n JSR EXNO               \\ the crosshairs, so call EXNO to make the sound of\n                        \\ us making a laser strike on another ship\n\n LDA INWK+35            \\ Fetch the hit ship's energy from byte #35 and subtract\n SEC                    \\ our current laser power, and if the result is greater\n SBC LAS                \\ than zero, the other ship has survived the hit, so\n BCS MA14               \\ jump down to MA14 to make it angry\n\n LDA TYPE               \\ Did we just hit the space station? If so, jump to\n CMP #SST               \\ MA14+2 to make the station hostile, skipping the\n BEQ MA14+2             \\ following as we can't destroy a space station\n\n LDA INWK+31            \\ Set bit 7 of the enemy ship's byte #31, to indicate\n ORA #%10000000         \\ that it has been killed\n STA INWK+31\n\n BCS MA8                \\ If the enemy ship type is >= SST (i.e. missile,\n                        \\ asteroid, canister, Thargon or escape pod) then\n                        \\ jump down to MA8\n\n JSR DORND              \\ Fetch a random number, and jump to oh if it is\n BPL oh                 \\ positive (50% chance)\n\n LDY #0                 \\ Fetch the first byte of the hit ship's blueprint,\n AND (XX0),Y            \\ which determines the maximum number of bits of\n                        \\ debris shown when the ship is destroyed, and AND\n                        \\ with the random number we just fetched\n\n STA CNT                \\ Store the result in CNT, so CNT contains a random\n                        \\ number between 0 and the maximum number of bits of\n                        \\ debris that this ship will release when destroyed\n\n.um\n\n BEQ oh                 \\ We're going to go round a loop using CNT as a counter\n                        \\ so this checks whether the counter is zero and jumps\n                        \\ to oh when it gets there (which might be straight\n                        \\ away)\n\n LDX #OIL               \\ Call SFS1 to spawn a cargo canister from the now\n LDA #0                 \\ deceased parent ship, giving the spawned canister an\n JSR SFS1               \\ AI flag of 0 (no AI, zero aggression, no E.C.M.)\n\n DEC CNT                \\ Decrease the loop counter\n\n BPL um                 \\ Jump back up to um (this BPL is effectively a JMP as\n                        \\ CNT will never be negative)\n\n.oh\n\n JSR EXNO2              \\ Call EXNO2 to process the fact that we have killed a\n                        \\ ship (so increase the kill tally, make an explosion\n                        \\ sound and so on)\n\n.MA14\n\n STA INWK+35            \\ Store the hit ship's updated energy in ship byte #35\n\n LDA TYPE               \\ Call ANGRY to make this ship angry; if this is the\n JSR ANGRY              \\ space station this will make it hostile, or if this is\n                        \\ a ship it will wake up its AI and give it a kick of\n                        \\ speed (later calls to TACTICS may make the ship start\n                        \\ to attack us if it has a high enough aggression level)\n\n\\ ******************************************************************************\n\\\n\\       Name: Main flight loop (Part 12 of 16)\n\\       Type: Subroutine\n\\   Category: Main loop\n\\    Summary: For each nearby ship: Draw the ship, remove if killed, loop back\n\\  Deep dive: Program flow of the main game loop\n\\             Drawing ships\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The main flight loop covers most of the flight-specific aspects of Elite. This\n\\ section covers the following:\n\\\n\\   * Continue looping through all the ships in the local bubble, and for each\n\\     one:\n\\\n\\     * Draw the ship\n\\\n\\     * Process removal of killed ships\n\\\n\\   * Loop back up to MAL1 to move onto the next ship in the local bubble\n\\\n\\ ******************************************************************************\n\n.MA8\n\n JSR LL9                \\ Call LL9 to draw the ship we're processing on-screen\n\n.MA15\n\n LDY #35                \\ Fetch the ship's energy from byte #35 and copy it to\n LDA INWK+35            \\ byte #35 in INF (so the ship's data in K% gets\n STA (INF),Y            \\ updated)\n\n LDA INWK+31            \\ If bit 7 of the ship's byte #31 is clear, then the\n BPL MAC1               \\ ship hasn't been killed by energy bomb, collision or\n                        \\ laser fire, so jump to MAC1 to skip the following\n\n AND #%00100000         \\ If bit 5 of the ship's byte #31 is clear then the\n BEQ NBOUN              \\ ship is no longer exploding, so jump to NBOUN to skip\n                        \\ the following\n\n LDA TYPE               \\ If the ship we just destroyed was a cop, keep going,\n CMP #COPS              \\ otherwise jump to q2 to skip the following\n BNE q2\n\n LDA FIST               \\ We shot the sheriff, so update our FIST flag\n ORA #64                \\ (\"fugitive/innocent status\") to at least 64, which\n STA FIST               \\ will instantly make us a fugitive\n\n.q2\n\n LDA DLY                \\ If we already have an in-flight message on-screen (in\n ORA MJ                 \\ which case DLY > 0), or we are in witchspace (in\n BNE KS1S               \\ which case MJ > 0), jump to KS1S to skip showing an\n                        \\ on-screen bounty for this kill\n\n LDY #10                \\ Fetch byte #10 of the ship's blueprint, which is the\n LDA (XX0),Y            \\ low byte of the bounty awarded when this ship is\n BEQ KS1S               \\ killed (in Cr * 10), and if it's zero jump to KS1S as\n                        \\ there is no on-screen bounty to display\n\n TAX                    \\ Put the low byte of the bounty into X\n\n INY                    \\ Fetch byte #11 of the ship's blueprint, which is the\n LDA (XX0),Y            \\ high byte of the bounty awarded (in Cr * 10), and put\n TAY                    \\ it into Y\n\n JSR MCASH              \\ Call MCASH to add (Y X) to the cash pot\n\n LDA #0                 \\ Print control code 0 (current cash, right-aligned to\n JSR MESS               \\ width 9, then \" CR\", newline) as an in-flight message\n\n.KS1S\n\n JMP KS1                \\ Process the killing of this ship (which removes this\n                        \\ ship from its slot and shuffles all the other ships\n                        \\ down to close up the gap)\n\n.NBOUN\n\n.MAC1\n\n LDA TYPE               \\ If the ship we are processing is a planet or sun,\n BMI MA27               \\ jump to MA27 to skip the following two instructions\n\n JSR FAROF              \\ If the ship we are processing is a long way away (its\n BCC KS1S               \\ distance in any one direction is > 224, jump to KS1S\n                        \\ to remove the ship from our local bubble, as it's just\n                        \\ left the building\n\n.MA27\n\n LDY #31                \\ Fetch the ship's explosion/killed state from byte #31\n LDA INWK+31            \\ and copy it to byte #31 in INF (so the ship's data in\n STA (INF),Y            \\ K% gets updated)\n\n LDX XSAV               \\ We're done processing this ship, so fetch the ship's\n                        \\ slot number, which we saved in XSAV back at the start\n                        \\ of the loop\n\n INX                    \\ Increment the slot number to move on to the next slot\n\n JMP MAL1               \\ And jump back up to the beginning of the loop to get\n                        \\ the next ship in the local bubble for processing\n\n\\ ******************************************************************************\n\\\n\\       Name: Main flight loop (Part 13 of 16)\n\\       Type: Subroutine\n\\   Category: Main loop\n\\    Summary: Show energy bomb effect, charge shields and energy banks\n\\  Deep dive: Program flow of the main game loop\n\\             Scheduling tasks with the main loop counter\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The main flight loop covers most of the flight-specific aspects of Elite. This\n\\ section covers the following:\n\\\n\\   * Show energy bomb effect (if applicable)\n\\\n\\   * Charge shields and energy banks (every 7 iterations of the main loop)\n\\\n\\ ******************************************************************************\n\n.MA18\n\n LDA BOMB               \\ If we set off our energy bomb (see MA24 above), then\n BPL MA77               \\ BOMB is now negative, so this skips to MA21 if our\n                        \\ energy bomb is not going off\n\n ASL BOMB               \\ We set off our energy bomb, so rotate BOMB to the\n                        \\ left by one place. BOMB was rotated left once already\n                        \\ during this iteration of the main loop, back at MA24,\n                        \\ so if this is the first pass it will already be\n                        \\ %11111110, and this will shift it to %11111100 - so\n                        \\ if we set off an energy bomb, it stays activated\n                        \\ (BOMB > 0) for four iterations of the main loop\n\n JSR WSCAN              \\ Call WSCAN to wait for the vertical sync, so the whole\n                        \\ screen gets drawn and the following palette change\n                        \\ won't kick in while the screen is still refreshing\n\n LDA #%00110000         \\ Set the palette byte at SHEILA &21 to map logical\n STA VIA+&21            \\ colour 0 to physical colour 7 (white), but with only\n                        \\ one mapping (rather than the 7 mappings required to\n                        \\ do the mapping properly). This makes the space screen\n                        \\ flash with black and white stripes. See page 382 of\n                        \\ the \"Advanced User Guide for the BBC Micro\" by Bray,\n                        \\ Dickens and Holmes for details of why this single\n                        \\ palette change creates a special effect\n\n.MA77\n\n LDA MCNT               \\ Fetch the main loop counter and calculate MCNT mod 8,\n AND #7                 \\ jumping to MA22 if it is non-zero (so the following\n BNE MA22               \\ code only runs every 8 iterations of the main loop)\n\n LDX ENERGY             \\ Fetch our ship's energy levels and skip to b if bit 7\n BPL b                  \\ is not set, i.e. only charge the shields from the\n                        \\ energy banks if they are at more than 50% charge\n\n LDX ASH                \\ Call SHD to recharge our aft shield and update the\n JSR SHD                \\ shield status in ASH\n STX ASH\n\n LDX FSH                \\ Call SHD to recharge our forward shield and update\n JSR SHD                \\ the shield status in FSH\n STX FSH\n\n.b\n\n SEC                    \\ Set A = ENERGY + ENGY + 1, so our ship's energy\n LDA ENGY               \\ level goes up by 2 if we have an energy unit fitted,\n ADC ENERGY             \\ otherwise it goes up by 1\n\n BCS P%+5               \\ If the value of A did not overflow (the maximum\n STA ENERGY             \\ energy level is &FF), then store A in ENERGY\n\n\\ ******************************************************************************\n\\\n\\       Name: Main flight loop (Part 14 of 16)\n\\       Type: Subroutine\n\\   Category: Main loop\n\\    Summary: Spawn a space station if we are close enough to the planet\n\\  Deep dive: Program flow of the main game loop\n\\             Scheduling tasks with the main loop counter\n\\             Ship data blocks\n\\             The space station safe zone\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The main flight loop covers most of the flight-specific aspects of Elite. This\n\\ section covers the following:\n\\\n\\   * Spawn a space station if we are close enough to the planet (every 32\n\\     iterations of the main loop)\n\\\n\\ ******************************************************************************\n\n LDA MJ                 \\ If we are in witchspace, jump down to MA23S to skip\n BNE MA23S              \\ the following, as there are no space stations in\n                        \\ witchspace\n\n LDA MCNT               \\ Fetch the main loop counter and calculate MCNT mod 32,\n AND #31                \\ jumping to MA93 if it is on-zero (so the following\n BNE MA93               \\ code only runs every 32 iterations of the main loop)\n\n LDA SSPR               \\ If we are inside the space station safe zone, jump to\n BNE MA23S              \\ MA23S to skip the following, as we already have a\n                        \\ space station and don't need another\n\n TAY                    \\ Set Y = A = 0 (A is 0 as we didn't branch with the\n                        \\ previous BNE instruction)\n\n JSR MAS2               \\ Call MAS2 to calculate the largest distance to the\n BNE MA23S              \\ planet in any of the three axes, and if it's\n                        \\ non-zero, jump to MA23S to skip the following, as we\n                        \\ are too far from the planet to bump into a space\n                        \\ station\n\n                        \\ We now want to spawn a space station, so first we\n                        \\ need to set up a ship data block for the station in\n                        \\ INWK that we can then pass to NWSPS to add a new\n                        \\ station to our bubble of universe. We do this by\n                        \\ copying the planet data block from K% to INWK so we\n                        \\ can work on it, but we only need the first 29 bytes,\n                        \\ as we don't need to worry about bytes #29 to #35\n                        \\ for planets (as they don't have rotation counters,\n                        \\ AI, explosions, missiles, a ship line heap or energy\n                        \\ levels)\n\n LDX #28                \\ So we set a counter in X to copy 29 bytes from K%+0\n                        \\ to K%+28\n\n.MAL4\n\n LDA K%,X               \\ Load the X-th byte of K% and store in the X-th byte\n STA INWK,X             \\ of the INWK workspace\n\n DEX                    \\ Decrement the loop counter\n\n BPL MAL4               \\ Loop back for the next byte until we have copied the\n                        \\ first 28 bytes of K% to INWK\n\n                        \\ We now check the distance from our ship (at the\n                        \\ origin) towards the point where we will spawn the\n                        \\ space station if we are close enough\n                        \\\n                        \\ This point is calculated by starting at the planet's\n                        \\ centre and adding 2 * nosev, which takes us to a point\n                        \\ above the planet's surface, at an altitude that\n                        \\ matches the planet's radius\n                        \\\n                        \\ This point pitches and rolls around the planet as the\n                        \\ nosev vector rotates with the planet, and if our ship\n                        \\ is within a distance of (192 0) from this point in all\n                        \\ three axes, then we spawn the space station at this\n                        \\ point, with the station's slot facing towards the\n                        \\ planet, along the nosev vector\n                        \\\n                        \\ This works because in the following, we calculate the\n                        \\ station's coordinates one axis at a time, and store\n                        \\ the results in the INWK block, so by the time we have\n                        \\ calculated and checked all three, the ship data block\n                        \\ is set up with the correct spawning coordinates\n\n INX                    \\ Set X = 0 (as we ended the above loop with X as &FF)\n\n LDY #9                 \\ Call MAS1 with X = 0, Y = 9 to do the following:\n JSR MAS1               \\\n                        \\   (x_sign x_hi x_lo) += (nosev_x_hi nosev_x_lo) * 2\n                        \\\n                        \\   A = |x_sign|\n\n BNE MA23S              \\ If A > 0, jump to MA23S to skip the following, as we\n                        \\ are too far from the planet in the x-direction to\n                        \\ bump into a space station\n\n LDX #3                 \\ Call MAS1 with X = 3, Y = 11 to do the following:\n LDY #11                \\\n JSR MAS1               \\   (y_sign y_hi y_lo) += (nosev_y_hi nosev_y_lo) * 2\n                        \\\n                        \\   A = |y_sign|\n\n BNE MA23S              \\ If A > 0, jump to MA23S to skip the following, as we\n                        \\ are too far from the planet in the y-direction to\n                        \\ bump into a space station\n\n LDX #6                 \\ Call MAS1 with X = 6, Y = 13 to do the following:\n LDY #13                \\\n JSR MAS1               \\   (z_sign z_hi z_lo) += (nosev_z_hi nosev_z_lo) * 2\n                        \\\n                        \\   A = |z_sign|\n\n BNE MA23S              \\ If A > 0, jump to MA23S to skip the following, as we\n                        \\ are too far from the planet in the z-direction to\n                        \\ bump into a space station\n\n LDA #192               \\ Call FAROF2 to compare x_hi, y_hi and z_hi with 192,\n JSR FAROF2             \\ which will set the C flag if all three are < 192, or\n                        \\ clear the C flag if any of them are >= 192\n\n BCC MA23S              \\ Jump to MA23S if any one of x_hi, y_hi or z_hi are\n                        \\ >= 192 (i.e. they must all be < 192 for us to be near\n                        \\ enough to the planet to bump into a space station)\n\n LDA QQ11               \\ If the current view is not a space view, skip the\n BNE P%+5               \\ following instruction (so we only remove the sun from\n                        \\ the screen if we are potentially looking at it)\n\n JSR WPLS               \\ Call WPLS to remove the sun from the screen, as we\n                        \\ can't have both the sun and the space station at the\n                        \\ same time\n\n JSR NWSPS              \\ Add a new space station to our local bubble of\n                        \\ universe\n\n.MA23S\n\n JMP MA23               \\ Jump to MA23 to skip the following planet and sun\n                        \\ altitude checks\n\n\\ ******************************************************************************\n\\\n\\       Name: Main flight loop (Part 15 of 16)\n\\       Type: Subroutine\n\\   Category: Main loop\n\\    Summary: Perform altitude checks with the planet and sun and process fuel\n\\             scooping if appropriate\n\\  Deep dive: Program flow of the main game loop\n\\             Scheduling tasks with the main loop counter\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The main flight loop covers most of the flight-specific aspects of Elite. This\n\\ section covers the following:\n\\\n\\   * Perform an altitude check with the planet (every 32 iterations of the main\n\\     loop, on iteration 10 of each 32)\n\\\n\\   * Perform an altitude check with the sun and process fuel scooping (every\n\\     32 iterations of the main loop, on iteration 20 of each 32)\n\\\n\\ ******************************************************************************\n\n.MA22\n\n LDA MJ                 \\ If we are in witchspace, jump down to MA23 to skip\n BNE MA23               \\ the following, as there are no planets or suns to\n                        \\ bump into in witchspace\n\n LDA MCNT               \\ Fetch the main loop counter and calculate MCNT mod 32,\n AND #31                \\ which tells us the position of this loop in each block\n                        \\ of 32 iterations\n\n.MA93\n\n CMP #10                \\ If this is the tenth iteration in this block of 32,\n BNE MA29               \\ do the following, otherwise jump to MA29 to skip the\n                        \\ planet altitude check and move on to the sun distance\n                        \\ check\n\n LDA #50                \\ If our energy bank status in ENERGY is >= 50, skip\n CMP ENERGY             \\ printing the following message (so the message is\n BCC P%+6               \\ only shown if our energy is low)\n\n ASL A                  \\ Print recursive token 100 (\"ENERGY LOW{beep}\") as an\n JSR MESS               \\ in-flight message\n\n LDY #&FF               \\ Set our altitude in ALTIT to &FF, the maximum\n STY ALTIT\n\n INY                    \\ Set Y = 0\n\n JSR m                  \\ Call m to calculate the maximum distance to the\n                        \\ planet in any of the three axes, returned in A\n\n BNE MA23               \\ If A > 0 then we are a fair distance away from the\n                        \\ planet in at least one axis, so jump to MA23 to skip\n                        \\ the rest of the altitude check\n\n JSR MAS3               \\ Set A = x_hi^2 + y_hi^2 + z_hi^2, so using Pythagoras\n                        \\ we now know that A now contains the square of the\n                        \\ distance between our ship (at the origin) and the\n                        \\ centre of the planet at (x_hi, y_hi, z_hi)\n\n BCS MA23               \\ If the C flag was set by MAS3, then the result\n                        \\ overflowed (was greater than &FF) and we are still a\n                        \\ fair distance from the planet, so jump to MA23 as we\n                        \\ haven't crashed into the planet\n\n SBC #36                \\ Subtract 37 from x_hi^2 + y_hi^2 + z_hi^2\n                        \\\n                        \\ The SBC subtracts 37 as we just passed through a BCS\n                        \\ so we know the C flag is clear\n                        \\\n                        \\ When we do the 3D Pythagoras calculation, we only use\n                        \\ the high bytes of the coordinates, so that's x_hi,\n                        \\ y_hi and z_hi and\n                        \\\n                        \\ The planet radius is (0 96 0), as defined in the\n                        \\ PLANET routine, so the high byte is 96\n                        \\\n                        \\ When we square the coordinates above and add them,\n                        \\ the result gets divided by 256 (otherwise the result\n                        \\ wouldn't fit into one byte), so if we do the same for\n                        \\ the planet's radius, we get:\n                        \\\n                        \\   96 * 96 / 256 = 36\n                        \\\n                        \\ So for the planet, the equivalent figure to test the\n                        \\ sum of the _hi bytes against is 36, so A now contains\n                        \\ the high byte of our altitude above the planet\n                        \\ surface, squared, with an extra 1 subtracted so the\n                        \\ test in the next instruction will ensure we crash\n                        \\ even if we are exactly one planet radius away\n\n BCC MA28               \\ If A < 0 then jump to MA28 as we have crashed into\n                        \\ the planet\n\n STA R                  \\ We are getting close to the planet, so we need to\n JSR LL5                \\ work out how close. We know from the above that A\n                        \\ contains our altitude squared, so we store A in R\n                        \\ and call LL5 to calculate:\n                        \\\n                        \\   Q = SQRT(R Q) = SQRT(A Q)\n                        \\\n                        \\ Interestingly, Q doesn't appear to be set to 0 for\n                        \\ this calculation, so presumably this doesn't make a\n                        \\ difference\n\n LDA Q                  \\ Store the result in ALTIT, our altitude\n STA ALTIT\n\n BNE MA23               \\ If our altitude is non-zero then we haven't crashed,\n                        \\ so jump to MA23 to skip to the next section\n\n.MA28\n\n JMP DEATH              \\ If we get here then we just crashed into the planet\n                        \\ or got too close to the sun, so jump to DEATH to start\n                        \\ the funeral preparations and return from the main\n                        \\ flight loop using a tail call\n\n.MA29\n\n CMP #20                \\ If this is the 20th iteration in this block of 32,\n BNE MA23               \\ do the following, otherwise jump to MA23 to skip the\n                        \\ sun altitude check\n\n LDA #30                \\ Set CABTMP to 30, the cabin temperature in deep space\n STA CABTMP             \\ (i.e. one notch on the dashboard bar)\n\n LDA SSPR               \\ If we are inside the space station safe zone, jump to\n BNE MA23               \\ MA23 to skip the following, as we can't have both the\n                        \\ sun and space station at the same time, so we clearly\n                        \\ can't be flying near the sun\n\n LDY #NI%               \\ Set Y to NI%, which is the offset in K% for the sun's\n                        \\ data block, as the second block at K% is reserved for\n                        \\ the sun (or space station)\n\n JSR MAS2               \\ Call MAS2 to calculate the largest distance to the\n BNE MA23               \\ sun in any of the three axes, and if it's non-zero,\n                        \\ jump to MA23 to skip the following, as we are too far\n                        \\ from the sun for scooping or temperature changes\n\n JSR MAS3               \\ Set (A ?) = x_hi^2 + y_hi^2 + z_hi^2, so using\n                        \\ Pythagoras we now know that A now contains the high\n                        \\ byte of the square of the distance between our ship\n                        \\ (at the origin) and the heart of the sun at coordinate\n                        \\ (x_hi, y_hi, z_hi)\n                        \\\n                        \\ If the calculation overflows so it doesn't fit into\n                        \\ one byte, then A is set to &FF and the C flag is set\n\n EOR #%11111111         \\ Invert A, so A is now small if we are far from the\n                        \\ sun and large if we are close to the sun, in the\n                        \\ range 0 = far away to &FF = extremely close, ouch,\n                        \\ hot, hot, hot!\n\n ADC #30                \\ Add the minimum cabin temperature of 30, plus the C\n                        \\ flag, so we get one of the following:\n                        \\\n                        \\   * If the MAS3 calculation overflowed then we are a\n                        \\     long way from the sun, A will be zero and the C\n                        \\     flag will be set, so this addition sets A = 31\n                        \\     and clears the C flag\n                        \\\n                        \\   * If the result of the MAS3 calculation fitted into\n                        \\     one byte, then A will be in the range 0 to 255 and\n                        \\     the C flag will be clear, so this addition has a\n                        \\     result in the range 0 to 285, with the higher\n                        \\     values overflowing the addition and setting the\n                        \\     C flag\n                        \\\n                        \\ So the C flag is set if the cabin temperature is too\n                        \\ hot to handle, and if it's clear then A contains the\n                        \\ cabin temperature\n\n STA CABTMP             \\ Store the updated cabin temperature\n\n BCS MA28               \\ If the C flag is set then jump to MA28 to die, as\n                        \\ our temperature is off the scale\n\n CMP #224               \\ If the cabin temperature < 224 then jump to MA23 to\n BCC MA23               \\ skip fuel scooping, as we aren't close enough\n\n LDA BST                \\ If we don't have fuel scoops fitted, jump to BA23 to\n BEQ MA23               \\ skip fuel scooping, as we can't scoop without fuel\n                        \\ scoops\n\n LDA DELT4+1            \\ We are now successfully fuel scooping, so it's time\n LSR A                  \\ to work out how much fuel we're scooping. Fetch the\n                        \\ high byte of DELT4, which contains our current speed\n                        \\ divided by 4, and halve it to get our current speed\n                        \\ divided by 8 (so it's now a value between 1 and 5, as\n                        \\ our speed is normally between 1 and 40). This gives\n                        \\ us the amount of fuel that's being scooped in A, so\n                        \\ the faster we go, the more fuel we scoop, and because\n                        \\ the fuel levels are stored as 10 * the fuel in light\n                        \\ years, that means we just scooped between 0.1 and 0.5\n                        \\ light years of free fuel\n\n ADC QQ14               \\ Set A = A + the current fuel level * 10 (from QQ14)\n\n CMP #70                \\ If A > 70 then set A = 70 (as 70 is the maximum fuel\n BCC P%+4               \\ level, or 7.0 light years)\n LDA #70\n\n STA QQ14               \\ Store the updated fuel level in QQ14\n\n LDA #160               \\ Print recursive token 0 (\"FUEL SCOOPS ON\") as an\n JSR MESS               \\ in-flight message\n\n\\ ******************************************************************************\n\\\n\\       Name: Main flight loop (Part 16 of 16)\n\\       Type: Subroutine\n\\   Category: Main loop\n\\    Summary: Process laser pulsing, E.C.M. energy drain, call stardust routine\n\\  Deep dive: Program flow of the main game loop\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The main flight loop covers most of the flight-specific aspects of Elite. This\n\\ section covers the following:\n\\\n\\   * Process laser pulsing\n\\\n\\   * Process E.C.M. energy drain\n\\\n\\   * Jump to the stardust routine if we are in a space view\n\\\n\\   * Return from the main flight loop\n\\\n\\ ******************************************************************************\n\n.MA23\n\n LDA LAS2               \\ If the current view has no laser, jump to MA16 to skip\n BEQ MA16               \\ the following\n\n LDA LASCT              \\ If LASCT >= 8, jump to MA16 to skip the following, so\n CMP #8                 \\ for a pulse laser with a LASCT between 8 and 10, the\n BCS MA16               \\ laser stays on, but for a LASCT of 7 or less it gets\n                        \\ turned off and stays off until LASCT reaches zero and\n                        \\ the next pulse can start (if the fire button is still\n                        \\ being pressed)\n                        \\\n                        \\ For pulse lasers, LASCT gets set to 10 in ma1 above,\n                        \\ and it decrements every vertical sync (50 times a\n                        \\ second), so this means it pulses five times a second,\n                        \\ with the laser being on for the first 3/10 of each\n                        \\ pulse and off for the rest of the pulse\n                        \\\n                        \\ If this is a beam laser, LASCT is 0 so we always keep\n                        \\ going here. This means the laser doesn't pulse, but it\n                        \\ does get drawn and removed every cycle, in a slightly\n                        \\ different place each time, so the beams still flicker\n                        \\ around the screen\n\n JSR LASLI2             \\ Redraw the existing laser lines, which has the effect\n                        \\ of removing them from the screen\n\n LDA #0                 \\ Set LAS2 to 0 so if this is a pulse laser, it will\n STA LAS2               \\ skip over the above until the next pulse (this has no\n                        \\ effect if this is a beam laser)\n\n.MA16\n\n LDA ECMP               \\ If our E.C.M is not on, skip to MA69, otherwise keep\n BEQ MA69               \\ going to drain some energy\n\n JSR DENGY              \\ Call DENGY to deplete our energy banks by 1\n\n BEQ MA70               \\ If we have no energy left, jump to MA70 to turn our\n                        \\ E.C.M. off\n\n.MA69\n\n LDA ECMA               \\ If an E.C.M is going off (ours or an opponent's) then\n BEQ MA66               \\ keep going, otherwise skip to MA66\n\n DEC ECMA               \\ Decrement the E.C.M. countdown timer, and if it has\n BNE MA66               \\ reached zero, keep going, otherwise skip to MA66\n\n.MA70\n\n JSR ECMOF              \\ If we get here then either we have either run out of\n                        \\ energy, or the E.C.M. timer has run down, so switch\n                        \\ off the E.C.M.\n\n.MA66\n\n LDA QQ11               \\ If this is not a space view (i.e. QQ11 is non-zero)\n BNE MA9                \\ then jump to MA9 to return from the main flight loop\n                        \\ (as MA9 is an RTS)\n\n JMP STARS              \\ This is a space view, so jump to the STARS routine to\n                        \\ process the stardust, and return from the main flight\n                        \\ loop using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: MAS1\n\\       Type: Subroutine\n\\   Category: Maths (Geometry)\n\\    Summary: Add an orientation vector coordinate to an INWK coordinate\n\\  Deep dive: The space station safe zone\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Add a doubled nosev vector coordinate, e.g. (nosev_y_hi nosev_y_lo) * 2, to\n\\ an INWK coordinate, e.g. (x_sign x_hi x_lo), storing the result in the INWK\n\\ coordinate. The axes used in each side of the addition are specified by the\n\\ arguments X and Y.\n\\\n\\ In the comments below, we document the routine as if we are doing the\n\\ following, i.e. if X = 0 and Y = 11:\n\\\n\\   (x_sign x_hi x_lo) = (x_sign x_hi x_lo) + (nosev_y_hi nosev_y_lo) * 2\n\\\n\\ as that way the variable names in the comments contain \"x\" and \"y\" to match\n\\ the registers that specify the vector axis to use.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   The coordinate to add, as follows:\n\\\n\\                         * If X = 0, add (x_sign x_hi x_lo)\n\\                         * If X = 3, add (y_sign y_hi y_lo)\n\\                         * If X = 6, add (z_sign z_hi z_lo)\n\\\n\\   Y                   The vector to add, as follows:\n\\\n\\                         * If Y = 9,  add (nosev_x_hi nosev_x_lo)\n\\                         * If Y = 11, add (nosev_y_hi nosev_y_lo)\n\\                         * If Y = 13, add (nosev_z_hi nosev_z_lo)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   A                   The highest byte of the result with the sign cleared\n\\                       (e.g. |x_sign| when X = 0, etc.)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   MA9                 Contains an RTS\n\\\n\\ ******************************************************************************\n\n.MAS1\n\n LDA INWK,Y             \\ Set K(2 1) = (nosev_y_hi nosev_y_lo) * 2\n ASL A\n STA K+1\n LDA INWK+1,Y\n ROL A\n STA K+2\n\n LDA #0                 \\ Set K+3 bit 7 to the C flag, so the sign bit of the\n ROR A                  \\ above result goes into K+3\n STA K+3\n\n JSR MVT3               \\ Add (x_sign x_hi x_lo) to K(3 2 1)\n\n STA INWK+2,X           \\ Store the sign of the result in x_sign\n\n LDY K+1                \\ Store K(2 1) in (x_hi x_lo)\n STY INWK,X\n LDY K+2\n STY INWK+1,X\n\n AND #%01111111         \\ Set A to the sign byte with the sign cleared,\n                        \\ i.e. |x_sign| when X = 0\n\n.MA9\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: MAS2\n\\       Type: Subroutine\n\\   Category: Maths (Geometry)\n\\    Summary: Calculate a cap on the maximum distance to the planet or sun\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Given a value in Y that points to the start of a ship data block as an offset\n\\ from K%, calculate the following:\n\\\n\\   A = A OR x_sign OR y_sign OR z_sign\n\\\n\\ and clear the sign bit of the result. The K% workspace contains the ship data\n\\ blocks, so the offset in Y must be 0 or a multiple of NI% (as each block in\n\\ K% contains NI% bytes).\n\\\n\\ The result effectively contains a maximum cap of the three values (though it\n\\ might not be one of the three input values - it's just guaranteed to be\n\\ larger than all of them).\n\\\n\\ If Y = 0 and A = 0, then this calculates the maximum cap of the highest byte\n\\ containing the distance to the planet, as K%+2 = x_sign, K%+5 = y_sign and\n\\ K%+8 = z_sign (the first slot in the K% workspace represents the planet).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   Y                   The offset from K% for the start of the ship data block\n\\                       to use\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   A                   A OR K%+2+Y OR K%+5+Y OR K%+8+Y, with bit 7 cleared\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   m                   Do not include A in the calculation\n\\\n\\ ******************************************************************************\n\n.m\n\n LDA #0                 \\ Set A = 0 and fall through into MAS2 to calculate the\n                        \\ OR of the three bytes at K%+2+Y, K%+5+Y and K%+8+Y\n\n.MAS2\n\n ORA K%+2,Y             \\ Set A = A OR x_sign OR y_sign OR z_sign\n ORA K%+5,Y\n ORA K%+8,Y\n\n AND #%01111111         \\ Clear bit 7 in A\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: MAS3\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate A = x_hi^2 + y_hi^2 + z_hi^2 in the K% block\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Given a value in Y that points to the start of a ship data block as an offset\n\\ from K%, calculate the following:\n\\\n\\   (A ?) = x_hi^2 + y_hi^2 + z_hi^2\n\\\n\\ returning A = &FF if the calculation overflows a one-byte result. The K%\n\\ workspace contains the ship data blocks, so the offset in Y must be 0 or a\n\\ multiple of NI% (as each block in K% contains NI% bytes).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   Y                   The offset from K% for the start of the ship data block\n\\                       to use\n\\\n\\ Returns\n\\\n\\   A                   The high byte of x_hi^2 + y_hi^2 + z_hi^2\n\\\n\\   C flag              The overflow status (i.e. did the result fit into one\n\\                       byte):\n\\\n\\                         * Clear if the calculation didn't overflow\n\\\n\\                         * Set if the calculation overflowed (in which case A\n\\                           is set to &FF)\n\\\n\\ ******************************************************************************\n\n.MAS3\n\n LDA K%+1,Y             \\ Set (A P) = x_hi * x_hi\n JSR SQUA2\n\n STA R                  \\ Store A (high byte of result) in R\n\n LDA K%+4,Y             \\ Set (A P) = y_hi * y_hi\n JSR SQUA2\n\n ADC R                  \\ Add A (high byte of second result) to R\n\n BCS MA30               \\ If the addition of the two high bytes caused a carry\n                        \\ (i.e. they overflowed), jump to MA30 to return A = &FF\n\n STA R                  \\ Store A (sum of the two high bytes) in R\n\n LDA K%+7,Y             \\ Set (A P) = z_hi * z_hi\n JSR SQUA2\n\n ADC R                  \\ Add A (high byte of third result) to R, so R now\n                        \\ contains the high byte of the entire sum, i.e. of\n                        \\ x_hi^2 + y_hi^2 + z_hi^2\n\n BCC P%+4               \\ If there is no carry, skip the following instruction\n                        \\ to return straight from the subroutine\n\n.MA30\n\n LDA #&FF               \\ The calculation has overflowed, so set A = &FF\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: MVEIT (Part 1 of 9)\n\\       Type: Subroutine\n\\   Category: Moving\n\\    Summary: Move current ship: Tidy the orientation vectors\n\\  Deep dive: Program flow of the ship-moving routine\n\\             Scheduling tasks with the main loop counter\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine has multiple stages. This stage does the following:\n\\\n\\   * Tidy the orientation vectors for one of the ship slots\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   INWK                The current ship/planet/sun's data block\n\\\n\\   XSAV                The slot number of the current ship/planet/sun\n\\\n\\   TYPE                The type of the current ship/planet/sun\n\\\n\\ ******************************************************************************\n\n.MVEIT\n\n LDA INWK+31            \\ If bits 5 or 7 of ship byte #31 are set, jump to MV30\n AND #%10100000         \\ as the ship is either exploding or has been killed, so\n BNE MV30               \\ we don't need to tidy its orientation vectors or apply\n                        \\ tactics\n\n LDA MCNT               \\ Fetch the main loop counter\n\n EOR XSAV               \\ Fetch the slot number of the ship we are moving, EOR\n AND #15                \\ with the loop counter and apply mod 15 to the result.\n BNE MV3                \\ The result will be zero when \"counter mod 15\" matches\n                        \\ the slot number, so this makes sure we call TIDY 12\n                        \\ times every 16 main loop iterations, like this:\n                        \\\n                        \\   Iteration 0, tidy the ship in slot 0\n                        \\   Iteration 1, tidy the ship in slot 1\n                        \\   Iteration 2, tidy the ship in slot 2\n                        \\     ...\n                        \\   Iteration 11, tidy the ship in slot 11\n                        \\   Iteration 12, do nothing\n                        \\   Iteration 13, do nothing\n                        \\   Iteration 14, do nothing\n                        \\   Iteration 15, do nothing\n                        \\   Iteration 16, tidy the ship in slot 0\n                        \\     ...\n                        \\\n                        \\ and so on\n\n JSR TIDY               \\ Call TIDY to tidy up the orientation vectors, to\n                        \\ prevent the ship from getting elongated and out of\n                        \\ shape due to the imprecise nature of trigonometry\n                        \\ in assembly language\n\n\\ ******************************************************************************\n\\\n\\       Name: MVEIT (Part 2 of 9)\n\\       Type: Subroutine\n\\   Category: Moving\n\\    Summary: Move current ship: Call tactics routine, remove ship from scanner\n\\  Deep dive: Scheduling tasks with the main loop counter\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine has multiple stages. This stage does the following:\n\\\n\\   * Apply tactics to ships with AI enabled (by calling the TACTICS routine)\n\\\n\\   * Remove the ship from the scanner, so we can move it\n\\\n\\ ******************************************************************************\n\n.MV3\n\n LDX TYPE               \\ If the type of the ship we are moving is positive,\n BPL P%+5               \\ i.e. it is not a planet (types 128 and 130) or sun\n                        \\ (type 129), then skip the following instruction\n\n JMP MV40               \\ This item is the planet or sun, so jump to MV40 to\n                        \\ move it, which ends by jumping back into this routine\n                        \\ at MV45 (after all the rotation, tactics and scanner\n                        \\ code, which we don't need to apply to planets or suns)\n\n LDA INWK+32            \\ Fetch the ship's byte #32 (AI flag) into A\n\n BPL MV30               \\ If bit 7 of the AI flag is clear, then if this is a\n                        \\ ship or missile it is dumb and has no AI, and if this\n                        \\ is the space station it is not hostile, so in both\n                        \\ cases skip the following as it has no tactics\n\n CPX #MSL               \\ If the ship is a missile, skip straight to MV26 to\n BEQ MV26               \\ call the TACTICS routine, as we do this every\n                        \\ iteration of the main loop for missiles only\n\n LDA MCNT               \\ Fetch the main loop counter\n\n EOR XSAV               \\ Fetch the slot number of the ship we are moving, EOR\n AND #7                 \\ with the loop counter and apply mod 8 to the result.\n BNE MV30               \\ The result will be zero when \"counter mod 8\" matches\n                        \\ the slot number mod 8, so this makes sure we call\n                        \\ TACTICS 12 times every 8 main loop iterations, like\n                        \\ this:\n                        \\\n                        \\   Iteration 0, apply tactics to slots 0 and 8\n                        \\   Iteration 1, apply tactics to slots 1 and 9\n                        \\   Iteration 2, apply tactics to slots 2 and 10\n                        \\   Iteration 3, apply tactics to slots 3 and 11\n                        \\   Iteration 4, apply tactics to slot 4\n                        \\   Iteration 5, apply tactics to slot 5\n                        \\   Iteration 6, apply tactics to slot 6\n                        \\   Iteration 7, apply tactics to slot 7\n                        \\   Iteration 8, apply tactics to slots 0 and 8\n                        \\     ...\n                        \\\n                        \\ and so on\n\n.MV26\n\n JSR TACTICS            \\ Call TACTICS to apply AI tactics to this ship\n\n.MV30\n\n JSR SCAN               \\ Draw the ship on the scanner, which has the effect of\n                        \\ removing it, as it's already at this point and hasn't\n                        \\ yet moved\n\n\\ ******************************************************************************\n\\\n\\       Name: MVEIT (Part 3 of 9)\n\\       Type: Subroutine\n\\   Category: Moving\n\\    Summary: Move current ship: Move ship forward according to its speed\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine has multiple stages. This stage does the following:\n\\\n\\   * Move the ship forward (along the vector pointing in the direction of\n\\     travel) according to its speed:\n\\\n\\     (x, y, z) += nosev_hi * speed / 64\n\\\n\\ ******************************************************************************\n\n LDA INWK+27            \\ Set Q = the ship's speed byte #27 * 4\n ASL A\n ASL A\n STA Q\n\n LDA INWK+10            \\ Set A = |nosev_x_hi|\n AND #%01111111\n\n JSR FMLTU              \\ Set R = A * Q / 256\n STA R                  \\       = |nosev_x_hi| * speed / 64\n\n LDA INWK+10            \\ If nosev_x_hi is positive, then:\n LDX #0                 \\\n JSR MVT1-2             \\   (x_sign x_hi x_lo) = (x_sign x_hi x_lo) + R\n                        \\\n                        \\ If nosev_x_hi is negative, then:\n                        \\\n                        \\   (x_sign x_hi x_lo) = (x_sign x_hi x_lo) - R\n                        \\\n                        \\ So in effect, this does:\n                        \\\n                        \\   (x_sign x_hi x_lo) += nosev_x_hi * speed / 64\n\n LDA INWK+12            \\ Set A = |nosev_y_hi|\n AND #%01111111\n\n JSR FMLTU              \\ Set R = A * Q / 256\n STA R                  \\       = |nosev_y_hi| * speed / 64\n\n LDA INWK+12            \\ If nosev_y_hi is positive, then:\n LDX #3                 \\\n JSR MVT1-2             \\   (y_sign y_hi y_lo) = (y_sign y_hi y_lo) + R\n                        \\\n                        \\ If nosev_y_hi is negative, then:\n                        \\\n                        \\   (y_sign y_hi y_lo) = (y_sign y_hi y_lo) - R\n                        \\\n                        \\ So in effect, this does:\n                        \\\n                        \\   (y_sign y_hi y_lo) += nosev_y_hi * speed / 64\n\n LDA INWK+14            \\ Set A = |nosev_z_hi|\n AND #%01111111\n\n JSR FMLTU              \\ Set R = A * Q / 256\n STA R                  \\       = |nosev_z_hi| * speed / 64\n\n LDA INWK+14            \\ If nosev_y_hi is positive, then:\n LDX #6                 \\\n JSR MVT1-2             \\   (z_sign z_hi z_lo) = (z_sign z_hi z_lo) + R\n                        \\\n                        \\ If nosev_z_hi is negative, then:\n                        \\\n                        \\   (z_sign z_hi z_lo) = (z_sign z_hi z_lo) - R\n                        \\\n                        \\ So in effect, this does:\n                        \\\n                        \\   (z_sign z_hi z_lo) += nosev_z_hi * speed / 64\n\n\\ ******************************************************************************\n\\\n\\       Name: MVEIT (Part 4 of 9)\n\\       Type: Subroutine\n\\   Category: Moving\n\\    Summary: Move current ship: Apply acceleration to ship's speed as a one-off\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine has multiple stages. This stage does the following:\n\\\n\\   * Apply acceleration to the ship's speed (if acceleration is non-zero),\n\\     and then zero the acceleration as it's a one-off change\n\\\n\\ ******************************************************************************\n\n LDA INWK+27            \\ Set A = the ship's speed in byte #24 + the ship's\n CLC                    \\ acceleration in byte #28\n ADC INWK+28\n\n BPL P%+4               \\ If the result is positive, skip the following\n                        \\ instruction\n\n LDA #0                 \\ Set A to 0 to stop the speed from going negative\n\n LDY #15                \\ We now fetch byte #15 from the ship's blueprint, which\n                        \\ contains the ship's maximum speed, so set Y = 15 to\n                        \\ use as an index\n\n CMP (XX0),Y            \\ If A < the ship's maximum speed, skip the following\n BCC P%+4               \\ instruction\n\n LDA (XX0),Y            \\ Set A to the ship's maximum speed\n\n STA INWK+27            \\ We have now calculated the new ship's speed after\n                        \\ accelerating and keeping the speed within the ship's\n                        \\ limits, so store the updated speed in byte #27\n\n LDA #0                 \\ We have added the ship's acceleration, so we now set\n STA INWK+28            \\ it back to 0 in byte #28, as it's a one-off change\n\n\\ ******************************************************************************\n\\\n\\       Name: MVEIT (Part 5 of 9)\n\\       Type: Subroutine\n\\   Category: Moving\n\\    Summary: Move current ship: Rotate ship's location by our pitch and roll\n\\  Deep dive: Rotating the universe\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine has multiple stages. This stage does the following:\n\\\n\\   * Rotate the ship's location in space by the amount of pitch and roll of\n\\     our ship. See below for a deeper explanation of this routine\n\\\n\\ ******************************************************************************\n\n LDX ALP1               \\ Fetch the magnitude of the current roll into X, so\n                        \\ if the roll angle is alpha, X contains |alpha|\n\n LDA INWK               \\ Set P = ~x_lo (i.e. with all its bits flipped) so that\n EOR #%11111111         \\ we can pass x_lo to MLTU2 below)\n STA P\n\n LDA INWK+1             \\ Set A = x_hi\n\n JSR MLTU2-2            \\ Set (A P+1 P) = (A ~P) * X\n                        \\               = (x_hi x_lo) * alpha\n\n STA P+2                \\ Store the high byte of the result in P+2, so we now\n                        \\ have:\n                        \\\n                        \\ P(2 1 0) = (x_hi x_lo) * alpha\n\n LDA ALP2+1             \\ Fetch the flipped sign of the current roll angle alpha\n EOR INWK+2             \\ from ALP2+1 and EOR with byte #2 (x_sign), so if the\n                        \\ flipped roll angle and x_sign have the same sign, A\n                        \\ will be positive, else it will be negative. So A will\n                        \\ contain the sign bit of x_sign * flipped alpha sign,\n                        \\ which is the opposite to the sign of the above result,\n                        \\ so we now have:\n                        \\\n                        \\ (A P+2 P+1) = - (x_sign x_hi x_lo) * alpha / 256\n\n LDX #3                 \\ Set (A P+2 P+1) = (y_sign y_hi y_lo) + (A P+2 P+1)\n JSR MVT6               \\                 = y - x * alpha / 256\n\n STA K2+3               \\ Set K2(3) = A = the sign of the result\n\n LDA P+1                \\ Set K2(1) = P+1, the low byte of the result\n STA K2+1\n\n EOR #%11111111         \\ Set P = ~K2+1 (i.e. with all its bits flipped) so\n STA P                  \\ that we can pass K2+1 to MLTU2 below)\n\n LDA P+2                \\ Set K2(2) = A = P+2\n STA K2+2\n\n                        \\ So we now have result 1 above:\n                        \\\n                        \\ K2(3 2 1) = (A P+2 P+1)\n                        \\           = y - x * alpha / 256\n\n LDX BET1               \\ Fetch the magnitude of the current pitch into X, so\n                        \\ if the pitch angle is beta, X contains |beta|\n\n JSR MLTU2-2            \\ Set (A P+1 P) = (A ~P) * X\n                        \\               = K2(2 1) * beta\n\n STA P+2                \\ Store the high byte of the result in P+2, so we now\n                        \\ have:\n                        \\\n                        \\ P(2 1 0) = K2(2 1) * beta\n\n LDA K2+3               \\ Fetch the sign of the above result in K(3 2 1) from\n EOR BET2               \\ K2+3 and EOR with BET2, the sign of the current pitch\n                        \\ rate, so if the pitch and K(3 2 1) have the same sign,\n                        \\ A will be positive, else it will be negative. So A\n                        \\ will contain the sign bit of K(3 2 1) * beta, which is\n                        \\ the same as the sign of the above result, so we now\n                        \\ have:\n                        \\\n                        \\ (A P+2 P+1) = K2(3 2 1) * beta / 256\n\n LDX #6                 \\ Set (A P+2 P+1) = (z_sign z_hi z_lo) + (A P+2 P+1)\n JSR MVT6               \\                 = z + K2 * beta / 256\n\n STA INWK+8             \\ Set z_sign = A = the sign of the result\n\n LDA P+1                \\ Set z_lo = P+1, the low byte of the result\n STA INWK+6\n\n EOR #%11111111         \\ Set P = ~z_lo (i.e. with all its bits flipped) so that\n STA P                  \\ we can pass z_lo to MLTU2 below)\n\n LDA P+2                \\ Set z_hi = P+2\n STA INWK+7\n\n                        \\ So we now have result 2 above:\n                        \\\n                        \\ (z_sign z_hi z_lo) = (A P+2 P+1)\n                        \\                    = z + K2 * beta / 256\n\n JSR MLTU2              \\ MLTU2 doesn't change Q, and Q was set to beta in\n                        \\ the previous call to MLTU2, so this call does:\n                        \\\n                        \\ (A P+1 P) = (A ~P) * Q\n                        \\           = (z_hi z_lo) * beta\n\n STA P+2                \\ Set P+2 = A = the high byte of the result, so we\n                        \\ now have:\n                        \\\n                        \\ P(2 1 0) = (z_hi z_lo) * beta\n\n LDA K2+3               \\ Set y_sign = K2+3\n STA INWK+5\n\n EOR BET2               \\ EOR y_sign with BET2, the sign of the current pitch\n EOR INWK+8             \\ rate, and z_sign. If the result is positive jump to\n BPL MV43               \\ MV43, otherwise this means beta * z and y have\n                        \\ different signs, i.e. P(2 1) and K2(3 2 1) have\n                        \\ different signs, so we need to add them in order to\n                        \\ calculate K2(2 1) - P(2 1)\n\n LDA P+1                \\ Set (y_hi y_lo) = K2(2 1) + P(2 1)\n ADC K2+1\n STA INWK+3\n LDA P+2\n ADC K2+2\n STA INWK+4\n\n JMP MV44               \\ Jump to MV44 to continue the calculation\n\n.MV43\n\n LDA K2+1               \\ Reversing the logic above, we need to subtract P(2 1)\n SBC P+1                \\ and K2(3 2 1) to calculate K2(2 1) - P(2 1), so this\n STA INWK+3             \\ sets (y_hi y_lo) = K2(2 1) - P(2 1)\n LDA K2+2\n SBC P+2\n STA INWK+4\n\n BCS MV44               \\ If the above subtraction did not underflow, then\n                        \\ jump to MV44, otherwise we need to negate the result\n\n LDA #1                 \\ Negate (y_sign y_hi y_lo) using two's complement,\n SBC INWK+3             \\ first doing the low bytes:\n STA INWK+3             \\\n                        \\ y_lo = 1 - y_lo\n\n LDA #0                 \\ Then the high bytes:\n SBC INWK+4             \\\n STA INWK+4             \\ y_hi = 0 - y_hi\n\n LDA INWK+5             \\ And finally flip the sign in y_sign\n EOR #%10000000\n STA INWK+5\n\n.MV44\n\n                        \\ So we now have result 3 above:\n                        \\\n                        \\ (y_sign y_hi y_lo) = K2(2 1) - P(2 1)\n                        \\                    = K2 - beta * z\n\n LDX ALP1               \\ Fetch the magnitude of the current roll into X, so\n                        \\ if the roll angle is alpha, X contains |alpha|\n\n LDA INWK+3             \\ Set P = ~y_lo (i.e. with all its bits flipped) so that\n EOR #&FF               \\ we can pass y_lo to MLTU2 below)\n STA P\n\n LDA INWK+4             \\ Set A = y_hi\n\n JSR MLTU2-2            \\ Set (A P+1 P) = (A ~P) * X\n                        \\               = (y_hi y_lo) * alpha\n\n STA P+2                \\ Store the high byte of the result in P+2, so we now\n                        \\ have:\n                        \\\n                        \\ P(2 1 0) = (y_hi y_lo) * alpha\n\n LDA ALP2               \\ Fetch the correct sign of the current roll angle alpha\n EOR INWK+5             \\ from ALP2 and EOR with byte #5 (y_sign), so if the\n                        \\ correct roll angle and y_sign have the same sign, A\n                        \\ will be positive, else it will be negative. So A will\n                        \\ contain the sign bit of x_sign * correct alpha sign,\n                        \\ which is the same as the sign of the above result,\n                        \\ so we now have:\n                        \\\n                        \\ (A P+2 P+1) = (y_sign y_hi y_lo) * alpha / 256\n\n LDX #0                 \\ Set (A P+2 P+1) = (x_sign x_hi x_lo) + (A P+2 P+1)\n JSR MVT6               \\                 = x + y * alpha / 256\n\n STA INWK+2             \\ Set x_sign = A = the sign of the result\n\n LDA P+2                \\ Set x_hi = P+2, the high byte of the result\n STA INWK+1\n\n LDA P+1                \\ Set x_lo = P+1, the low byte of the result\n STA INWK\n\n                        \\ So we now have result 4 above:\n                        \\\n                        \\ x = x + alpha * y\n                        \\\n                        \\ and the rotation of (x, y, z) is done\n\n\\ ******************************************************************************\n\\\n\\       Name: MVEIT (Part 6 of 9)\n\\       Type: Subroutine\n\\   Category: Moving\n\\    Summary: Move current ship: Move the ship in space according to our speed\n\\  Deep dive: A sense of scale\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine has multiple stages. This stage does the following:\n\\\n\\   * Move the ship in space according to our speed (we already moved it\n\\     according to its own speed in part 3).\n\\\n\\ We do this by subtracting our speed (i.e. the distance we travel in this\n\\ iteration of the loop) from the other ship's z-coordinate. We subtract because\n\\ they appear to be \"moving\" in the opposite direction to us, and the whole\n\\ MVEIT routine is about moving the other ships rather than us (even though we\n\\ are the one doing the moving).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   MV45                Rejoin the MVEIT routine after the rotation, tactics and\n\\                       scanner code\n\\\n\\ ******************************************************************************\n\n.MV45\n\n LDA DELTA              \\ Set R to our speed in DELTA\n STA R\n\n LDA #%10000000         \\ Set A to zeroes but with bit 7 set, so that (A R) is\n                        \\ a 16-bit number containing -R, or -speed\n\n LDX #6                 \\ Set X to the z-axis so the call to MVT1 does this:\n JSR MVT1               \\\n                        \\ (z_sign z_hi z_lo) = (z_sign z_hi z_lo) + (A R)\n                        \\                    = (z_sign z_hi z_lo) - speed\n\n LDA TYPE               \\ If the ship type is not the sun (129) then skip the\n AND #%10000001         \\ next instruction, otherwise return from the subroutine\n CMP #129               \\ as we don't need to rotate the sun around its origin.\n BNE P%+3               \\ Having both the AND and the CMP is a little odd, as\n                        \\ the sun is the only ship type with bits 0 and 7 set,\n                        \\ so the AND has no effect and could be removed\n\n RTS                    \\ Return from the subroutine, as the ship we are moving\n                        \\ is the sun and doesn't need any of the following\n\n\\ ******************************************************************************\n\\\n\\       Name: MVEIT (Part 7 of 9)\n\\       Type: Subroutine\n\\   Category: Moving\n\\    Summary: Move current ship: Rotate ship's orientation vectors by pitch/roll\n\\  Deep dive: Orientation vectors\n\\             Pitching and rolling\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine has multiple stages. This stage does the following:\n\\\n\\   * Rotate the ship's orientation vectors according to our pitch and roll\n\\\n\\ As with the previous step, this is all about moving the other ships rather\n\\ than us (even though we are the one doing the moving). So we rotate the\n\\ current ship's orientation vectors (which defines its orientation in space),\n\\ by the angles we are \"moving\" the rest of the sky through (alpha and beta, our\n\\ roll and pitch), so the ship appears to us to be stationary while we rotate.\n\\\n\\ ******************************************************************************\n\n LDY #9                 \\ Apply our pitch and roll rotations to the current\n JSR MVS4               \\ ship's nosev vector\n\n LDY #15                \\ Apply our pitch and roll rotations to the current\n JSR MVS4               \\ ship's roofv vector\n\n LDY #21                \\ Apply our pitch and roll rotations to the current\n JSR MVS4               \\ ship's sidev vector\n\n\\ ******************************************************************************\n\\\n\\       Name: MVEIT (Part 8 of 9)\n\\       Type: Subroutine\n\\   Category: Moving\n\\    Summary: Move current ship: Rotate ship about itself by its own pitch/roll\n\\  Deep dive: Orientation vectors\n\\             Pitching and rolling by a fixed angle\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine has multiple stages. This stage does the following:\n\\\n\\   * If the ship we are processing is rolling or pitching itself, rotate it and\n\\     apply damping if required\n\\\n\\ ******************************************************************************\n\n LDA INWK+30            \\ Fetch the ship's pitch counter and extract the sign\n AND #%10000000         \\ into RAT2\n STA RAT2\n\n LDA INWK+30            \\ Fetch the ship's pitch counter and extract the value\n AND #%01111111         \\ without the sign bit into A\n\n BEQ MV8                \\ If the pitch counter is 0, then jump to MV8 to skip\n                        \\ the following, as the ship is not pitching\n\n CMP #%01111111         \\ If bits 0-6 are set in the pitch counter (i.e. the\n                        \\ ship's pitch is not damping down), then the C flag\n                        \\ will be set by this instruction\n\n SBC #0                 \\ Set A = A - 0 - (1 - C), so if we are damping then we\n                        \\ reduce A by 1, otherwise it is unchanged\n\n ORA RAT2               \\ Change bit 7 of A to the sign we saved in RAT2, so\n                        \\ the updated pitch counter in A retains its sign\n\n STA INWK+30            \\ Store the updated pitch counter in byte #30\n\n LDX #15                \\ Rotate (roofv_x, nosev_x) by a small angle (pitch)\n LDY #9\n JSR MVS5\n\n LDX #17                \\ Rotate (roofv_y, nosev_y) by a small angle (pitch)\n LDY #11\n JSR MVS5\n\n LDX #19                \\ Rotate (roofv_z, nosev_z) by a small angle (pitch)\n LDY #13\n JSR MVS5\n\n.MV8\n\n LDA INWK+29            \\ Fetch the ship's roll counter and extract the sign\n AND #%10000000         \\ into RAT2\n STA RAT2\n\n LDA INWK+29            \\ Fetch the ship's roll counter and extract the value\n AND #%01111111         \\ without the sign bit into A\n\n BEQ MV5                \\ If the roll counter is 0, then jump to MV5 to skip the\n                        \\ following, as the ship is not rolling\n\n CMP #%01111111         \\ If bits 0-6 are set in the roll counter (i.e. the\n                        \\ ship's roll is not damping down), then the C flag\n                        \\ will be set by this instruction\n\n SBC #0                 \\ Set A = A - 0 - (1 - C), so if we are damping then we\n                        \\ reduce A by 1, otherwise it is unchanged\n\n ORA RAT2               \\ Change bit 7 of A to the sign we saved in RAT2, so\n                        \\ the updated roll counter in A retains its sign\n\n STA INWK+29            \\ Store the updated pitch counter in byte #29\n\n LDX #15                \\ Rotate (roofv_x, sidev_x) by a small angle (roll)\n LDY #21\n JSR MVS5\n\n LDX #17                \\ Rotate (roofv_y, sidev_y) by a small angle (roll)\n LDY #23\n JSR MVS5\n\n LDX #19                \\ Rotate (roofv_z, sidev_z) by a small angle (roll)\n LDY #25\n JSR MVS5\n\n\\ ******************************************************************************\n\\\n\\       Name: MVEIT (Part 9 of 9)\n\\       Type: Subroutine\n\\   Category: Moving\n\\    Summary: Move current ship: Redraw on scanner, if it hasn't been destroyed\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine has multiple stages. This stage does the following:\n\\\n\\   * If the ship is exploding or being removed, hide it on the scanner\n\\\n\\   * Otherwise redraw the ship on the scanner, now that it's been moved\n\\\n\\ ******************************************************************************\n\n.MV5\n\n LDA INWK+31            \\ Fetch the ship's exploding/killed state from byte #31\n\n AND #%10100000         \\ If we are exploding or removing this ship then jump to\n BNE MVD1               \\ MVD1 to remove it from the scanner permanently\n\n LDA INWK+31            \\ Set bit 4 to keep the ship visible on the scanner\n ORA #%00010000\n STA INWK+31\n\n JMP SCAN               \\ Display the ship on the scanner, returning from the\n                        \\ subroutine using a tail call\n\n.MVD1\n\n LDA INWK+31            \\ Clear bit 4 to hide the ship on the scanner\n AND #%11101111\n STA INWK+31\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: MVT1\n\\       Type: Subroutine\n\\   Category: Moving\n\\    Summary: Calculate (x_sign x_hi x_lo) = (x_sign x_hi x_lo) + (A R)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Add the signed delta (A R) to a ship's coordinate, along the axis given in X.\n\\ Mathematically speaking, this routine translates the ship along a single axis\n\\ by a signed delta. Taking the example of X = 0, the x-axis, it does the\n\\ following:\n\\\n\\   (x_sign x_hi x_lo) = (x_sign x_hi x_lo) + (A R)\n\\\n\\ (In practice, MVT1 is only ever called directly with A = 0 or 128, otherwise\n\\ it is always called via MVT-2, which clears A apart from the sign bit. The\n\\ routine is written to cope with a non-zero delta_hi, so it supports a full\n\\ 16-bit delta, but it appears that delta_hi is only ever used to hold the\n\\ sign of the delta.)\n\\\n\\ The comments below assume we are adding delta to the x-axis, though the axis\n\\ is determined by the value of X.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   (A R)               The signed delta, so A = delta_hi and R = delta_lo\n\\\n\\   X                   Determines which coordinate axis of INWK to change:\n\\\n\\                         * X = 0 adds the delta to (x_lo, x_hi, x_sign)\n\\\n\\                         * X = 3 adds the delta to (y_lo, y_hi, y_sign)\n\\\n\\                         * X = 6 adds the delta to (z_lo, z_hi, z_sign)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   MVT1-2              Clear bits 0-6 of A before entering MVT1\n\\\n\\ ******************************************************************************\n\n AND #%10000000         \\ Clear bits 0-6 of A\n\n.MVT1\n\n ASL A                  \\ Set the C flag to the sign bit of the delta, leaving\n                        \\ delta_hi << 1 in A\n\n STA S                  \\ Set S = delta_hi << 1\n                        \\\n                        \\ This also clears bit 0 of S\n\n LDA #0                 \\ Set T = just the sign bit of delta (in bit 7)\n ROR A\n STA T\n\n LSR S                  \\ Set S = delta_hi >> 1\n                        \\       = |delta_hi|\n                        \\\n                        \\ This also clear the C flag, as we know that bit 0 of\n                        \\ S was clear before the LSR\n\n EOR INWK+2,X           \\ If T EOR x_sign has bit 7 set, then x_sign and delta\n BMI MV10               \\ have different signs, so jump to MV10\n\n                        \\ At this point, we know x_sign and delta have the same\n                        \\ sign, that sign is in T, and S contains |delta_hi|,\n                        \\ so now we want to do:\n                        \\\n                        \\   (x_sign x_hi x_lo) = (x_sign x_hi x_lo) + (S R)\n                        \\\n                        \\ and then set the sign of the result to the same sign\n                        \\ as x_sign and delta\n\n LDA R                  \\ First we add the low bytes, so:\n ADC INWK,X             \\\n STA INWK,X             \\   x_lo = x_lo + R\n\n LDA S                  \\ Then we add the high bytes:\n ADC INWK+1,X           \\\n STA INWK+1,X           \\   x_hi = x_hi + S\n\n LDA INWK+2,X           \\ And finally we add any carry into x_sign, and if the\n ADC #0                 \\ sign of x_sign and delta in T is negative, make sure\n ORA T                  \\ the result is negative (by OR'ing with T)\n STA INWK+2,X\n\n RTS                    \\ Return from the subroutine\n\n.MV10\n\n                        \\ If we get here, we know x_sign and delta have\n                        \\ different signs, with delta's sign in T, and\n                        \\ |delta_hi| in S, so now we want to do:\n                        \\\n                        \\   (x_sign x_hi x_lo) = (x_sign x_hi x_lo) - (S R)\n                        \\\n                        \\ and then set the sign of the result according to\n                        \\ the signs of x_sign and delta\n\n LDA INWK,X             \\ First we subtract the low bytes, so:\n SEC                    \\\n SBC R                  \\   x_lo = x_lo - R\n STA INWK,X\n\n LDA INWK+1,X           \\ Then we subtract the high bytes:\n SBC S                  \\\n STA INWK+1,X           \\   x_hi = x_hi - S\n\n LDA INWK+2,X           \\ And finally we subtract any borrow from bits 0-6 of\n AND #%01111111         \\ x_sign, and give the result the opposite sign bit to T\n SBC #0                 \\ (i.e. give it the sign of the original x_sign)\n ORA #%10000000\n EOR T\n STA INWK+2,X\n\n BCS MV11               \\ If the C flag is set by the above SBC, then our sum\n                        \\ above didn't underflow and is correct - to put it\n                        \\ another way, (x_sign x_hi x_lo) >= (S R) so the result\n                        \\ should indeed have the same sign as x_sign, so jump to\n                        \\ MV11 to return from the subroutine\n\n                        \\ Otherwise our subtraction underflowed because\n                        \\ (x_sign x_hi x_lo) < (S R), so we now need to flip the\n                        \\ subtraction around by using two's complement to this:\n                        \\\n                        \\   (S R) - (x_sign x_hi x_lo)\n                        \\\n                        \\ and then we need to give the result the same sign as\n                        \\ (S R), the delta, as that's the dominant figure in the\n                        \\ sum\n\n LDA #1                 \\ First we subtract the low bytes, so:\n SBC INWK,X             \\\n STA INWK,X             \\   x_lo = 1 - x_lo\n\n LDA #0                 \\ Then we subtract the high bytes:\n SBC INWK+1,X           \\\n STA INWK+1,X           \\   x_hi = 0 - x_hi\n\n LDA #0                 \\ And then we subtract the sign bytes:\n SBC INWK+2,X           \\\n                        \\   x_sign = 0 - x_sign\n\n AND #%01111111         \\ Finally, we set the sign bit to the sign in T, the\n ORA T                  \\ sign of the original delta, as the delta is the\n STA INWK+2,X           \\ dominant figure in the sum\n\n.MV11\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: MVT3\n\\       Type: Subroutine\n\\   Category: Moving\n\\    Summary: Calculate K(3 2 1) = (x_sign x_hi x_lo) + K(3 2 1)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Add an INWK position coordinate - i.e. x, y or z - to K(3 2 1), like this:\n\\\n\\   K(3 2 1) = (x_sign x_hi x_lo) + K(3 2 1)\n\\\n\\ The INWK coordinate to add to K(3 2 1) is specified by X.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   The coordinate to add to K(3 2 1), as follows:\n\\\n\\                         * If X = 0, add (x_sign x_hi x_lo)\n\\\n\\                         * If X = 3, add (y_sign y_hi y_lo)\n\\\n\\                         * If X = 6, add (z_sign z_hi z_lo)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   A                   Contains a copy of the high byte of the result, K+3\n\\\n\\   X                   X is preserved\n\\\n\\ ******************************************************************************\n\n.MVT3\n\n LDA K+3                \\ Set S = K+3\n STA S\n\n AND #%10000000         \\ Set T = sign bit of K(3 2 1)\n STA T\n\n EOR INWK+2,X           \\ If x_sign has a different sign to K(3 2 1), jump to\n BMI MV13               \\ MV13 to process the addition as a subtraction\n\n LDA K+1                \\ Set K(3 2 1) = K(3 2 1) + (x_sign x_hi x_lo)\n CLC                    \\ starting with the low bytes\n ADC INWK,X\n STA K+1\n\n LDA K+2                \\ Then the middle bytes\n ADC INWK+1,X\n STA K+2\n\n LDA K+3                \\ And finally the high bytes\n ADC INWK+2,X\n\n AND #%01111111         \\ Setting the sign bit of K+3 to T, the original sign\n ORA T                  \\ of K(3 2 1)\n STA K+3\n\n RTS                    \\ Return from the subroutine\n\n.MV13\n\n LDA S                  \\ Set S = |K+3| (i.e. K+3 with the sign bit cleared)\n AND #%01111111\n STA S\n\n LDA INWK,X             \\ Set K(3 2 1) = (x_sign x_hi x_lo) - K(3 2 1)\n SEC                    \\ starting with the low bytes\n SBC K+1\n STA K+1\n\n LDA INWK+1,X           \\ Then the middle bytes\n SBC K+2\n STA K+2\n\n LDA INWK+2,X           \\ And finally the high bytes, doing A = |x_sign| - |K+3|\n AND #%01111111         \\ and setting the C flag for testing below\n SBC S\n\n ORA #%10000000         \\ Set the sign bit of K+3 to the opposite sign of T,\n EOR T                  \\ i.e. the opposite sign to the original K(3 2 1)\n STA K+3\n\n BCS MV14               \\ If the C flag is set, i.e. |x_sign| >= |K+3|, then\n                        \\ the sign of K(3 2 1). In this case, we want the\n                        \\ result to have the same sign as the largest argument,\n                        \\ which is (x_sign x_hi x_lo), which we know has the\n                        \\ opposite sign to K(3 2 1), and that's what we just set\n                        \\ the sign of K(3 2 1) to... so we can jump to MV14 to\n                        \\ return from the subroutine\n\n LDA #1                 \\ We need to swap the sign of the result in K(3 2 1),\n SBC K+1                \\ which we do by calculating 0 - K(3 2 1), which we can\n STA K+1                \\ do with 1 - C - K(3 2 1), as we know the C flag is\n                        \\ clear. We start with the low bytes\n\n LDA #0                 \\ Then the middle bytes\n SBC K+2\n STA K+2\n\n LDA #0                 \\ And finally the high bytes\n SBC K+3\n\n AND #%01111111         \\ Set the sign bit of K+3 to the same sign as T,\n ORA T                  \\ i.e. the same sign as the original K(3 2 1), as\n STA K+3                \\ that's the largest argument\n\n.MV14\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: MVS4\n\\       Type: Subroutine\n\\   Category: Moving\n\\    Summary: Apply pitch and roll to an orientation vector\n\\  Deep dive: Orientation vectors\n\\             Pitching and rolling\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Apply pitch and roll angles alpha and beta to the orientation vector in Y.\n\\\n\\ Specifically, this routine rotates a point (x, y, z) around the origin by\n\\ pitch alpha and roll beta, using the small angle approximation to make the\n\\ maths easier, and incorporating the Minsky circle algorithm to make the\n\\ rotation more stable (though more elliptic).\n\\\n\\ If that paragraph makes sense to you, then you should probably be writing\n\\ this commentary! For the rest of us, see the associated deep dives.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   Y                   Determines which of the INWK orientation vectors to\n\\                       transform:\n\\\n\\                         * Y = 9 rotates nosev: (nosev_x, nosev_y, nosev_z)\n\\\n\\                         * Y = 15 rotates roofv: (roofv_x, roofv_y, roofv_z)\n\\\n\\                         * Y = 21 rotates sidev: (sidev_x, sidev_y, sidev_z)\n\\\n\\ ******************************************************************************\n\n.MVS4\n\n LDA ALPHA              \\ Set Q = alpha (the roll angle to rotate through)\n STA Q\n\n LDX INWK+2,Y           \\ Set (S R) = nosev_y\n STX R\n LDX INWK+3,Y\n STX S\n\n LDX INWK,Y             \\ These instructions have no effect as MAD overwrites\n STX P                  \\ X and P when called, but they set X = P = nosev_x_lo\n\n LDA INWK+1,Y           \\ Set A = -nosev_x_hi\n EOR #%10000000\n\n JSR MAD                \\ Set (A X) = Q * A + (S R)\n STA INWK+3,Y           \\           = alpha * -nosev_x_hi + nosev_y\n STX INWK+2,Y           \\\n                        \\ and store (A X) in nosev_y, so this does:\n                        \\\n                        \\ nosev_y = nosev_y - alpha * nosev_x_hi\n\n STX P                  \\ This instruction has no effect as MAD overwrites P,\n                        \\ but it sets P = nosev_y_lo\n\n LDX INWK,Y             \\ Set (S R) = nosev_x\n STX R\n LDX INWK+1,Y\n STX S\n\n LDA INWK+3,Y           \\ Set A = nosev_y_hi\n\n JSR MAD                \\ Set (A X) = Q * A + (S R)\n STA INWK+1,Y           \\           = alpha * nosev_y_hi + nosev_x\n STX INWK,Y             \\\n                        \\ and store (A X) in nosev_x, so this does:\n                        \\\n                        \\ nosev_x = nosev_x + alpha * nosev_y_hi\n\n STX P                  \\ This instruction has no effect as MAD overwrites P,\n                        \\ but it sets P = nosev_x_lo\n\n LDA BETA               \\ Set Q = beta (the pitch angle to rotate through)\n STA Q\n\n LDX INWK+2,Y           \\ Set (S R) = nosev_y\n STX R\n LDX INWK+3,Y\n STX S\n LDX INWK+4,Y\n\n STX P                  \\ This instruction has no effect as MAD overwrites P,\n                        \\ but it sets P = nosev_y\n\n LDA INWK+5,Y           \\ Set A = -nosev_z_hi\n EOR #%10000000\n\n JSR MAD                \\ Set (A X) = Q * A + (S R)\n STA INWK+3,Y           \\           = beta * -nosev_z_hi + nosev_y\n STX INWK+2,Y           \\\n                        \\ and store (A X) in nosev_y, so this does:\n                        \\\n                        \\ nosev_y = nosev_y - beta * nosev_z_hi\n\n STX P                  \\ This instruction has no effect as MAD overwrites P,\n                        \\ but it sets P = nosev_y_lo\n\n LDX INWK+4,Y           \\ Set (S R) = nosev_z\n STX R\n LDX INWK+5,Y\n STX S\n\n LDA INWK+3,Y           \\ Set A = nosev_y_hi\n\n JSR MAD                \\ Set (A X) = Q * A + (S R)\n STA INWK+5,Y           \\           = beta * nosev_y_hi + nosev_z\n STX INWK+4,Y           \\\n                        \\ and store (A X) in nosev_z, so this does:\n                        \\\n                        \\ nosev_z = nosev_z + beta * nosev_y_hi\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: MVS5\n\\       Type: Subroutine\n\\   Category: Moving\n\\    Summary: Apply a 3.6 degree pitch or roll to an orientation vector\n\\  Deep dive: Orientation vectors\n\\             Pitching and rolling by a fixed angle\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Pitch or roll a ship by a small, fixed amount (1/16 radians, or 3.6 degrees),\n\\ in a specified direction, by rotating the orientation vectors. The vectors to\n\\ rotate are given in X and Y, and the direction of the rotation is given in\n\\ RAT2. The calculation is as follows:\n\\\n\\   * If the direction is positive:\n\\\n\\     X = X * (1 - 1/512) + Y / 16\n\\     Y = Y * (1 - 1/512) - X / 16\n\\\n\\   * If the direction is negative:\n\\\n\\     X = X * (1 - 1/512) - Y / 16\n\\     Y = Y * (1 - 1/512) + X / 16\n\\\n\\ So if X = 15 (roofv_x), Y = 21 (sidev_x) and RAT2 is positive, it does this:\n\\\n\\   roofv_x = roofv_x * (1 - 1/512)  + sidev_x / 16\n\\   sidev_x = sidev_x * (1 - 1/512)  - roofv_x / 16\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   The first vector to rotate:\n\\\n\\                         * If X = 15, rotate roofv_x\n\\\n\\                         * If X = 17, rotate roofv_y\n\\\n\\                         * If X = 19, rotate roofv_z\n\\\n\\                         * If X = 21, rotate sidev_x\n\\\n\\                         * If X = 23, rotate sidev_y\n\\\n\\                         * If X = 25, rotate sidev_z\n\\\n\\   Y                   The second vector to rotate:\n\\\n\\                         * If Y = 9,  rotate nosev_x\n\\\n\\                         * If Y = 11, rotate nosev_y\n\\\n\\                         * If Y = 13, rotate nosev_z\n\\\n\\                         * If Y = 21, rotate sidev_x\n\\\n\\                         * If Y = 23, rotate sidev_y\n\\\n\\                         * If Y = 25, rotate sidev_z\n\\\n\\   RAT2                The direction of the pitch or roll to perform, positive\n\\                       or negative (i.e. the sign of the roll or pitch counter\n\\                       in bit 7)\n\\\n\\ ******************************************************************************\n\n.MVS5\n\n LDA INWK+1,X           \\ Fetch roofv_x_hi, clear the sign bit, divide by 2 and\n AND #%01111111         \\ store in T, so:\n LSR A                  \\\n STA T                  \\ T = |roofv_x_hi| / 2\n                        \\   = |roofv_x| / 512\n                        \\\n                        \\ The above is true because:\n                        \\\n                        \\ |roofv_x| = |roofv_x_hi| * 256 + roofv_x_lo\n                        \\\n                        \\ so:\n                        \\\n                        \\ |roofv_x| / 512 = |roofv_x_hi| * 256 / 512\n                        \\                    + roofv_x_lo / 512\n                        \\                  = |roofv_x_hi| / 2\n\n LDA INWK,X             \\ Now we do the following subtraction:\n SEC                    \\\n SBC T                  \\ (S R) = (roofv_x_hi roofv_x_lo) - |roofv_x| / 512\n STA R                  \\       = (1 - 1/512) * roofv_x\n                        \\\n                        \\ by doing the low bytes first\n\n LDA INWK+1,X           \\ And then the high bytes (the high byte of the right\n SBC #0                 \\ side of the subtraction being 0)\n STA S\n\n LDA INWK,Y             \\ Set P = nosev_x_lo\n STA P\n\n LDA INWK+1,Y           \\ Fetch the sign of nosev_x_hi (bit 7) and store in T\n AND #%10000000\n STA T\n\n LDA INWK+1,Y           \\ Fetch nosev_x_hi into A and clear the sign bit, so\n AND #%01111111         \\ A = |nosev_x_hi|\n\n LSR A                  \\ Set (A P) = (A P) / 16\n ROR P                  \\           = |nosev_x_hi nosev_x_lo| / 16\n LSR A                  \\           = |nosev_x| / 16\n ROR P\n LSR A\n ROR P\n LSR A\n ROR P\n\n ORA T                  \\ Set the sign of A to the sign in T (i.e. the sign of\n                        \\ the original nosev_x), so now:\n                        \\\n                        \\ (A P) = nosev_x / 16\n\n EOR RAT2               \\ Give it the sign as if we multiplied by the direction\n                        \\ by the pitch or roll direction\n\n STX Q                  \\ Store the value of X so it can be restored after the\n                        \\ call to ADD\n\n JSR ADD                \\ (A X) = (A P) + (S R)\n                        \\       = +/-nosev_x / 16 + (1 - 1/512) * roofv_x\n\n STA K+1                \\ Set K(1 0) = (1 - 1/512) * roofv_x +/- nosev_x / 16\n STX K\n\n LDX Q                  \\ Restore the value of X from before the call to ADD\n\n LDA INWK+1,Y           \\ Fetch nosev_x_hi, clear the sign bit, divide by 2 and\n AND #%01111111         \\ store in T, so:\n LSR A                  \\\n STA T                  \\ T = |nosev_x_hi| / 2\n                        \\   = |nosev_x| / 512\n\n LDA INWK,Y             \\ Now we do the following subtraction:\n SEC                    \\\n SBC T                  \\ (S R) = (nosev_x_hi nosev_x_lo) - |nosev_x| / 512\n STA R                  \\       = (1 - 1/512) * nosev_x\n                        \\\n                        \\ by doing the low bytes first\n\n LDA INWK+1,Y           \\ And then the high bytes (the high byte of the right\n SBC #0                 \\ side of the subtraction being 0)\n STA S\n\n LDA INWK,X             \\ Set P = roofv_x_lo\n STA P\n\n LDA INWK+1,X           \\ Fetch the sign of roofv_x_hi (bit 7) and store in T\n AND #%10000000\n STA T\n\n LDA INWK+1,X           \\ Fetch roofv_x_hi into A and clear the sign bit, so\n AND #%01111111         \\ A = |roofv_x_hi|\n\n LSR A                  \\ Set (A P) = (A P) / 16\n ROR P                  \\           = |roofv_x_hi roofv_x_lo| / 16\n LSR A                  \\           = |roofv_x| / 16\n ROR P\n LSR A\n ROR P\n LSR A\n ROR P\n\n ORA T                  \\ Set the sign of A to the opposite sign to T (i.e. the\n EOR #%10000000         \\ sign of the original -roofv_x), so now:\n                        \\\n                        \\ (A P) = -roofv_x / 16\n\n EOR RAT2               \\ Give it the sign as if we multiplied by the direction\n                        \\ by the pitch or roll direction\n\n STX Q                  \\ Store the value of X so it can be restored after the\n                        \\ call to ADD\n\n JSR ADD                \\ (A X) = (A P) + (S R)\n                        \\       = -/+roofv_x / 16 + (1 - 1/512) * nosev_x\n\n STA INWK+1,Y           \\ Set nosev_x = (1-1/512) * nosev_x -/+ roofv_x / 16\n STX INWK,Y\n\n LDX Q                  \\ Restore the value of X from before the call to ADD\n\n LDA K                  \\ Set roofv_x = K(1 0)\n STA INWK,X             \\             = (1-1/512) * roofv_x +/- nosev_x / 16\n LDA K+1\n STA INWK+1,X\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: MVT6\n\\       Type: Subroutine\n\\   Category: Moving\n\\    Summary: Calculate (A P+2 P+1) = (x_sign x_hi x_lo) + (A P+2 P+1)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Do the following calculation, for the coordinate given by X (so this is what\n\\ it does for the x-coordinate):\n\\\n\\   (A P+2 P+1) = (x_sign x_hi x_lo) + (A P+2 P+1)\n\\\n\\ A is a sign bit and is not included in the calculation, but bits 0-6 of A are\n\\ preserved. Bit 7 is set to the sign of the result.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The sign of P(2 1) in bit 7\n\\\n\\   P(2 1)              The 16-bit value we want to add the coordinate to\n\\\n\\   X                   The coordinate to add, as follows:\n\\\n\\                         * If X = 0, add to (x_sign x_hi x_lo)\n\\\n\\                         * If X = 3, add to (y_sign y_hi y_lo)\n\\\n\\                         * If X = 6, add to (z_sign z_hi z_lo)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   A                   The sign of the result (in bit 7)\n\\\n\\ ******************************************************************************\n\n.MVT6\n\n TAY                    \\ Store argument A into Y, for later use\n\n EOR INWK+2,X           \\ Set A = A EOR x_sign\n\n BMI MV50               \\ If the sign is negative, i.e. A and x_sign have\n                        \\ different signs, jump to MV50\n\n                        \\ The signs are the same, so we can add the two\n                        \\ arguments and keep the sign to get the result\n\n LDA P+1                \\ First we add the low bytes:\n CLC                    \\\n ADC INWK,X             \\   P+1 = P+1 + x_lo\n STA P+1\n\n LDA P+2                \\ And then the high bytes:\n ADC INWK+1,X           \\\n STA P+2                \\   P+2 = P+2 + x_hi\n\n TYA                    \\ Restore the original A argument that we stored earlier\n                        \\ so that we keep the original sign\n\n RTS                    \\ Return from the subroutine\n\n.MV50\n\n LDA INWK,X             \\ First we subtract the low bytes:\n SEC                    \\\n SBC P+1                \\   P+1 = x_lo - P+1\n STA P+1\n\n LDA INWK+1,X           \\ And then the high bytes:\n SBC P+2                \\\n STA P+2                \\   P+2 = x_hi - P+2\n\n BCC MV51               \\ If the last subtraction underflowed, then the C flag\n                        \\ will be clear and x_hi < P+2, so jump to MV51 to\n                        \\ negate the result\n\n TYA                    \\ Restore the original A argument that we stored earlier\n EOR #%10000000         \\ but flip bit 7, which flips the sign. We do this\n                        \\ because x_hi >= P+2 so we want the result to have the\n                        \\ same sign as x_hi (as it's the dominant side in this\n                        \\ calculation). The sign of x_hi is x_sign, and x_sign\n                        \\ has the opposite sign to A, so we flip the sign in A\n                        \\ to return the correct result\n\n RTS                    \\ Return from the subroutine\n\n.MV51\n\n LDA #1                 \\ Our subtraction underflowed, so we negate the result\n SBC P+1                \\ using two's complement, first with the low byte:\n STA P+1                \\\n                        \\   P+1 = 1 - P+1\n\n LDA #0                 \\ And then the high byte:\n SBC P+2                \\\n STA P+2                \\   P+2 = 0 - P+2\n\n TYA                    \\ Restore the original A argument that we stored earlier\n                        \\ as this is the correct sign for the result. This is\n                        \\ because x_hi < P+2, so we want to return the same sign\n                        \\ as P+2, the dominant side\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: MV40\n\\       Type: Subroutine\n\\   Category: Moving\n\\    Summary: Rotate the planet or sun's location in space by the amount of\n\\             pitch and roll of our ship\n\\  Deep dive: Rotating the universe\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ We implement this using the same equations as in part 5 of MVEIT, where we\n\\ rotated the current ship's location by our pitch and roll. Specifically, the\n\\ calculation is as follows:\n\\\n\\   1. K2 = y - alpha * x\n\\   2. z = z + beta * K2\n\\   3. y = K2 - beta * z\n\\   4. x = x + alpha * y\n\\\n\\ ******************************************************************************\n\n.MV40\n\n LDA ALPHA              \\ Set Q = -ALPHA, so Q contains the angle we want to\n EOR #%10000000         \\ roll the planet through (i.e. in the opposite\n STA Q                  \\ direction to our ship's roll angle alpha)\n\n LDA INWK               \\ Set P(1 0) = (x_hi x_lo)\n STA P\n LDA INWK+1\n STA P+1\n\n LDA INWK+2             \\ Set A = x_sign\n\n JSR MULT3              \\ Set K(3 2 1 0) = (A P+1 P) * Q\n                        \\\n                        \\ which also means:\n                        \\\n                        \\   K(3 2 1) = (A P+1 P) * Q / 256\n                        \\            = x * -alpha / 256\n                        \\            = - alpha * x / 256\n\n LDX #3                 \\ Set K(3 2 1) = (y_sign y_hi y_lo) + K(3 2 1)\n JSR MVT3               \\              = y - alpha * x / 256\n\n LDA K+1                \\ Set K2(2 1) = P(1 0) = K(2 1)\n STA K2+1\n STA P\n\n LDA K+2                \\ Set K2+2 = K+2\n STA K2+2\n\n STA P+1                \\ Set P+1 = K+2\n\n LDA BETA               \\ Set Q = beta, the pitch angle of our ship\n STA Q\n\n LDA K+3                \\ Set K+3 to K2+3, so now we have result 1 above:\n STA K2+3               \\\n                        \\   K2(3 2 1) = K(3 2 1)\n                        \\             = y - alpha * x / 256\n\n                        \\ We also have:\n                        \\\n                        \\   A = K+3\n                        \\\n                        \\   P(1 0) = K(2 1)\n                        \\\n                        \\ so combined, these mean:\n                        \\\n                        \\   (A P+1 P) = K(3 2 1)\n                        \\             = K2(3 2 1)\n\n JSR MULT3              \\ Set K(3 2 1 0) = (A P+1 P) * Q\n                        \\\n                        \\ which also means:\n                        \\\n                        \\   K(3 2 1) = (A P+1 P) * Q / 256\n                        \\            = K2(3 2 1) * beta / 256\n                        \\            = beta * K2 / 256\n\n LDX #6                 \\ K(3 2 1) = (z_sign z_hi z_lo) + K(3 2 1)\n JSR MVT3               \\          = z + beta * K2 / 256\n\n LDA K+1                \\ Set P = K+1\n STA P\n\n STA INWK+6             \\ Set z_lo = K+1\n\n LDA K+2                \\ Set P+1 = K+2\n STA P+1\n\n STA INWK+7             \\ Set z_hi = K+2\n\n LDA K+3                \\ Set A = z_sign = K+3, so now we have:\n STA INWK+8             \\\n                        \\   (z_sign z_hi z_lo) = K(3 2 1)\n                        \\                      = z + beta * K2 / 256\n\n                        \\ So we now have result 2 above:\n                        \\\n                        \\   z = z + beta * K2\n\n EOR #%10000000         \\ Flip the sign bit of A to give A = -z_sign\n\n JSR MULT3              \\ Set K(3 2 1 0) = (A P+1 P) * Q\n                        \\                = (-z_sign z_hi z_lo) * beta\n                        \\                = -z * beta\n\n LDA K+3                \\ Set T to the sign bit of K(3 2 1 0), i.e. to the sign\n AND #%10000000         \\ bit of -z * beta\n STA T\n\n EOR K2+3               \\ If K2(3 2 1 0) has a different sign to K(3 2 1 0),\n BMI MV1                \\ then EOR'ing them will produce a 1 in bit 7, so jump\n                        \\ to MV1 to take this into account\n\n                        \\ If we get here, K and K2 have the same sign, so we can\n                        \\ add them together to get the result we're after, and\n                        \\ then set the sign afterwards\n\n LDA K                  \\ We now do the following sum:\n\\CLC                    \\\n ADC K2                 \\   (A y_hi y_lo -) = K(3 2 1 0) + K2(3 2 1 0)\n                        \\\n                        \\ starting with the low bytes (which we don't keep)\n                        \\\n                        \\ The CLC instruction is commented out in the original\n                        \\ source. It isn't needed because MULT3 clears the C\n                        \\ flag, so this is an example of the authors finding\n                        \\ one more precious byte to save\n\n LDA K+1                \\ We then do the middle bytes, which go into y_lo\n ADC K2+1\n STA INWK+3\n\n LDA K+2                \\ And then the high bytes, which go into y_hi\n ADC K2+2\n STA INWK+4\n\n LDA K+3                \\ And then the sign bytes into A, so overall we have the\n ADC K2+3               \\ following, if we drop the low bytes from the result:\n                        \\\n                        \\   (A y_hi y_lo) = (K + K2) / 256\n\n JMP MV2                \\ Jump to MV2 to skip the calculation for when K and K2\n                        \\ have different signs\n\n.MV1\n\n LDA K                  \\ If we get here then K2 and K have different signs, so\n SEC                    \\ instead of adding, we need to subtract to get the\n SBC K2                 \\ result we want, like this:\n                        \\\n                        \\   (A y_hi y_lo -) = K(3 2 1 0) - K2(3 2 1 0)\n                        \\\n                        \\ starting with the low bytes (which we don't keep)\n\n LDA K+1                \\ We then do the middle bytes, which go into y_lo\n SBC K2+1\n STA INWK+3\n\n LDA K+2                \\ And then the high bytes, which go into y_hi\n SBC K2+2\n STA INWK+4\n\n LDA K2+3               \\ Now for the sign bytes, so first we extract the sign\n AND #%01111111         \\ byte from K2 without the sign bit, so P = |K2+3|\n STA P\n\n LDA K+3                \\ And then we extract the sign byte from K without the\n AND #%01111111         \\ sign bit, so A = |K+3|\n\n SBC P                  \\ And finally we subtract the sign bytes, so P = A - P\n STA P\n\n                        \\ By now we have the following, if we drop the low bytes\n                        \\ from the result:\n                        \\\n                        \\   (A y_hi y_lo) = (K - K2) / 256\n                        \\\n                        \\ so now we just need to make sure the sign of the\n                        \\ result is correct\n\n BCS MV2                \\ If the C flag is set, then the last subtraction above\n                        \\ didn't underflow and the result is correct, so jump to\n                        \\ MV2 as we are done with this particular stage\n\n LDA #1                 \\ Otherwise the subtraction above underflowed, as K2 is\n SBC INWK+3             \\ the dominant part of the subtraction, so we need to\n STA INWK+3             \\ negate the result using two's complement, starting\n                        \\ with the low bytes:\n                        \\\n                        \\   y_lo = 1 - y_lo\n\n LDA #0                 \\ And then the high bytes:\n SBC INWK+4             \\\n STA INWK+4             \\   y_hi = 0 - y_hi\n\n LDA #0                 \\ And finally the sign bytes:\n SBC P                  \\\n                        \\   A = 0 - P\n\n ORA #%10000000         \\ We now force the sign bit to be negative, so that the\n                        \\ final result below gets the opposite sign to K, which\n                        \\ we want as K2 is the dominant part of the sum\n\n.MV2\n\n EOR T                  \\ T contains the sign bit of K, so if K is negative,\n                        \\ this flips the sign of A\n\n STA INWK+5             \\ Store A in y_sign\n\n                        \\ So we now have result 3 above:\n                        \\\n                        \\   y = K2 + K\n                        \\     = K2 - beta * z\n\n LDA ALPHA              \\ Set A = alpha\n STA Q\n\n LDA INWK+3             \\ Set P(1 0) = (y_hi y_lo)\n STA P\n LDA INWK+4\n STA P+1\n\n LDA INWK+5             \\ Set A = y_sign\n\n JSR MULT3              \\ Set K(3 2 1 0) = (A P+1 P) * Q\n                        \\                = (y_sign y_hi y_lo) * alpha\n                        \\                = y * alpha\n\n LDX #0                 \\ Set K(3 2 1) = (x_sign x_hi x_lo) + K(3 2 1)\n JSR MVT3               \\              = x + y * alpha / 256\n\n LDA K+1                \\ Set (x_sign x_hi x_lo) = K(3 2 1)\n STA INWK               \\                        = x + y * alpha / 256\n LDA K+2\n STA INWK+1\n LDA K+3\n STA INWK+2\n\n                        \\ So we now have result 4 above:\n                        \\\n                        \\   x = x + y * alpha\n\n JMP MV45               \\ We have now finished rotating the planet or sun by\n                        \\ our pitch and roll, so jump back into the MVEIT\n                        \\ routine at MV45 to apply all the other movements\n\n\\ ******************************************************************************\n\\\n\\ Save ELTA.bin\n\\\n\\ ******************************************************************************\n\n PRINT \"ELITE A\"\n PRINT \"Assembled at \", ~CODE%\n PRINT \"Ends at \", ~P%\n PRINT \"Code size is \", ~(P% - CODE%)\n PRINT \"Execute at \", ~LOAD%\n PRINT \"Reload at \", ~LOAD_A%\n\n PRINT \"S.ELTA \", ~CODE%, \" \", ~P%, \" \", ~LOAD%, \" \", ~LOAD_A%\n SAVE \"3-assembled-output/ELTA.bin\", CODE%, P%, LOAD%\n\n\\ ******************************************************************************\n\\\n\\ ELITE B FILE\n\\\n\\ Produces the binary file ELTB.bin that gets loaded by elite-bcfs.asm.\n\\\n\\ ******************************************************************************\n\n CODE_B% = P%\n\n LOAD_B% = LOAD% + P% - CODE%\n\n\\ ******************************************************************************\n\\\n\\       Name: NA%\n\\       Type: Variable\n\\   Category: Save and load\n\\    Summary: The data block for the last saved commander\n\\  Deep dive: Commander save files\n\\             The competition code\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Contains the last saved commander data, with the name at NA% and the data at\n\\ NA%+8 onwards. The size of the data block is given in NT% (which also includes\n\\ the two checksum bytes that follow this block). This block is initially set up\n\\ with the default commander, which can be maxed out for testing purposes by\n\\ setting Q% to TRUE.\n\\\n\\ The commander's name is stored at NA%, and can be up to 7 characters long\n\\ (the DFS filename limit). It is terminated with a carriage return character,\n\\ ASCII 13.\n\\\n\\ The offset of each byte within a saved commander file is also shown as #0, #1\n\\ and so on, so the kill tally, for example, is in bytes #71 and #72 of the\n\\ saved file. The related variable name from the current commander block is\n\\ also shown.\n\\\n\\ ******************************************************************************\n\n.NA%\n\n EQUS \"JAMESON\"         \\ The current commander name, which defaults to JAMESON\n EQUB 13                \\\n                        \\ The commander name can be up to seven characters (the\n                        \\ DFS limit for filenames), and is terminated by a\n                        \\ carriage return\n\n                        \\ NA%+8 is the start of the commander data block\n                        \\\n                        \\ This block contains the last saved commander data\n                        \\ block. As the game is played it uses an identical\n                        \\ block at location TP to store the current commander\n                        \\ state, and that block is copied here when the game is\n                        \\ saved. Conversely, when the game starts up, the block\n                        \\ here is copied to TP, which restores the last saved\n                        \\ commander when we die\n                        \\\n                        \\ The initial state of this block defines the default\n                        \\ commander. Q% can be set to TRUE to give the default\n                        \\ commander lots of credits and equipment\n\n EQUB 0                 \\ TP = Mission status, #0\n\n EQUB 20                \\ QQ0 = Current system X-coordinate (Lave), #1\n EQUB 173               \\ QQ1 = Current system Y-coordinate (Lave), #2\n\n EQUW &5A4A             \\ QQ21 = Seed s0 for system 0, galaxy 0 (Tibedied), #3-4\n EQUW &0248             \\ QQ21 = Seed s1 for system 0, galaxy 0 (Tibedied), #5-6\n EQUW &B753             \\ QQ21 = Seed s2 for system 0, galaxy 0 (Tibedied), #7-8\n\nIF Q%\n EQUD &00CA9A3B         \\ CASH = Amount of cash (100,000,000 Cr), #9-12\nELSE\n EQUD &E8030000         \\ CASH = Amount of cash (100 Cr), #9-12\nENDIF\n\n EQUB 70                \\ QQ14 = Fuel level, #13\n\n EQUB 0                 \\ COK = Competition flags, #14\n\n EQUB 0                 \\ GCNT = Galaxy number, 0-7, #15\n\n EQUB POW+(128 AND Q%)  \\ LASER = Front laser, #16\n\n EQUB (POW+128) AND Q%  \\ LASER+1 = Rear laser, #17\n\n EQUB 0                 \\ LASER+2 = Left laser, #18\n\n EQUB 0                 \\ LASER+3 = Right laser, #19\n\n EQUW 0                 \\ These bytes appear to be unused (they were originally\n                        \\ used for up/down lasers, but they were dropped),\n                        \\ #20-21\n\n EQUB 22 + (15 AND Q%)  \\ CRGO = Cargo capacity, #22\n\n EQUB 0                 \\ QQ20+0  = Amount of food in cargo hold, #23\n EQUB 0                 \\ QQ20+1  = Amount of textiles in cargo hold, #24\n EQUB 0                 \\ QQ20+2  = Amount of radioactives in cargo hold, #25\n EQUB 0                 \\ QQ20+3  = Amount of slaves in cargo hold, #26\n EQUB 0                 \\ QQ20+4  = Amount of liquor/Wines in cargo hold, #27\n EQUB 0                 \\ QQ20+5  = Amount of luxuries in cargo hold, #28\n EQUB 0                 \\ QQ20+6  = Amount of narcotics in cargo hold, #29\n EQUB 0                 \\ QQ20+7  = Amount of computers in cargo hold, #30\n EQUB 0                 \\ QQ20+8  = Amount of machinery in cargo hold, #31\n EQUB 0                 \\ QQ20+9  = Amount of alloys in cargo hold, #32\n EQUB 0                 \\ QQ20+10 = Amount of firearms in cargo hold, #33\n EQUB 0                 \\ QQ20+11 = Amount of furs in cargo hold, #34\n EQUB 0                 \\ QQ20+12 = Amount of minerals in cargo hold, #35\n EQUB 0                 \\ QQ20+13 = Amount of gold in cargo hold, #36\n EQUB 0                 \\ QQ20+14 = Amount of platinum in cargo hold, #37\n EQUB 0                 \\ QQ20+15 = Amount of gem-stones in cargo hold, #38\n EQUB 0                 \\ QQ20+16 = Amount of alien items in cargo hold, #39\n\n EQUB Q%                \\ ECM = E.C.M. system, #40\n\n EQUB Q%                \\ BST = Fuel scoops (\"barrel status\"), #41\n\n EQUB Q% AND 127        \\ BOMB = Energy bomb, #42\n\n EQUB Q% AND 1          \\ ENGY = Energy/shield level, #43\n\n EQUB Q%                \\ DKCMP = Docking computer, #44\n\n EQUB Q%                \\ GHYP = Galactic hyperdrive, #45\n\n EQUB Q%                \\ ESCP = Escape pod, #46\n\n EQUD 0                 \\ These four bytes appear to be unused, #47-50\n\n EQUB 3 + (Q% AND 1)    \\ NOMSL = Number of missiles, #51\n\n EQUB 0                 \\ FIST = Legal status (\"fugitive/innocent status\"), #52\n\n EQUB 16                \\ AVL+0  = Market availability of food, #53\n EQUB 15                \\ AVL+1  = Market availability of textiles, #54\n EQUB 17                \\ AVL+2  = Market availability of radioactives, #55\n EQUB 0                 \\ AVL+3  = Market availability of slaves, #56\n EQUB 3                 \\ AVL+4  = Market availability of liquor/Wines, #57\n EQUB 28                \\ AVL+5  = Market availability of luxuries, #58\n EQUB 14                \\ AVL+6  = Market availability of narcotics, #59\n EQUB 0                 \\ AVL+7  = Market availability of computers, #60\n EQUB 0                 \\ AVL+8  = Market availability of machinery, #61\n EQUB 10                \\ AVL+9  = Market availability of alloys, #62\n EQUB 0                 \\ AVL+10 = Market availability of firearms, #63\n EQUB 17                \\ AVL+11 = Market availability of furs, #64\n EQUB 58                \\ AVL+12 = Market availability of minerals, #65\n EQUB 7                 \\ AVL+13 = Market availability of gold, #66\n EQUB 9                 \\ AVL+14 = Market availability of platinum, #67\n EQUB 8                 \\ AVL+15 = Market availability of gem-stones, #68\n EQUB 0                 \\ AVL+16 = Market availability of alien items, #69\n\n EQUB 0                 \\ QQ26 = Random byte that changes for each visit to a\n                        \\ system, for randomising market prices, #70\n\n EQUW 0                 \\ TALLY = Number of kills, #71-72\n\n EQUB 128               \\ SVC = Save count, #73\n\n\\ ******************************************************************************\n\\\n\\       Name: CHK2\n\\       Type: Variable\n\\   Category: Save and load\n\\    Summary: Second checksum byte for the saved commander data file\n\\  Deep dive: Commander save files\n\\             The competition code\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Second commander checksum byte. If the default commander is changed, a new\n\\ checksum will be calculated and inserted by the elite-checksum.py script.\n\\\n\\ The offset of this byte within a saved commander file is also shown (it's at\n\\ byte #74).\n\\\n\\ ******************************************************************************\n\n.CHK2\n\n EQUB &03 EOR &A9       \\ The checksum value for the default commander, EOR'd\n                        \\ with &A9 to make it harder to tamper with the checksum\n                        \\ byte, #74\n\n\\ ******************************************************************************\n\\\n\\       Name: CHK\n\\       Type: Variable\n\\   Category: Save and load\n\\    Summary: First checksum byte for the saved commander data file\n\\  Deep dive: Commander save files\n\\             The competition code\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Commander checksum byte. If the default commander is changed, a new checksum\n\\ will be calculated and inserted by the elite-checksum.py script.\n\\\n\\ The offset of this byte within a saved commander file is also shown (it's at\n\\ byte #75).\n\\\n\\ ******************************************************************************\n\n.CHK\n\n EQUB &03               \\ The checksum value for the default commander, #75\n\n\\ ******************************************************************************\n\\\n\\       Name: UNIV\n\\       Type: Variable\n\\   Category: Universe\n\\    Summary: Table of pointers to the local universe's ship data blocks\n\\  Deep dive: The local bubble of universe\n\\             Ship data blocks\n\\\n\\ ******************************************************************************\n\n.UNIV\n\n FOR I%, 0, NOSH\n\n  EQUW K% + I% * NI%    \\ Address of block no. I%, of size NI%, in workspace K%\n\n NEXT\n\n\\ ******************************************************************************\n\\\n\\       Name: TWOS\n\\       Type: Variable\n\\   Category: Drawing pixels\n\\    Summary: Ready-made single-pixel character row bytes for mode 4\n\\  Deep dive: Drawing monochrome pixels on the BBC Micro\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Ready-made bytes for plotting one-pixel points in mode 4 (the top part of the\n\\ split screen). See the PIXEL routine for details.\n\\\n\\ ******************************************************************************\n\n.TWOS\n\n EQUB %10000000\n EQUB %01000000\n EQUB %00100000\n EQUB %00010000\n EQUB %00001000\n EQUB %00000100\n EQUB %00000010\n EQUB %00000001\n\n\\ ******************************************************************************\n\\\n\\       Name: TWOS2\n\\       Type: Variable\n\\   Category: Drawing pixels\n\\    Summary: Ready-made double-pixel character row bytes for mode 4\n\\  Deep dive: Drawing monochrome pixels on the BBC Micro\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Ready-made bytes for plotting two-pixel dashes in mode 4 (the top part of the\n\\ split screen). See the PIXEL routine for details.\n\\\n\\ ******************************************************************************\n\n.TWOS2\n\n EQUB %11000000\n EQUB %01100000\n EQUB %00110000\n EQUB %00011000\n EQUB %00001100\n EQUB %00000110\n EQUB %00000011\n EQUB %00000011\n\n\\ ******************************************************************************\n\\\n\\       Name: CTWOS\n\\       Type: Variable\n\\   Category: Drawing pixels\n\\    Summary: Ready-made single-pixel character row bytes for mode 5\n\\  Deep dive: Drawing colour pixels on the BBC Micro\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Ready-made bytes for plotting one-pixel points in mode 5 (the bottom part of\n\\ the split screen). See the dashboard routines SCAN, DIL2 and CPIX2 for\n\\ details.\n\\\n\\ There is one extra row to support the use of CTWOS+1,X indexing in the CPIX2\n\\ routine. The extra row is a repeat of the first row, and saves us from having\n\\ to work out whether CTWOS+1+X needs to be wrapped around when drawing a\n\\ two-pixel dash that crosses from one character block into another. See CPIX2\n\\ for more details.\n\\\n\\ ******************************************************************************\n\n.CTWOS\n\n EQUB %10001000\n EQUB %01000100\n EQUB %00100010\n EQUB %00010001\n EQUB %10001000\n\n\\ ******************************************************************************\n\\\n\\       Name: LOIN (Part 1 of 7)\n\\       Type: Subroutine\n\\   Category: Drawing lines\n\\    Summary: Draw a line: Calculate the line gradient in the form of deltas\n\\  Deep dive: Bresenham's line algorithm\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine draws a line from (X1, Y1) to (X2, Y2). It has multiple stages.\n\\ This stage calculates the line deltas.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X1                  The screen x-coordinate of the start of the line\n\\\n\\   Y1                  The screen y-coordinate of the start of the line\n\\\n\\   X2                  The screen x-coordinate of the end of the line\n\\\n\\   Y2                  The screen y-coordinate of the end of the line\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   Y                   Y is preserved\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   LL30                LL30 is a synonym for LOIN and draws a line from\n\\                       (X1, Y1) to (X2, Y2)\n\\\n\\ ******************************************************************************\n\n.LL30\n\n SKIP 0                 \\ LL30 is a synonym for LOIN\n                        \\\n                        \\ In the BBC Micro cassette and disc versions of Elite,\n                        \\ LL30 and LOIN are synonyms for the same routine,\n                        \\ presumably because the two developers each had their\n                        \\ own line routines to start with, and then chose one of\n                        \\ them for the final game\n\n.LOIN\n\n STY YSAV               \\ Store Y into YSAV, so we can preserve it across the\n                        \\ call to this subroutine\n\n LDA #128               \\ Set S = 128, which is the starting point for the\n STA S                  \\ slope error (representing half a pixel)\n\n ASL A                  \\ Set SWAP = 0, as %10000000 << 1 = 0\n STA SWAP\n\n LDA X2                 \\ Set A = X2 - X1\n SBC X1                 \\       = delta_x\n                        \\\n                        \\ This subtraction works as the ASL A above sets the C\n                        \\ flag\n\n BCS LI1                \\ If X2 > X1 then A is already positive and we can skip\n                        \\ the next three instructions\n\n EOR #%11111111         \\ Negate the result in A by flipping all the bits and\n ADC #1                 \\ adding 1, i.e. using two's complement to make it\n                        \\ positive\n\n SEC                    \\ Set the C flag, ready for the subtraction below\n\n.LI1\n\n STA P                  \\ Store A in P, so P = |X2 - X1|, or |delta_x|\n\n LDA Y2                 \\ Set A = Y2 - Y1\n SBC Y1                 \\       = delta_y\n                        \\\n                        \\ This subtraction works as we either set the C flag\n                        \\ above, or we skipped that SEC instruction with a BCS\n\n BCS LI2                \\ If Y2 > Y1 then A is already positive and we can skip\n                        \\ the next two instructions\n\n EOR #%11111111         \\ Negate the result in A by flipping all the bits and\n ADC #1                 \\ adding 1, i.e. using two's complement to make it\n                        \\ positive\n\n.LI2\n\n STA Q                  \\ Store A in Q, so Q = |Y2 - Y1|, or |delta_y|\n\n CMP P                  \\ If Q < P, jump to STPX to step along the x-axis, as\n BCC STPX               \\ the line is closer to being horizontal than vertical\n\n JMP STPY               \\ Otherwise Q >= P so jump to STPY to step along the\n                        \\ y-axis, as the line is closer to being vertical than\n                        \\ horizontal\n\n\\ ******************************************************************************\n\\\n\\       Name: LOIN (Part 2 of 7)\n\\       Type: Subroutine\n\\   Category: Drawing lines\n\\    Summary: Draw a line: Line has a shallow gradient, step right along x-axis\n\\  Deep dive: Bresenham's line algorithm\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine draws a line from (X1, Y1) to (X2, Y2). It has multiple stages.\n\\ If we get here, then:\n\\\n\\   * |delta_y| < |delta_x|\n\\\n\\   * The line is closer to being horizontal than vertical\n\\\n\\   * We are going to step right along the x-axis\n\\\n\\   * We potentially swap coordinates to make sure X1 < X2\n\\\n\\ ******************************************************************************\n\n.STPX\n\n LDX X1                 \\ Set X = X1\n\n CPX X2                 \\ If X1 < X2, jump down to LI3, as the coordinates are\n BCC LI3                \\ already in the order that we want\n\n DEC SWAP               \\ Otherwise decrement SWAP from 0 to &FF, to denote that\n                        \\ we are swapping the coordinates around\n\n LDA X2                 \\ Swap the values of X1 and X2\n STA X1\n STX X2\n\n TAX                    \\ Set X = X1\n\n LDA Y2                 \\ Swap the values of Y1 and Y2\n LDY Y1\n STA Y1\n STY Y2\n\n.LI3\n\n                        \\ By this point we know the line is horizontal-ish and\n                        \\ X1 < X2, so we're going from left to right as we go\n                        \\ from X1 to X2\n\n LDA Y1                 \\ Set A to the y-coordinate in Y1\n\n LSR A                  \\ Set A = A >> 3\n LSR A                  \\       = y div 8\n LSR A                  \\\n                        \\ So A now contains the number of the character row\n                        \\ that will contain the start of the line\n\n ORA #&60               \\ As A < 32, this effectively adds &60 to A, which gives\n                        \\ us the screen address of the character row (as each\n                        \\ character row takes up 256 bytes, and the first\n                        \\ character row is at screen address &6000, or page &60)\n\n STA SCH                \\ Store the page number of the character row in SCH, so\n                        \\ the high byte of SC is set correctly for drawing the\n                        \\ start of our line\n\n LDA Y1                 \\ Set Y = Y1 mod 8, which is the pixel row within the\n AND #7                 \\ character block at which we want to draw the start of\n TAY                    \\ our line (as each character block has 8 rows)\n\n TXA                    \\ Set A = bits 3-7 of X1\n AND #%11111000\n\n STA SC                 \\ Store this value in SC, so SC(1 0) now contains the\n                        \\ screen address of the far left end (x-coordinate = 0)\n                        \\ of the horizontal pixel row that we want to draw the\n                        \\ start of our line on\n\n TXA                    \\ Set X = X1 mod 8, which is the horizontal pixel number\n AND #7                 \\ within the character block where the line starts (as\n TAX                    \\ each pixel line in the character block is 8 pixels\n                        \\ wide)\n\n LDA TWOS,X             \\ Fetch a one-pixel byte from TWOS where pixel X is set,\n STA R                  \\ and store it in R\n\n                        \\ The following calculates:\n                        \\\n                        \\   Q = Q / P\n                        \\     = |delta_y| / |delta_x|\n                        \\\n                        \\ using the same shift-and-subtract algorithm that's\n                        \\ documented in TIS2\n\n LDA Q                  \\ Set A = |delta_y|\n\n LDX #%11111110         \\ Set Q to have bits 1-7 set, so we can rotate through 7\n STX Q                  \\ loop iterations, getting a 1 each time, and then\n                        \\ getting a 0 on the 8th iteration... and we can also\n                        \\ use Q to catch our result bits into bit 0 each time\n\n.LIL1\n\n ASL A                  \\ Shift A to the left\n\n BCS LI4                \\ If bit 7 of A was set, then jump straight to the\n                        \\ subtraction\n\n CMP P                  \\ If A < P, skip the following subtraction\n BCC LI5\n\n.LI4\n\n SBC P                  \\ A >= P, so set A = A - P\n\n SEC                    \\ Set the C flag to rotate into the result in Q\n\n.LI5\n\n ROL Q                  \\ Rotate the counter in Q to the left, and catch the\n                        \\ result bit into bit 0 (which will be a 0 if we didn't\n                        \\ do the subtraction, or 1 if we did)\n\n BCS LIL1               \\ If we still have set bits in Q, loop back to TIL2 to\n                        \\ do the next iteration of 7\n\n                        \\ We now have:\n                        \\\n                        \\   Q = A / P\n                        \\     = |delta_y| / |delta_x|\n                        \\\n                        \\ and the C flag is clear\n\n LDX P                  \\ Set X = P + 1\n INX                    \\       = |delta_x| + 1\n                        \\\n                        \\ We add 1 so we can skip the first pixel plot if the\n                        \\ line is being drawn with swapped coordinates\n\n LDA Y2                 \\ Set A = Y2 - Y1 - 1 (as the C flag is clear following\n SBC Y1                 \\ the above division)\n\n BCS DOWN               \\ If Y2 >= Y1 - 1 then jump to DOWN, as we need to draw\n                        \\ the line to the right and down\n\n\\ ******************************************************************************\n\\\n\\       Name: LOIN (Part 3 of 7)\n\\       Type: Subroutine\n\\   Category: Drawing lines\n\\    Summary: Draw a shallow line going right and up or left and down\n\\  Deep dive: Bresenham's line algorithm\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine draws a line from (X1, Y1) to (X2, Y2). It has multiple stages.\n\\ If we get here, then:\n\\\n\\   * The line is going right and up (no swap) or left and down (swap)\n\\\n\\   * X1 < X2 and Y1-1 > Y2\n\\\n\\   * Draw from (X1, Y1) at bottom left to (X2, Y2) at top right, omitting the\n\\     first pixel\n\\\n\\ ******************************************************************************\n\n LDA SWAP               \\ If SWAP > 0 then we swapped the coordinates above, so\n BNE LI6                \\ jump down to LI6 to skip plotting the first pixel\n                        \\\n                        \\ This appears to be a bug that omits the last pixel\n                        \\ of this type of shallow line, rather than the first\n                        \\ pixel, which makes the treatment of this kind of line\n                        \\ different to the other kinds of slope (they all have a\n                        \\ BEQ instruction at this point, rather than a BNE)\n                        \\\n                        \\ The result is a rather messy line join when a shallow\n                        \\ line that goes right and up or left and down joins a\n                        \\ line with any of the other three types of slope\n                        \\\n                        \\ This bug was fixed in the advanced versions of Elite,\n                        \\ where the BNE is replaced by a BEQ to bring it in line\n                        \\ with the other three slopes\n\n DEX                    \\ Decrement the counter in X because we're about to plot\n                        \\ the first pixel\n\n.LIL2\n\n                        \\ We now loop along the line from left to right, using X\n                        \\ as a decreasing counter, and at each count we plot a\n                        \\ single pixel using the pixel mask in R\n\n LDA R                  \\ Fetch the pixel byte from R\n\n EOR (SC),Y             \\ Store R into screen memory at SC(1 0), using EOR\n STA (SC),Y             \\ logic so it merges with whatever is already on-screen\n\n.LI6\n\n LSR R                  \\ Shift the single pixel in R to the right to step along\n                        \\ the x-axis, so the next pixel we plot will be at the\n                        \\ next x-coordinate along\n\n BCC LI7                \\ If the pixel didn't fall out of the right end of R\n                        \\ into the C flag, then jump to LI7\n\n ROR R                  \\ Otherwise we need to move over to the next character\n                        \\ block, so first rotate R right so the set C flag goes\n                        \\ back into the left end, giving %10000000\n\n LDA SC                 \\ Add 8 to SC, so SC(1 0) now points to the next\n ADC #8                 \\ character along to the right\n STA SC\n\n.LI7\n\n LDA S                  \\ Set S = S + Q to update the slope error\n ADC Q\n STA S\n\n BCC LIC2               \\ If the addition didn't overflow, jump to LIC2\n\n DEY                    \\ Otherwise we just overflowed, so decrement Y to move\n                        \\ to the pixel line above\n\n BPL LIC2               \\ If Y is positive we are still within the same\n                        \\ character block, so skip to LIC2\n\n DEC SCH                \\ Otherwise we need to move up into the character block\n LDY #7                 \\ above, so decrement the high byte of the screen\n                        \\ address and set the pixel line to the last line in\n                        \\ that character block\n\n.LIC2\n\n DEX                    \\ Decrement the counter in X\n\n BNE LIL2               \\ If we haven't yet reached the right end of the line,\n                        \\ loop back to LIL2 to plot the next pixel along\n\n LDY YSAV               \\ Restore Y from YSAV, so that it's preserved\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: LOIN (Part 4 of 7)\n\\       Type: Subroutine\n\\   Category: Drawing lines\n\\    Summary: Draw a shallow line going right and down or left and up\n\\  Deep dive: Bresenham's line algorithm\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine draws a line from (X1, Y1) to (X2, Y2). It has multiple stages.\n\\ If we get here, then:\n\\\n\\   * The line is going right and down (no swap) or left and up (swap)\n\\\n\\   * X1 < X2 and Y1-1 <= Y2\n\\\n\\   * Draw from (X1, Y1) at top left to (X2, Y2) at bottom right, omitting the\n\\     first pixel\n\\\n\\ ******************************************************************************\n\n.DOWN\n\n LDA SWAP               \\ If SWAP = 0 then we didn't swap the coordinates above,\n BEQ LI9                \\ so jump down to LI9 to skip plotting the first pixel\n\n DEX                    \\ Decrement the counter in X because we're about to plot\n                        \\ the first pixel\n\n.LIL3\n\n                        \\ We now loop along the line from left to right, using X\n                        \\ as a decreasing counter, and at each count we plot a\n                        \\ single pixel using the pixel mask in R\n\n LDA R                  \\ Fetch the pixel byte from R\n\n EOR (SC),Y             \\ Store R into screen memory at SC(1 0), using EOR\n STA (SC),Y             \\ logic so it merges with whatever is already on-screen\n\n.LI9\n\n LSR R                  \\ Shift the single pixel in R to the right to step along\n                        \\ the x-axis, so the next pixel we plot will be at the\n                        \\ next x-coordinate along\n\n BCC LI10               \\ If the pixel didn't fall out of the right end of R\n                        \\ into the C flag, then jump to LI10\n\n ROR R                  \\ Otherwise we need to move over to the next character\n                        \\ block, so first rotate R right so the set C flag goes\n                        \\ back into the left end, giving %10000000\n\n LDA SC                 \\ Add 8 to SC, so SC(1 0) now points to the next\n ADC #8                 \\ character along to the right\n STA SC\n\n.LI10\n\n LDA S                  \\ Set S = S + Q to update the slope error\n ADC Q\n STA S\n\n BCC LIC3               \\ If the addition didn't overflow, jump to LIC3\n\n INY                    \\ Otherwise we just overflowed, so increment Y to move\n                        \\ to the pixel line below\n\n CPY #8                 \\ If Y < 8 we are still within the same character block,\n BNE LIC3               \\ so skip to LIC3\n\n INC SCH                \\ Otherwise we need to move down into the character\n LDY #0                 \\ block below, so increment the high byte of the screen\n                        \\ address and set the pixel line to the first line in\n                        \\ that character block\n\n.LIC3\n\n DEX                    \\ Decrement the counter in X\n\n BNE LIL3               \\ If we haven't yet reached the right end of the line,\n                        \\ loop back to LIL3 to plot the next pixel along\n\n LDY YSAV               \\ Restore Y from YSAV, so that it's preserved\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: LOIN (Part 5 of 7)\n\\       Type: Subroutine\n\\   Category: Drawing lines\n\\    Summary: Draw a line: Line has a steep gradient, step up along y-axis\n\\  Deep dive: Bresenham's line algorithm\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine draws a line from (X1, Y1) to (X2, Y2). It has multiple stages.\n\\ If we get here, then:\n\\\n\\   * |delta_y| >= |delta_x|\n\\\n\\   * The line is closer to being vertical than horizontal\n\\\n\\   * We are going to step up along the y-axis\n\\\n\\   * We potentially swap coordinates to make sure Y1 >= Y2\n\\\n\\ ******************************************************************************\n\n.STPY\n\n LDY Y1                 \\ Set A = Y = Y1\n TYA\n\n LDX X1                 \\ Set X = X1\n\n CPY Y2                 \\ If Y1 >= Y2, jump down to LI15, as the coordinates are\n BCS LI15               \\ already in the order that we want\n\n DEC SWAP               \\ Otherwise decrement SWAP from 0 to &FF, to denote that\n                        \\ we are swapping the coordinates around\n\n LDA X2                 \\ Swap the values of X1 and X2\n STA X1\n STX X2\n\n TAX                    \\ Set X = X1\n\n LDA Y2                 \\ Swap the values of Y1 and Y2\n STA Y1\n STY Y2\n\n TAY                    \\ Set Y = A = Y1\n\n.LI15\n\n                        \\ By this point we know the line is vertical-ish and\n                        \\ Y1 >= Y2, so we're going from top to bottom as we go\n                        \\ from Y1 to Y2\n\n LSR A                  \\ Set A = A >> 3\n LSR A                  \\       = y div 8\n LSR A                  \\\n                        \\ So A now contains the number of the character row\n                        \\ that will contain the (X1, Y1) pixel\n\n ORA #&60               \\ As A < 32, this effectively adds &60 to A, which gives\n                        \\ us the screen address of the character row (as each\n                        \\ character row takes up 256 bytes, and the first\n                        \\ character row is at screen address &6000, or page &60)\n\n STA SCH                \\ Store the page number of the character row in SCH, so\n                        \\ the high byte of SC is set correctly for drawing the\n                        \\ start of our line\n\n TXA                    \\ Set A = bits 3-7 of X1\n AND #%11111000\n\n STA SC                 \\ Store this value in SC, so SC(1 0) now contains the\n                        \\ screen address of the far left end (x-coordinate = 0)\n                        \\ of the horizontal pixel row that we want to draw the\n                        \\ start of our line on\n\n TXA                    \\ Set X = X1 mod 8, which is the horizontal pixel number\n AND #7                 \\ within the character block where the line starts (as\n TAX                    \\ each pixel line in the character block is 8 pixels\n                        \\ wide)\n\n LDA TWOS,X             \\ Fetch a one-pixel byte from TWOS where pixel X is set,\n STA R                  \\ and store it in R\n\n LDA Y1                 \\ Set Y = Y1 mod 8, which is the pixel row within the\n AND #7                 \\ character block at which we want to draw the start of\n TAY                    \\ our line (as each character block has 8 rows)\n\n                        \\ The following calculates:\n                        \\\n                        \\   P = P / Q\n                        \\     = |delta_x| / |delta_y|\n                        \\\n                        \\ using the same shift-and-subtract algorithm\n                        \\ documented in TIS2\n\n LDA P                  \\ Set A = |delta_x|\n\n LDX #1                 \\ Set Q to have bits 1-7 clear, so we can rotate through\n STX P                  \\ 7 loop iterations, getting a 1 each time, and then\n                        \\ getting a 1 on the 8th iteration... and we can also\n                        \\ use P to catch our result bits into bit 0 each time\n\n.LIL4\n\n ASL A                  \\ Shift A to the left\n\n BCS LI13               \\ If bit 7 of A was set, then jump straight to the\n                        \\ subtraction\n\n CMP Q                  \\ If A < Q, skip the following subtraction\n BCC LI14\n\n.LI13\n\n SBC Q                  \\ A >= Q, so set A = A - Q\n\n SEC                    \\ Set the C flag to rotate into the result in Q\n\n.LI14\n\n ROL P                  \\ Rotate the counter in P to the left, and catch the\n                        \\ result bit into bit 0 (which will be a 0 if we didn't\n                        \\ do the subtraction, or 1 if we did)\n\n BCC LIL4               \\ If we still have set bits in P, loop back to TIL2 to\n                        \\ do the next iteration of 7\n\n                        \\ We now have:\n                        \\\n                        \\   P = A / Q\n                        \\     = |delta_x| / |delta_y|\n                        \\\n                        \\ and the C flag is set\n\n LDX Q                  \\ Set X = Q + 1\n INX                    \\       = |delta_y| + 1\n                        \\\n                        \\ We add 1 so we can skip the first pixel plot if the\n                        \\ line is being drawn with swapped coordinates\n\n LDA X2                 \\ Set A = X2 - X1 (the C flag is set as we didn't take\n SBC X1                 \\ the above BCC)\n\n BCC LFT                \\ If X2 < X1 then jump to LFT, as we need to draw the\n                        \\ line to the left and down\n\n\\ ******************************************************************************\n\\\n\\       Name: LOIN (Part 6 of 7)\n\\       Type: Subroutine\n\\   Category: Drawing lines\n\\    Summary: Draw a steep line going up and left or down and right\n\\  Deep dive: Bresenham's line algorithm\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine draws a line from (X1, Y1) to (X2, Y2). It has multiple stages.\n\\ If we get here, then:\n\\\n\\   * The line is going up and left (no swap) or down and right (swap)\n\\\n\\   * X1 < X2 and Y1 >= Y2\n\\\n\\   * Draw from (X1, Y1) at top left to (X2, Y2) at bottom right, omitting the\n\\     first pixel\n\\\n\\ ******************************************************************************\n\n CLC                    \\ Clear the C flag\n\n LDA SWAP               \\ If SWAP = 0 then we didn't swap the coordinates above,\n BEQ LI17               \\ so jump down to LI17 to skip plotting the first pixel\n\n DEX                    \\ Decrement the counter in X because we're about to plot\n                        \\ the first pixel\n\n.LIL5\n\n                        \\ We now loop along the line from left to right, using X\n                        \\ as a decreasing counter, and at each count we plot a\n                        \\ single pixel using the pixel mask in R\n\n LDA R                  \\ Fetch the pixel byte from R\n\n EOR (SC),Y             \\ Store R into screen memory at SC(1 0), using EOR\n STA (SC),Y             \\ logic so it merges with whatever is already on-screen\n\n.LI17\n\n DEY                    \\ Decrement Y to step up along the y-axis\n\n BPL LI16               \\ If Y is positive we are still within the same\n                        \\ character block, so skip to LI16\n\n DEC SCH                \\ Otherwise we need to move up into the character block\n LDY #7                 \\ above, so decrement the high byte of the screen\n                        \\ address and set the pixel line to the last line in\n                        \\ that character block\n\n.LI16\n\n LDA S                  \\ Set S = S + P to update the slope error\n ADC P\n STA S\n\n BCC LIC5               \\ If the addition didn't overflow, jump to LIC5\n\n LSR R                  \\ Otherwise we just overflowed, so shift the single\n                        \\ pixel in R to the right, so the next pixel we plot\n                        \\ will be at the next x-coordinate along\n\n BCC LIC5               \\ If the pixel didn't fall out of the right end of R\n                        \\ into the C flag, then jump to LIC5\n\n ROR R                  \\ Otherwise we need to move over to the next character\n                        \\ block, so first rotate R right so the set C flag goes\n                        \\ back into the left end, giving %10000000\n\n LDA SC                 \\ Add 8 to SC, so SC(1 0) now points to the next\n ADC #8                 \\ character along to the right\n STA SC\n\n.LIC5\n\n DEX                    \\ Decrement the counter in X\n\n BNE LIL5               \\ If we haven't yet reached the right end of the line,\n                        \\ loop back to LIL5 to plot the next pixel along\n\n LDY YSAV               \\ Restore Y from YSAV, so that it's preserved\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: LOIN (Part 7 of 7)\n\\       Type: Subroutine\n\\   Category: Drawing lines\n\\    Summary: Draw a steep line going up and right or down and left\n\\  Deep dive: Bresenham's line algorithm\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine draws a line from (X1, Y1) to (X2, Y2). It has multiple stages.\n\\ If we get here, then:\n\\\n\\   * The line is going up and right (no swap) or down and left (swap)\n\\\n\\   * X1 >= X2 and Y1 >= Y2\n\\\n\\   * Draw from (X1, Y1) at bottom left to (X2, Y2) at top right, omitting the\n\\     first pixel\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   HL6                 Contains an RTS\n\\\n\\ ******************************************************************************\n\n.LFT\n\n LDA SWAP               \\ If SWAP = 0 then we didn't swap the coordinates above,\n BEQ LI18               \\ so jump down to LI18 to skip plotting the first pixel\n\n DEX                    \\ Decrement the counter in X because we're about to plot\n                        \\ the first pixel\n\n.LIL6\n\n LDA R                  \\ Fetch the pixel byte from R\n\n EOR (SC),Y             \\ Store R into screen memory at SC(1 0), using EOR\n STA (SC),Y             \\ logic so it merges with whatever is already on-screen\n\n.LI18\n\n DEY                    \\ Decrement Y to step up along the y-axis\n\n BPL LI19               \\ If Y is positive we are still within the same\n                        \\ character block, so skip to LI19\n\n DEC SCH                \\ Otherwise we need to move up into the character block\n LDY #7                 \\ above, so decrement the high byte of the screen\n                        \\ address and set the pixel line to the last line in\n                        \\ that character block\n\n.LI19\n\n LDA S                  \\ Set S = S + P to update the slope error\n ADC P\n STA S\n\n BCC LIC6               \\ If the addition didn't overflow, jump to LIC6\n\n ASL R                  \\ Otherwise we just overflowed, so shift the single\n                        \\ pixel in R to the left, so the next pixel we plot\n                        \\ will be at the previous x-coordinate\n\n BCC LIC6               \\ If the pixel didn't fall out of the left end of R\n                        \\ into the C flag, then jump to LIC6\n\n ROL R                  \\ Otherwise we need to move over to the next character\n                        \\ block, so first rotate R left so the set C flag goes\n                        \\ back into the right end, giving %0000001\n\n LDA SC                 \\ Subtract 7 from SC, so SC(1 0) now points to the\n SBC #7                 \\ previous character along to the left\n STA SC\n\n CLC                    \\ Clear the C flag so it doesn't affect the additions\n                        \\ if we loop back\n\n.LIC6\n\n DEX                    \\ Decrement the counter in X\n\n BNE LIL6               \\ If we haven't yet reached the left end of the line,\n                        \\ loop back to LIL6 to plot the next pixel along\n\n LDY YSAV               \\ Restore Y from YSAV, so that it's preserved\n\n.HL6\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: NLIN3\n\\       Type: Subroutine\n\\   Category: Drawing lines\n\\    Summary: Print a title and draw a horizontal line at row 19 to box it in\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine print a text token at the cursor position and draws a horizontal\n\\ line at pixel row 19. It is used for the Status Mode screen, the Short-range\n\\ Chart, the Market Price screen and the Equip Ship screen.\n\\\n\\ ******************************************************************************\n\n.NLIN3\n\n JSR TT27               \\ Print the text token in A\n\n                        \\ Fall through into NLIN4 to draw a horizontal line at\n                        \\ pixel row 19\n\n\\ ******************************************************************************\n\\\n\\       Name: NLIN4\n\\       Type: Subroutine\n\\   Category: Drawing lines\n\\    Summary: Draw a horizontal line at pixel row 19 to box in a title\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine is used on the Inventory screen to draw a horizontal line at\n\\ pixel row 19 to box in the title.\n\\\n\\ ******************************************************************************\n\n.NLIN4\n\n LDA #19                \\ Jump to NLIN2 to draw a horizontal line at pixel row\n BNE NLIN2              \\ 19, returning from the subroutine with using a tail\n                        \\ call (this BNE is effectively a JMP as A will never\n                        \\ be zero)\n\n\\ ******************************************************************************\n\\\n\\       Name: NLIN\n\\       Type: Subroutine\n\\   Category: Drawing lines\n\\    Summary: Draw a horizontal line at pixel row 23 to box in a title\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Draw a horizontal line at pixel row 23 and move the text cursor down one\n\\ line.\n\\\n\\ ******************************************************************************\n\n.NLIN\n\n LDA #23                \\ Set A = 23 so NLIN2 below draws a horizontal line at\n                        \\ pixel row 23\n\n INC YC                 \\ Move the text cursor down one line\n\n                        \\ Fall through into NLIN2 to draw the horizontal line\n                        \\ at row 23\n\n\\ ******************************************************************************\n\\\n\\       Name: NLIN2\n\\       Type: Subroutine\n\\   Category: Drawing lines\n\\    Summary: Draw a screen-wide horizontal line at the pixel row in A\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This draws a line from (2, A) to (254, A), which is almost screen-wide and\n\\ fits in nicely between the border boxes without clashing with it.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The pixel row on which to draw the horizontal line\n\\\n\\ ******************************************************************************\n\n.NLIN2\n\n STA Y1                 \\ Set Y1 = A\n\n LDX #2                 \\ Set X1 = 2, so (X1, Y1) = (2, A)\n STX X1\n\n LDX #254               \\ Set X2 = 254, so (X2, Y2) = (254, A)\n STX X2\n\n BNE HLOIN              \\ Call HLOIN to draw a horizontal line from (2, A) to\n                        \\ (254, A) and return from the subroutine (this BNE is\n                        \\ effectively a JMP as A will never be zero)\n\n\\ ******************************************************************************\n\\\n\\       Name: HLOIN2\n\\       Type: Subroutine\n\\   Category: Drawing lines\n\\    Summary: Remove a line from the sun line heap and draw it on-screen\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Specifically, this does the following:\n\\\n\\   * Set X1 and X2 to the x-coordinates of the ends of the horizontal line with\n\\     centre YY(1 0) and length A to the left and right\n\\\n\\   * Set the Y-th byte of the LSO block to 0 (i.e. remove this line from the\n\\     sun line heap)\n\\\n\\   * Draw a horizontal line from (X1, Y) to (X2, Y)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   YY(1 0)             The x-coordinate of the centre point of the line\n\\\n\\   A                   The half-width of the line, i.e. the contents of the\n\\                       Y-th byte of the sun line heap\n\\\n\\   Y                   The number of the entry in the sun line heap (which is\n\\                       also the y-coordinate of the line)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   Y                   Y is preserved\n\\\n\\ ******************************************************************************\n\n.HLOIN2\n\n JSR EDGES              \\ Call EDGES to calculate X1 and X2 for the horizontal\n                        \\ line centred on YY(1 0) and with half-width A\n\n STY Y1                 \\ Set Y1 = Y\n\n LDA #0                 \\ Set the Y-th byte of the LSO block to 0\n STA LSO,Y\n\n                        \\ Fall through into HLOIN to draw a horizontal line from\n                        \\ (X1, Y) to (X2, Y)\n\n\\ ******************************************************************************\n\\\n\\       Name: HLOIN\n\\       Type: Subroutine\n\\   Category: Drawing lines\n\\    Summary: Draw a horizontal line from (X1, Y1) to (X2, Y1)\n\\  Deep dive: Drawing monochrome pixels on the BBC Micro\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ We do not draw a pixel at the right end of the line.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   Y                   Y is preserved\n\\\n\\ ******************************************************************************\n\n.HLOIN\n\n STY YSAV               \\ Store Y into YSAV, so we can preserve it across the\n                        \\ call to this subroutine\n\n LDX X1                 \\ Set X = X1\n\n CPX X2                 \\ If X1 = X2 then the start and end points are the same,\n BEQ HL6                \\ so return from the subroutine (as HL6 contains an RTS)\n\n BCC HL5                \\ If X1 < X2, jump to HL5 to skip the following code, as\n                        \\ (X1, Y1) is already the left point\n\n LDA X2                 \\ Swap the values of X1 and X2, so we know that (X1, Y1)\n STA X1                 \\ is on the left and (X2, Y1) is on the right\n STX X2\n\n TAX                    \\ Set X = X1\n\n.HL5\n\n DEC X2                 \\ Decrement X2 so we do not draw a pixel at the end\n                        \\ point\n\n LDA Y1                 \\ Set A to the y-coordinate in Y1\n\n LSR A                  \\ Set A = A >> 3\n LSR A                  \\       = y div 8\n LSR A                  \\\n                        \\ So A now contains the number of the character row\n                        \\ that will contain our horizontal line\n\n ORA #&60               \\ As A < 32, this effectively adds &60 to A, which gives\n                        \\ us the screen address of the character row (as each\n                        \\ character row takes up 256 bytes, and the first\n                        \\ character row is at screen address &6000, or page &60)\n\n STA SCH                \\ Store the page number of the character row in SCH, so\n                        \\ the high byte of SC is set correctly for drawing our\n                        \\ line\n\n LDA Y1                 \\ Set A = Y1 mod 8, which is the pixel row within the\n AND #7                 \\ character block at which we want to draw our line (as\n                        \\ each character block has 8 rows)\n\n STA SC                 \\ Store this value in SC, so SC(1 0) now contains the\n                        \\ screen address of the far left end (x-coordinate = 0)\n                        \\ of the horizontal pixel row that we want to draw our\n                        \\ horizontal line on\n\n TXA                    \\ Set Y = bits 3-7 of X1\n AND #%11111000\n TAY\n\n.HL1\n\n TXA                    \\ Set T = bits 3-7 of X1, which will contain the\n AND #%11111000         \\ character number of the start of the line * 8\n STA T\n\n LDA X2                 \\ Set A = bits 3-7 of X2, which will contain the\n AND #%11111000         \\ character number of the end of the line * 8\n\n SEC                    \\ Set A = A - T, which will contain the number of\n SBC T                  \\ character blocks we need to fill - 1 * 8\n\n BEQ HL2                \\ If A = 0 then the start and end character blocks are\n                        \\ the same, so the whole line fits within one block, so\n                        \\ jump down to HL2 to draw the line\n\n                        \\ Otherwise the line spans multiple characters, so we\n                        \\ start with the left character, then do any characters\n                        \\ in the middle, and finish with the right character\n\n LSR A                  \\ Set R = A / 8, so R now contains the number of\n LSR A                  \\ character blocks we need to fill - 1\n LSR A\n STA R\n\n LDA X1                 \\ Set X = X1 mod 8, which is the horizontal pixel number\n AND #7                 \\ within the character block where the line starts (as\n TAX                    \\ each pixel line in the character block is 8 pixels\n                        \\ wide)\n\n LDA TWFR,X             \\ Fetch a ready-made byte with X pixels filled in at the\n                        \\ right end of the byte (so the filled pixels start at\n                        \\ point X and go all the way to the end of the byte),\n                        \\ which is the shape we want for the left end of the\n                        \\ line\n\n EOR (SC),Y             \\ Store this into screen memory at SC(1 0), using EOR\n STA (SC),Y             \\ logic so it merges with whatever is already on-screen,\n                        \\ so we have now drawn the line's left cap\n\n TYA                    \\ Set Y = Y + 8 so (SC),Y points to the next character\n ADC #8                 \\ block along, on the same pixel row as before\n TAY\n\n LDX R                  \\ Fetch the number of character blocks we need to fill\n                        \\ from R\n\n DEX                    \\ Decrement the number of character blocks in X\n\n BEQ HL3                \\ If X = 0 then we only have the last block to do (i.e.\n                        \\ the right cap), so jump down to HL3 to draw it\n\n CLC                    \\ Otherwise clear the C flag so we can do some additions\n                        \\ while we draw the character blocks with full-width\n                        \\ lines in them\n\n.HLL1\n\n LDA #%11111111         \\ Store a full-width eight-pixel horizontal line in\n EOR (SC),Y             \\ SC(1 0) so that it draws the line on-screen, using EOR\n STA (SC),Y             \\ logic so it merges with whatever is already on-screen\n\n TYA                    \\ Set Y = Y + 8 so (SC),Y points to the next character\n ADC #8                 \\ block along, on the same pixel row as before\n TAY\n\n DEX                    \\ Decrement the number of character blocks in X\n\n BNE HLL1               \\ Loop back to draw more full-width lines, if we have\n                        \\ any more to draw\n\n.HL3\n\n LDA X2                 \\ Now to draw the last character block at the right end\n AND #7                 \\ of the line, so set X = X2 mod 8, which is the\n TAX                    \\ horizontal pixel number where the line ends\n\n LDA TWFL,X             \\ Fetch a ready-made byte with X pixels filled in at the\n                        \\ left end of the byte (so the filled pixels start at\n                        \\ the left edge and go up to point X), which is the\n                        \\ shape we want for the right end of the line\n\n EOR (SC),Y             \\ Store this into screen memory at SC(1 0), using EOR\n STA (SC),Y             \\ logic so it merges with whatever is already on-screen,\n                        \\ so we have now drawn the line's right cap\n\n LDY YSAV               \\ Restore Y from YSAV, so that it's preserved across the\n                        \\ call to this subroutine\n\n RTS                    \\ Return from the subroutine\n\n.HL2\n\n                        \\ If we get here then the entire horizontal line fits\n                        \\ into one character block\n\n LDA X1                 \\ Set X = X1 mod 8, which is the horizontal pixel number\n AND #7                 \\ within the character block where the line starts (as\n TAX                    \\ each pixel line in the character block is 8 pixels\n                        \\ wide)\n\n LDA TWFR,X             \\ Fetch a ready-made byte with X pixels filled in at the\n STA T                  \\ right end of the byte (so the filled pixels start at\n                        \\ point X and go all the way to the end of the byte)\n\n LDA X2                 \\ Set X = X2 mod 8, which is the horizontal pixel number\n AND #7                 \\ where the line ends\n TAX\n\n LDA TWFL,X             \\ Fetch a ready-made byte with X pixels filled in at the\n                        \\ left end of the byte (so the filled pixels start at\n                        \\ the left edge and go up to point X)\n\n AND T                  \\ We now have two bytes, one (T) containing pixels from\n                        \\ the starting point X1 onwards, and the other (A)\n                        \\ containing pixels up to the end point at X2, so we can\n                        \\ get the actual line we want to draw by AND'ing them\n                        \\ together. For example, if we want to draw a line from\n                        \\ point 2 to point 5 (within the row of 8 pixels\n                        \\ numbered from 0 to 7), we would have this:\n                        \\\n                        \\   T       = %00111111\n                        \\   A       = %11111100\n                        \\   T AND A = %00111100\n                        \\\n                        \\ So we can stick T AND A in screen memory to get the\n                        \\ line we want, which is what we do here by setting\n                        \\ A = A AND T\n\n EOR (SC),Y             \\ Store our horizontal line byte into screen memory at\n STA (SC),Y             \\ SC(1 0), using EOR logic so it merges with whatever is\n                        \\ already on-screen\n\n LDY YSAV               \\ Restore Y from YSAV, so that it's preserved\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: TWFL\n\\       Type: Variable\n\\   Category: Drawing lines\n\\    Summary: Ready-made character rows for the left end of a horizontal line in\n\\             mode 4\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Ready-made bytes for plotting horizontal line end caps in mode 4 (the top part\n\\ of the split screen). This table provides a byte with pixels at the left end,\n\\ which is used for the right end of the line.\n\\\n\\ See the HLOIN routine for details.\n\\\n\\ ******************************************************************************\n\n.TWFL\n\n EQUB %10000000\n EQUB %11000000\n EQUB %11100000\n EQUB %11110000\n EQUB %11111000\n EQUB %11111100\n EQUB %11111110\n\n\\ ******************************************************************************\n\\\n\\       Name: TWFR\n\\       Type: Variable\n\\   Category: Drawing lines\n\\    Summary: Ready-made character rows for the right end of a horizontal line\n\\             in mode 4\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Ready-made bytes for plotting horizontal line end caps in mode 4 (the top part\n\\ of the split screen). This table provides a byte with pixels at the right end,\n\\ which is used for the left end of the line.\n\\\n\\ See the HLOIN routine for details.\n\\\n\\ ******************************************************************************\n\n.TWFR\n\n EQUB %11111111\n EQUB %01111111\n EQUB %00111111\n EQUB %00011111\n EQUB %00001111\n EQUB %00000111\n EQUB %00000011\n EQUB %00000001\n\n\\ ******************************************************************************\n\\\n\\       Name: PX3\n\\       Type: Subroutine\n\\   Category: Drawing pixels\n\\    Summary: Plot a single pixel at (X, Y) within a character block\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine is called from PIXEL to set 1 pixel within a character block for\n\\ a distant point (i.e. where the distance ZZ >= &90). See the PIXEL routine for\n\\ details, as this routine is effectively part of PIXEL.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   The x-coordinate of the pixel within the character block\n\\\n\\   Y                   The y-coordinate of the pixel within the character block\n\\\n\\   SC(1 0)             The screen address of the character block\n\\\n\\   T1                  The value of Y to restore on exit, so Y is preserved by\n\\                       the call to PIXEL\n\\\n\\ ******************************************************************************\n\n.PX3\n\n LDA TWOS,X             \\ Fetch a one-pixel byte from TWOS and EOR it into SC+Y\n EOR (SC),Y\n STA (SC),Y\n\n LDY T1                 \\ Restore Y from T1, so Y is preserved by the routine\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: PIX1\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate (YY+1 SYL+Y) = (A P) + (S R) and draw stardust particle\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following:\n\\\n\\   (YY+1 SYL+Y) = (A P) + (S R)\n\\\n\\ and draw a stardust particle at (X1,Y1) with distance ZZ.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   (A P)               A is the angle ALPHA or BETA, P is always 0\n\\\n\\   (S R)               YY(1 0) or YY(1 0) + Q * A\n\\\n\\   Y                   Stardust particle number\n\\\n\\   X1                  The x-coordinate offset\n\\\n\\   Y1                  The y-coordinate offset\n\\\n\\   ZZ                  The distance of the point, with bigger distances drawing\n\\                       smaller points:\n\\\n\\                         * ZZ < 80           Double-height four-pixel square\n\\\n\\                         * 80 <= ZZ <= 143   Single-height two-pixel dash\n\\\n\\                         * ZZ > 143          Single-height one-pixel dot\n\\\n\\ ******************************************************************************\n\n.PIX1\n\n JSR ADD                \\ Set (A X) = (A P) + (S R)\n\n STA YY+1               \\ Set YY+1 to A, the high byte of the result\n\n TXA                    \\ Set SYL+Y to X, the low byte of the result\n STA SYL,Y\n\n                        \\ Fall through into PIXEL2 to draw the stardust particle\n                        \\ at (X1,Y1)\n\n\\ ******************************************************************************\n\\\n\\       Name: PIXEL2\n\\       Type: Subroutine\n\\   Category: Drawing pixels\n\\    Summary: Draw a stardust particle relative to the screen centre\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Draw a point (X1, Y1) from the middle of the screen with a size determined by\n\\ a distance value. Used to draw stardust particles.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X1                  The x-coordinate offset\n\\\n\\   Y1                  The y-coordinate offset (positive means up the screen\n\\                       from the centre, negative means down the screen)\n\\\n\\   ZZ                  The distance of the point, with bigger distances drawing\n\\                       smaller points:\n\\\n\\                         * ZZ < 80           Double-height four-pixel square\n\\\n\\                         * 80 <= ZZ <= 143   Single-height two-pixel dash\n\\\n\\                         * ZZ > 143          Single-height one-pixel dot\n\\\n\\ ******************************************************************************\n\n.PIXEL2\n\n LDA X1                 \\ Fetch the x-coordinate offset into A\n\n BPL PX1                \\ If the x-coordinate offset is positive, jump to PX1\n                        \\ to skip the following negation\n\n EOR #%01111111         \\ The x-coordinate offset is negative, so flip all the\n CLC                    \\ bits apart from the sign bit and add 1, to convert it\n ADC #1                 \\ from a sign-magnitude number to a signed number\n\n.PX1\n\n EOR #%10000000         \\ Set X = X1 + 128\n TAX                    \\\n                        \\ So X is now the offset converted to an x-coordinate,\n                        \\ centred on x-coordinate 128\n\n LDA Y1                 \\ Fetch the y-coordinate offset into A and clear the\n AND #%01111111         \\ sign bit, so A = |Y1|\n\n CMP #96                \\ If |Y1| >= 96 then it's off the screen (as 96 is half\n BCS PX4                \\ the screen height), so return from the subroutine (as\n                        \\ PX4 contains an RTS)\n\n LDA Y1                 \\ Fetch the y-coordinate offset into A\n\n BPL PX2                \\ If the y-coordinate offset is positive, jump to PX2\n                        \\ to skip the following negation\n\n EOR #%01111111         \\ The y-coordinate offset is negative, so flip all the\n ADC #1                 \\ bits apart from the sign bit and subtract 1, to negate\n                        \\ it to a positive number, i.e. A is now |Y1|\n\n.PX2\n\n STA T                  \\ Set A = #Y + 1 - Y1\n LDA #Y+1               \\\n SBC T                  \\ So if Y1 is positive we display the point up from the\n                        \\ centre at y-coordinate 97, while a negative Y1 means\n                        \\ down from the centre\n\n                        \\ Fall through into PIXEL to draw the stardust at the\n                        \\ screen coordinates in (X, A)\n\n\\ ******************************************************************************\n\\\n\\       Name: PIXEL\n\\       Type: Subroutine\n\\   Category: Drawing pixels\n\\    Summary: Draw a one-pixel dot, two-pixel dash or four-pixel square\n\\  Deep dive: Drawing monochrome pixels on the BBC Micro\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Draw a point at screen coordinate (X, A) with the point size determined by the\n\\ distance in ZZ. This applies to the top part of the screen (the monochrome\n\\ mode 4 portion).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   The screen x-coordinate of the point to draw\n\\\n\\   A                   The screen y-coordinate of the point to draw\n\\\n\\   ZZ                  The distance of the point, with bigger distances drawing\n\\                       smaller points:\n\\\n\\                         * ZZ < 80           Double-height four-pixel square\n\\\n\\                         * 80 <= ZZ <= 143   Single-height two-pixel dash\n\\\n\\                         * ZZ > 143          Single-height one-pixel dot\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   Y                   Y is preserved\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   PX4                 Contains an RTS\n\\\n\\ ******************************************************************************\n\n.PIXEL\n\n STY T1                 \\ Store Y in T1 so we can restore it at the end of the\n                        \\ subroutine\n\n TAY                    \\ Copy A into Y, for use later\n\n LSR A                  \\ Set SCH = &60 + A >> 3\n LSR A\n LSR A\n ORA #&60\n STA SCH\n\n TXA                    \\ Set SC = (X >> 3) * 8\n AND #%11111000\n STA SC\n\n TYA                    \\ Set Y = Y mod 8, which is the pixel row within the\n AND #7                 \\ character block at which we want to draw our pixel\n TAY                    \\ (as each character block has 8 rows)\n\n TXA                    \\ Set X = X mod 8, which is the horizontal pixel number\n AND #7                 \\ within the character block where the pixel lies (as\n TAX                    \\ each pixel line in the character block is 8 pixels\n                        \\ wide)\n\n LDA ZZ                 \\ If distance in ZZ >= 144, then this point is a very\n CMP #144               \\ long way away, so jump to PX3 to fetch a one-pixel\n BCS PX3                \\ point from TWOS and EOR it into SC+Y\n\n LDA TWOS2,X            \\ Otherwise fetch a two-pixel dash from TWOS2 and EOR it\n EOR (SC),Y             \\ into SC+Y\n STA (SC),Y\n\n LDA ZZ                 \\ If distance in ZZ >= 80, then this point is a medium\n CMP #80                \\ distance away, so jump to PX13 to stop drawing, as a\n BCS PX13               \\ two-pixel dash is enough\n\n                        \\ Otherwise we keep going to draw another 2 pixel point\n                        \\ either above or below the one we just drew, to make a\n                        \\ four-pixel square\n\n DEY                    \\ Reduce Y by 1 to point to the pixel row above the one\n BPL PX14               \\ we just plotted, and if it is still positive, jump to\n                        \\ PX14 to draw our second two-pixel dash\n\n LDY #1                 \\ Reducing Y by 1 made it negative, which means Y was\n                        \\ 0 before we did the DEY above, so set Y to 1 to point\n                        \\ to the pixel row after the one we just plotted\n\n.PX14\n\n LDA TWOS2,X            \\ Fetch a two-pixel dash from TWOS2 and EOR it into this\n EOR (SC),Y             \\ second row to make a four-pixel square\n STA (SC),Y\n\n.PX13\n\n LDY T1                 \\ Restore Y from T1, so Y is preserved by the routine\n\n.PX4\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: BLINE\n\\       Type: Subroutine\n\\   Category: Drawing circles\n\\    Summary: Draw a circle segment and add it to the ball line heap\n\\  Deep dive: The ball line heap\n\\             Drawing circles\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Draw a single segment of a circle, adding the point to the ball line heap.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   CNT                 The number of this segment\n\\\n\\   STP                 The step size for the circle\n\\\n\\   K6(1 0)             The x-coordinate of the new point on the circle, as\n\\                       a screen coordinate\n\\\n\\   (T X)               The y-coordinate of the new point on the circle, as\n\\                       an offset from the centre of the circle\n\\\n\\   FLAG                Set to &FF for the first call, so it sets up the first\n\\                       point in the heap but waits until the second call before\n\\                       drawing anything (as we need two points, i.e. two calls,\n\\                       before we can draw a line)\n\\\n\\   K4(1 0)             Pixel y-coordinate of the centre of the circle\n\\\n\\   K5(1 0)             Screen x-coordinate of the previous point added to the\n\\                       ball line heap (if this is not the first point)\n\\\n\\   K5(3 2)             Screen y-coordinate of the previous point added to the\n\\                       ball line heap (if this is not the first point)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   CNT                 CNT is updated to CNT + STP\n\\\n\\   A                   The new value of CNT\n\\\n\\   K5(1 0)             Screen x-coordinate of the point that we just added to\n\\                       the ball line heap\n\\\n\\   K5(3 2)             Screen y-coordinate of the point that we just added to\n\\                       the ball line heap\n\\\n\\   FLAG                Set to 0\n\\\n\\ ******************************************************************************\n\n.BLINE\n\n TXA                    \\ Set K6(3 2) = (T X) + K4(1 0)\n ADC K4                 \\             = y-coord of centre + y-coord of new point\n STA K6+2               \\\n LDA K4+1               \\ so K6(3 2) now contains the y-coordinate of the new\n ADC T                  \\ point on the circle but as a screen coordinate, to go\n STA K6+3               \\ along with the screen x-coordinate in K6(1 0)\n\n LDA FLAG               \\ If FLAG = 0, jump down to BL1\n BEQ BL1\n\n INC FLAG               \\ Flag is &FF so this is the first call to BLINE, so\n                        \\ increment FLAG to set it to 0, as then the next time\n                        \\ we call BLINE it can draw the first line, from this\n                        \\ point to the next\n\n.BL5\n\n                        \\ The following inserts a &FF marker into the LSY2 line\n                        \\ heap to indicate that the next call to BLINE should\n                        \\ store both the (X1, Y1) and (X2, Y2) points. We do\n                        \\ this on the very first call to BLINE (when FLAG is\n                        \\ &FF), and on subsequent calls if the segment does not\n                        \\ fit on-screen, in which case we don't draw or store\n                        \\ that segment, and we start a new segment with the next\n                        \\ call to BLINE that does fit on-screen\n\n LDY LSP                \\ If byte LSP-1 of LSY2 = &FF, jump to BL7 to tidy up\n LDA #&FF               \\ and return from the subroutine, as the point that has\n CMP LSY2-1,Y           \\ been passed to BLINE is the start of a segment, so all\n BEQ BL7                \\ we need to do is save the coordinate in K5, without\n                        \\ moving the pointer in LSP\n\n STA LSY2,Y             \\ Otherwise we just tried to plot a segment but it\n                        \\ didn't fit on-screen, so put the &FF marker into the\n                        \\ heap for this point, so the next call to BLINE starts\n                        \\ a new segment\n\n INC LSP                \\ Increment LSP to point to the next point in the heap\n\n BNE BL7                \\ Jump to BL7 to tidy up and return from the subroutine\n                        \\ (this BNE is effectively a JMP, as LSP will never be\n                        \\ zero)\n\n.BL1\n\n LDA K5                 \\ Set XX15 = K5 = x_lo of previous point\n STA XX15\n\n LDA K5+1               \\ Set XX15+1 = K5+1 = x_hi of previous point\n STA XX15+1\n\n LDA K5+2               \\ Set XX15+2 = K5+2 = y_lo of previous point\n STA XX15+2\n\n LDA K5+3               \\ Set XX15+3 = K5+3 = y_hi of previous point\n STA XX15+3\n\n LDA K6                 \\ Set XX15+4 = x_lo of new point\n STA XX15+4\n\n LDA K6+1               \\ Set XX15+5 = x_hi of new point\n STA XX15+5\n\n LDA K6+2               \\ Set XX12 = y_lo of new point\n STA XX12\n\n LDA K6+3               \\ Set XX12+1 = y_hi of new point\n STA XX12+1\n\n JSR LL145              \\ Call LL145 to see if the new line segment needs to be\n                        \\ clipped to fit on-screen, returning the clipped line's\n                        \\ end-points in (X1, Y1) and (X2, Y2)\n\n BCS BL5                \\ If the C flag is set then the line is not visible on\n                        \\ screen anyway, so jump to BL5, to avoid drawing and\n                        \\ storing this line\n\n LDA SWAP               \\ If SWAP = 0, then we didn't have to swap the line\n BEQ BL9                \\ coordinates around during the clipping process, so\n                        \\ jump to BL9 to skip the following swap\n\n LDA X1                 \\ Otherwise the coordinates were swapped by the call to\n LDY X2                 \\ LL145 above, so we swap (X1, Y1) and (X2, Y2) back\n STA X2                 \\ again\n STY X1\n LDA Y1\n LDY Y2\n STA Y2\n STY Y1\n\n.BL9\n\n LDY LSP                \\ Set Y = LSP\n\n LDA LSY2-1,Y           \\ If byte LSP-1 of LSY2 is not &FF, jump down to BL8\n CMP #&FF               \\ to skip the following (X1, Y1) code\n BNE BL8\n\n                        \\ Byte LSP-1 of LSY2 is &FF, which indicates that we\n                        \\ need to store (X1, Y1) in the heap\n\n LDA X1                 \\ Store X1 in the LSP-th byte of LSX2\n STA LSX2,Y\n\n LDA Y1                 \\ Store Y1 in the LSP-th byte of LSY2\n STA LSY2,Y\n\n INY                    \\ Increment Y to point to the next byte in LSX2/LSY2\n\n.BL8\n\n LDA X2                 \\ Store X2 in the LSP-th byte of LSX2\n STA LSX2,Y\n\n LDA Y2                 \\ Store Y2 in the LSP-th byte of LSX2\n STA LSY2,Y\n\n INY                    \\ Increment Y to point to the next byte in LSX2/LSY2\n\n STY LSP                \\ Update LSP to point to the same as Y\n\n JSR LOIN               \\ Draw a line from (X1, Y1) to (X2, Y2)\n\n LDA XX13               \\ If XX13 is non-zero, jump up to BL5 to add a &FF\n BNE BL5                \\ marker to the end of the line heap. XX13 is non-zero\n                        \\ after the call to the clipping routine LL145 above if\n                        \\ the end of the line was clipped, meaning the next line\n                        \\ sent to BLINE can't join onto the end but has to start\n                        \\ a new segment, and that's what inserting the &FF\n                        \\ marker does\n\n.BL7\n\n LDA K6                 \\ Copy the data for this step point from K6(3 2 1 0)\n STA K5                 \\ into K5(3 2 1 0), for use in the next call to BLINE:\n LDA K6+1               \\\n STA K5+1               \\   * K5(1 0) = screen x-coordinate of this point\n LDA K6+2               \\\n STA K5+2               \\   * K5(3 2) = screen y-coordinate of this point\n LDA K6+3               \\\n STA K5+3               \\ They now become the \"previous point\" in the next call\n\n LDA CNT                \\ Set CNT = CNT + STP\n CLC\n ADC STP\n STA CNT\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: FLIP\n\\       Type: Subroutine\n\\   Category: Stardust\n\\    Summary: Reflect the stardust particles in the screen diagonal and redraw\n\\             the stardust field\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Swap the x- and y-coordinates of all the stardust particles and draw the new\n\\ set of particles. Called by LOOK1 when we switch views.\n\\\n\\ This is a quick way of making the stardust field in the new view feel\n\\ different without having to generate a whole new field. If you look carefully\n\\ at the stardust field when you switch views, you can just about see that the\n\\ new field is a reflection of the previous field in the screen diagonal, i.e.\n\\ in the line from bottom left to top right. This is the line where x = y when\n\\ the origin is in the middle of the screen, and positive x and y are right and\n\\ up, which is the coordinate system we use for stardust).\n\\\n\\ ******************************************************************************\n\n.FLIP\n\n\\LDA MJ                 \\ These instructions are commented out in the original\n\\BNE FLIP-1             \\ source. They would have the effect of not swapping the\n                        \\ stardust if we had mis-jumped into witchspace\n\n LDY NOSTM              \\ Set Y to the current number of stardust particles, so\n                        \\ we can use it as a counter through all the stardust\n\n.FLL1\n\n LDX SY,Y               \\ Copy the Y-th particle's y-coordinate from SY+Y into X\n\n LDA SX,Y               \\ Copy the Y-th particle's x-coordinate from SX+Y into\n STA Y1                 \\ both Y1 and the particle's y-coordinate\n STA SY,Y\n\n TXA                    \\ Copy the Y-th particle's original y-coordinate into\n STA X1                 \\ both X1 and the particle's x-coordinate, so the x- and\n STA SX,Y               \\ y-coordinates are now swapped and (X1, Y1) contains\n                        \\ the particle's new coordinates\n\n LDA SZ,Y               \\ Fetch the Y-th particle's distance from SZ+Y into ZZ\n STA ZZ\n\n JSR PIXEL2             \\ Draw a stardust particle at (X1,Y1) with distance ZZ\n\n DEY                    \\ Decrement the counter to point to the next particle of\n                        \\ stardust\n\n BNE FLL1               \\ Loop back to FLL1 until we have moved all the stardust\n                        \\ particles\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: STARS\n\\       Type: Subroutine\n\\   Category: Stardust\n\\    Summary: The main routine for processing the stardust\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Called at the very end of the main flight loop.\n\\\n\\ ******************************************************************************\n\n.STARS\n\n\\LDA #&FF               \\ These instructions are commented out in the original\n\\STA COL                \\ source, but they would set the stardust colour to\n                        \\ white. That said, COL is only used when updating the\n                        \\ dashboard, so this would have no effect - perhaps it's\n                        \\ left over from experiments with a colour top part of\n                        \\ the screen? Who knows...\n\n LDX VIEW               \\ Load the current view into X:\n                        \\\n                        \\   0 = front\n                        \\   1 = rear\n                        \\   2 = left\n                        \\   3 = right\n\n BEQ STARS1             \\ If this is view 0, jump to STARS1 to process the\n                        \\ stardust for the front view\n\n DEX                    \\ If this is view 2 or 3, jump to STARS2 (via ST11) to\n BNE ST11               \\ process the stardust for the left or right views\n\n JMP STARS6             \\ Otherwise this is the rear view, so jump to STARS6 to\n                        \\ process the stardust for the rear view\n\n.ST11\n\n JMP STARS2             \\ Jump to STARS2 for the left or right views, as it's\n                        \\ too far for the branch instruction above\n\n\\ ******************************************************************************\n\\\n\\       Name: STARS1\n\\       Type: Subroutine\n\\   Category: Stardust\n\\    Summary: Process the stardust for the front view\n\\  Deep dive: Stardust in the front view\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This moves the stardust towards us according to our speed (so the dust rushes\n\\ past us), and applies our current pitch and roll to each particle of dust, so\n\\ the stardust moves correctly when we steer our ship.\n\\\n\\ When a stardust particle rushes past us and falls off the side of the screen,\n\\ its memory is recycled as a new particle that's positioned randomly on-screen.\n\\\n\\ These are the calculations referred to in the commentary:\n\\\n\\   1. q = 64 * speed / z_hi\n\\   2. z = z - speed * 64\n\\   3. y = y + |y_hi| * q\n\\   4. x = x + |x_hi| * q\n\\\n\\   5. y = y + alpha * x / 256\n\\   6. x = x - alpha * y / 256\n\\\n\\   7. x = x + 2 * (beta * y / 256) ^ 2\n\\   8. y = y - beta * 256\n\\\n\\ For more information see the associated deep dive.\n\\\n\\ ******************************************************************************\n\n.STARS1\n\n LDY NOSTM              \\ Set Y to the current number of stardust particles, so\n                        \\ we can use it as a counter through all the stardust\n\n                        \\ In the following, we're going to refer to the 16-bit\n                        \\ space coordinates of the current particle of stardust\n                        \\ (i.e. the Y-th particle) like this:\n                        \\\n                        \\   x = (x_hi x_lo)\n                        \\   y = (y_hi y_lo)\n                        \\   z = (z_hi z_lo)\n                        \\\n                        \\ These values are stored in (SX+Y SXL+Y), (SY+Y SYL+Y)\n                        \\ and (SZ+Y SZL+Y) respectively\n\n.STL1\n\n JSR DV42               \\ Call DV42 to set the following:\n                        \\\n                        \\   (P R) = 256 * DELTA / z_hi\n                        \\         = 256 * speed / z_hi\n                        \\\n                        \\ The maximum value returned is P = 2 and R = 128 (see\n                        \\ DV42 for an explanation)\n\n LDA R                  \\ Set A = R, so now:\n                        \\\n                        \\   (P A) = 256 * speed / z_hi\n\n LSR P                  \\ Rotate (P A) right by 2 places, which sets P = 0 (as P\n ROR A                  \\ has a maximum value of 2) and leaves:\n LSR P                  \\\n ROR A                  \\   A = 64 * speed / z_hi\n\n ORA #1                 \\ Make sure A is at least 1, and store it in Q, so we\n STA Q                  \\ now have result 1 above:\n                        \\\n                        \\   Q = 64 * speed / z_hi\n\n LDA SZL,Y              \\ We now calculate the following:\n SBC DELT4              \\\n STA SZL,Y              \\  (z_hi z_lo) = (z_hi z_lo) - DELT4(1 0)\n                        \\\n                        \\ starting with the low bytes\n\n LDA SZ,Y               \\ And then we do the high bytes\n STA ZZ                 \\\n SBC DELT4+1            \\ We also set ZZ to the original value of z_hi, which we\n STA SZ,Y               \\ use below to remove the existing particle\n                        \\\n                        \\ So now we have result 2 above:\n                        \\\n                        \\   z = z - DELT4(1 0)\n                        \\     = z - speed * 64\n\n JSR MLU1               \\ Call MLU1 to set:\n                        \\\n                        \\   Y1 = y_hi\n                        \\\n                        \\   (A P) = |y_hi| * Q\n                        \\\n                        \\ So Y1 contains the original value of y_hi, which we\n                        \\ use below to remove the existing particle\n\n                        \\ We now calculate:\n                        \\\n                        \\   (S R) = YY(1 0) = (A P) + y\n\n STA YY+1               \\ First we do the low bytes with:\n LDA P                  \\\n ADC SYL,Y              \\   YY+1 = A\n STA YY                 \\   R = YY = P + y_lo\n STA R                  \\\n                        \\ so we get this:\n                        \\\n                        \\   (? R) = YY(1 0) = (A P) + y_lo\n\n LDA Y1                 \\ And then we do the high bytes with:\n ADC YY+1               \\\n STA YY+1               \\   S = YY+1 = y_hi + YY+1\n STA S                  \\\n                        \\ so we get our result:\n                        \\\n                        \\   (S R) = YY(1 0) = (A P) + (y_hi y_lo)\n                        \\                   = |y_hi| * Q + y\n                        \\\n                        \\ which is result 3 above, and (S R) is set to the new\n                        \\ value of y\n\n LDA SX,Y               \\ Set X1 = A = x_hi\n STA X1                 \\\n                        \\ So X1 contains the original value of x_hi, which we\n                        \\ use below to remove the existing particle\n\n JSR MLU2               \\ Set (A P) = |x_hi| * Q\n\n                        \\ We now calculate:\n                        \\\n                        \\   XX(1 0) = (A P) + x\n\n STA XX+1               \\ First we do the low bytes:\n LDA P                  \\\n ADC SXL,Y              \\   XX(1 0) = (A P) + x_lo\n STA XX\n\n LDA X1                 \\ And then we do the high bytes:\n ADC XX+1               \\\n STA XX+1               \\   XX(1 0) = XX(1 0) + (x_hi 0)\n                        \\\n                        \\ so we get our result:\n                        \\\n                        \\   XX(1 0) = (A P) + x\n                        \\           = |x_hi| * Q + x\n                        \\\n                        \\ which is result 4 above, and we also have:\n                        \\\n                        \\   A = XX+1 = (|x_hi| * Q + x) / 256\n                        \\\n                        \\ i.e. A is the new value of x, divided by 256\n\n EOR ALP2+1             \\ EOR with the flipped sign of the roll angle alpha, so\n                        \\ A has the opposite sign to the flipped roll angle\n                        \\ alpha, i.e. it gets the same sign as alpha\n\n JSR MLS1               \\ Call MLS1 to calculate:\n                        \\\n                        \\   (A P) = A * ALP1\n                        \\         = (x / 256) * alpha\n\n JSR ADD                \\ Call ADD to calculate:\n                        \\\n                        \\   (A X) = (A P) + (S R)\n                        \\         = (x / 256) * alpha + y\n                        \\         = y + alpha * x / 256\n\n STA YY+1               \\ Set YY(1 0) = (A X) to give:\n STX YY                 \\\n                        \\   YY(1 0) = y + alpha * x / 256\n                        \\\n                        \\ which is result 5 above, and we also have:\n                        \\\n                        \\   A = YY+1 = y + alpha * x / 256\n                        \\\n                        \\ i.e. A is the new value of y, divided by 256\n\n EOR ALP2               \\ EOR A with the correct sign of the roll angle alpha,\n                        \\ so A has the opposite sign to the roll angle alpha\n\n JSR MLS2               \\ Call MLS2 to calculate:\n                        \\\n                        \\   (S R) = XX(1 0)\n                        \\         = x\n                        \\\n                        \\   (A P) = A * ALP1\n                        \\         = -y / 256 * alpha\n\n JSR ADD                \\ Call ADD to calculate:\n                        \\\n                        \\   (A X) = (A P) + (S R)\n                        \\         = -y / 256 * alpha + x\n\n STA XX+1               \\ Set XX(1 0) = (A X), which gives us result 6 above:\n STX XX                 \\\n                        \\   x = x - alpha * y / 256\n\n LDX BET1               \\ Fetch the pitch magnitude into X\n\n LDA YY+1               \\ Set A to y_hi and set it to the flipped sign of beta\n EOR BET2+1\n\n JSR MULTS-2            \\ Call MULTS-2 to calculate:\n                        \\\n                        \\   (A P) = X * A\n                        \\         = -beta * y_hi\n\n STA Q                  \\ Store the high byte of the result in Q, so:\n                        \\\n                        \\   Q = -beta * y_hi / 256\n\n JSR MUT2               \\ Call MUT2 to calculate:\n                        \\\n                        \\   (S R) = XX(1 0) = x\n                        \\\n                        \\   (A P) = Q * A\n                        \\         = (-beta * y_hi / 256) * (-beta * y_hi / 256)\n                        \\         = (beta * y / 256) ^ 2\n\n ASL P                  \\ Double (A P), store the top byte in A and set the C\n ROL A                  \\ flag to bit 7 of the original A, so this does:\n STA T                  \\\n                        \\   (T P) = (A P) << 1\n                        \\         = 2 * (beta * y / 256) ^ 2\n\n LDA #0                 \\ Set bit 7 in A to the sign bit from the A in the\n ROR A                  \\ calculation above and apply it to T, so we now have:\n ORA T                  \\\n                        \\   (A P) = (A P) * 2\n                        \\         = 2 * (beta * y / 256) ^ 2\n                        \\\n                        \\ with the doubling retaining the sign of (A P)\n\n JSR ADD                \\ Call ADD to calculate:\n                        \\\n                        \\   (A X) = (A P) + (S R)\n                        \\         = 2 * (beta * y / 256) ^ 2 + x\n\n STA XX+1               \\ Store the high byte A in XX+1\n\n TXA                    \\ Store the low byte X in x_lo\n STA SXL,Y\n\n                        \\ So (XX+1 x_lo) now contains:\n                        \\\n                        \\   x = x + 2 * (beta * y / 256) ^ 2\n                        \\\n                        \\ which is result 7 above\n\n LDA YY                 \\ Set (S R) = YY(1 0) = y\n STA R                  \\\n LDA YY+1               \\ The call to MAD and the two store instructions are\n\\JSR MAD                \\ commented out in the original source\n\\STA S\n\\STX R\n STA S\n\n LDA #0                 \\ Set P = 0\n STA P\n\n LDA BETA               \\ Set A = -beta, so:\n EOR #%10000000         \\\n                        \\   (A P) = (-beta 0)\n                        \\         = -beta * 256\n\n JSR PIX1               \\ Call PIX1 to calculate the following:\n                        \\\n                        \\   (YY+1 y_lo) = (A P) + (S R)\n                        \\               = -beta * 256 + y\n                        \\\n                        \\ i.e. y = y - beta * 256, which is result 8 above\n                        \\\n                        \\ PIX1 also draws a particle at (X1, Y1) with distance\n                        \\ ZZ, which will remove the old stardust particle, as we\n                        \\ set X1, Y1 and ZZ to the original values for this\n                        \\ particle during the calculations above\n\n                        \\ We now have our newly moved stardust particle at\n                        \\ x-coordinate (XX+1 x_lo) and y-coordinate (YY+1 y_lo)\n                        \\ and distance z_hi, so we draw it if it's still on\n                        \\ screen, otherwise we recycle it as a new bit of\n                        \\ stardust and draw that\n\n LDA XX+1               \\ Set X1 and x_hi to the high byte of XX in XX+1, so\n STA X1                 \\ the new x-coordinate is in (x_hi x_lo) and the high\n STA SX,Y               \\ byte is in X1\n\n AND #%01111111         \\ If |x_hi| >= 120 then jump to KILL1 to recycle this\n CMP #120               \\ particle, as it's gone off the side of the screen,\n BCS KILL1              \\ and rejoin at STC1 with the new particle\n\n LDA YY+1               \\ Set Y1 and y_hi to the high byte of YY in YY+1, so\n STA SY,Y               \\ the new x-coordinate is in (y_hi y_lo) and the high\n STA Y1                 \\ byte is in Y1\n\n AND #%01111111         \\ If |y_hi| >= 120 then jump to KILL1 to recycle this\n CMP #120               \\ particle, as it's gone off the top or bottom of the\n BCS KILL1              \\ screen, and rejoin at STC1 with the new particle\n\n LDA SZ,Y               \\ If z_hi < 16 then jump to KILL1 to recycle this\n CMP #16                \\ particle, as it's so close that it's effectively gone\n BCC KILL1              \\ past us, and rejoin at STC1 with the new particle\n\n STA ZZ                 \\ Set ZZ to the z-coordinate in z_hi\n\n.STC1\n\n JSR PIXEL2             \\ Draw a stardust particle at (X1,Y1) with distance ZZ,\n                        \\ i.e. draw the newly moved particle at (x_hi, y_hi)\n                        \\ with distance z_hi\n\n DEY                    \\ Decrement the loop counter to point to the next\n                        \\ stardust particle\n\n BEQ P%+5               \\ If we have just done the last particle, skip the next\n                        \\ instruction to return from the subroutine\n\n JMP STL1               \\ We have more stardust to process, so jump back up to\n                        \\ STL1 for the next particle\n\n RTS                    \\ Return from the subroutine\n\n.KILL1\n\n                        \\ Our particle of stardust just flew past us, so let's\n                        \\ recycle that particle, starting it at a random\n                        \\ position that isn't too close to the centre point\n\n JSR DORND              \\ Set A and X to random numbers\n\n ORA #4                 \\ Make sure A is at least 4 and store it in Y1 and y_hi,\n STA Y1                 \\ so the new particle starts at least 4 pixels above or\n STA SY,Y               \\ below the centre of the screen\n\n JSR DORND              \\ Set A and X to random numbers\n\n ORA #8                 \\ Make sure A is at least 8 and store it in X1 and x_hi,\n STA X1                 \\ so the new particle starts at least 8 pixels either\n STA SX,Y               \\ side of the centre of the screen\n\n JSR DORND              \\ Set A and X to random numbers\n\n ORA #144               \\ Make sure A is at least 144 and store it in ZZ and\n STA SZ,Y               \\ z_hi so the new particle starts in the far distance\n STA ZZ\n\n LDA Y1                 \\ Set A to the new value of y_hi. This has no effect as\n                        \\ STC1 starts with a jump to PIXEL2, which starts with a\n                        \\ LDA instruction\n\n JMP STC1               \\ Jump up to STC1 to draw this new particle\n\n\\ ******************************************************************************\n\\\n\\       Name: STARS6\n\\       Type: Subroutine\n\\   Category: Stardust\n\\    Summary: Process the stardust for the rear view\n\\  Deep dive: Stardust in the front view\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine is very similar to STARS1, which processes stardust for the front\n\\ view. The main difference is that the direction of travel is reversed, so the\n\\ signs in the calculations are different, as well as the order of the first\n\\ batch of calculations.\n\\\n\\ When a stardust particle falls away into the far distance, it is removed from\n\\ the screen and its memory is recycled as a new particle, positioned randomly\n\\ along one of the four edges of the screen.\n\\\n\\ These are the calculations referred to in the commentary:\n\\\n\\   1. q = 64 * speed / z_hi\n\\   2. z = z - speed * 64\n\\   3. y = y + |y_hi| * q\n\\   4. x = x + |x_hi| * q\n\\\n\\   5. y = y + alpha * x / 256\n\\   6. x = x - alpha * y / 256\n\\\n\\   7. x = x + 2 * (beta * y / 256) ^ 2\n\\   8. y = y - beta * 256\n\\\n\\ For more information see the associated deep dive.\n\\\n\\ ******************************************************************************\n\n.STARS6\n\n LDY NOSTM              \\ Set Y to the current number of stardust particles, so\n                        \\ we can use it as a counter through all the stardust\n\n.STL6\n\n JSR DV42               \\ Call DV42 to set the following:\n                        \\\n                        \\   (P R) = 256 * DELTA / z_hi\n                        \\         = 256 * speed / z_hi\n                        \\\n                        \\ The maximum value returned is P = 2 and R = 128 (see\n                        \\ DV42 for an explanation)\n\n LDA R                  \\ Set A = R, so now:\n                        \\\n                        \\   (P A) = 256 * speed / z_hi\n\n LSR P                  \\ Rotate (P A) right by 2 places, which sets P = 0 (as P\n ROR A                  \\ has a maximum value of 2) and leaves:\n LSR P                  \\\n ROR A                  \\   A = 64 * speed / z_hi\n\n ORA #1                 \\ Make sure A is at least 1, and store it in Q, so we\n STA Q                  \\ now have result 1 above:\n                        \\\n                        \\   Q = 64 * speed / z_hi\n\n LDA SX,Y               \\ Set X1 = A = x_hi\n STA X1                 \\\n                        \\ So X1 contains the original value of x_hi, which we\n                        \\ use below to remove the existing particle\n\n JSR MLU2               \\ Set (A P) = |x_hi| * Q\n\n                        \\ We now calculate:\n                        \\\n                        \\   XX(1 0) = x - (A P)\n\n STA XX+1               \\ First we do the low bytes:\n LDA SXL,Y              \\\n SBC P                  \\   XX(1 0) = x_lo - (A P)\n STA XX\n\n LDA X1                 \\ And then we do the high bytes:\n SBC XX+1               \\\n STA XX+1               \\   XX(1 0) = (x_hi 0) - XX(1 0)\n                        \\\n                        \\ so we get our result:\n                        \\\n                        \\   XX(1 0) = x - (A P)\n                        \\           = x - |x_hi| * Q\n                        \\\n                        \\ which is result 2 above, and we also have:\n\n JSR MLU1               \\ Call MLU1 to set:\n                        \\\n                        \\   Y1 = y_hi\n                        \\\n                        \\   (A P) = |y_hi| * Q\n                        \\\n                        \\ So Y1 contains the original value of y_hi, which we\n                        \\ use below to remove the existing particle\n\n                        \\ We now calculate:\n                        \\\n                        \\   (S R) = YY(1 0) = y - (A P)\n\n STA YY+1               \\ First we do the low bytes with:\n LDA SYL,Y              \\\n SBC P                  \\   YY+1 = A\n STA YY                 \\   R = YY = y_lo - P\n STA R                  \\\n                        \\ so we get this:\n                        \\\n                        \\   (? R) = YY(1 0) = y_lo - (A P)\n\n LDA Y1                 \\ And then we do the high bytes with:\n SBC YY+1               \\\n STA YY+1               \\   S = YY+1 = y_hi - YY+1\n STA S                  \\\n                        \\ so we get our result:\n                        \\\n                        \\   (S R) = YY(1 0) = (y_hi y_lo) - (A P)\n                        \\                   = y - |y_hi| * Q\n                        \\\n                        \\ which is result 3 above, and (S R) is set to the new\n                        \\ value of y\n\n LDA SZL,Y              \\ We now calculate the following:\n ADC DELT4              \\\n STA SZL,Y              \\  (z_hi z_lo) = (z_hi z_lo) + DELT4(1 0)\n                        \\\n                        \\ starting with the low bytes\n\n LDA SZ,Y               \\ And then we do the high bytes\n STA ZZ                 \\\n ADC DELT4+1            \\ We also set ZZ to the original value of z_hi, which we\n STA SZ,Y               \\ use below to remove the existing particle\n                        \\\n                        \\ So now we have result 4 above:\n                        \\\n                        \\   z = z + DELT4(1 0)\n                        \\     = z + speed * 64\n\n LDA XX+1               \\ EOR x with the correct sign of the roll angle alpha,\n EOR ALP2               \\ so A has the opposite sign to the roll angle alpha\n\n JSR MLS1               \\ Call MLS1 to calculate:\n                        \\\n                        \\   (A P) = A * ALP1\n                        \\         = (-x / 256) * alpha\n\n JSR ADD                \\ Call ADD to calculate:\n                        \\\n                        \\   (A X) = (A P) + (S R)\n                        \\         = (-x / 256) * alpha + y\n                        \\         = y - alpha * x / 256\n\n STA YY+1               \\ Set YY(1 0) = (A X) to give:\n STX YY                 \\\n                        \\   YY(1 0) = y - alpha * x / 256\n                        \\\n                        \\ which is result 5 above, and we also have:\n                        \\\n                        \\   A = YY+1 = y - alpha * x / 256\n                        \\\n                        \\ i.e. A is the new value of y, divided by 256\n\n EOR ALP2+1             \\ EOR with the flipped sign of the roll angle alpha, so\n                        \\ A has the opposite sign to the flipped roll angle\n                        \\ alpha, i.e. it gets the same sign as alpha\n\n JSR MLS2               \\ Call MLS2 to calculate:\n                        \\\n                        \\   (S R) = XX(1 0)\n                        \\         = x\n                        \\\n                        \\   (A P) = A * ALP1\n                        \\         = y / 256 * alpha\n\n JSR ADD                \\ Call ADD to calculate:\n                        \\\n                        \\   (A X) = (A P) + (S R)\n                        \\         = y / 256 * alpha + x\n\n STA XX+1               \\ Set XX(1 0) = (A X), which gives us result 6 above:\n STX XX                 \\\n                        \\   x = x + alpha * y / 256\n\n LDA YY+1               \\ Set A to y_hi and set it to the flipped sign of beta\n EOR BET2+1\n\n LDX BET1               \\ Fetch the pitch magnitude into X\n\n JSR MULTS-2            \\ Call MULTS-2 to calculate:\n                        \\\n                        \\   (A P) = X * A\n                        \\         = beta * y_hi\n\n STA Q                  \\ Store the high byte of the result in Q, so:\n                        \\\n                        \\   Q = beta * y_hi / 256\n\n LDA XX+1               \\ Set S = x_hi\n STA S\n\n EOR #%10000000         \\ Flip the sign of A, so A now contains -x\n\n JSR MUT1               \\ Call MUT1 to calculate:\n                        \\\n                        \\   R = XX = x_lo\n                        \\\n                        \\   (A P) = Q * A\n                        \\         = (beta * y_hi / 256) * (-beta * y_hi / 256)\n                        \\         = (-beta * y / 256) ^ 2\n\n ASL P                  \\ Double (A P), store the top byte in A and set the C\n ROL A                  \\ flag to bit 7 of the original A, so this does:\n STA T                  \\\n                        \\   (T P) = (A P) << 1\n                        \\         = 2 * (-beta * y / 256) ^ 2\n\n LDA #0                 \\ Set bit 7 in A to the sign bit from the A in the\n ROR A                  \\ calculation above and apply it to T, so we now have:\n ORA T                  \\\n                        \\   (A P) = -2 * (beta * y / 256) ^ 2\n                        \\\n                        \\ with the doubling retaining the sign of (A P)\n\n JSR ADD                \\ Call ADD to calculate:\n                        \\\n                        \\   (A X) = (A P) + (S R)\n                        \\         = -2 * (beta * y / 256) ^ 2 + x\n\n STA XX+1               \\ Store the high byte A in XX+1\n\n TXA                    \\ Store the low byte X in x_lo\n STA SXL,Y\n\n                        \\ So (XX+1 x_lo) now contains:\n                        \\\n                        \\   x = x - 2 * (beta * y / 256) ^ 2\n                        \\\n                        \\ which is result 7 above\n\n LDA YY                 \\ Set (S R) = YY(1 0) = y\n STA R\n LDA YY+1\n STA S\n\n\\EOR #128               \\ These instructions are commented out in the original\n\\JSR MAD                \\ source\n\\STA S\n\\STX R\n\n LDA #0                 \\ Set P = 0\n STA P\n\n LDA BETA               \\ Set A = beta, so (A P) = (beta 0) = beta * 256\n\n JSR PIX1               \\ Call PIX1 to calculate the following:\n                        \\\n                        \\   (YY+1 y_lo) = (A P) + (S R)\n                        \\               = beta * 256 + y\n                        \\\n                        \\ i.e. y = y + beta * 256, which is result 8 above\n                        \\\n                        \\ PIX1 also draws a particle at (X1, Y1) with distance\n                        \\ ZZ, which will remove the old stardust particle, as we\n                        \\ set X1, Y1 and ZZ to the original values for this\n                        \\ particle during the calculations above\n\n                        \\ We now have our newly moved stardust particle at\n                        \\ x-coordinate (XX+1 x_lo) and y-coordinate (YY+1 y_lo)\n                        \\ and distance z_hi, so we draw it if it's still on\n                        \\ screen, otherwise we recycle it as a new bit of\n                        \\ stardust and draw that\n\n LDA XX+1               \\ Set X1 and x_hi to the high byte of XX in XX+1, so\n STA X1                 \\ the new x-coordinate is in (x_hi x_lo) and the high\n STA SX,Y               \\ byte is in X1\n\n LDA YY+1               \\ Set Y1 and y_hi to the high byte of YY in YY+1, so\n STA SY,Y               \\ the new x-coordinate is in (y_hi y_lo) and the high\n STA Y1                 \\ byte is in Y1\n\n AND #%01111111         \\ If |y_hi| >= 110 then jump to KILL6 to recycle this\n CMP #110               \\ particle, as it's gone off the top or bottom of the\n BCS KILL6              \\ screen, and rejoin at STC6 with the new particle\n\n LDA SZ,Y               \\ If z_hi >= 160 then jump to KILL6 to recycle this\n CMP #160               \\ particle, as it's so far away that it's too far to\n BCS KILL6              \\ see, and rejoin at STC1 with the new particle\n\n STA ZZ                 \\ Set ZZ to the z-coordinate in z_hi\n\n.STC6\n\n JSR PIXEL2             \\ Draw a stardust particle at (X1,Y1) with distance ZZ,\n                        \\ i.e. draw the newly moved particle at (x_hi, y_hi)\n                        \\ with distance z_hi\n\n DEY                    \\ Decrement the loop counter to point to the next\n                        \\ stardust particle\n\n BEQ ST3                \\ If we have just done the last particle, skip the next\n                        \\ instruction to return from the subroutine\n\n JMP STL6               \\ We have more stardust to process, so jump back up to\n                        \\ STL6 for the next particle\n\n.ST3\n\n RTS                    \\ Return from the subroutine\n\n.KILL6\n\n JSR DORND              \\ Set A and X to random numbers\n\n AND #%01111111         \\ Clear the sign bit of A to get |A|\n\n ADC #10                \\ Make sure A is at least 10 and store it in z_hi and\n STA SZ,Y               \\ ZZ, so the new particle starts close to us\n STA ZZ\n\n LSR A                  \\ Divide A by 2 and randomly set the C flag\n\n BCS ST4                \\ Jump to ST4 half the time\n\n LSR A                  \\ Randomly set the C flag again\n\n LDA #252               \\ Set A to either +126 or -126 (252 >> 1) depending on\n ROR A                  \\ the C flag, as this is a sign-magnitude number with\n                        \\ the C flag rotated into its sign bit\n\n STA X1                 \\ Set x_hi and X1 to A, so this particle starts on\n STA SX,Y               \\ either the left or right edge of the screen\n\n JSR DORND              \\ Set A and X to random numbers\n\n STA Y1                 \\ Set y_hi and Y1 to random numbers, so the particle\n STA SY,Y               \\ starts anywhere along either the left or right edge\n\n JMP STC6               \\ Jump up to STC6 to draw this new particle\n\n.ST4\n\n JSR DORND              \\ Set A and X to random numbers\n\n STA X1                 \\ Set x_hi and X1 to random numbers, so the particle\n STA SX,Y               \\ starts anywhere along the x-axis\n\n LSR A                  \\ Randomly set the C flag\n\n LDA #230               \\ Set A to either +115 or -115 (230 >> 1) depending on\n ROR A                  \\ the C flag, as this is a sign-magnitude number with\n                        \\ the C flag rotated into its sign bit\n\n STA Y1                 \\ Set y_hi and Y1 to A, so the particle starts anywhere\n STA SY,Y               \\ along either the top or bottom edge of the screen\n\n BNE STC6               \\ Jump up to STC6 to draw this new particle (this BNE is\n                        \\ effectively a JMP as A will never be zero)\n\n\\ ******************************************************************************\n\\\n\\       Name: PRXS\n\\       Type: Variable\n\\   Category: Equipment\n\\    Summary: Equipment prices\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Equipment prices are stored as 10 * the actual value, so we can support prices\n\\ with fractions of credits (0.1 Cr). This is used for the price of fuel only.\n\\\n\\ ******************************************************************************\n\n.PRXS\n\n EQUW 1                 \\ 0  Fuel, calculated in EQSHP  140.0 Cr (full tank)\n EQUW 300               \\ 1  Missile                     30.0 Cr\n EQUW 4000              \\ 2  Large Cargo Bay            400.0 Cr\n EQUW 6000              \\ 3  E.C.M. System              600.0 Cr\n EQUW 4000              \\ 4  Extra Pulse Lasers         400.0 Cr\n EQUW 10000             \\ 5  Extra Beam Lasers         1000.0 Cr\n EQUW 5250              \\ 6  Fuel Scoops                525.0 Cr\n EQUW 10000             \\ 7  Escape Pod                1000.0 Cr\n EQUW 9000              \\ 8  Energy Bomb                900.0 Cr\n EQUW 15000             \\ 9  Energy Unit               1500.0 Cr\n EQUW 10000             \\ 10 Docking Computer          1000.0 Cr\n EQUW 50000             \\ 11 Galactic Hyperspace       5000.0 Cr\n\n\\ ******************************************************************************\n\\\n\\       Name: STATUS\n\\       Type: Subroutine\n\\   Category: Status\n\\    Summary: Show the Status Mode screen (red key f8)\n\\  Deep dive: Combat rank\n\\\n\\ ******************************************************************************\n\n.st4\n\n                        \\ We call this from st5 below with the high byte of the\n                        \\ kill tally in A, which is non-zero, and want to return\n                        \\ with the following in X, depending on our rating:\n                        \\\n                        \\   Competent = 6\n                        \\   Dangerous = 7\n                        \\   Deadly    = 8\n                        \\   Elite     = 9\n                        \\\n                        \\ The high bytes of the top tier ratings are as follows,\n                        \\ so this a relatively simple calculation:\n                        \\\n                        \\   Competent = 1\n                        \\   Dangerous = 2 to 9\n                        \\   Deadly    = 10 to 24\n                        \\   Elite     = 25 and up\n\n LDX #9                 \\ Set X to 9 for an Elite rating\n\n CMP #25                \\ If A >= 25, jump to st3 to print out our rating, as we\n BCS st3                \\ are Elite\n\n DEX                    \\ Decrement X to 8 for a Deadly rating\n\n CMP #10                \\ If A >= 10, jump to st3 to print out our rating, as we\n BCS st3                \\ are Deadly\n\n DEX                    \\ Decrement X to 7 for a Dangerous rating\n\n CMP #2                 \\ If A >= 2, jump to st3 to print out our rating, as we\n BCS st3                \\ are Dangerous\n\n DEX                    \\ Decrement X to 6 for a Competent rating\n\n BNE st3                \\ Jump to st3 to print out our rating, as we are\n                        \\ Competent (this BNE is effectively a JMP as A will\n                        \\ never be zero)\n\n.STATUS\n\n LDA #8                 \\ Clear the top part of the screen, draw a border box,\n JSR TT66               \\ and set the current view type in QQ11 to 8 (Status\n                        \\ Mode screen)\n\n JSR TT111              \\ Select the system closest to galactic coordinates\n                        \\ (QQ9, QQ10)\n\n LDA #7                 \\ Move the text cursor to column 7\n STA XC\n\n LDA #126               \\ Print recursive token 126, which prints the top\n JSR NLIN3              \\ four lines of the Status Mode screen:\n                        \\\n                        \\         COMMANDER {commander name}\n                        \\\n                        \\\n                        \\   Present System      : {current system name}\n                        \\   Hyperspace System   : {selected system name}\n                        \\   Condition           :\n                        \\\n                        \\ and draw a horizontal line at pixel row 19 to box\n                        \\ in the title\n\n LDA #15                \\ Set A to token 129 (\"{sentence case}DOCKED\")\n\n LDY QQ12               \\ Fetch the docked status from QQ12, and if we are\n BNE st6                \\ docked, jump to st6 to print \"Docked\" for our\n                        \\ ship's condition\n\n LDA #230               \\ Otherwise we are in space, so start off by setting A\n                        \\ to token 70 (\"GREEN\")\n\n LDY MANY+AST           \\ Set Y to the number of asteroids in our local bubble\n                        \\ of universe\n\n LDX FRIN+2,Y           \\ The ship slots at FRIN are ordered with the first two\n                        \\ slots reserved for the planet and sun/space station,\n                        \\ and then any ships, so if the slot at FRIN+2+Y is not\n                        \\ empty (i.e. is non-zero), then that means the number\n                        \\ of non-asteroids in the vicinity is at least 1\n\n BEQ st6                \\ So if X = 0, there are no ships in the vicinity, so\n                        \\ jump to st6 to print \"Green\" for our ship's condition\n\n LDY ENERGY             \\ Otherwise we have ships in the vicinity, so we load\n                        \\ our energy levels into Y\n\n CPY #128               \\ Set the C flag if Y >= 128, so C is set if we have\n                        \\ more than half of our energy banks charged\n\n ADC #1                 \\ Add 1 + C to A, so if C is not set (i.e. we have low\n                        \\ energy levels) then A is set to token 231 (\"RED\"),\n                        \\ and if C is set (i.e. we have healthy energy levels)\n                        \\ then A is set to token 232 (\"YELLOW\")\n\n.st6\n\n JSR plf                \\ Print the text token in A (which contains our ship's\n                        \\ condition) followed by a newline\n\n LDA #125               \\ Print recursive token 125, which prints the next\n JSR spc                \\ three lines of the Status Mode screen:\n                        \\\n                        \\   Fuel: {fuel level} Light Years\n                        \\   Cash: {cash} Cr\n                        \\   Legal Status:\n                        \\\n                        \\ followed by a space\n\n LDA #19                \\ Set A to token 133 (\"CLEAN\")\n\n LDY FIST               \\ Fetch our legal status, and if it is 0, we are clean,\n BEQ st5                \\ so jump to st5 to print \"Clean\"\n\n CPY #50                \\ Set the C flag if Y >= 50, so C is set if we have\n                        \\ a legal status of 50+ (i.e. we are a fugitive)\n\n ADC #1                 \\ Add 1 + C to A, so if C is not set (i.e. we have a\n                        \\ legal status between 1 and 49) then A is set to token\n                        \\ 134 (\"OFFENDER\"), and if C is set (i.e. we have a\n                        \\ legal status of 50+) then A is set to token 135\n                        \\ (\"FUGITIVE\")\n\n.st5\n\n JSR plf                \\ Print the text token in A (which contains our legal\n                        \\ status) followed by a newline\n\n LDA #16                \\ Print recursive token 130 (\"RATING:\") followed by a\n JSR spc                \\ space\n\n LDA TALLY+1            \\ Fetch the high byte of the kill tally, and if it is\n BNE st4                \\ not zero, then we have more than 256 kill points, so\n                        \\ jump to st4 to work out whether we are Competent,\n                        \\ Dangerous, Deadly or Elite\n\n                        \\ Otherwise we have fewer than 256 kill pointss, so we\n                        \\ are one of Harmless, Mostly Harmless, Poor, Average,\n                        \\ Above Average or Competent\n\n TAX                    \\ Set X to 0 (as A is 0)\n\n LDA TALLY              \\ Set A to the lower byte of tally, with bits 0 and 1\n LSR A                  \\ shifted off to the right, so we can now analyse bits\n LSR A                  \\ 2 to 7 by shifting A to the right one bit at a time\n\n.st5L\n\n                        \\ We now loop through bits 2 to 7, shifting each of them\n                        \\ off the end of A until there are no set bits left, and\n                        \\ incrementing X before each shift, so at the end of the\n                        \\ process, X contains the position of the leftmost 1 in\n                        \\ A. Looking at the rank values in TALLY:\n                        \\\n                        \\   Harmless        = %00000000 to %00000111\n                        \\   Mostly Harmless = %00001000 to %00001111\n                        \\   Poor            = %00010000 to %00011111\n                        \\   Average         = %00100000 to %00111111\n                        \\   Above Average   = %01000000 to %01111111\n                        \\   Competent       = %10000000 to %11111111\n                        \\\n                        \\ we can see that the values returned by this process\n                        \\ are:\n                        \\\n                        \\   Harmless        = 1\n                        \\   Mostly Harmless = 2\n                        \\   Poor            = 3\n                        \\   Average         = 4\n                        \\   Above Average   = 5\n                        \\   Competent       = 6\n\n INX                    \\ Increment X to count the number of shifts\n\n LSR A                  \\ Shift A to the right\n\n BNE st5L               \\ Keep looping around until A = 0, which means there are\n                        \\ no set bits left in A\n\n.st3\n\n TXA                    \\ A now contains our rating as a value of 1 to 9, so\n                        \\ transfer X to A, so we can print it out\n\n CLC                    \\ Print recursive token 135 + A, which will be in the\n ADC #21                \\ range 136 (\"HARMLESS\") to 144 (\"---- E L I T E ----\")\n JSR plf                \\ followed by a newline\n\n LDA #18                \\ Print recursive token 132, which prints the next bit\n JSR plf2               \\ of the Status Mode screen:\n                        \\\n                        \\   EQUIPMENT:\n                        \\\n                        \\ followed by a newline and an indent of 6 characters\n\n LDA CRGO               \\ If our ship's cargo capacity is < 26 (i.e. we do not\n CMP #26                \\ have a cargo bay extension), skip the following two\n BCC P%+7               \\ instructions\n\n LDA #107               \\ We do have a cargo bay extension, so print recursive\n JSR plf2               \\ token 107 (\"LARGE CARGO{sentence case} BAY\"), followed\n                        \\ by a newline and an indent of 6 characters\n\n LDA BST                \\ If we don't have fuel scoops fitted, skip the\n BEQ P%+7               \\ following two instructions\n\n LDA #111               \\ We do have fuel scoops fitted, so print recursive\n JSR plf2               \\ token 111 (\"FUEL SCOOPS\"), followed by a newline and\n                        \\ an indent of 6 characters\n\n LDA ECM                \\ If we don't have an E.C.M. fitted, skip the following\n BEQ P%+7               \\ two instructions\n\n LDA #108               \\ We do have an E.C.M. fitted, so print recursive token\n JSR plf2               \\ 108 (\"E.C.M.SYSTEM\"), followed by a newline and an\n                        \\ indent of 6 characters\n\n LDA #113               \\ We now cover the four pieces of equipment whose flags\n STA XX4                \\ are stored in BOMB through BOMB+3, and whose names\n                        \\ correspond with text tokens 113 through 116:\n                        \\\n                        \\   BOMB+0 = BOMB  = token 113 = Energy bomb\n                        \\   BOMB+1 = ENGY  = token 114 = Energy unit\n                        \\   BOMB+2 = DKCMP = token 115 = Docking computer\n                        \\   BOMB+3 = GHYP  = token 116 = Galactic hyperdrive\n                        \\\n                        \\ We can print these out using a loop, so we set XX4 to\n                        \\ 113 as a counter (and we also set A as well, to pass\n                        \\ through to plf2)\n\n.stqv\n\n TAY                    \\ Fetch byte BOMB+0 through BOMB+4 for values of XX4\n LDX BOMB-113,Y         \\ from 113 through 117\n\n BEQ P%+5               \\ If it is zero then we do not own that piece of\n                        \\ equipment, so skip the next instruction\n\n JSR plf2               \\ Print the recursive token in A from 113 (\"ENERGY\n                        \\ BOMB\") through 116 (\"GALACTIC HYPERSPACE \"), followed\n                        \\ by a newline and an indent of 6 characters\n\n INC XX4                \\ Increment the counter (and A as well)\n LDA XX4\n\n CMP #117               \\ If A < 117, loop back up to stqv to print the next\n BCC stqv               \\ piece of equipment\n\n LDX #0                 \\ Now to print our ship's lasers, so set a counter in X\n                        \\ to count through the four views (0 = front, 1 = rear,\n                        \\ 2 = left, 3 = right)\n\n.st\n\n STX CNT                \\ Store the view number in CNT\n\n LDY LASER,X            \\ Fetch the laser power for view X, and if we do not\n BEQ st1                \\ have a laser fitted to that view, jump to st1 to move\n                        \\ on to the next one\n\n TXA                    \\ Print recursive token 96 + X, which will print from 96\n CLC                    \\ (\"FRONT\") through to 99 (\"RIGHT\"), followed by a space\n ADC #96\n JSR spc\n\n LDA #103               \\ Set A to token 103 (\"PULSE LASER\")\n\n LDX CNT                \\ If the laser power for view X has bit 7 clear, then it\n LDY LASER,X            \\ is a pulse laser, so skip the following instruction\n BPL P%+4\n\n LDA #104               \\ Set A to token 104 (\"BEAM LASER\")\n\n JSR plf2               \\ Print the text token in A (which contains the laser\n                        \\ type) followed by a newline and an indent of 6\n                        \\ characters\n\n.st1\n\n LDX CNT                \\ Increment the counter in X and CNT to point to the\n INX                    \\ next view\n\n CPX #4                 \\ If this isn't the last of the four views, jump back up\n BCC st                 \\ to st to print out the next one\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: plf2\n\\       Type: Subroutine\n\\   Category: Text\n\\    Summary: Print text followed by a newline and indent of 6 characters\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Print a text token followed by a newline, and indent the next line to text\n\\ column 6.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The text token to be printed\n\\\n\\ ******************************************************************************\n\n.plf2\n\n JSR plf                \\ Print the text token in A followed by a newline\n\n LDX #6                 \\ Move the text cursor to column 6\n STX XC\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: TENS\n\\       Type: Variable\n\\   Category: Text\n\\    Summary: A constant used when printing large numbers in BPRNT\n\\  Deep dive: Printing decimal numbers\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Contains the four low bytes of the value 100,000,000,000 (100 billion).\n\\\n\\ The maximum number of digits that we can print with the BPRNT routine is 11,\n\\ so the biggest number we can print is 99,999,999,999. This maximum number\n\\ plus 1 is 100,000,000,000, which in hexadecimal is:\n\\\n\\   17 48 76 E8 00\n\\\n\\ The TENS variable contains the lowest four bytes in this number, with the\n\\ most significant byte first, i.e. 48 76 E8 00. This value is used in the\n\\ BPRNT routine when working out which decimal digits to print when printing a\n\\ number.\n\\\n\\ ******************************************************************************\n\n.TENS\n\n EQUD &00E87648\n\n\\ ******************************************************************************\n\\\n\\       Name: pr2\n\\       Type: Subroutine\n\\   Category: Text\n\\    Summary: Print an 8-bit number, left-padded to 3 digits, and optional point\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Print the 8-bit number in X to 3 digits, left-padding with spaces for numbers\n\\ with fewer than 3 digits (so numbers < 100 are right-aligned). Optionally\n\\ include a decimal point.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   The number to print\n\\\n\\   C flag              If set, include a decimal point\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   pr2+2               Print the 8-bit number in X to the number of digits in A\n\\\n\\ ******************************************************************************\n\n.pr2\n\n LDA #3                 \\ Set A to the number of digits (3)\n\n LDY #0                 \\ Zero the Y register, so we can fall through into TT11\n                        \\ to print the 16-bit number (Y X) to 3 digits, which\n                        \\ effectively prints X to 3 digits as the high byte is\n                        \\ zero\n\n\\ ******************************************************************************\n\\\n\\       Name: TT11\n\\       Type: Subroutine\n\\   Category: Text\n\\    Summary: Print a 16-bit number, left-padded to n digits, and optional point\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Print the 16-bit number in (Y X) to a specific number of digits, left-padding\n\\ with spaces for numbers with fewer digits (so lower numbers will be right-\n\\ aligned). Optionally include a decimal point.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   The low byte of the number to print\n\\\n\\   Y                   The high byte of the number to print\n\\\n\\   A                   The number of digits\n\\\n\\   C flag              If set, include a decimal point\n\\\n\\ ******************************************************************************\n\n.TT11\n\n STA U                  \\ We are going to use the BPRNT routine (below) to\n                        \\ print this number, so we store the number of digits\n                        \\ in U, as that's what BPRNT takes as an argument\n\n LDA #0                 \\ BPRNT takes a 32-bit number in K to K+3, with the\n STA K                  \\ most significant byte first (big-endian), so we set\n STA K+1                \\ the two most significant bytes to zero (K and K+1)\n STY K+2                \\ and store (Y X) in the least two significant bytes\n STX K+3                \\ (K+2 and K+3), so we are going to print the 32-bit\n                        \\ number (0 0 Y X)\n\n                        \\ Finally we fall through into BPRNT to print out the\n                        \\ number in K to K+3, which now contains (Y X), to A\n                        \\ digits (as U = A), using the same C flag as when pr2\n                        \\ was called to control the decimal point\n\n\\ ******************************************************************************\n\\\n\\       Name: BPRNT\n\\       Type: Subroutine\n\\   Category: Text\n\\    Summary: Print a 32-bit number, left-padded to a specific number of digits,\n\\             with an optional decimal point\n\\  Deep dive: Printing decimal numbers\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Print the 32-bit number stored in K(0 1 2 3) to a specific number of digits,\n\\ left-padding with spaces for numbers with fewer digits (so lower numbers are\n\\ right-aligned). Optionally include a decimal point.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   K(0 1 2 3)          The number to print, stored with the most significant\n\\                       byte in K and the least significant in K+3 (i.e. as a\n\\                       big-endian number, which is the opposite way to how the\n\\                       6502 assembler stores addresses, for example)\n\\\n\\   U                   The maximum number of digits to print, including the\n\\                       decimal point (spaces will be used on the left to pad\n\\                       out the result to this width, so the number is right-\n\\                       aligned to this width). U must be 11 or less\n\\\n\\   C flag              If set, include a decimal point followed by one\n\\                       fractional digit (i.e. show the number to 1 decimal\n\\                       place). In this case, the number in K(0 1 2 3) contains\n\\                       10 * the number we end up printing, so to print 123.4,\n\\                       we would pass 1234 in K(0 1 2 3) and would set the C\n\\                       flag to include the decimal point\n\\\n\\ ******************************************************************************\n\n.BPRNT\n\n LDX #11                \\ Set T to the maximum number of digits allowed (11\n STX T                  \\ characters, which is the number of digits in 10\n                        \\ billion). We will use this as a flag when printing\n                        \\ characters in TT37 below\n\n PHP                    \\ Make a copy of the status register (in particular\n                        \\ the C flag) so we can retrieve it later\n\n BCC TT30               \\ If the C flag is clear, we do not want to print a\n                        \\ decimal point, so skip the next two instructions\n\n DEC T                  \\ As we are going to show a decimal point, decrement\n DEC U                  \\ both the number of characters and the number of\n                        \\ digits (as one of them is now a decimal point)\n\n.TT30\n\n LDA #11                \\ Set A to 11, the maximum number of digits allowed\n\n SEC                    \\ Set the C flag so we can do subtraction without the\n                        \\ C flag affecting the result\n\n STA XX17               \\ Store the maximum number of digits allowed (11) in\n                        \\ XX17\n\n SBC U                  \\ Set U = 11 - U + 1, so U now contains the maximum\n STA U                  \\ number of digits minus the number of digits we want\n INC U                  \\ to display, plus 1 (so this is the number of digits\n                        \\ we should skip before starting to print the number\n                        \\ itself, and the plus 1 is there to ensure we print at\n                        \\ least one digit)\n\n LDY #0                 \\ In the main loop below, we use Y to count the number\n                        \\ of times we subtract 10 billion to get the leftmost\n                        \\ digit, so set this to zero\n\n STY S                  \\ In the main loop below, we use location S as an\n                        \\ 8-bit overflow for the 32-bit calculations, so\n                        \\ we need to set this to 0 before joining the loop\n\n JMP TT36               \\ Jump to TT36 to start the process of printing this\n                        \\ number's digits\n\n.TT35\n\n                        \\ This subroutine multiplies K(S 0 1 2 3) by 10 and\n                        \\ stores the result back in K(S 0 1 2 3), using the fact\n                        \\ that K * 10 = (K * 2) + (K * 2 * 2 * 2)\n\n ASL K+3                \\ Set K(S 0 1 2 3) = K(S 0 1 2 3) * 2 by rotating left\n ROL K+2\n ROL K+1\n ROL K\n ROL S\n\n LDX #3                 \\ Now we want to make a copy of the newly doubled K in\n                        \\ XX15, so we can use it for the first (K * 2) in the\n                        \\ equation above, so set up a counter in X for copying\n                        \\ four bytes, starting with the last byte in memory\n                        \\ (i.e. the least significant)\n\n.tt35\n\n LDA K,X                \\ Copy the X-th byte of K(0 1 2 3) to the X-th byte of\n STA XX15,X             \\ XX15(0 1 2 3), so that XX15 will contain a copy of\n                        \\ K(0 1 2 3) once we've copied all four bytes\n\n DEX                    \\ Decrement the loop counter\n\n BPL tt35               \\ Loop back to copy the next byte until we have copied\n                        \\ all four\n\n LDA S                  \\ Store the value of location S, our overflow byte, in\n STA XX15+4             \\ XX15+4, so now XX15(4 0 1 2 3) contains a copy of\n                        \\ K(S 0 1 2 3), which is the value of (K * 2) that we\n                        \\ want to use in our calculation\n\n ASL K+3                \\ Now to calculate the (K * 2 * 2 * 2) part. We still\n ROL K+2                \\ have (K * 2) in K(S 0 1 2 3), so we just need to shift\n ROL K+1                \\ it twice. This is the first one, so we do this:\n ROL K                  \\\n ROL S                  \\   K(S 0 1 2 3) = K(S 0 1 2 3) * 2 = K * 4\n\n ASL K+3                \\ And then we do it again, so that means:\n ROL K+2                \\\n ROL K+1                \\   K(S 0 1 2 3) = K(S 0 1 2 3) * 2 = K * 8\n ROL K\n ROL S\n\n CLC                    \\ Clear the C flag so we can do addition without the\n                        \\ C flag affecting the result\n\n LDX #3                 \\ By now we've got (K * 2) in XX15(4 0 1 2 3) and\n                        \\ (K * 8) in K(S 0 1 2 3), so the final step is to add\n                        \\ these two 32-bit numbers together to get K * 10.\n                        \\ So we set a counter in X for four bytes, starting\n                        \\ with the last byte in memory (i.e. the least\n                        \\ significant)\n\n.tt36\n\n LDA K,X                \\ Fetch the X-th byte of K into A\n\n ADC XX15,X             \\ Add the X-th byte of XX15 to A, with carry\n\n STA K,X                \\ Store the result in the X-th byte of K\n\n DEX                    \\ Decrement the loop counter\n\n BPL tt36               \\ Loop back to add the next byte, moving from the least\n                        \\ significant byte to the most significant, until we\n                        \\ have added all four\n\n LDA XX15+4             \\ Finally, fetch the overflow byte from XX15(4 0 1 2 3)\n\n ADC S                  \\ And add it to the overflow byte from K(S 0 1 2 3),\n                        \\ with carry\n\n STA S                  \\ And store the result in the overflow byte from\n                        \\ K(S 0 1 2 3), so now we have our desired result, i.e.\n                        \\\n                        \\   K(S 0 1 2 3) = K(S 0 1 2 3) * 10\n\n LDY #0                 \\ In the main loop below, we use Y to count the number\n                        \\ of times we subtract 10 billion to get the leftmost\n                        \\ digit, so set this to zero so we can rejoin the main\n                        \\ loop for another subtraction process\n\n.TT36\n\n                        \\ This is the main loop of our digit-printing routine.\n                        \\ In the following loop, we are going to count the\n                        \\ number of times that we can subtract 10 million and\n                        \\ store that count in Y, which we have already set to 0\n\n LDX #3                 \\ Our first calculation concerns 32-bit numbers, so\n                        \\ set up a counter for a four-byte loop\n\n SEC                    \\ Set the C flag so we can do subtraction without the\n                        \\ C flag affecting the result\n\n.tt37\n\n                        \\ We now loop through each byte in turn to do this:\n                        \\\n                        \\   XX15(4 0 1 2 3) = K(S 0 1 2 3) - 100,000,000,000\n\n LDA K,X                \\ Subtract the X-th byte of TENS (i.e. 10 billion) from\n SBC TENS,X             \\ the X-th byte of K\n\n STA XX15,X             \\ Store the result in the X-th byte of XX15\n\n DEX                    \\ Decrement the loop counter\n\n BPL tt37               \\ Loop back to subtract the next byte, moving from the\n                        \\ least significant byte to the most significant, until\n                        \\ we have subtracted all four\n\n LDA S                  \\ Subtract the fifth byte of 10 billion (i.e. &17) from\n SBC #&17               \\ the fifth (overflow) byte of K, which is S\n\n STA XX15+4             \\ Store the result in the overflow byte of XX15\n\n BCC TT37               \\ If subtracting 10 billion took us below zero, jump to\n                        \\ TT37 to print out this digit, which is now in Y\n\n LDX #3                 \\ We now want to copy XX15(4 0 1 2 3) back into\n                        \\ K(S 0 1 2 3), so we can loop back up to do the next\n                        \\ subtraction, so set up a counter for a four-byte loop\n\n.tt38\n\n LDA XX15,X             \\ Copy the X-th byte of XX15(0 1 2 3) to the X-th byte\n STA K,X                \\ of K(0 1 2 3), so that K(0 1 2 3) will contain a copy\n                        \\ of XX15(0 1 2 3) once we've copied all four bytes\n\n DEX                    \\ Decrement the loop counter\n\n BPL tt38               \\ Loop back to copy the next byte, until we have copied\n                        \\ all four\n\n LDA XX15+4             \\ Store the value of location XX15+4, our overflow\n STA S                  \\ byte in S, so now K(S 0 1 2 3) contains a copy of\n                        \\ XX15(4 0 1 2 3)\n\n INY                    \\ We have now managed to subtract 10 billion from our\n                        \\ number, so increment Y, which is where we are keeping\n                        \\ a count of the number of subtractions so far\n\n JMP TT36               \\ Jump back to TT36 to subtract the next 10 billion\n\n.TT37\n\n TYA                    \\ If we get here then Y contains the digit that we want\n                        \\ to print (as Y has now counted the total number of\n                        \\ subtractions of 10 billion), so transfer Y into A\n\n BNE TT32               \\ If the digit is non-zero, jump to TT32 to print it\n\n LDA T                  \\ Otherwise the digit is zero. If we are already\n                        \\ printing the number then we will want to print a 0,\n                        \\ but if we haven't started printing the number yet,\n                        \\ then we probably don't, as we don't want to print\n                        \\ leading zeroes unless this is the only digit before\n                        \\ the decimal point\n                        \\\n                        \\ To help with this, we are going to use T as a flag\n                        \\ that tells us whether we have already started\n                        \\ printing digits:\n                        \\\n                        \\   * If T <> 0 we haven't printed anything yet\n                        \\\n                        \\   * If T = 0 then we have started printing digits\n                        \\\n                        \\ We initially set T above to the maximum number of\n                        \\ characters allowed, less 1 if we are printing a\n                        \\ decimal point, so the first time we enter the digit\n                        \\ printing routine at TT37, it is definitely non-zero\n\n BEQ TT32               \\ If T = 0, jump straight to the print routine at TT32,\n                        \\ as we have already started printing the number, so we\n                        \\ definitely want to print this digit too\n\n DEC U                  \\ We initially set U to the number of digits we want to\n BPL TT34               \\ skip before starting to print the number. If we get\n                        \\ here then we haven't printed any digits yet, so\n                        \\ decrement U to see if we have reached the point where\n                        \\ we should start printing the number, and if not, jump\n                        \\ to TT34 to set up things for the next digit\n\n LDA #' '               \\ We haven't started printing any digits yet, but we\n BNE tt34               \\ have reached the point where we should start printing\n                        \\ our number, so call TT26 (via tt34) to print a space\n                        \\ so that the number is left-padded with spaces (this\n                        \\ BNE is effectively a JMP as A will never be zero)\n\n.TT32\n\n LDY #0                 \\ We are printing an actual digit, so first set T to 0,\n STY T                  \\ to denote that we have now started printing digits as\n                        \\ opposed to spaces\n\n CLC                    \\ The digit value is in A, so add ASCII \"0\" to get the\n ADC #'0'               \\ ASCII character number to print\n\n.tt34\n\n JSR TT26               \\ Call TT26 to print the character in A and fall through\n                        \\ into TT34 to get things ready for the next digit\n\n.TT34\n\n DEC T                  \\ Decrement T but keep T >= 0 (by incrementing it\n BPL P%+4               \\ again if the above decrement made T negative)\n INC T\n\n DEC XX17               \\ Decrement the total number of characters left to\n                        \\ print, which we stored in XX17\n\n BMI RR3+1              \\ If the result is negative, we have printed all the\n                        \\ characters, so return from the subroutine (as RR3\n                        \\ contains an ORA #&60 instruction, so RR3+1 is &60,\n                        \\ which is the opcode for an RTS)\n\n BNE P%+10              \\ If the result is positive (> 0) then we still have\n                        \\ characters left to print, so loop back to TT35 (via\n                        \\ the JMP TT35 instruction below) to print the next\n                        \\ digit\n\n PLP                    \\ If we get here then we have printed the exact number\n                        \\ of digits that we wanted to, so restore the C flag\n                        \\ that we stored at the start of the routine\n\n BCC P%+7               \\ If the C flag is clear, we don't want a decimal point,\n                        \\ so loop back to TT35 (via the JMP TT35 instruction\n                        \\ below) to print the next digit\n\n LDA #'.'               \\ Otherwise the C flag is set, so print the decimal\n JSR TT26               \\ point\n\n JMP TT35               \\ Loop back to TT35 to print the next digit\n\n\\ ******************************************************************************\n\\\n\\       Name: BELL\n\\       Type: Subroutine\n\\   Category: Sound\n\\    Summary: Make a standard system beep\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This is the standard system beep, as made by the ASCII 7 \"BELL\" control code.\n\\\n\\ ******************************************************************************\n\n.BELL\n\n LDA #7                 \\ Control code 7 makes a beep, so load this into A\n\n                        \\ Fall through into the TT26 print routine to\n                        \\ actually make the sound\n\n\\ ******************************************************************************\n\\\n\\       Name: TT26\n\\       Type: Subroutine\n\\   Category: Text\n\\    Summary: Print a character at the text cursor by poking into screen memory\n\\  Deep dive: Drawing text\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Print a character at the text cursor (XC, YC), do a beep, print a newline,\n\\ or delete left (backspace).\n\\\n\\ WRCHV is set to point here by the loading process.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The character to be printed. Can be one of the\n\\                       following:\n\\\n\\                         * 7 (beep)\n\\\n\\                         * 10-13 (line feeds and carriage returns)\n\\\n\\                         * 32-95 (ASCII capital letters, numbers and\n\\                           punctuation)\n\\\n\\                         * 127 (delete the character to the left of the text\n\\                           cursor and move the cursor to the left)\n\\\n\\   XC                  Contains the text column to print at (the x-coordinate)\n\\\n\\   YC                  Contains the line number to print on (the y-coordinate)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   A                   A is preserved\n\\\n\\   X                   X is preserved\n\\\n\\   Y                   Y is preserved\n\\\n\\   C flag              The C flag is cleared\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   RR3+1               Contains an RTS\n\\\n\\   RREN                Prints the character definition pointed to by P(2 1) at\n\\                       the screen address pointed to by (A SC). Used by the\n\\                       BULB routine\n\\\n\\   rT9                 Contains an RTS\n\\\n\\ ******************************************************************************\n\n.TT26\n\n STA K3                 \\ Store the A, X and Y registers, so we can restore\n STY YSAV2              \\ them at the end (so they don't get changed by this\n STX XSAV2              \\ routine)\n\n LDY QQ17               \\ Load the QQ17 flag, which contains the text printing\n                        \\ flags\n\n CPY #255               \\ If QQ17 = 255 then printing is disabled, so jump to\n BEQ RR4                \\ RR4, which doesn't print anything, it just restores\n                        \\ the registers and returns from the subroutine\n\n CMP #7                 \\ If this is a beep character (A = 7), jump to R5,\n BEQ R5                 \\ which will emit the beep, restore the registers and\n                        \\ return from the subroutine\n\n CMP #32                \\ If this is an ASCII character (A >= 32), jump to RR1\n BCS RR1                \\ below, which will print the character, restore the\n                        \\ registers and return from the subroutine\n\n CMP #10                \\ If this is control code 10 (line feed) then jump to\n BEQ RRX1               \\ RRX1, which will move down a line, restore the\n                        \\ registers and return from the subroutine\n\n LDX #1                 \\ If we get here, then this is control code 11-13, of\n STX XC                 \\ which only 13 is used. This code prints a newline,\n                        \\ which we can achieve by moving the text cursor\n                        \\ to the start of the line (carriage return) and down\n                        \\ one line (line feed). These two lines do the first\n                        \\ bit by setting XC = 1, and we then fall through into\n                        \\ the line feed routine that's used by control code 10\n\n.RRX1\n\n INC YC                 \\ Print a line feed, simply by incrementing the row\n                        \\ number (y-coordinate) of the text cursor, which is\n                        \\ stored in YC\n\n BNE RR4                \\ Jump to RR4 to restore the registers and return from\n                        \\ the subroutine (this BNE is effectively a JMP as Y\n                        \\ will never be zero)\n\n.RR1\n\n                        \\ If we get here, then the character to print is an\n                        \\ ASCII character in the range 32-95. The quickest way\n                        \\ to display text on-screen is to poke the character\n                        \\ pixel by pixel, directly into screen memory, so\n                        \\ that's what the rest of this routine does\n                        \\\n                        \\ The first step, then, is to get hold of the bitmap\n                        \\ definition for the character we want to draw on the\n                        \\ screen (i.e. we need the pixel shape of this\n                        \\ character). The MOS ROM contains bitmap definitions\n                        \\ of the system's ASCII characters, starting from &C000\n                        \\ for space (ASCII 32) and ending with the £ symbol\n                        \\ (ASCII 126)\n                        \\\n                        \\ There are definitions for 32 characters in each of the\n                        \\ three pages of MOS memory, as each definition takes up\n                        \\ 8 bytes (8 rows of 8 pixels) and 32 * 8 = 256 bytes =\n                        \\ 1 page. So:\n                        \\\n                        \\   ASCII 32-63  are defined in &C000-&C0FF (page 0)\n                        \\   ASCII 64-95  are defined in &C100-&C1FF (page 1)\n                        \\   ASCII 96-126 are defined in &C200-&C2F0 (page 2)\n                        \\\n                        \\ The following code reads the relevant character\n                        \\ bitmap from the above locations in ROM and pokes\n                        \\ those values into the correct position in screen\n                        \\ memory, thus printing the character on-screen\n                        \\\n                        \\ It's a long way from 10 PRINT \"Hello world!\":GOTO 10\n\n\\LDX #LO(K3)            \\ These instructions are commented out in the original\n\\INX                    \\ source, but they call OSWORD 10, which reads the\n\\STX P+1                \\ character bitmap for the character number in K3 and\n\\DEX                    \\ stores it in the block at K3+1, while also setting\n\\                       \\ P+1 to point to the character definition. This is\n\\LDY #HI(K3)            \\ exactly what the following uncommented code does,\n\\STY P+2                \\ just without calling OSWORD. Presumably the code\n\\                       \\ below is faster than using the system call, as this\n\\LDA #10                \\ version takes up 15 bytes, while the version below\n\\JSR OSWORD             \\ (which ends with STA P+1 and SYX P+2) is 17 bytes.\n                        \\ Every efficiency saving helps, especially as this\n                        \\ routine is run each time the game prints a character\n                        \\\n                        \\ If you want to switch this code back on, uncomment\n                        \\ the above block, and comment out the code below from\n                        \\ TAY to STX P+2. You will also need to uncomment the\n                        \\ LDA YC instruction a few lines down (in RR2), just to\n                        \\ make sure the rest of the code doesn't shift in\n                        \\ memory. To be honest I can't see a massive difference\n                        \\ in speed, but there you go\n\n TAY                    \\ Copy the character number from A to Y, as we are\n                        \\ about to pull A apart to work out where this\n                        \\ character definition lives in memory\n\n                        \\ Now we want to set X to point to the relevant page\n                        \\ number for this character - i.e. &C0, &C1 or &C2.\n\n                        \\ The following logic is easier to follow if we look\n                        \\ at the three character number ranges in binary:\n                        \\\n                        \\   Bit #  76543210\n                        \\\n                        \\   32  = %00100000     Page 0 of bitmap definitions\n                        \\   63  = %00111111\n                        \\\n                        \\   64  = %01000000     Page 1 of bitmap definitions\n                        \\   95  = %01011111\n                        \\\n                        \\   96  = %01100000     Page 2 of bitmap definitions\n                        \\   125 = %01111101\n                        \\\n                        \\ We'll refer to this below\n\n LDX #&BF               \\ Set X to point to the first font page in ROM minus 1,\n                        \\ which is &C0 - 1, or &BF\n\n ASL A                  \\ If bit 6 of the character is clear (A is 32-63)\n ASL A                  \\ then skip the following instruction\n BCC P%+4\n\n LDX #&C1               \\ A is 64-126, so set X to point to page &C1\n\n ASL A                  \\ If bit 5 of the character is clear (A is 64-95)\n BCC P%+3               \\ then skip the following instruction\n\n INX                    \\ Increment X\n                        \\\n                        \\ By this point, we started with X = &BF, and then\n                        \\ we did the following:\n                        \\\n                        \\   If A = 32-63:   skip    then INX  so X = &C0\n                        \\   If A = 64-95:   X = &C1 then skip so X = &C1\n                        \\   If A = 96-126:  X = &C1 then INX  so X = &C2\n                        \\\n                        \\ In other words, X points to the relevant page. But\n                        \\ what about the value of A? That gets shifted to the\n                        \\ left three times during the above code, which\n                        \\ multiplies the number by 8 but also drops bits 7, 6\n                        \\ and 5 in the process. Look at the above binary\n                        \\ figures and you can see that if we cleared bits 5-7,\n                        \\ then that would change 32-53 to 0-31... but it would\n                        \\ do exactly the same to 64-95 and 96-125. And because\n                        \\ we also multiply this figure by 8, A now points to\n                        \\ the start of the character's definition within its\n                        \\ page (because there are 8 bytes per character\n                        \\ definition)\n                        \\\n                        \\ Or, to put it another way, X contains the high byte\n                        \\ (the page) of the address of the definition that we\n                        \\ want, while A contains the low byte (the offset into\n                        \\ the page) of the address\n\n STA P+1                \\ Store the address of this character's definition in\n STX P+2                \\ P(2 1)\n\n LDA XC                 \\ Fetch XC, the x-coordinate (column) of the text cursor\n                        \\ into A\n\n ASL A                  \\ Multiply A by 8, and store in SC. As each character is\n ASL A                  \\ 8 pixels wide, and the special screen mode Elite uses\n ASL A                  \\ for the top part of the screen is 256 pixels across\n STA SC                 \\ with one bit per pixel, this value is not only the\n                        \\ screen address offset of the text cursor from the left\n                        \\ side of the screen, it's also the least significant\n                        \\ byte of the screen address where we want to print this\n                        \\ character, as each row of on-screen pixels corresponds\n                        \\ to one page. To put this more explicitly, the screen\n                        \\ starts at &6000, so the text rows are stored in screen\n                        \\ memory like this:\n                        \\\n                        \\   Row 1: &6000 - &60FF    YC = 1, XC = 0 to 31\n                        \\   Row 2: &6100 - &61FF    YC = 2, XC = 0 to 31\n                        \\   Row 3: &6200 - &62FF    YC = 3, XC = 0 to 31\n                        \\\n                        \\ and so on\n\n LDA YC                 \\ Fetch YC, the y-coordinate (row) of the text cursor\n\n CPY #127               \\ If the character number (which is in Y) <> 127, then\n BNE RR2                \\ skip to RR2 to print that character, otherwise this is\n                        \\ the delete character, so continue on\n\n DEC XC                 \\ We want to delete the character to the left of the\n                        \\ text cursor and move the cursor back one, so let's\n                        \\ do that by decrementing YC. Note that this doesn't\n                        \\ have anything to do with the actual deletion below,\n                        \\ we're just updating the cursor so it's in the right\n                        \\ position following the deletion\n\n ADC #&5E               \\ A contains YC (from above) and the C flag is set (from\n TAX                    \\ the CPY #127 above), so these instructions do this:\n                        \\\n                        \\   X = YC + &5E + 1\n                        \\     = YC + &5F\n\n                        \\ Because YC starts at 0 for the first text row, this\n                        \\ means that X will be &5F for row 0, &60 for row 1 and\n                        \\ so on. In other words, X is now set to the page number\n                        \\ for the row before the one containing the text cursor,\n                        \\ and given that we set SC above to point to the offset\n                        \\ in memory of the text cursor within the row's page,\n                        \\ this means that (X SC) now points to the character\n                        \\ above the text cursor\n\n LDY #&F8               \\ Set Y = &F8, so the following call to ZES2 will count\n                        \\ Y upwards from &F8 to &FF\n\n JSR ZES2               \\ Call ZES2, which zero-fills from address (X SC) + Y to\n                        \\ (X SC) + &FF. (X SC) points to the character above the\n                        \\ text cursor, and adding &FF to this would point to the\n                        \\ cursor, so adding &F8 points to the character before\n                        \\ the cursor, which is the one we want to delete. So\n                        \\ this call zero-fills the character to the left of the\n                        \\ cursor, which erases it from the screen\n\n BEQ RR4                \\ We are done deleting, so restore the registers and\n                        \\ return from the subroutine (this BNE is effectively\n                        \\ a JMP as ZES2 always returns with the Z flag set)\n\n.RR2\n\n                        \\ Now to actually print the character\n\n INC XC                 \\ Once we print the character, we want to move the text\n                        \\ cursor to the right, so we do this by incrementing\n                        \\ XC. Note that this doesn't have anything to do\n                        \\ with the actual printing below, we're just updating\n                        \\ the cursor so it's in the right position following\n                        \\ the print\n\n\\LDA YC                 \\ This instruction is commented out in the original\n                        \\ source. It isn't required because we only just did a\n                        \\ LDA YC before jumping to RR2, so this is presumably\n                        \\ an example of the authors squeezing the code to save\n                        \\ 2 bytes and 3 cycles\n                        \\\n                        \\ If you want to re-enable the commented block near the\n                        \\ start of this routine, you should uncomment this\n                        \\ instruction as well\n\n CMP #24                \\ If the text cursor is on the screen (i.e. YC < 24, so\n BCC RR3                \\ we are on rows 0-23), then jump to RR3 to print the\n                        \\ character\n\n JSR TTX66              \\ Otherwise we are off the bottom of the screen, so\n                        \\ clear the screen and draw a border box\n\n JMP RR4                \\ And restore the registers and return from the\n                        \\ subroutine\n\n.RR3\n\n                        \\ A contains the value of YC - the screen row where we\n                        \\ want to print this character - so now we need to\n                        \\ convert this into a screen address, so we can poke\n                        \\ the character data to the right place in screen\n                        \\ memory\n\n ORA #&60               \\ We already stored the least significant byte\n                        \\ of this screen address in SC above (see the STA SC\n                        \\ instruction above), so all we need is the most\n                        \\ significant byte. As mentioned above, in Elite's\n                        \\ square mode 4 screen, each row of text on-screen\n                        \\ takes up exactly one page, so the first row is page\n                        \\ &60xx, the second row is page &61xx, so we can get\n                        \\ the page for character (XC, YC) by OR'ing with &60.\n                        \\ To see this in action, consider that our two values\n                        \\ are, in binary:\n                        \\\n                        \\   YC is between:  %00000000\n                        \\             and:  %00010111\n                        \\          &60 is:  %01100000\n                        \\\n                        \\ so YC OR &60 effectively adds &60 to YC, giving us\n                        \\ the page number that we want\n\n.RREN\n\n STA SC+1               \\ Store the page number of the destination screen\n                        \\ location in SC+1, so SC now points to the full screen\n                        \\ location where this character should go\n\n LDY #7                 \\ We want to print the 8 bytes of character data to the\n                        \\ screen (one byte per row), so set up a counter in Y\n                        \\ to count these bytes\n\n.RRL1\n\n LDA (P+1),Y            \\ The character definition is at P(2 1) - we set this up\n                        \\ above - so load the Y-th byte from P(2 1), which will\n                        \\ contain the bitmap for the Y-th row of the character\n\n EOR (SC),Y             \\ If we EOR this value with the existing screen\n                        \\ contents, then it's reversible (so reprinting the\n                        \\ same character in the same place will revert the\n                        \\ screen to what it looked like before we printed\n                        \\ anything); this means that printing a white pixel\n                        \\ onto a white background results in a black pixel, but\n                        \\ that's a small price to pay for easily erasable text\n\n STA (SC),Y             \\ Store the Y-th byte at the screen address for this\n                        \\ character location\n\n DEY                    \\ Decrement the loop counter\n\n BPL RRL1               \\ Loop back for the next byte to print to the screen\n\n.RR4\n\n LDY YSAV2              \\ We're done printing, so restore the values of the\n LDX XSAV2              \\ A, X and Y registers that we saved above and clear\n LDA K3                 \\ the C flag, so everything is back to how it was\n CLC\n\n.rT9\n\n RTS                    \\ Return from the subroutine\n\n.R5\n\n JSR BEEP               \\ Call the BEEP subroutine to make a short, high beep\n\n JMP RR4                \\ Jump to RR4 to restore the registers and return from\n                        \\ the subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: DIALS (Part 1 of 4)\n\\       Type: Subroutine\n\\   Category: Dashboard\n\\    Summary: Update the dashboard: speed indicator\n\\  Deep dive: The dashboard indicators\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine updates the dashboard. First we draw all the indicators in the\n\\ right part of the dashboard, from top (speed) to bottom (energy banks), and\n\\ then we move on to the left part, again drawing from top (forward shield) to\n\\ bottom (altitude).\n\\\n\\ This first section starts us off with the speedometer in the top right.\n\\\n\\ ******************************************************************************\n\n.DIALS\n\n LDA #&D0               \\ Set SC(1 0) = &78D0, which is the screen address for\n STA SC                 \\ the character block containing the left end of the\n LDA #&78               \\ top indicator in the right part of the dashboard, the\n STA SC+1               \\ one showing our speed\n\n JSR PZW                \\ Call PZW to set A to the colour for dangerous values\n                        \\ and X to the colour for safe values\n\n STX K+1                \\ Set K+1 (the colour we should show for low values) to\n                        \\ X (the colour to use for safe values)\n\n STA K                  \\ Set K (the colour we should show for high values) to\n                        \\ A (the colour to use for dangerous values)\n\n                        \\ The above sets the following indicators to show red\n                        \\ for high values and yellow/white for low values\n\n LDA #14                \\ Set T1 to 14, the threshold at which we change the\n STA T1                 \\ indicator's colour\n\n LDA DELTA              \\ Fetch our ship's speed into A, in the range 0-40\n\n\\LSR A                  \\ Draw the speed indicator using a range of 0-31, and\n JSR DIL-1              \\ increment SC to point to the next indicator (the roll\n                        \\ indicator). The LSR is commented out as it isn't\n                        \\ required with a call to DIL-1, so perhaps this was\n                        \\ originally a call to DIL that got optimised\n\n\\ ******************************************************************************\n\\\n\\       Name: DIALS (Part 2 of 4)\n\\       Type: Subroutine\n\\   Category: Dashboard\n\\    Summary: Update the dashboard: pitch and roll indicators\n\\  Deep dive: The dashboard indicators\n\\\n\\ ******************************************************************************\n\n LDA #0                 \\ Set R = P = 0 for the low bytes in the call to the ADD\n STA R                  \\ routine below\n STA P\n\n LDA #8                 \\ Set S = 8, which is the value of the centre of the\n STA S                  \\ roll indicator\n\n LDA ALP1               \\ Fetch the roll angle alpha as a value between 0 and\n LSR A                  \\ 31, and divide by 4 to get a value of 0 to 7\n LSR A\n\n ORA ALP2               \\ Apply the roll sign to the value, and flip the sign,\n EOR #%10000000         \\ so it's now in the range -7 to +7, with a positive\n                        \\ roll angle alpha giving a negative value in A\n\n JSR ADD                \\ We now add A to S to give us a value in the range 1 to\n                        \\ 15, which we can pass to DIL2 to draw the vertical\n                        \\ bar on the indicator at this position. We use the ADD\n                        \\ routine like this:\n                        \\\n                        \\ (A X) = (A 0) + (S 0)\n                        \\\n                        \\ and just take the high byte of the result. We use ADD\n                        \\ rather than a normal ADC because ADD separates out the\n                        \\ sign bit and does the arithmetic using absolute values\n                        \\ and separate sign bits, which we want here rather than\n                        \\ the two's complement that ADC uses\n\n JSR DIL2               \\ Draw a vertical bar on the roll indicator at offset A\n                        \\ and increment SC to point to the next indicator (the\n                        \\ pitch indicator)\n\n LDA BETA               \\ Fetch the pitch angle beta as a value between -8 and\n                        \\ +8\n\n LDX BET1               \\ Fetch the magnitude of the pitch angle beta, and if it\n BEQ P%+4               \\ is 0 (i.e. we are not pitching), skip the next\n                        \\ instruction\n\n SBC #1                 \\ The pitch angle beta is non-zero, so set A = A - 1\n                        \\ (the C flag is set by the call to DIL2 above, so we\n                        \\ don't need to do a SEC). This gives us a value of A\n                        \\ from -7 to +7 because these are magnitude-based\n                        \\ numbers with sign bits, rather than two's complement\n                        \\ numbers\n\n JSR ADD                \\ We now add A to S to give us a value in the range 1 to\n                        \\ 15, which we can pass to DIL2 to draw the vertical\n                        \\ bar on the indicator at this position (see the JSR ADD\n                        \\ above for more on this)\n\n JSR DIL2               \\ Draw a vertical bar on the pitch indicator at offset A\n                        \\ and increment SC to point to the next indicator (the\n                        \\ four energy banks)\n\n\\ ******************************************************************************\n\\\n\\       Name: DIALS (Part 3 of 4)\n\\       Type: Subroutine\n\\   Category: Dashboard\n\\    Summary: Update the dashboard: four energy banks\n\\  Deep dive: The dashboard indicators\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This and the next section only run once every four iterations of the main\n\\ loop, so while the speed, pitch and roll indicators update every iteration,\n\\ the other indicators update less often.\n\\\n\\ ******************************************************************************\n\n LDA MCNT               \\ Fetch the main loop counter and calculate MCNT mod 4,\n AND #3                 \\ jumping to rT9 if it is non-zero. rT9 contains an RTS,\n BNE rT9                \\ so the following code only runs every 4 iterations of\n                        \\ the main loop, otherwise we return from the subroutine\n\n LDY #0                 \\ Set Y = 0, for use in various places below\n\n JSR PZW                \\ Call PZW to set A to the colour for dangerous values\n                        \\ and X to the colour for safe values\n\n STX K                  \\ Set K (the colour we should show for high values) to X\n                        \\ (the colour to use for safe values)\n\n STA K+1                \\ Set K+1 (the colour we should show for low values) to\n                        \\ A (the colour to use for dangerous values)\n\n                        \\ The above sets the following indicators to show red\n                        \\ for low values and yellow/white for high values, which\n                        \\ we use not only for the energy banks, but also for the\n                        \\ shield levels and current fuel\n\n LDX #3                 \\ Set up a counter in X so we can zero the four bytes at\n                        \\ XX12, so we can then calculate each of the four energy\n                        \\ banks' values before drawing them later\n\n STX T1                 \\ Set T1 to 3, the threshold at which we change the\n                        \\ indicator's colour\n\n.DLL23\n\n STY XX12,X             \\ Set the X-th byte of XX12 to 0\n\n DEX                    \\ Decrement the counter\n\n BPL DLL23              \\ Loop back for the next byte until the four bytes at\n                        \\ XX12 are all zeroed\n\n LDX #3                 \\ Set up a counter in X to loop through the 4 energy\n                        \\ bank indicators, so we can calculate each of the four\n                        \\ energy banks' values and store them in XX12\n\n LDA ENERGY             \\ Set A = Q = ENERGY / 4, so they are both now in the\n LSR A                  \\ range 0-63 (so that's a maximum of 16 in each of the\n LSR A                  \\ banks, and a maximum of 15 in the top bank)\n\n STA Q                  \\ Set Q to A, so we can use Q to hold the remaining\n                        \\ energy as we work our way through each bank, from the\n                        \\ full ones at the bottom to the empty ones at the top\n\n.DLL24\n\n SEC                    \\ Set A = A - 16 to reduce the energy count by a full\n SBC #16                \\ bank\n\n BCC DLL26              \\ If the C flag is clear then A < 16, so this bank is\n                        \\ not full to the brim, and is therefore the last one\n                        \\ with any energy in it, so jump to DLL26\n\n STA Q                  \\ This bank is full, so update Q with the energy of the\n                        \\ remaining banks\n\n LDA #16                \\ Store this bank's level in XX12 as 16, as it is full,\n STA XX12,X             \\ with XX12+3 for the bottom bank and XX12+0 for the top\n\n LDA Q                  \\ Set A to the remaining energy level again\n\n DEX                    \\ Decrement X to point to the next bank, i.e. the one\n                        \\ above the bank we just processed\n\n BPL DLL24              \\ Loop back to DLL24 until we have either processed all\n                        \\ four banks, or jumped out early to DLL26 if the top\n                        \\ banks have no charge\n\n BMI DLL9               \\ Jump to DLL9 as we have processed all four banks (this\n                        \\ BMI is effectively a JMP as A will never be positive)\n\n.DLL26\n\n LDA Q                  \\ If we get here then the bank we just checked is not\n STA XX12,X             \\ fully charged, so store its value in XX12 (using Q,\n                        \\ which contains the energy of the remaining banks -\n                        \\ i.e. this one)\n\n                        \\ Now that we have the four energy bank values in XX12,\n                        \\ we can draw them, starting with the top bank in XX12\n                        \\ and looping down to the bottom bank in XX12+3, using Y\n                        \\ as a loop counter, which was set to 0 above\n\n.DLL9\n\n LDA XX12,Y             \\ Fetch the value of the Y-th indicator, starting from\n                        \\ the top\n\n STY P                  \\ Store the indicator number in P for retrieval later\n\n JSR DIL                \\ Draw the energy bank using a range of 0-15, and\n                        \\ increment SC to point to the next indicator (the\n                        \\ next energy bank down)\n\n LDY P                  \\ Restore the indicator number into Y\n\n INY                    \\ Increment the indicator number\n\n CPY #4                 \\ Check to see if we have drawn the last energy bank\n\n BNE DLL9               \\ Loop back to DLL9 if we have more banks to draw,\n                        \\ otherwise we are done\n\n\\ ******************************************************************************\n\\\n\\       Name: DIALS (Part 4 of 4)\n\\       Type: Subroutine\n\\   Category: Dashboard\n\\    Summary: Update the dashboard: shields, fuel, laser & cabin temp, altitude\n\\  Deep dive: The dashboard indicators\n\\\n\\ ******************************************************************************\n\n LDA #&78               \\ Set SC(1 0) = &7810, which is the screen address for\n STA SC+1               \\ the character block containing the left end of the\n LDA #&10               \\ top indicator in the left part of the dashboard, the\n STA SC                 \\ one showing the forward shield\n\n LDA FSH                \\ Draw the forward shield indicator using a range of\n JSR DILX               \\ 0-255, and increment SC to point to the next indicator\n                        \\ (the aft shield)\n\n LDA ASH                \\ Draw the aft shield indicator using a range of 0-255,\n JSR DILX               \\ and increment SC to point to the next indicator (the\n                        \\ fuel level)\n\n LDA QQ14               \\ Draw the fuel level indicator using a range of 0-63,\n JSR DILX+2             \\ and increment SC to point to the next indicator (the\n                        \\ cabin temperature)\n\n JSR PZW                \\ Call PZW to set A to the colour for dangerous values\n                        \\ and X to the colour for safe values\n\n STX K+1                \\ Set K+1 (the colour we should show for low values) to\n                        \\ X (the colour to use for safe values)\n\n STA K                  \\ Set K (the colour we should show for high values) to\n                        \\ A (the colour to use for dangerous values)\n\n                        \\ The above sets the following indicators to show red\n                        \\ for high values and yellow/white for low values, which\n                        \\ we use for the cabin and laser temperature bars\n\n LDX #11                \\ Set T1 to 11, the threshold at which we change the\n STX T1                 \\ cabin and laser temperature indicators' colours\n\n LDA CABTMP             \\ Draw the cabin temperature indicator using a range of\n JSR DILX               \\ 0-255, and increment SC to point to the next indicator\n                        \\ (the laser temperature)\n\n LDA GNTMP              \\ Draw the laser temperature indicator using a range of\n JSR DILX               \\ 0-255, and increment SC to point to the next indicator\n                        \\ (the altitude)\n\n LDA #240               \\ Set T1 to 240, the threshold at which we change the\n STA T1                 \\ altitude indicator's colour. As the altitude has a\n                        \\ range of 0-255, pixel 16 will not be filled in, and\n                        \\ 240 would change the colour when moving between pixels\n                        \\ 15 and 16, so this effectively switches off the colour\n                        \\ change for the altitude indicator\n\n STA K+1                \\ Set K+1 (the colour we should show for low values) to\n                        \\ 240, or &F0 (dashboard colour 2, yellow/white), so the\n                        \\ altitude indicator always shows in this colour\n\n LDA ALTIT              \\ Draw the altitude indicator using a range of 0-255\n JSR DILX\n\n JMP COMPAS             \\ We have now drawn all the indicators, so jump to\n                        \\ COMPAS to draw the compass, returning from the\n                        \\ subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: PZW\n\\       Type: Subroutine\n\\   Category: Dashboard\n\\    Summary: Fetch the current dashboard colours, to support flashing\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Set A and X to the colours we should use for indicators showing dangerous and\n\\ safe values respectively. This enables us to implement flashing indicators,\n\\ which is one of the game's configurable options.\n\\\n\\ If flashing is enabled, the colour returned in A (dangerous values) will be\n\\ red for 8 iterations of the main loop, and yellow/white for the next 8, before\n\\ going back to red. If we always use PZW to decide which colours we should use\n\\ when updating indicators, flashing colours will be automatically taken care of\n\\ for us.\n\\\n\\ The values returned are &F0 for yellow/white and &0F for red. These are mode 5\n\\ bytes that contain 4 pixels, with the colour of each pixel given in two bits,\n\\ the high bit from the first nibble (bits 4-7) and the low bit from the second\n\\ nibble (bits 0-3). So in &F0 each pixel is %10, or colour 2 (yellow or white,\n\\ depending on the dashboard palette), while in &0F each pixel is %01, or colour\n\\ 1 (red).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   A                   The colour to use for indicators with dangerous values\n\\\n\\   X                   The colour to use for indicators with safe values\n\\\n\\ ******************************************************************************\n\n.PZW\n\n LDX #&F0               \\ Set X to dashboard colour 2 (yellow/white)\n\n LDA MCNT               \\ A will be non-zero for 8 out of every 16 main loop\n AND #%00001000         \\ counts, when bit 4 is set, so this is what we use to\n                        \\ flash the \"danger\" colour\n\n AND FLH                \\ A will be zeroed if flashing colours are disabled\n\n BEQ P%+4               \\ If A is zero, skip to the LDA instruction below\n\n TXA                    \\ Otherwise flashing colours are enabled and it's the\n                        \\ main loop iteration where we flash them, so set A to\n                        \\ colour 2 (yellow/white) and use the BIT trick below to\n                        \\ return from the subroutine\n\n EQUB &2C               \\ Skip the next instruction by turning it into\n                        \\ &2C &A9 &0F, or BIT &0FA9, which does nothing apart\n                        \\ from affect the flags\n\n LDA #&0F               \\ Set A to dashboard colour 1 (red)\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: DILX\n\\       Type: Subroutine\n\\   Category: Dashboard\n\\    Summary: Update a bar-based indicator on the dashboard\n\\  Deep dive: The dashboard indicators\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The range of values shown on the indicator depends on which entry point is\n\\ called. For the default entry point of DILX, the range is 0-255 (as the value\n\\ passed in A is one byte). The other entry points are shown below.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The value to be shown on the indicator (so the larger\n\\                       the value, the longer the bar)\n\\\n\\   T1                  The threshold at which we change the indicator's colour\n\\                       from the low value colour to the high value colour. The\n\\                       threshold is in pixels, so it should have a value from\n\\                       0-16, as each bar indicator is 16 pixels wide\n\\\n\\   K                   The colour to use when A is a high value, as a\n\\                       four-pixel mode 5 character row byte\n\\\n\\   K+1                 The colour to use when A is a low value, as a\n\\                       four-pixel mode 5 character row byte\n\\\n\\   SC(1 0)             The screen address of the first character block in the\n\\                       indicator\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   DILX+2              The range of the indicator is 0-64 (for the fuel\n\\                       indicator)\n\\\n\\   DIL-1               The range of the indicator is 0-32 (for the speed\n\\                       indicator)\n\\\n\\   DIL                 The range of the indicator is 0-16 (for the energy\n\\                       banks)\n\\\n\\ ******************************************************************************\n\n.DILX\n\n LSR A                  \\ If we call DILX, we set A = A / 16, so A is 0-15\n LSR A\n\n LSR A                  \\ If we call DILX+2, we set A = A / 4, so A is 0-15\n\n LSR A                  \\ If we call DIL-1, we set A = A / 2, so A is 0-15\n\n.DIL\n\n                        \\ If we call DIL, we leave A alone, so A is 0-15\n\n STA Q                  \\ Store the indicator value in Q, now reduced to 0-15,\n                        \\ which is the length of the indicator to draw in pixels\n\n LDX #&FF               \\ Set R = &FF, to use as a mask for drawing each row of\n STX R                  \\ each character block of the bar, starting with a full\n                        \\ character's width of 4 pixels\n\n CMP T1                 \\ If A >= T1 then we have passed the threshold where we\n BCS DL30               \\ change bar colour, so jump to DL30 to set A to the\n                        \\ \"high value\" colour\n\n LDA K+1                \\ Set A to K+1, the \"low value\" colour to use\n\n BNE DL31               \\ Jump down to DL31 (this BNE is effectively a JMP as A\n                        \\ will never be zero)\n\n.DL30\n\n LDA K                  \\ Set A to K, the \"high value\" colour to use\n\n.DL31\n\n STA COL                \\ Store the colour of the indicator in COL\n\n LDY #2                 \\ We want to start drawing the indicator on the third\n                        \\ line in this character row, so set Y to point to that\n                        \\ row's offset\n\n LDX #3                 \\ Set up a counter in X for the width of the indicator,\n                        \\ which is 4 characters (each of which is 4 pixels wide,\n                        \\ to give a total width of 16 pixels)\n\n.DL1\n\n LDA Q                  \\ Fetch the indicator value (0-15) from Q into A\n\n CMP #4                 \\ If Q < 4, then we need to draw the end cap of the\n BCC DL2                \\ indicator, which is less than a full character's\n                        \\ width, so jump down to DL2 to do this\n\n SBC #4                 \\ Otherwise we can draw a four-pixel wide block, so\n STA Q                  \\ subtract 4 from Q so it contains the amount of the\n                        \\ indicator that's left to draw after this character\n\n LDA R                  \\ Fetch the shape of the indicator row that we need to\n                        \\ display from R, so we can use it as a mask when\n                        \\ painting the indicator. It will be &FF at this point\n                        \\ (i.e. a full four-pixel row)\n\n.DL5\n\n AND COL                \\ Fetch the four-pixel mode 5 colour byte from COL, and\n                        \\ only keep pixels that have their equivalent bits set\n                        \\ in the mask byte in A\n\n STA (SC),Y             \\ Draw the shape of the mask on pixel row Y of the\n                        \\ character block we are processing\n\n INY                    \\ Draw the next pixel row, incrementing Y\n STA (SC),Y\n\n INY                    \\ And draw the third pixel row, incrementing Y\n STA (SC),Y\n\n TYA                    \\ Add 6 to Y, so Y is now 8 more than when we started\n CLC                    \\ this loop iteration, so Y now points to the address\n ADC #6                 \\ of the first line of the indicator bar in the next\n TAY                    \\ character block (as each character is 8 bytes of\n                        \\ screen memory)\n\n DEX                    \\ Decrement the loop counter for the next character\n                        \\ block along in the indicator\n\n BMI DL6                \\ If we just drew the last character block then we are\n                        \\ done drawing, so jump down to DL6 to finish off\n\n BPL DL1                \\ Loop back to DL1 to draw the next character block of\n                        \\ the indicator (this BPL is effectively a JMP as A will\n                        \\ never be negative following the previous BMI)\n\n.DL2\n\n EOR #3                 \\ If we get here then we are drawing the indicator's\n STA Q                  \\ end cap, so Q is < 4, and this EOR flips the bits, so\n                        \\ instead of containing the number of indicator columns\n                        \\ we need to fill in on the left side of the cap's\n                        \\ character block, Q now contains the number of blank\n                        \\ columns there should be on the right side of the cap's\n                        \\ character block\n\n LDA R                  \\ Fetch the current mask from R, which will be &FF at\n                        \\ this point, so we need to turn Q of the columns on the\n                        \\ right side of the mask to black to get the correct end\n                        \\ cap shape for the indicator\n\n.DL3\n\n ASL A                  \\ Shift the mask left so bit 0 is cleared, and then\n AND #%11101111         \\ clear bit 4, which has the effect of shifting zeroes\n                        \\ from the left into each nibble (i.e. xxxx xxxx becomes\n                        \\ xxx0 xxx0, which blanks out the last column in the\n                        \\ four-pixel mode 5 character block)\n\n DEC Q                  \\ Decrement the counter for the number of columns to\n                        \\ blank out\n\n BPL DL3                \\ If we still have columns to blank out in the mask,\n                        \\ loop back to DL3 until the mask is correct for the\n                        \\ end cap\n\n PHA                    \\ Store the mask byte on the stack while we use the\n                        \\ accumulator for a bit\n\n LDA #0                 \\ Change the mask so no bits are set, so the characters\n STA R                  \\ after the one we're about to draw will be all blank\n\n LDA #99                \\ Set Q to a high number (99, why not) so we will keep\n STA Q                  \\ drawing blank characters until we reach the end of\n                        \\ the indicator row\n\n PLA                    \\ Restore the mask byte from the stack so we can use it\n                        \\ to draw the end cap of the indicator\n\n JMP DL5                \\ Jump back up to DL5 to draw the mask byte on-screen\n\n.DL6\n\n INC SC+1               \\ Increment the high byte of SC to point to the next\n                        \\ character row on-screen (as each row takes up exactly\n                        \\ one page of 256 bytes) - so this sets up SC to point\n                        \\ to the next indicator, i.e. the one below the one we\n                        \\ just drew\n\n.DL9\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: DIL2\n\\       Type: Subroutine\n\\   Category: Dashboard\n\\    Summary: Update the roll or pitch indicator on the dashboard\n\\  Deep dive: The dashboard indicators\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The indicator can show a vertical bar in 16 positions, with a value of 8\n\\ showing the bar in the middle of the indicator.\n\\\n\\ In practice this routine is only ever called with A in the range 1 to 15, so\n\\ the vertical bar never appears in the leftmost position (though it does appear\n\\ in the rightmost).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The offset of the vertical bar to show in the indicator,\n\\                       from 0 at the far left, to 8 in the middle, and 15 at\n\\                       the far right\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   C flag              The C flag is set\n\\\n\\ ******************************************************************************\n\n.DIL2\n\n LDY #1                 \\ We want to start drawing the vertical indicator bar on\n                        \\ the second line in the indicator's character block, so\n                        \\ set Y to point to that row's offset\n\n STA Q                  \\ Store the offset of the vertical bar to draw in Q\n\n                        \\ We are now going to work our way along the indicator\n                        \\ on the dashboard, from left to right, working our way\n                        \\ along one character block at a time. Y will be used as\n                        \\ a pixel row counter to work our way through the\n                        \\ character blocks, so each time we draw a character\n                        \\ block, we will increment Y by 8 to move on to the next\n                        \\ block (as each character block contains 8 rows)\n\n.DLL10\n\n SEC                    \\ Set A = Q - 4, so that A contains the offset of the\n LDA Q                  \\ vertical bar from the start of this character block\n SBC #4\n\n BCS DLL11              \\ If Q >= 4 then the character block we are drawing does\n                        \\ not contain the vertical indicator bar, so jump to\n                        \\ DLL11 to draw a blank character block\n\n LDA #&FF               \\ Set A to a high number (and &FF is as high as they go)\n\n LDX Q                  \\ Set X to the offset of the vertical bar, which we know\n                        \\ is within this character block\n\n STA Q                  \\ Set Q to a high number (&FF, why not) so we will keep\n                        \\ drawing blank characters after this one until we reach\n                        \\ the end of the indicator row\n\n LDA CTWOS,X            \\ CTWOS is a table of ready-made one-pixel mode 5 bytes,\n                        \\ just like the TWOS and TWOS2 tables for mode 4 (see\n                        \\ the PIXEL routine for details of how they work). This\n                        \\ fetches a mode 5 one-pixel byte with the pixel\n                        \\ position at X, so the pixel is at the offset that we\n                        \\ want for our vertical bar\n\n AND #&F0               \\ The four-pixel mode 5 colour byte &F0 represents four\n                        \\ pixels of colour %10 (3), which is yellow in the\n                        \\ normal dashboard palette and white if we have an\n                        \\ escape pod fitted. We AND this with A so that we only\n                        \\ keep the pixel that matches the position of the\n                        \\ vertical bar (i.e. A is acting as a mask on the\n                        \\ four-pixel colour byte)\n\n BNE DLL12              \\ Jump to DLL12 to skip the code for drawing a blank,\n                        \\ and move on to drawing the indicator (this BNE is\n                        \\ effectively a JMP as A is always non-zero)\n\n.DLL11\n\n                        \\ If we get here then we want to draw a blank for this\n                        \\ character block\n\n STA Q                  \\ Update Q with the new offset of the vertical bar, so\n                        \\ it becomes the offset after the character block we\n                        \\ are about to draw\n\n LDA #0                 \\ Change the mask so no bits are set, so all of the\n                        \\ character blocks we display from now on will be blank\n.DLL12\n\n STA (SC),Y             \\ Draw the shape of the mask on pixel row Y of the\n                        \\ character block we are processing\n\n INY                    \\ Draw the next pixel row, incrementing Y\n STA (SC),Y\n\n INY                    \\ And draw the third pixel row, incrementing Y\n STA (SC),Y\n\n INY                    \\ And draw the fourth pixel row, incrementing Y\n STA (SC),Y\n\n TYA                    \\ Add 5 to Y, so Y is now 8 more than when we started\n CLC                    \\ this loop iteration, so Y now points to the address\n ADC #5                 \\ of the first line of the indicator bar in the next\n TAY                    \\ character block (as each character is 8 bytes of\n                        \\ screen memory)\n\n CPY #30                \\ If Y < 30 then we still have some more character\n BCC DLL10              \\ blocks to draw, so loop back to DLL10 to display the\n                        \\ next one along\n\n INC SC+1               \\ Increment the high byte of SC to point to the next\n                        \\ character row on-screen (as each row takes up exactly\n                        \\ one page of 256 bytes) - so this sets up SC to point\n                        \\ to the next indicator, i.e. the one below the one we\n                        \\ just drew\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: TVT1\n\\       Type: Variable\n\\   Category: Drawing the screen\n\\    Summary: Palette data for space and the two dashboard colour schemes\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Palette bytes for use with the split-screen mode (see IRQ1 below for more\n\\ details).\n\\\n\\ Palette data is given as a set of bytes, with each byte mapping a logical\n\\ colour to a physical one. In each byte, the logical colour is given in bits\n\\ 4-7 and the physical colour in bits 0-3. See page 379 of the \"Advanced User\n\\ Guide for the BBC Micro\" by Bray, Dickens and Holmes for details of how\n\\ palette mapping works, as in modes 4 and 5 we have to do multiple palette\n\\ commands to change the colours correctly, and the physical colour value is\n\\ EOR'd with 7, just to make things even more confusing.\n\\\n\\ Similarly, the palette at TVT1+16 is for the monochrome space view, where\n\\ logical colour 1 is mapped to physical colour 0 EOR 7 = 7 (white), and\n\\ logical colour 0 is mapped to physical colour 7 EOR 7 = 0 (black). Each of\n\\ these mappings requires six calls to SHEILA &21 - see page 379 of the\n\\ \"Advanced User Guide for the BBC Micro\" by Bray, Dickens and Holmes for an\n\\ explanation.\n\\\n\\ The mode 5 palette table has two blocks which overlap. The block used depends\n\\ on whether or not we have an escape pod fitted. The block at TVT1 is used for\n\\ the standard dashboard colours, while TVT1+8 is used for the dashboard when an\n\\ escape pod is fitted. The colours are as follows:\n\\\n\\                 Normal (TVT1)     Escape pod (TVT1+8)\n\\\n\\   Colour 0      Black             Black\n\\   Colour 1      Red               Red\n\\   Colour 2      Yellow            White\n\\   Colour 3      Green             Cyan\n\\\n\\ ******************************************************************************\n\n.TVT1\n\n EQUB &D4, &C4          \\ This block of palette data is used to create two\n EQUB &94, &84          \\ palettes used in three different places, all of them\n EQUB &F5, &E5          \\ redefining four colours in mode 5:\n EQUB &B5, &A5          \\\n                        \\ 12 bytes from TVT1 (i.e. the first 6 rows): applied\n EQUB &76, &66          \\ when the T1 timer runs down at the switch from the\n EQUB &36, &26          \\ space view to the dashboard, so this is the standard\n                        \\ dashboard palette\n EQUB &E1, &F1          \\\n EQUB &B1, &A1          \\ 8 bytes from TVT1+8 (i.e. the last 4 rows): applied\n                        \\ when the T1 timer runs down at the switch from the\n                        \\ space view to the dashboard, and we have an escape\n                        \\ pod fitted, so this is the escape pod dashboard\n                        \\ palette\n                        \\\n                        \\ 8 bytes from TVT1+8 (i.e. the last 4 rows): applied\n                        \\ at vertical sync in LINSCN when HFX is non-zero, to\n                        \\ create the hyperspace effect in LINSCN (where the\n                        \\ whole screen is switched to mode 5 at vertical sync)\n\n EQUB &F0, &E0          \\ 12 bytes of palette data at TVT1+16, used to set the\n EQUB &B0, &A0          \\ mode 4 palette in LINSCN when we hit vertical sync,\n EQUB &D0, &C0          \\ so the palette is set to monochrome when we start to\n EQUB &90, &80          \\ draw the first row of the screen\n EQUB &77, &67\n EQUB &37, &27\n\n\\ ******************************************************************************\n\\\n\\       Name: IRQ1\n\\       Type: Subroutine\n\\   Category: Drawing the screen\n\\    Summary: The main screen-mode interrupt handler (IRQ1V points here)\n\\  Deep dive: The split-screen mode in BBC Micro Elite\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The main interrupt handler, which implements Elite's split-screen mode.\n\\\n\\ IRQ1V is set to point to IRQ1 by the loading process.\n\\\n\\ ******************************************************************************\n\n.LINSCN\n\n                        \\ This is called from the interrupt handler below, at\n                        \\ the start of each vertical sync (i.e. when the screen\n                        \\ refresh starts)\n\n LDA #30                \\ Set the line scan counter to a non-zero value, so\n STA DL                 \\ routines like WSCAN can set DL to 0 and then wait for\n                        \\ it to change to non-zero to catch the vertical sync\n\n STA VIA+&44            \\ Set 6522 System VIA T1C-L timer 1 low-order counter\n                        \\ (SHEILA &44) to 30\n\n LDA #VSCAN             \\ Set 6522 System VIA T1C-L timer 1 high-order counter\n STA VIA+&45            \\ (SHEILA &45) to VSCAN (57) to start the T1 counter\n                        \\ counting down from 14622 at a rate of 1 MHz\n\n LDA HFX                \\ If HFX is non-zero, jump to VNT1 to set the mode 5\n BNE VNT1               \\ palette instead of switching to mode 4, which will\n                        \\ have the effect of blurring and colouring the top\n                        \\ screen. This is how the white hyperspace rings turn\n                        \\ to colour when we do a hyperspace jump, and is\n                        \\ triggered by setting HFX to 1 in routine LL164\n\n LDA #%00001000         \\ Set the Video ULA control register (SHEILA &20) to\n STA VIA+&20            \\ %00001000, which is the same as switching to mode 4\n                        \\ (i.e. the top part of the screen) but with no cursor\n\n.VNT3\n\n LDA TVT1+16,Y          \\ Copy the Y-th palette byte from TVT1+16 to SHEILA &21\n STA VIA+&21            \\ to map logical to actual colours for the bottom part\n                        \\ of the screen (i.e. the dashboard)\n\n DEY                    \\ Decrement the palette byte counter\n\n BPL VNT3               \\ Loop back to VNT3 until we have copied all the\n                        \\ palette bytes\n\n LDA LASCT              \\ Decrement the value of LASCT, but if we go too far\n BEQ P%+5               \\ and it becomes negative, bump it back up again (this\n DEC LASCT              \\ controls the pulsing of pulse lasers)\n\n LDA SVN                \\ If SVN is non-zero, we are in the process of saving\n BNE jvec               \\ the commander file, so jump to jvec to pass control\n                        \\ to the next interrupt handler, so we don't break file\n                        \\ saving by blocking the interrupt chain\n\n PLA                    \\ Otherwise restore Y from the stack\n TAY\n\n LDA VIA+&41            \\ Read 6522 System VIA input register IRA (SHEILA &41)\n\n LDA &FC                \\ Set A to the interrupt accumulator save register,\n                        \\ which restores A to the value it had on entering the\n                        \\ interrupt\n\n RTI                    \\ Return from interrupts, so this interrupt is not\n                        \\ passed on to the next interrupt handler, but instead\n                        \\ the interrupt terminates here\n\n.IRQ1\n\n TYA                    \\ Store Y on the stack\n PHA\n\n LDY #11                \\ Set Y as a counter for 12 bytes, to use when setting\n                        \\ the dashboard palette below\n\n LDA #%00000010         \\ Read the 6522 System VIA status byte bit 1 (SHEILA\n BIT VIA+&4D            \\ &4D), which is set if vertical sync has occurred on\n                        \\ the video system\n\n BNE LINSCN             \\ If we are on the vertical sync pulse, jump to LINSCN\n                        \\ to set up the timers to enable us to switch the\n                        \\ screen mode between the space view and dashboard\n\n BVC jvec               \\ Read the 6522 System VIA status byte bit 6, which is\n                        \\ set if timer 1 has timed out. We set the timer in\n                        \\ LINSCN above, so this means we only run the next bit\n                        \\ if the screen redraw has reached the boundary between\n                        \\ the space view and the dashboard. Otherwise bit 6 is\n                        \\ clear and we aren't at the boundary, so we jump to\n                        \\ jvec to pass control to the next interrupt handler\n\n ASL A                  \\ Double the value in A to 4\n\n STA VIA+&20            \\ Set the Video ULA control register (SHEILA &20) to\n                        \\ %00000100, which is the same as switching to mode 5,\n                        \\ (i.e. the bottom part of the screen) but with no\n                        \\ cursor\n\n LDA ESCP               \\ If an escape pod is fitted, jump to VNT1 to set the\n BNE VNT1               \\ mode 5 palette differently (so the dashboard is a\n                        \\ different colour if we have an escape pod)\n\n LDA TVT1,Y             \\ Copy the Y-th palette byte from TVT1 to SHEILA &21\n STA VIA+&21            \\ to map logical to actual colours for the bottom part\n                        \\ of the screen (i.e. the dashboard)\n\n DEY                    \\ Decrement the palette byte counter\n\n BPL P%-7               \\ Loop back to the LDA TVT1,Y instruction until we have\n                        \\ copied all the palette bytes\n\n.jvec\n\n PLA                    \\ Restore Y from the stack\n TAY\n\n JMP (VEC)              \\ Jump to the address in VEC, which was set to the\n                        \\ original IRQ1V vector by the loading process, so this\n                        \\ instruction passes control to the next interrupt\n                        \\ handler\n\n.VNT1\n\n LDY #7                 \\ Set Y as a counter for 8 bytes\n\n LDA TVT1+8,Y           \\ Copy the Y-th palette byte from TVT1+8 to SHEILA &21\n STA VIA+&21            \\ to map logical to actual colours for the bottom part\n                        \\ of the screen (i.e. the dashboard)\n\n DEY                    \\ Decrement the palette byte counter\n\n BPL VNT1+2             \\ Loop back to the LDA TVT1+8,Y instruction until we\n                        \\ have copied all the palette bytes\n\n BMI jvec               \\ Jump up to jvec to pass control to the next interrupt\n                        \\ handler (this BMI is effectively a JMP as we didn't\n                        \\ loop back with the BPL above, so BMI is always true)\n\n\\ ******************************************************************************\n\\\n\\       Name: ESCAPE\n\\       Type: Subroutine\n\\   Category: Flight\n\\    Summary: Launch our escape pod\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine displays our doomed Cobra Mk III disappearing off into the ether\n\\ before arranging our replacement ship. Called when we press ESCAPE during\n\\ flight and have an escape pod fitted.\n\\\n\\ ******************************************************************************\n\n.ESCAPE\n\n LDA MJ                 \\ Store the value of MJ on the stack (the \"are we in\n PHA                    \\ witchspace?\" flag)\n\n JSR RES2               \\ Reset a number of flight variables and workspaces\n\n LDX #CYL               \\ Set the current ship type to a Cobra Mk III, so we\n STX TYPE               \\ can show our ship disappear into the distance when we\n                        \\ eject in our pod\n\n JSR FRS1               \\ Call FRS1 to launch the Cobra Mk III straight ahead,\n                        \\ like a missile launch, but with our ship instead\n\n LDA #8                 \\ Set the Cobra's byte #27 (speed) to 8\n STA INWK+27\n\n LDA #194               \\ Set the Cobra's byte #30 (pitch counter) to 194, so it\n STA INWK+30            \\ pitches up as we pull away\n\n LSR A                  \\ Set the Cobra's byte #32 (AI flag) to %01100001, so it\n STA INWK+32            \\ has no AI, and we can use this value as a counter to\n                        \\ do the following loop 97 times\n\n.ESL1\n\n JSR MVEIT              \\ Call MVEIT to move the Cobra in space\n\n JSR LL9                \\ Call LL9 to draw the Cobra on-screen\n\n DEC INWK+32            \\ Decrement the counter in byte #32\n\n BNE ESL1               \\ Loop back to keep moving the Cobra until the AI flag\n                        \\ is 0, which gives it time to drift away from our pod\n\n JSR SCAN               \\ Call SCAN to remove the Cobra from the scanner (by\n                        \\ redrawing it)\n\n JSR RESET              \\ Call RESET to reset our ship and various controls\n\n PLA                    \\ Restore the witchspace flag from before the escape pod\n BEQ P%+5               \\ launch, and if we were in normal space, skip the\n                        \\ following instruction\n\n JMP DEATH              \\ Launching an escape pod in witchspace is fatal, so\n                        \\ jump to DEATH to begin the funeral and return from the\n                        \\ subroutine using a tail call\n\n LDX #16                \\ We lose all our cargo when using our escape pod, so\n                        \\ up a counter in X so we can zero the 17 cargo slots\n                        \\ in QQ20\n\n.ESL2\n\n STA QQ20,X             \\ Set the X-th byte of QQ20 to zero (as we know A = 0\n                        \\ from the BEQ above), so we no longer have any of item\n                        \\ type X in the cargo hold\n\n DEX                    \\ Decrement the counter\n\n BPL ESL2               \\ Loop back to ESL2 until we have emptied the entire\n                        \\ cargo hold\n\n STA FIST               \\ Launching an escape pod also clears our criminal\n                        \\ record, so set our legal status in FIST to 0 (\"clean\")\n\n STA ESCP               \\ The escape pod is a one-use item, so set ESCP to 0 so\n                        \\ we no longer have one fitted\n\n LDA #70                \\ Our replacement ship is delivered with a full tank of\n STA QQ14               \\ fuel, so set the current fuel level in QQ14 to 70, or\n                        \\ 7.0 light years\n\n JMP BAY                \\ Go to the docking bay (i.e. show the Status Mode\n                        \\ screen) and return from the subroutine with a tail\n                        \\ call\n\n\\ ******************************************************************************\n\\\n\\ Save ELTB.bin\n\\\n\\ ******************************************************************************\n\n PRINT \"ELITE B\"\n PRINT \"Assembled at \", ~CODE_B%\n PRINT \"Ends at \", ~P%\n PRINT \"Code size is \", ~(P% - CODE_B%)\n PRINT \"Execute at \", ~LOAD%\n PRINT \"Reload at \", ~LOAD_B%\n\n PRINT \"S.ELTB \", ~CODE_B%, \" \", ~P%, \" \", ~LOAD%, \" \", ~LOAD_B%\n SAVE \"3-assembled-output/ELTB.bin\", CODE_B%, P%, LOAD%\n\n\\ ******************************************************************************\n\\\n\\ ELITE C FILE\n\\\n\\ Produces the binary file ELTC.bin that gets loaded by elite-bcfs.asm.\n\\\n\\ ******************************************************************************\n\n CODE_C% = P%\n\n LOAD_C% = LOAD% +P% - CODE%\n\n\\ ******************************************************************************\n\\\n\\       Name: TACTICS (Part 1 of 7)\n\\       Type: Subroutine\n\\   Category: Tactics\n\\    Summary: Apply tactics: Process missiles, both enemy missiles and our own\n\\  Deep dive: Program flow of the tactics routine\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This section implements missile tactics and is entered at TA18 from the main\n\\ entry point below, if the current ship is a missile. Specifically:\n\\\n\\   * If E.C.M. is active, destroy the missile\n\\\n\\   * If the missile is hostile towards us, then check how close it is. If it\n\\     hasn't reached us, jump to part 3 so it can streak towards us, otherwise\n\\     we've been hit, so process a large amount of damage to our ship\n\\\n\\   * Otherwise see how close the missile is to its target. If it has not yet\n\\     reached its target, give the target a chance to activate its E.C.M. if it\n\\     has one, otherwise jump to TA19 with K3 set to the vector from the target\n\\     to the missile\n\\\n\\   * If it has reached its target and the target is the space station, destroy\n\\     the missile, potentially damaging us if we are nearby\n\\\n\\   * If it has reached its target and the target is a ship, destroy the missile\n\\     and the ship, potentially damaging us if we are nearby\n\\\n\\ ******************************************************************************\n\n.TA34\n\n                        \\ If we get here, the missile is hostile\n\n LDA #0                 \\ Set A to x_hi OR y_hi OR z_hi\n JSR MAS4\n\n BEQ P%+5               \\ If A = 0 then the missile is very close to our ship,\n                        \\ so skip the following instruction\n\n JMP TA21               \\ Jump down to part 3 to set up the vectors and skip\n                        \\ straight to aggressive manoeuvring\n\n JSR TA87+3             \\ The missile has hit our ship, so call TA87+3 to set\n                        \\ bit 7 of the missile's byte #31, which marks the\n                        \\ missile as being killed\n\n JSR EXNO3              \\ Make the sound of the missile exploding\n\n LDA #250               \\ Call OOPS to damage the ship by 250, which is a pretty\n JMP OOPS               \\ big hit, and return from the subroutine using a tail\n                        \\ call\n\n.TA18\n\n                        \\ This is the entry point for missile tactics and is\n                        \\ called from the main TACTICS routine below\n\n LDA ECMA               \\ If an E.C.M. is currently active (either ours or an\n BNE TA35               \\ opponent's), jump to TA35 to destroy this missile\n\n LDA INWK+32            \\ Fetch the AI flag from byte #32 and if bit 6 is set\n ASL A                  \\ (i.e. missile is hostile), jump up to TA34 to check\n BMI TA34               \\ whether the missile has hit us\n\n LSR A                  \\ Otherwise shift A right again. We know bits 6 and 7\n                        \\ are now clear, so this leaves bits 0-5. Bits 1-5\n                        \\ contain the target's slot number, and bit 0 is cleared\n                        \\ in FRMIS when a missile is launched, so A contains\n                        \\ the slot number shifted left by 1 (i.e. doubled) so we\n                        \\ can use it as an index for the two-byte address table\n                        \\ at UNIV\n\n TAX                    \\ Copy the address of the target ship's data block from\n LDA UNIV,X             \\ UNIV(X+1 X) to V(1 0)\n STA V\n LDA UNIV+1,X\n STA V+1\n\n LDY #2                 \\ K3(2 1 0) = (x_sign x_hi x_lo) - x-coordinate of\n JSR TAS1               \\ target ship\n\n LDY #5                 \\ K3(5 4 3) = (y_sign y_hi z_lo) - y-coordinate of\n JSR TAS1               \\ target ship\n\n LDY #8                 \\ K3(8 7 6) = (z_sign z_hi z_lo) - z-coordinate of\n JSR TAS1               \\ target ship\n\n                        \\ So K3 now contains the vector from the target ship to\n                        \\ the missile\n\n LDA K3+2               \\ Set A = OR of all the sign and high bytes of the\n ORA K3+5               \\ above, clearing bit 7 (i.e. ignore the signs)\n ORA K3+8\n AND #%01111111\n ORA K3+1\n ORA K3+4\n ORA K3+7\n\n BNE TA64               \\ If the result is non-zero, then the missile is some\n                        \\ distance from the target, so jump down to TA64 see if\n                        \\ the target activates its E.C.M.\n\n LDA INWK+32            \\ Fetch the AI flag from byte #32 and if only bits 7 and\n CMP #%10000010         \\ 1 are set (AI is enabled and the target is slot 1, the\n BEQ TA35               \\ space station), jump to TA35 to destroy this missile,\n                        \\ as the space station ain't kidding around\n\n LDY #31                \\ Fetch byte #31 (the exploding flag) of the target ship\n LDA (V),Y              \\ into A\n\n BIT M32+1              \\ M32 contains an LDY #32 instruction, so M32+1 contains\n                        \\ 32, so this instruction tests A with %00100000, which\n                        \\ checks bit 5 of A (the \"already exploding?\" bit)\n\n BNE TA35               \\ If the target ship is already exploding, jump to TA35\n                        \\ to destroy this missile\n\n ORA #%10000000         \\ Otherwise set bit 7 of the target's byte #31 to mark\n STA (V),Y              \\ the ship as having been killed, so it explodes\n\n.TA35\n\n LDA INWK               \\ Set A = x_lo OR y_lo OR z_lo of the missile\n ORA INWK+3\n ORA INWK+6\n\n BNE TA87               \\ If A is non-zero then the missile is not near our\n                        \\ ship, so jump to TA87 to skip damaging our ship\n\n LDA #80                \\ Otherwise the missile just got destroyed near us, so\n JSR OOPS               \\ call OOPS to damage the ship by 80, which is nowhere\n                        \\ near as bad as the 250 damage from a missile slamming\n                        \\ straight into us, but it's still pretty nasty\n\n.TA87\n\n JSR EXNO2              \\ Call EXNO2 to process the fact that we have killed a\n                        \\ missile (so increase the kill tally, make an explosion\n                        \\ sound and so on)\n\n ASL INWK+31            \\ Set bit 7 of the missile's byte #31 flag to mark it as\n SEC                    \\ having been killed, so it explodes\n ROR INWK+31\n\n.TA1\n\n RTS                    \\ Return from the subroutine\n\n.TA64\n\n                        \\ If we get here then the missile has not reached the\n                        \\ target\n\n JSR DORND              \\ Set A and X to random numbers\n\n CMP #16                \\ If A >= 16 (94% chance), jump down to TA19 with the\n BCS TA19               \\ vector from the target to the missile in K3\n\n.M32\n\n LDY #32                \\ Fetch byte #32 for the target and shift bit 0 (E.C.M.)\n LDA (V),Y              \\ into the C flag\n LSR A\n\n BCC TA19               \\ If the C flag is clear then the target does not have\n                        \\ E.C.M. fitted, so jump down to TA19 with the vector\n                        \\ from the target to the missile in K3\n\n JMP ECBLB2             \\ The target has E.C.M., so jump to ECBLB2 to set it\n                        \\ off, returning from the subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: TACTICS (Part 2 of 7)\n\\       Type: Subroutine\n\\   Category: Tactics\n\\    Summary: Apply tactics: Escape pod, station, lone Thargon, safe-zone pirate\n\\  Deep dive: Program flow of the tactics routine\n\\             Aggression and hostility in ship tactics\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This section contains the main entry point at TACTICS, which is called from\n\\ part 2 of MVEIT for ships that have the AI flag set (i.e. bit 7 of byte #32).\n\\ This part does the following:\n\\\n\\   * If this is a missile, jump up to the missile code in part 1\n\\\n\\   * If this is an escape pod, point it at the planet and jump to the\n\\     manoeuvring code in part 7\n\\\n\\   * If this is the space station and it is hostile, consider spawning a cop\n\\     (45% chance, up to a maximum of four) and we're done\n\\\n\\   * If this is a lone Thargon without a mothership, set it adrift aimlessly\n\\     and we're done\n\\\n\\   * If this is a pirate and we are within the space station safe zone, stop\n\\     the pirate from attacking by removing all its aggression\n\\\n\\   * Recharge the ship's energy banks by 1\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   The ship type\n\\\n\\ ******************************************************************************\n\n.TACTICS\n\n CPX #MSL               \\ If this is a missile, jump up to TA18 to implement\n BEQ TA18               \\ missile tactics\n\n CPX #ESC               \\ If this is not an escape pod, skip the following two\n BNE P%+8               \\ instructions\n\n JSR SPS1               \\ This is an escape pod, so call SPS1 to calculate the\n                        \\ vector to the planet and store it in XX15\n\n JMP TA15               \\ Jump down to TA15\n\n CPX #SST               \\ If this is not the space station, jump down to TA13\n BNE TA13\n\n                        \\ We only call the tactics routine for the space station\n                        \\ when it is hostile, so if we get here then this is the\n                        \\ station, and we already know it's hostile, so we need\n                        \\ to spawn some cops\n\n JSR DORND              \\ Set A and X to random numbers\n\n CMP #140               \\ If A < 140 (55% chance) then return from the\n BCC TA14-1             \\ subroutine (as TA14-1 contains an RTS)\n\n LDA MANY+COPS          \\ We only call the tactics routine for the space station\n CMP #4                 \\ when it is hostile, so first check the number of cops\n BCS TA14-1             \\ in the vicinity, and if we already have 4 or more, we\n                        \\ don't need to spawn any more, so return from the\n                        \\ subroutine (as TA14-1 contains an RTS)\n\n LDX #COPS              \\ Set X to the ship type for a cop\n\n LDA #%11110001         \\ Set the AI flag to give the ship E.C.M., enable AI and\n                        \\ make it very aggressive (56 out of 63)\n\n JMP SFS1               \\ Jump to SFS1 to spawn the ship, returning from the\n                        \\ subroutine using a tail call\n\n.TA13\n\n CPX #TGL               \\ If this is not a Thargon, jump down to TA14\n BNE TA14\n\n LDA MANY+THG           \\ If there is at least one Thargoid in the vicinity,\n BNE TA14               \\ jump down to TA14\n\n LSR INWK+32            \\ This is a Thargon but there is no Thargoid mothership,\n ASL INWK+32            \\ so clear bit 0 of the AI flag to disable its E.C.M.\n\n LSR INWK+27            \\ And halve the Thargon's speed\n\n RTS                    \\ Return from the subroutine\n\n.TA14\n\n CPX #CYL               \\ If A >= #CYL, i.e. this is a Cobra Mk III trader (as\n BCS TA62               \\ asteroids and cargo canisters never have AI), jump\n                        \\ down to TA62\n\n CPX #COPS              \\ If this is a cop, jump down to TA62\n BEQ TA62\n\n LDA SSPR               \\ If we aren't within range of the space station, jump\n BEQ TA62               \\ down to TA62\n\n LDA INWK+32            \\ This is a pirate or bounty hunter, but we are inside\n AND #%10000001         \\ the space station's safe zone, so clear bits 1-6 of\n STA INWK+32            \\ the AI flag to set it to zero aggression, because even\n                        \\ pirates aren't crazy enough to breach the station's\n                        \\ no-fire zone\n\n.TA62\n\n LDY #14                \\ If the ship's energy is greater or equal to the\n LDA INWK+35            \\ maximum value from the ship's blueprint pointed to by\n CMP (XX0),Y            \\ XX0, then skip the next instruction\n BCS TA21\n\n INC INWK+35            \\ The ship's energy is not at maximum, so recharge the\n                        \\ energy banks by 1\n\n\\ ******************************************************************************\n\\\n\\       Name: TACTICS (Part 3 of 7)\n\\       Type: Subroutine\n\\   Category: Tactics\n\\    Summary: Apply tactics: Calculate dot product to determine ship's aim\n\\  Deep dive: Program flow of the tactics routine\n\\             Aggression and hostility in ship tactics\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This section sets up some vectors and calculates dot products. Specifically:\n\\\n\\   * Calculate the dot product of the ship's nose vector (i.e. the direction it\n\\     is pointing) with the vector between us and the ship. This value will help\n\\     us work out later on whether the enemy ship is pointing towards us, and\n\\     therefore whether it can hit us with its lasers.\n\\\n\\ ******************************************************************************\n\n.TA21\n\n LDX #8                 \\ We now want to copy the ship's x, y and z coordinates\n                        \\ from INWK to K3, so set up a counter for 9 bytes\n\n.TAL1\n\n LDA INWK,X             \\ Copy the X-th byte from INWK to the X-th byte of K3\n STA K3,X\n\n DEX                    \\ Decrement the counter\n\n BPL TAL1               \\ Loop back until we have copied all 9 bytes\n\n.TA19\n\n                        \\ If this is a missile that's heading for its target\n                        \\ (not us, one of the other ships), then the missile\n                        \\ routine at TA18 above jumps here after setting K3 to\n                        \\ the vector from the target to the missile\n\n JSR TAS2               \\ Normalise the vector in K3 and store the normalised\n                        \\ version in XX15, so XX15 contains the normalised\n                        \\ vector from our ship to the ship we are applying AI\n                        \\ tactics to (or the normalised vector from the target\n                        \\ to the missile - in both cases it's the vector from\n                        \\ the potential victim to the attacker)\n\n LDY #10                \\ Set (A X) = nosev . XX15\n JSR TAS3\n\n STA CNT                \\ Store the high byte of the dot product in CNT. The\n                        \\ bigger the value, the more aligned the two ships are,\n                        \\ with a maximum magnitude of 36 (96 * 96 >> 8). If CNT\n                        \\ is positive, the ships are facing in a similar\n                        \\ direction, if it's negative they are facing in\n                        \\ opposite directions\n\n\\ ******************************************************************************\n\\\n\\       Name: TACTICS (Part 4 of 7)\n\\       Type: Subroutine\n\\   Category: Tactics\n\\    Summary: Apply tactics: Check energy levels, maybe launch escape pod if low\n\\  Deep dive: Program flow of the tactics routine\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This section works out what kind of condition the ship is in. Specifically:\n\\\n\\   * Rarely (2.5% chance) roll the ship by a noticeable amount\n\\\n\\   * If the ship has at least half its energy banks full, jump to part 6 to\n\\     consider firing the lasers\n\\\n\\   * If the ship is not into the last 1/8th of its energy, jump to part 5 to\n\\     consider firing a missile\n\\\n\\   * If the ship is into the last 1/8th of its energy, then rarely (10% chance)\n\\     the ship launches an escape pod and is left drifting in space\n\\\n\\ ******************************************************************************\n\n LDA TYPE               \\ If this is not a missile, skip the following\n CMP #MSL               \\ instruction\n BNE P%+5\n\n JMP TA20               \\ This is a missile, so jump down to TA20 to get\n                        \\ straight into some aggressive manoeuvring\n\n JSR DORND              \\ Set A and X to random numbers\n\n CMP #250               \\ If A < 250 (97.5% chance), jump down to TA7 to skip\n BCC TA7                \\ the following\n\n JSR DORND              \\ Set A and X to random numbers\n\n ORA #104               \\ Bump A up to at least 104 and store in the roll\n STA INWK+29            \\ counter, to gives the ship a noticeable roll\n\n.TA7\n\n LDY #14                \\ Set A = the ship's maximum energy / 2\n LDA (XX0),Y\n LSR A\n\n CMP INWK+35            \\ If the ship's current energy in byte #35 > A, i.e. the\n BCC TA3                \\ ship has at least half of its energy banks charged,\n                        \\ jump down to TA3\n\n LSR A                  \\ If the ship's current energy in byte #35 > A / 4, i.e.\n LSR A                  \\ the ship is not into the last 1/8th of its energy,\n CMP INWK+35            \\ jump down to ta3 to consider firing a missile\n BCC ta3\n\n JSR DORND              \\ Set A and X to random numbers\n\n CMP #230               \\ If A < 230 (90% chance), jump down to ta3 to consider\n BCC ta3                \\ firing a missile\n\n LDA TYPE               \\ If this is a Thargoid, jump down to ta3 to consider\n CMP #THG               \\ launching a Thargon\n BEQ ta3\n\n                        \\ By this point, the ship has run out of both energy and\n                        \\ luck, so it's time to bail\n\n LDA #%00000000         \\ Set the AI flag to 0 to disable AI, set aggression to\n STA INWK+32            \\ zero and disable any E.C.M., so the ship's a sitting\n                        \\ duck\n\n JMP SESCP              \\ Jump to SESCP to spawn an escape pod from the ship,\n                        \\ returning from the subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: TACTICS (Part 5 of 7)\n\\       Type: Subroutine\n\\   Category: Tactics\n\\    Summary: Apply tactics: Consider whether to launch a missile at us\n\\  Deep dive: Program flow of the tactics routine\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This section considers whether to launch a missile. Specifically:\n\\\n\\   * If the ship doesn't have any missiles, skip to the next part\n\\\n\\   * If an E.C.M. is firing, skip to the next part\n\\\n\\   * Randomly decide whether to fire a missile (or, in the case of Thargoids,\n\\     release a Thargon), and if we do, we're done\n\\\n\\ ******************************************************************************\n\n.ta3\n\n                        \\ If we get here then the ship has less than half energy\n                        \\ so there may not be enough juice for lasers, but let's\n                        \\ see if we can fire a missile\n\n LDA INWK+31            \\ Set A = bits 0-2 of byte #31, the number of missiles\n AND #%00000111         \\ the ship has left\n\n BEQ TA3                \\ If it doesn't have any missiles, jump to TA3\n\n STA T                  \\ Store the number of missiles in T\n\n JSR DORND              \\ Set A and X to random numbers\n\n AND #31                \\ Restrict A to a random number in the range 0-31\n\n CMP T                  \\ If A >= T, which is quite likely, though less likely\n BCS TA3                \\ with higher numbers of missiles, jump to TA3 to skip\n                        \\ firing a missile\n\n LDA ECMA               \\ If an E.C.M. is currently active (either ours or an\n BNE TA3                \\ opponent's), jump to TA3 to skip firing a missile\n\n DEC INWK+31            \\ We're done with the checks, so it's time to fire off a\n                        \\ missile, so reduce the missile count in byte #31 by 1\n\n LDA TYPE               \\ Fetch the ship type into A\n\n CMP #THG               \\ If this is not a Thargoid, jump down to TA16 to launch\n BNE TA16               \\ a missile\n\n LDX #TGL               \\ This is a Thargoid, so instead of launching a missile,\n LDA INWK+32            \\ the mothership launches a Thargon, so call SFS1 to\n JMP SFS1               \\ spawn a Thargon from the parent ship, and return from\n                        \\ the subroutine using a tail call\n\n.TA16\n\n JMP SFRMIS             \\ Jump to SFRMIS to spawn a missile as a child of the\n                        \\ current ship, make a noise and print a message warning\n                        \\ of incoming missiles, and return from the subroutine\n                        \\ using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: TACTICS (Part 6 of 7)\n\\       Type: Subroutine\n\\   Category: Tactics\n\\    Summary: Apply tactics: Consider firing a laser at us, if aim is true\n\\  Deep dive: Program flow of the tactics routine\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This section looks at potentially firing the ship's laser at us. Specifically:\n\\\n\\   * If the ship is not pointing at us, skip to the next part\n\\\n\\   * If the ship is pointing at us but not accurately, fire its laser at us and\n\\     skip to the next part\n\\\n\\   * If we are in the ship's crosshairs, register some damage to our ship, slow\n\\     down the attacking ship, make the noise of us being hit by laser fire, and\n\\     we're done\n\\\n\\ ******************************************************************************\n\n.TA3\n\n                        \\ If we get here then the ship either has plenty of\n                        \\ energy, or levels are low but it couldn't manage to\n                        \\ launch a missile, so maybe we can fire the laser?\n\n LDA #0                 \\ Set A to x_hi OR y_hi OR z_hi\n JSR MAS4\n\n AND #%11100000         \\ If any of the hi bytes have any of bits 5-7 set, then\n BNE TA4                \\ jump to TA4 to skip the laser checks, as the ship is\n                        \\ too far away from us to hit us with a laser\n\n LDX CNT                \\ Set X = the dot product set above in CNT. If this is\n                        \\ positive, this ship and our ship are facing in similar\n                        \\ directions, but if it's negative then we are facing\n                        \\ each other, so for us to be in the enemy ship's line\n                        \\ of fire, X needs to be negative. The value in X can\n                        \\ have a maximum magnitude of 36, which would mean we\n                        \\ were facing each other square on, so in the following\n                        \\ code we check X like this:\n                        \\\n                        \\   X = 0 to -31, we are not in the enemy ship's line\n                        \\       of fire, so they can't shoot at us\n                        \\\n                        \\   X = -32 to -34, we are in the enemy ship's line\n                        \\       of fire, so they can shoot at us, but they can't\n                        \\       hit us as we're not dead in their crosshairs\n                        \\\n                        \\   X = -35 to -36, we are bang in the middle of the\n                        \\       enemy ship's crosshairs, so they can not only\n                        \\       shoot us, they can hit us\n\n CPX #160               \\ If X < 160, i.e. X > -32, then we are not in the enemy\n BCC TA4                \\ ship's line of fire, so jump to TA4 to skip the laser\n                        \\ checks\n\n LDA INWK+31            \\ Set bit 6 in byte #31 to denote that the ship is\n ORA #%01000000         \\ firing its laser at us\n STA INWK+31\n\n CPX #163               \\ If X < 163, i.e. X > -35, then we are not in the enemy\n BCC TA4                \\ ship's crosshairs, so jump to TA4 to skip the laser\n                        \\ checks\n\n.HIT\n\n LDY #19                \\ We are being hit by enemy laser fire, so fetch the\n LDA (XX0),Y            \\ enemy ship's byte #19 from their ship's blueprint\n                        \\ into A\n\n LSR A                  \\ Halve the enemy ship's byte #19 (which contains both\n                        \\ the laser power and number of missiles) to get the\n                        \\ amount of damage we should take\n\n JSR OOPS               \\ Call OOPS to take some damage, which could do anything\n                        \\ from reducing the shields and energy, all the way to\n                        \\ losing cargo or dying (if the latter, we don't come\n                        \\ back from this subroutine)\n\n DEC INWK+28            \\ Halve the attacking ship's acceleration in byte #28\n\n LDA ECMA               \\ If an E.C.M. is currently active (either ours or an\n BNE TA10               \\ opponent's), return from the subroutine without making\n                        \\ the laser-strike sound (as TA10 contains an RTS)\n\n LDA #8                 \\ Call the NOISE routine with A = 8 to make the sound\n JMP NOISE              \\ of us being hit by lasers, returning from the\n                        \\ subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: TACTICS (Part 7 of 7)\n\\       Type: Subroutine\n\\   Category: Tactics\n\\    Summary: Apply tactics: Set pitch, roll, and acceleration\n\\  Deep dive: Program flow of the tactics routine\n\\             Aggression and hostility in ship tactics\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This section looks at manoeuvring the ship. Specifically:\n\\\n\\   * Work out which direction the ship should be moving, depending on whether\n\\     it's an escape pod, where it is, which direction it is pointing, and how\n\\     aggressive it is\n\\\n\\   * Set the pitch and roll counters to head in that direction\n\\\n\\   * Speed up or slow down, depending on where the ship is in relation to us\n\\\n\\ ******************************************************************************\n\n.TA4\n\n LDA INWK+7             \\ If z_hi >= 3 then the ship is quite far away, so jump\n CMP #3                 \\ down to TA5\n BCS TA5\n\n LDA INWK+1             \\ Otherwise set A = x_hi OR y_hi and extract bits 1-7\n ORA INWK+4\n AND #%11111110\n\n BEQ TA15               \\ If A = 0 then the ship is pretty close to us, so jump\n                        \\ to TA15 so it heads away from us\n\n.TA5\n\n                        \\ If we get here then the ship is quite far away\n\n JSR DORND              \\ Set A and X to random numbers\n\n ORA #%10000000         \\ Set bit 7 of A, so the following comparison ignores\n                        \\ the AI flag in bit 7 (as we already know bit 7 is set\n                        \\ in byte #32)\n\n CMP INWK+32            \\ If A >= byte #32 (the ship's AI flag) then jump down\n BCS TA15               \\ to TA15 so it heads away from us\n\n                        \\ We get here if byte #32 > A, where byte #32 is\n                        \\ composed of the following:\n                        \\\n                        \\   * Bit 7 set = AI is enabled\n                        \\\n                        \\   * Bits 1-6 = aggression level (0 to 63)\n                        \\\n                        \\   * Bit 0 set = ship has E.C.M.\n                        \\\n                        \\ We set bit 7 of A above, so if we get here we know the\n                        \\ ship has AI enabled, and the comparison then boils\n                        \\ down to the following:\n                        \\\n                        \\   Aggression level * 2 + E.C.M. > random number 0-127\n                        \\\n                        \\ In other words, higher aggression levels increase the\n                        \\ chances of a ship changing direction to head towards\n                        \\ us - or, to put it another way, ships with higher\n                        \\ aggression levels are spoiling for a fight, with\n                        \\ E.C.M. making them even more aggressive\n                        \\\n                        \\ Thargoids and missiles both have an aggression level\n                        \\ of 63 out of 63, which explains an awful lot\n                        \\\n                        \\ Interestingly, escape pods also have a maximum\n                        \\ agression level, but in this case it makes them fly\n                        \\ towards the planet rather than towards us\n\n.TA20\n\n                        \\ If this is a missile we will have jumped straight\n                        \\ here, but we also get here if the ship is either far\n                        \\ away and aggressive, or not too close\n\n LDA XX15               \\ Reverse the signs of XX15 and the dot product in CNT,\n EOR #%10000000         \\ starting with the x-coordinate\n STA XX15\n\n LDA XX15+1             \\ Then reverse the sign of the y-coordinate\n EOR #%10000000\n STA XX15+1\n\n LDA XX15+2             \\ And then the z-coordinate, so now the XX15 vector goes\n EOR #%10000000         \\ from the enemy ship to our ship (it was previously the\n STA XX15+2             \\ other way round)\n\n LDA CNT                \\ And finally change the sign of the dot product in CNT,\n EOR #%10000000         \\ so now it's positive if the ships are facing each\n STA CNT                \\ other, and negative if they are facing the same way\n\n.TA15\n\n                        \\ If we get here, then one of the following is true:\n                        \\\n                        \\   * This is an escape pod and XX15 is pointing towards\n                        \\     the planet\n                        \\\n                        \\   * The ship is pretty close to us, or it's just not\n                        \\     very aggressive (though there is a random factor\n                        \\     at play here too). XX15 is still pointing from our\n                        \\     ship towards the enemy ship\n                        \\\n                        \\   * The ship is aggressive (though again, there's an\n                        \\     element of randomness here). XX15 is pointing from\n                        \\     the enemy ship towards our ship\n                        \\\n                        \\   * This is a missile heading for a target. XX15 is\n                        \\     pointing from the missile towards the target\n                        \\\n                        \\ We now want to move the ship in the direction of XX15,\n                        \\ which will make aggressive ships head towards us, and\n                        \\ ships that are too close turn away. Escape pods,\n                        \\ meanwhile, head off towards the planet in search of a\n                        \\ space station, and missiles home in on their targets\n\n LDY #16                \\ Set (A X) = roofv . XX15\n JSR TAS3               \\\n                        \\ This will be positive if XX15 is pointing in the same\n                        \\ direction as an arrow out of the top of the ship, in\n                        \\ other words if the ship should pull up to head in the\n                        \\ direction of XX15\n\n EOR #%10000000         \\ Set the ship's pitch counter to 3, with the opposite\n AND #%10000000         \\ sign to the dot product result, which gently pitches\n ORA #%00000011         \\ the ship towards the direction of the XX15 vector\n STA INWK+30\n\n LDA INWK+29            \\ Fetch the roll counter from byte #29 into A and clear\n AND #%01111111         \\ the sign bit (to give an endless clockwise roll)\n\n CMP #16                \\ If A >= 16 then jump to TA6, as the ship is already\n BCS TA6                \\ in the process of rolling\n\n LDY #22                \\ Set (A X) = sidev . XX15\n JSR TAS3               \\\n                        \\ This will be positive if XX15 is pointing in the same\n                        \\ direction as an arrow out of the right side of the\n                        \\ ship, in other words if the ship should roll right to\n                        \\ head in the direction of XX15\n\n EOR INWK+30            \\ Set the ship's roll counter to 5, with the sign set to\n AND #%10000000         \\ positive (clockwise roll) if the pitch counter and dot\n EOR #%10000101         \\ product have different signs, negative (anti-clockwise\n STA INWK+29            \\ roll) if they have the same sign\n\n.TA6\n\n LDA CNT                \\ Fetch the dot product, and if it's negative jump to\n BMI TA9                \\ TA9, as the ships are facing away from each other and\n                        \\ the ship might want to slow down to take another shot\n\n CMP #22                \\ The dot product is positive, so the ships are facing\n BCC TA9                \\ each other. If A < 22 then the ships are not heading\n                        \\ directly towards each other, so jump to TA9 to slow\n                        \\ down\n\n LDA #3                 \\ Otherwise set the acceleration in byte #28 to 3\n STA INWK+28\n\n RTS                    \\ Return from the subroutine\n\n.TA9\n\n AND #%01111111         \\ Clear the sign bit of the dot product in A\n\n CMP #18                \\ If A < 18 then the ship is way off the XX15 vector, so\n BCC TA10               \\ return from the subroutine (TA10 contains an RTS)\n                        \\ without slowing down, as it still has quite a bit of\n                        \\ turning to do to get on course\n\n LDA #&FF               \\ Otherwise set A = -1\n\n LDX TYPE               \\ If this is not a missile then skip the ASL instruction\n CPX #MSL\n BNE P%+3\n\n ASL A                  \\ This is a missile, so set A = -2, as missiles are more\n                        \\ nimble and can brake more quickly\n\n STA INWK+28            \\ Set the ship's acceleration to A\n\n.TA10\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: TAS1\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate K3 = (x_sign x_hi x_lo) - V(1 0)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate one of the following, depending on the value in Y:\n\\\n\\   K3(2 1 0) = (x_sign x_hi x_lo) - x-coordinate in V(1 0)\n\\\n\\   K3(5 4 3) = (y_sign y_hi z_lo) - y-coordinate in V(1 0)\n\\\n\\   K3(8 7 6) = (z_sign z_hi z_lo) - z-coordinate in V(1 0)\n\\\n\\ where the first coordinate is from the ship data block in INWK, and the second\n\\ coordinate is from the ship data block pointed to by V(1 0).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   V(1 0)              The address of the ship data block to subtract\n\\\n\\   Y                   The coordinate in the V(1 0) block to subtract:\n\\\n\\                         * If Y = 2, subtract the x-coordinate and store the\n\\                           result in K3(2 1 0)\n\\\n\\                         * If Y = 5, subtract the y-coordinate and store the\n\\                           result in K3(5 4 3)\n\\\n\\                         * If Y = 8, subtract the z-coordinate and store the\n\\                           result in K3(8 7 6)\n\\\n\\ ******************************************************************************\n\n.TAS1\n\n LDA (V),Y              \\ Copy the sign byte of the V(1 0) coordinate into K+3,\n EOR #%10000000         \\ flipping it in the process\n STA K+3\n\n DEY                    \\ Copy the high byte of the V(1 0) coordinate into K+2\n LDA (V),Y\n STA K+2\n\n DEY                    \\ Copy the high byte of the V(1 0) coordinate into K+1,\n LDA (V),Y              \\ so now:\n STA K+1                \\\n                        \\   K(3 2 1) = - coordinate in V(1 0)\n\n STY U                  \\ Copy the index (now 0, 3 or 6) into U and X\n LDX U\n\n JSR MVT3               \\ Call MVT3 to add the same coordinates, but this time\n                        \\ from INWK, so this would look like this for the\n                        \\ x-axis:\n                        \\\n                        \\   K(3 2 1) = (x_sign x_hi x_lo) + K(3 2 1)\n                        \\            = (x_sign x_hi x_lo) - coordinate in V(1 0)\n\n LDY U                  \\ Restore the index into Y, though this instruction has\n                        \\ no effect, as Y is not used again, either here or\n                        \\ following calls to this routine\n\n STA K3+2,X             \\ Store K(3 2 1) in K3+X(2 1 0), starting with the sign\n                        \\ byte\n\n LDA K+2                \\ And then doing the high byte\n STA K3+1,X\n\n LDA K+1                \\ And finally the low byte\n STA K3,X\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: HITCH\n\\       Type: Subroutine\n\\   Category: Tactics\n\\    Summary: Work out if the ship in INWK is in our crosshairs\n\\  Deep dive: In the crosshairs\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This is called by the main flight loop to see if we have laser or missile lock\n\\ on an enemy ship.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   C flag              Set if the ship is in our crosshairs, clear if it isn't\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   HI1                 Contains an RTS\n\\\n\\ ******************************************************************************\n\n.HITCH\n\n CLC                    \\ Clear the C flag so we can return with it cleared if\n                        \\ our checks fail\n\n LDA INWK+8             \\ Set A = z_sign\n\n BNE HI1                \\ If A is non-zero then the ship is behind us and can't\n                        \\ be in our crosshairs, so return from the subroutine\n                        \\ with the C flag clear (as HI1 contains an RTS)\n\n LDA TYPE               \\ If the ship type has bit 7 set then it is the planet\n BMI HI1                \\ or sun, which we can't target or hit with lasers, so\n                        \\ return from the subroutine with the C flag clear (as\n                        \\ HI1 contains an RTS)\n\n LDA INWK+31            \\ Fetch bit 5 of byte #31 (the exploding flag) and OR\n AND #%00100000         \\ with x_hi and y_hi\n ORA INWK+1\n ORA INWK+4\n\n BNE HI1                \\ If this value is non-zero then either the ship is\n                        \\ exploding (so we can't target it), or the ship is too\n                        \\ far away from our line of fire to be targeted, so\n                        \\ return from the subroutine with the C flag clear (as\n                        \\ HI1 contains an RTS)\n\n LDA INWK               \\ Set A = x_lo\n\n JSR SQUA2              \\ Set (A P) = A * A = x_lo^2\n\n STA S                  \\ Set (S R) = (A P) = x_lo^2\n LDA P\n STA R\n\n LDA INWK+3             \\ Set A = y_lo\n\n JSR SQUA2              \\ Set (A P) = A * A = y_lo^2\n\n TAX                    \\ Store the high byte in X\n\n LDA P                  \\ Add the two low bytes, so:\n ADC R                  \\\n STA R                  \\   R = P + R\n\n TXA                    \\ Restore the high byte into A and add S to give the\n ADC S                  \\ following:\n                        \\\n                        \\   (A R) = (S R) + (A P) = x_lo^2 + y_lo^2\n\n BCS FR1-2              \\ If the addition just overflowed then there is no way\n                        \\ our crosshairs are within the ship's targetable area,\n                        \\ so return from the subroutine with the C flag clear\n                        \\ (as FR1-2 contains a CLC then an RTS)\n\n STA S                  \\ Set (S R) = (A P) = x_lo^2 + y_lo^2\n\n LDY #2                 \\ Fetch the ship's blueprint and set A to the high byte\n LDA (XX0),Y            \\ of the targetable area of the ship\n\n CMP S                  \\ We now compare the high bytes of the targetable area\n                        \\ and the calculation in (S R):\n                        \\\n                        \\   * If A >= S then then the C flag will be set\n                        \\\n                        \\   * If A < S then the C flag will be C clear\n\n BNE HI1                \\ If A <> S we have just set the C flag correctly, so\n                        \\ return from the subroutine (as HI1 contains an RTS)\n\n DEY                    \\ The high bytes were identical, so now we fetch the\n LDA (XX0),Y            \\ low byte of the targetable area into A\n\n CMP R                  \\ We now compare the low bytes of the targetable area\n                        \\ and the calculation in (S R):\n                        \\\n                        \\   * If A >= R then the C flag will be set\n                        \\\n                        \\   * If A < R then the C flag will be C clear\n\n.HI1\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: FRS1\n\\       Type: Subroutine\n\\   Category: Tactics\n\\    Summary: Launch a ship straight ahead of us, below the laser sights\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This is used in three places:\n\\\n\\   * When we launch a missile, in which case the missile is the ship that is\n\\     launched ahead of us\n\\\n\\   * When we launch our escape pod, in which case it's our abandoned Cobra Mk\n\\     III that is launched ahead of us\n\\\n\\   * The fq1 entry point is used to launch a bunch of cargo canisters ahead of\n\\     us as part of the death screen\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   The type of ship to launch ahead of us\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   C flag              Set if the ship was successfully launched, clear if it\n\\                       wasn't (as there wasn't enough free memory)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   fq1                 Used to add a cargo canister to the universe\n\\\n\\ ******************************************************************************\n\n.FRS1\n\n JSR ZINF               \\ Call ZINF to reset the INWK ship workspace\n\n LDA #28                \\ Set y_lo = 28\n STA INWK+3\n\n LSR A                  \\ Set z_lo = 14, so the launched ship starts out\n STA INWK+6             \\ ahead of us\n\n LDA #%10000000         \\ Set y_sign to be negative, so the launched ship is\n STA INWK+5             \\ launched just below our line of sight\n\n LDA MSTG               \\ Set A to the missile lock target, shifted left so the\n ASL A                  \\ slot number is in bits 1-5\n\n ORA #%10000000         \\ Set bit 7 and store the result in byte #32, the AI\n STA INWK+32            \\ flag launched ship for the launched ship. For missiles\n                        \\ this enables AI (bit 7), makes it friendly towards us\n                        \\ (bit 6), sets the target to the value of MSTG (bits\n                        \\ 1-5), and sets its lock status as launched (bit 0).\n                        \\ It doesn't matter what it does for our abandoned\n                        \\ Cobra, as the AI flag gets overwritten once we return\n                        \\ from the subroutine back to the ESCAPE routine that\n                        \\ called FRS1 in the first place\n\n.fq1\n\n LDA #&60               \\ Set byte #14 (nosev_z_hi) to 1 (&60), so the launched\n STA INWK+14            \\ ship is pointing away from us\n\n ORA #128               \\ Set byte #22 (sidev_x_hi) to -1 (&D0), so the launched\n STA INWK+22            \\ ship has the same orientation as spawned ships, just\n                        \\ pointing away from us (if we set sidev to +1 instead,\n                        \\ this ship would be a mirror image of all the other\n                        \\ ships, which are spawned with -1 in nosev and +1 in\n                        \\ sidev)\n\n LDA DELTA              \\ Set byte #27 (speed) to 2 * DELTA, so the launched\n ROL A                  \\ ship flies off at twice our speed\n STA INWK+27\n\n TXA                    \\ Add a new ship of type X to our local bubble of\n JMP NWSHP              \\ universe and return from the subroutine using a tail\n                        \\ call\n\n\\ ******************************************************************************\n\\\n\\       Name: FRMIS\n\\       Type: Subroutine\n\\   Category: Tactics\n\\    Summary: Fire a missile from our ship\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ We fired a missile, so send it streaking away from us to unleash mayhem and\n\\ destruction on our sworn enemies.\n\\\n\\ ******************************************************************************\n\n.FRMIS\n\n LDX #MSL               \\ Call FRS1 to launch a missile straight ahead of us\n JSR FRS1\n\n BCC FR1                \\ If FRS1 returns with the C flag clear, then there\n                        \\ isn't room in the universe for our missile, so jump\n                        \\ down to FR1 to display a \"missile jammed\" message\n\n LDX MSTG               \\ Fetch the slot number of the missile's target\n\n JSR GINF               \\ Get the address of the data block for the target ship\n                        \\ and store it in INF\n\n LDA FRIN,X             \\ Fetch the ship type of the missile's target into A\n\n JSR ANGRY              \\ Call ANGRY to make the target ship angry; if it is the\n                        \\ space station this will make it hostile, or if this is\n                        \\ a ship it will wake up its AI and give it a kick of\n                        \\ speed\n\n LDY #0                 \\ We have just launched a missile, so we need to remove\n JSR ABORT              \\ missile lock and hide the leftmost indicator on the\n                        \\ dashboard by setting it to black (Y = 0)\n\n DEC NOMSL              \\ Reduce the number of missiles we have by 1\n\n LDA #48                \\ Call the NOISE routine with A = 48 to make the sound\n JMP NOISE              \\ of a missile launch, returning from the subroutine\n                        \\ using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: ANGRY\n\\       Type: Subroutine\n\\   Category: Tactics\n\\    Summary: If this is a space station then make it hostile, or if this is a\n\\             ship then enable the ship's AI and give it a kick of speed\n\\  Deep dive: Aggression and hostility in ship tactics\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine makes a ship angry. For the space station this means setting the\n\\ hostile flag, while for other ships it means enabling the ship's AI and giving\n\\ it a kick of turning acceleration. Later calls to TACTICS may make the ship\n\\ start to attack us if it has a high enough aggression level.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The type of ship we're going to irritate\n\\\n\\   INF                 The address of the data block for the ship we're going\n\\                       to infuriate\n\\\n\\ ******************************************************************************\n\n.ANGRY\n\n CMP #SST               \\ If this is the space station, jump to AN2 to make the\n BEQ AN2                \\ space station hostile\n\n BCS HI1                \\ If A >= #SST then this is a missile, asteroid, cargo\n                        \\ canister, Thargon or escape pod, and they can't get\n                        \\ angry, so return from the subroutine (as HI1 contains\n                        \\ an RTS)\n\n CMP #CYL               \\ If this is not a Cobra Mk III trader, skip the\n BNE P%+5               \\ following instruction\n\n JSR AN2                \\ Call AN2 to make the space station hostile\n\n LDY #32                \\ Fetch the ship's byte #32 (AI flag)\n LDA (INF),Y\n\n BEQ HI1                \\ If the AI flag is zero then this ship has no AI and\n                        \\ zero aggression, so return from the subroutine (as\n                        \\ HI1 contains an RTS)\n\n ORA #%10000000         \\ Otherwise set bit 7 (AI enabled) to ensure AI is\n STA (INF),Y            \\ definitely enabled, so the ship can start acting\n                        \\ according to its aggression level\n\n LDY #28                \\ Set the ship's byte #28 (acceleration) to 2, so it\n LDA #2                 \\ speeds up\n STA (INF),Y\n\n ASL A                  \\ Set the ship's byte #30 (pitch counter) to 4, so it\n LDY #30                \\ starts diving\n STA (INF),Y\n\n RTS                    \\ Return from the subroutine\n\n.AN2\n\n ASL K%+NI%+32          \\ Fetch the AI counter (byte #32) of the second ship\n SEC                    \\ in the ship data workspace at K%, which is reserved\n ROR K%+NI%+32          \\ for the sun or the space station (in this case it's\n                        \\ the latter), and set bit 7 to make it hostile\n\n CLC                    \\ Clear the C flag, which isn't used by calls to this\n                        \\ routine, but it does set up the entry point FR1-2\n                        \\ so that it clears the C flag and does an RTS\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: FR1\n\\       Type: Subroutine\n\\   Category: Tactics\n\\    Summary: Display the \"missile jammed\" message\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This is shown if there isn't room in the local bubble of universe for a new\n\\ missile.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   FR1-2               Clear the C flag and return from the subroutine\n\\\n\\ ******************************************************************************\n\n.FR1\n\n LDA #201               \\ Print recursive token 41 (\"MISSILE JAMMED\") as an\n JMP MESS               \\ in-flight message and return from the subroutine using\n                        \\ a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: SESCP\n\\       Type: Subroutine\n\\   Category: Flight\n\\    Summary: Spawn an escape pod from the current (parent) ship\n\\  Deep dive: Aggression and hostility in ship tactics\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This is called when an enemy ship has run out of both energy and luck, so it's\n\\ time to bail.\n\\\n\\ ******************************************************************************\n\n.SESCP\n\n LDX #ESC               \\ Set X to the ship type for an escape pod\n\n LDA #%11111110         \\ Set A to use as an AI flag that has AI enabled, an\n                        \\ aggression level of 63 out of 63, and no E.C.M.\n                        \\\n                        \\ When spawning an escape pod, this high agression level\n                        \\ makes the pod turn towards the planet rather than\n                        \\ towards us\n                        \\\n                        \\ This instruction is also used as an entry point to\n                        \\ spawn missile (when calling via the SFS1-2 entry\n                        \\ point), in which case the missile has AI (bit 7 set),\n                        \\ is hostile (bit 6 set) and has been launched (bit 0\n                        \\ clear); the target slot number is set to 31, but this\n                        \\ is ignored as the hostile flag means we are the target\n\n                        \\ Fall through into SFS1 to spawn the escape pod or\n                        \\ missile\n\n\\ ******************************************************************************\n\\\n\\       Name: SFS1\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Spawn a child ship from the current (parent) ship\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ If the parent is a space station then the child ship is spawned coming out of\n\\ the slot, and if the child is a cargo canister, it is sent tumbling through\n\\ space. Otherwise the child ship is spawned with the same ship data as the\n\\ parent, just with damping disabled and the ship type and AI flag that are\n\\ passed in A and X.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   AI flag for the new ship (see the documentation on ship\n\\                       data byte #32 for details)\n\\\n\\   X                   The ship type of the child to spawn\n\\\n\\   INF                 Address of the parent's ship data block\n\\\n\\   TYPE                The type of the parent ship\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   C flag              Set if ship successfully added, clear if it failed\n\\\n\\   INF                 INF is preserved\n\\\n\\   XX0                 XX0 is preserved\n\\\n\\   INWK                The whole INWK workspace is preserved\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   SFS1-2              Used to add a missile to the local bubble that that has\n\\                       AI (bit 7 set), is hostile (bit 6 set) and has been\n\\                       launched (bit 0 clear); the target slot number is set to\n\\                       31, but this is ignored as the hostile flags means we\n\\                       are the target\n\\\n\\ ******************************************************************************\n\n.SFS1\n\n STA T1                 \\ Store the child ship's AI flag in T1\n\n                        \\ Before spawning our child ship, we need to save the\n                        \\ INF and XX00 variables and the whole INWK workspace,\n                        \\ so we can restore them later when returning from the\n                        \\ subroutine\n\n LDA XX0                \\ Store XX0(1 0) on the stack, so we can restore it\n PHA                    \\ later when returning from the subroutine\n LDA XX0+1\n PHA\n\n LDA INF                \\ Store INF(1 0) on the stack, so we can restore it\n PHA                    \\ later when returning from the subroutine\n LDA INF+1\n PHA\n\n LDY #NI%-1             \\ Now we want to store the current INWK data block in\n                        \\ temporary memory so we can restore it when we are\n                        \\ done, and we also want to copy the parent's ship data\n                        \\ into INWK, which we can do at the same time, so set up\n                        \\ a counter in Y for NI% bytes\n\n.FRL2\n\n LDA INWK,Y             \\ Copy the Y-th byte of INWK to the Y-th byte of\n STA XX3,Y              \\ temporary memory in XX3, so we can restore it later\n                        \\ when returning from the subroutine\n\n LDA (INF),Y            \\ Copy the Y-th byte of the parent ship's data block to\n STA INWK,Y             \\ the Y-th byte of INWK\n\n DEY                    \\ Decrement the loop counter\n\n BPL FRL2               \\ Loop back to copy the next byte until we have done\n                        \\ them all\n\n                        \\ INWK now contains the ship data for the parent ship,\n                        \\ so now we need to tweak the data before creating the\n                        \\ new child ship (in this way, the child inherits things\n                        \\ like location from the parent)\n\n LDA TYPE               \\ Fetch the ship type of the parent into A\n\n CMP #SST               \\ If the parent is not a space station, jump to rx to\n BNE rx                 \\ skip the following\n\n                        \\ The parent is a space station, so the child needs to\n                        \\ launch out of the space station's slot. The space\n                        \\ station's nosev vector points out of the station's\n                        \\ slot, so we want to move the ship along this vector.\n                        \\ We do this by taking the unit vector in nosev and\n                        \\ doubling it, so we spawn our ship 2 units along the\n                        \\ vector from the space station's centre\n\n TXA                    \\ Store the child's ship type in X on the stack\n PHA\n\n LDA #32                \\ Set the child's byte #27 (speed) to 32\n STA INWK+27\n\n LDX #0                 \\ Add 2 * nosev_x_hi to (x_lo, x_hi, x_sign) to get the\n LDA INWK+10            \\ child's x-coordinate\n JSR SFS2\n\n LDX #3                 \\ Add 2 * nosev_y_hi to (y_lo, y_hi, y_sign) to get the\n LDA INWK+12            \\ child's y-coordinate\n JSR SFS2\n\n LDX #6                 \\ Add 2 * nosev_z_hi to (z_lo, z_hi, z_sign) to get the\n LDA INWK+14            \\ child's z-coordinate\n JSR SFS2\n\n PLA                    \\ Restore the child's ship type from the stack into X\n TAX\n\n.rx\n\n LDA T1                 \\ Restore the child ship's AI flag from T1 and store it\n STA INWK+32            \\ in the child's byte #32 (AI)\n\n LSR INWK+29            \\ Clear bit 0 of the child's byte #29 (roll counter) so\n ASL INWK+29            \\ that its roll dampens (so if we are spawning from a\n                        \\ space station, for example, the spawned ship won't\n                        \\ keep rolling forever)\n\n TXA                    \\ Copy the child's ship type from X into A\n\n CMP #OIL               \\ If the child we are spawning is not a cargo canister,\n BNE NOIL               \\ jump to NOIL to skip us setting up the pitch and roll\n                        \\ for the canister\n\n JSR DORND              \\ Set A and X to random numbers\n\n ASL A                  \\ Set the child's byte #30 (pitch counter) to a random\n STA INWK+30            \\ value, and at the same time set the C flag randomly\n\n TXA                    \\ Set the child's byte #27 (speed) to a random value\n AND #%00001111         \\ between 0 and 15\n STA INWK+27\n\n LDA #&FF               \\ Set the child's byte #29 (roll counter) to a full\n ROR A                  \\ roll with no damping (as bits 0 to 6 are set), so the\n STA INWK+29            \\ canister tumbles through space, with the direction in\n                        \\ bit 7 set randomly, depending on the C flag from above\n\n LDA #OIL               \\ Set A to the ship type of a cargo canister\n\n.NOIL\n\n JSR NWSHP              \\ Add a new ship of type A to the local bubble\n\n                        \\ We have now created our child ship, so we need to\n                        \\ restore all the variables we saved at the start of\n                        \\ the routine, so they are preserved when we return\n                        \\ from the subroutine\n\n PLA                    \\ Restore INF(1 0) from the stack\n STA INF+1\n PLA\n STA INF\n\n LDX #NI%-1             \\ Now to restore the INWK workspace that we saved into\n                        \\ XX3 above, so set a counter in X for NI% bytes\n\n.FRL3\n\n LDA XX3,X              \\ Copy the Y-th byte of XX3 to the Y-th byte of INWK\n STA INWK,X\n\n DEX                    \\ Decrement the loop counter\n\n BPL FRL3               \\ Loop back to copy the next byte until we have done\n                        \\ them all\n\n PLA                    \\ Restore XX0(1 0) from the stack\n STA XX0+1\n PLA\n STA XX0\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: SFS2\n\\       Type: Subroutine\n\\   Category: Moving\n\\    Summary: Move a ship in space along one of the coordinate axes\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Move a ship's coordinates by a certain amount in the direction of one of the\n\\ axes, where X determines the axis. Mathematically speaking, this routine\n\\ translates the ship along a single axis by a signed delta.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The amount of movement, i.e. the signed delta\n\\\n\\   X                   Determines which coordinate axis of INWK to move:\n\\\n\\                         * X = 0 moves the ship along the x-axis\n\\\n\\                         * X = 3 moves the ship along the y-axis\n\\\n\\                         * X = 6 moves the ship along the z-axis\n\\\n\\ ******************************************************************************\n\n.SFS2\n\n ASL A                  \\ Set R = |A * 2|, with the C flag set to bit 7 of A\n STA R\n\n LDA #0                 \\ Set bit 7 of A to the C flag, i.e. the sign bit from\n ROR A                  \\ the original argument in A\n\n JMP MVT1               \\ Add the delta R with sign A to (x_lo, x_hi, x_sign)\n                        \\ (or y or z, depending on the value in X) and return\n                        \\ from the subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: LL164\n\\       Type: Subroutine\n\\   Category: Drawing circles\n\\    Summary: Make the hyperspace sound and draw the hyperspace tunnel\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ See the IRQ1 routine for details on the multi-coloured effect that's used.\n\\\n\\ ******************************************************************************\n\n.LL164\n\n LDA #56                \\ Call the NOISE routine with A = 56 to make the sound\n JSR NOISE              \\ of the hyperspace drive being engaged\n\n LDA #1                 \\ Set HFX to 1, which switches the screen mode to a full\n STA HFX                \\ mode 5 screen, therefore making the hyperspace rings\n                        \\ multi-coloured and all zig-zaggy (see the IRQ1 routine\n                        \\ for details)\n\n LDA #4                 \\ Set the step size for the hyperspace rings to 4, so\n                        \\ there are more sections in the rings and they are\n                        \\ quite round (compared to the step size of 8 used in\n                        \\ the much more polygonal launch rings)\n\n JSR HFS2               \\ Call HFS2 to draw the hyperspace tunnel rings\n\n DEC HFX                \\ Set HFX back to 0, so we switch back to the normal\n                        \\ split-screen mode\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: LAUN\n\\       Type: Subroutine\n\\   Category: Drawing circles\n\\    Summary: Make the launch sound and draw the launch tunnel\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This is shown when launching from or docking with the space station.\n\\\n\\ ******************************************************************************\n\n.LAUN\n\n LDA #48                \\ Call the NOISE routine with A = 48 to make the sound\n JSR NOISE              \\ of the ship launching from the station\n\n LDA #8                 \\ Set the step size for the launch tunnel rings to 8, so\n                        \\ there are fewer sections in the rings and they are\n                        \\ quite polygonal (compared to the step size of 4 used\n                        \\ in the much rounder hyperspace rings)\n\n                        \\ Fall through into HFS2 to draw the launch tunnel rings\n\n\\ ******************************************************************************\n\\\n\\       Name: HFS2\n\\       Type: Subroutine\n\\   Category: Drawing circles\n\\    Summary: Draw the launch or hyperspace tunnel\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The animation gets drawn like this. First, we draw a circle of radius 8 at the\n\\ centre, and then double the radius, draw another circle, double the radius\n\\ again and draw a circle, and we keep doing this until the radius is bigger\n\\ than 160 (which goes beyond the edge of the screen, which is 256 pixels wide,\n\\ equivalent to a radius of 128). We then repeat this whole process for an\n\\ initial circle of radius 9, then radius 10, all the way up to radius 15.\n\\\n\\ This has the effect of making the tunnel appear to be racing towards us as we\n\\ hurtle out into hyperspace or through the space station's docking tunnel.\n\\\n\\ The hyperspace effect is done in a full mode 5 screen, which makes the rings\n\\ all coloured and zig-zaggy, while the launch screen is in the normal\n\\ monochrome mode 4 screen.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The step size of the straight lines making up the rings\n\\                       (4 for launch, 8 for hyperspace)\n\\\n\\ ******************************************************************************\n\n.HFS2\n\n STA STP                \\ Store the step size in A\n\n JSR TTX66              \\ Clear the screen and draw a border box\n\n JSR HFS1               \\ Call HFS1 below and then fall through into the same\n                        \\ routine, so this effectively runs HFS1 twice, and as\n                        \\ HFS1 draws 8 concentric rings, this means we draw 16\n                        \\ of them in all\n\n.HFS1\n\n LDA #128               \\ Set K3 = 128 (the x-coordinate of the centre of the\n STA K3                 \\ screen)\n\n LDX #Y                 \\ Set K4 = #Y (the y-coordinate of the centre of the\n STX K4                 \\ screen)\n\n ASL A                  \\ Set A = 0\n\n STA XX4                \\ Set XX4 = 0, which we will use as a counter for\n                        \\ drawing eight concentric rings\n\n STA K3+1               \\ Set the high bytes of K3(1 0) and K4(1 0) to 0\n STA K4+1\n\n.HFL5\n\n JSR HFL1               \\ Call HFL1 below to draw a set of rings, with each one\n                        \\ twice the radius of the previous one, until they won't\n                        \\ fit on-screen\n\n INC XX4                \\ Increment the counter and fetch it into X\n LDX XX4\n\n CPX #8                 \\ If we haven't drawn 8 sets of rings yet, loop back to\n BNE HFL5               \\ HFL5 to draw the next ring\n\n RTS                    \\ Return from the subroutine\n\n.HFL1\n\n LDA XX4                \\ Set K to the ring number in XX4 (0-7) + 8, so K has\n AND #7                 \\ a value of 8 to 15, which we will use as the starting\n CLC                    \\ radius for our next set of rings\n ADC #8\n STA K\n\n.HFL2\n\n LDA #1                 \\ Set LSP = 1 to reset the ball line heap\n STA LSP\n\n JSR CIRCLE2            \\ Call CIRCLE2 to draw a circle with the centre at\n                        \\ (K3(1 0), K4(1 0)) and radius K\n\n ASL K                  \\ Double the radius in K\n\n BCS HF8                \\ If the radius had a 1 in bit 7 before the above shift,\n                        \\ then doubling K will means the circle will no longer\n                        \\ fit on the screen (which is width 256), so jump to\n                        \\ HF8 to stop drawing circles\n\n LDA K                  \\ If the radius in K <= 160, loop back to HFL2 to draw\n CMP #160               \\ another one\n BCC HFL2\n\n.HF8\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: STARS2\n\\       Type: Subroutine\n\\   Category: Stardust\n\\    Summary: Process the stardust for the left or right view\n\\  Deep dive: Stardust in the side views\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This moves the stardust sideways according to our speed and which side we are\n\\ looking out of, and applies our current pitch and roll to each particle of\n\\ dust, so the stardust moves correctly when we steer our ship.\n\\\n\\ These are the calculations referred to in the commentary:\n\\\n\\   1. delta_x = 8 * 256 * speed / z_hi\n\\   2. x = x + delta_x\n\\\n\\   3. x = x + beta * y\n\\   4. y = y - beta * x\n\\\n\\   5. x = x - alpha * x * y\n\\   6. y = y + alpha * y * y + alpha\n\\\n\\ For more information see the associated deep dive.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   The view to process:\n\\\n\\                         * X = 1 for left view\n\\\n\\                         * X = 2 for right view\n\\\n\\ ******************************************************************************\n\n.STARS2\n\n LDA #0                 \\ Set A to 0 so we can use it to capture a sign bit\n\n CPX #2                 \\ If X >= 2 then the C flag is set\n\n ROR A                  \\ Roll the C flag into the sign bit of A and store in\n STA RAT                \\ RAT, so:\n                        \\\n                        \\   * Left view, C is clear so RAT = 0 (positive)\n                        \\\n                        \\   * Right view, C is set so RAT = 128 (negative)\n                        \\\n                        \\ RAT represents the end of the x-axis where we want new\n                        \\ stardust particles to come from: positive for the left\n                        \\ view where new particles come in from the right,\n                        \\ negative for the right view where new particles come\n                        \\ in from the left\n\n EOR #%10000000         \\ Set RAT2 to the opposite sign, so:\n STA RAT2               \\\n                        \\   * Left view, RAT2 = 128 (negative)\n                        \\\n                        \\   * Right view, RAT2 = 0 (positive)\n                        \\\n                        \\ RAT2 represents the direction in which stardust\n                        \\ particles should move along the x-axis: negative for\n                        \\ the left view where particles go from right to left,\n                        \\ positive for the right view where particles go from\n                        \\ left to right\n\n JSR ST2                \\ Call ST2 to flip the signs of the following if this is\n                        \\ the right view: ALPHA, ALP2, ALP2+1, BET2 and BET2+1\n\n LDY NOSTM              \\ Set Y to the current number of stardust particles, so\n                        \\ we can use it as a counter through all the stardust\n\n.STL2\n\n LDA SZ,Y               \\ Set A = ZZ = z_hi\n\n STA ZZ                 \\ We also set ZZ to the original value of z_hi, which we\n                        \\ use below to remove the existing particle\n\n LSR A                  \\ Set A = z_hi / 8\n LSR A\n LSR A\n\n JSR DV41               \\ Call DV41 to set the following:\n                        \\\n                        \\   (P R) = 256 * DELTA / A\n                        \\         = 256 * speed / (z_hi / 8)\n                        \\         = 8 * 256 * speed / z_hi\n                        \\\n                        \\ This represents the distance we should move this\n                        \\ particle along the x-axis, let's call it delta_x\n\n LDA P                  \\ Set S = P but with the sign from RAT2, so we now have\n EOR RAT2               \\ the distance delta_x with the correct sign in (S R):\n STA S                  \\\n                        \\   (S R) = delta_x\n                        \\         = 8 * 256 * speed / z_hi\n                        \\\n                        \\ So (S R) is the delta, signed to match the direction\n                        \\ the stardust should move in, which is result 1 above\n\n LDA SXL,Y              \\ Set (A P) = (x_hi x_lo)\n STA P                  \\           = x\n LDA SX,Y\n\n STA X1                 \\ Set X1 = A, so X1 contains the original value of x_hi,\n                        \\ which we use below to remove the existing particle\n\n JSR ADD                \\ Call ADD to calculate:\n                        \\\n                        \\   (A X) = (A P) + (S R)\n                        \\         = x + delta_x\n\n STA S                  \\ Set (S R) = (A X)\n STX R                  \\           = x + delta_x\n\n LDA SY,Y               \\ Set A = y_hi\n\n STA Y1                 \\ Set Y1 = A, so Y1 contains the original value of y_hi,\n                        \\ which we use below to remove the existing particle\n\n EOR BET2               \\ Give A the correct sign of A * beta, i.e. y_hi * beta\n\n LDX BET1               \\ Fetch |beta| from BET1, the pitch angle\n\n JSR MULTS-2            \\ Call MULTS-2 to calculate:\n                        \\\n                        \\   (A P) = X * A\n                        \\         = beta * y_hi\n\n JSR ADD                \\ Call ADD to calculate:\n                        \\\n                        \\   (A X) = (A P) + (S R)\n                        \\         = beta * y + x + delta_x\n\n STX XX                 \\ Set XX(1 0) = (A X), which gives us results 2 and 3\n STA XX+1               \\ above, done at the same time:\n                        \\\n                        \\   x = x + delta_x + beta * y\n\n LDX SYL,Y              \\ Set (S R) = (y_hi y_lo)\n STX R                  \\           = y\n LDX Y1\n STX S\n\n LDX BET1               \\ Fetch |beta| from BET1, the pitch angle\n\n EOR BET2+1             \\ Give A the opposite sign to x * beta\n\n JSR MULTS-2            \\ Call MULTS-2 to calculate:\n                        \\\n                        \\   (A P) = X * A\n                        \\         = -beta * x\n\n JSR ADD                \\ Call ADD to calculate:\n                        \\\n                        \\   (A X) = (A P) + (S R)\n                        \\         = -beta * x + y\n\n STX YY                 \\ Set YY(1 0) = (A X), which gives us result 4 above:\n STA YY+1               \\\n                        \\   y = y - beta * x\n\n LDX ALP1               \\ Set X = |alpha| from ALP2, the roll angle\n\n EOR ALP2               \\ Give A the correct sign of A * alpha, i.e. y_hi *\n                        \\ alpha\n\n JSR MULTS-2            \\ Call MULTS-2 to calculate:\n                        \\\n                        \\   (A P) = X * A\n                        \\         = alpha * y\n\n STA Q                  \\ Set Q = high byte of alpha * y\n\n LDA XX                 \\ Set (S R) = XX(1 0)\n STA R                  \\           = x\n LDA XX+1               \\\n STA S                  \\ and set A = y_hi at the same time\n\n EOR #%10000000         \\ Flip the sign of A = -x_hi\n\n JSR MAD                \\ Call MAD to calculate:\n                        \\\n                        \\   (A X) = Q * A + (S R)\n                        \\         = alpha * y * -x + x\n\n STA XX+1               \\ Store the high byte A in XX+1\n\n TXA                    \\ Store the low byte X in x_lo\n STA SXL,Y\n\n                        \\ So (XX+1 x_lo) now contains result 5 above:\n                        \\\n                        \\   x = x - alpha * x * y\n\n LDA YY                 \\ Set (S R) = YY(1 0)\n STA R                  \\           = y\n LDA YY+1               \\\n STA S                  \\ and set A = y_hi at the same time\n\n JSR MAD                \\ Call MAD to calculate:\n                        \\\n                        \\   (A X) = Q * A + (S R)\n                        \\         = alpha * y * y_hi + y\n\n STA S                  \\ Set (S R) = (A X)\n STX R                  \\           = y + alpha * y * y\n\n LDA #0                 \\ Set P = 0\n STA P\n\n LDA ALPHA              \\ Set A = alpha, so:\n                        \\\n                        \\   (A P) = (alpha 0)\n                        \\         = alpha / 256\n\n JSR PIX1               \\ Call PIX1 to calculate the following:\n                        \\\n                        \\   (YY+1 y_lo) = (A P) + (S R)\n                        \\               = alpha * 256 + y + alpha * y * y\n                        \\\n                        \\ i.e. y = y + alpha / 256 + alpha * y^2, which is\n                        \\ result 6 above\n                        \\\n                        \\ PIX1 also draws a particle at (X1, Y1) with distance\n                        \\ ZZ, which will remove the old stardust particle, as we\n                        \\ set X1, Y1 and ZZ to the original values for this\n                        \\ particle during the calculations above\n\n                        \\ We now have our newly moved stardust particle at\n                        \\ x-coordinate (XX+1 x_lo) and y-coordinate (YY+1 y_lo)\n                        \\ and distance z_hi, so we draw it if it's still on\n                        \\ screen, otherwise we recycle it as a new bit of\n                        \\ stardust and draw that\n\n LDA XX+1               \\ Set X1 and x_hi to the high byte of XX in XX+1, so\n STA SX,Y               \\ the new x-coordinate is in (x_hi x_lo) and the high\n STA X1                 \\ byte is in X1\n\n AND #%01111111         \\ If |x_hi| >= 116 then jump to KILL2 to recycle this\n CMP #116               \\ particle, as it's gone off the side of the screen,\n BCS KILL2              \\ and rejoin at STC2 with the new particle\n\n LDA YY+1               \\ Set Y1 and y_hi to the high byte of YY in YY+1, so\n STA SY,Y               \\ the new x-coordinate is in (y_hi y_lo) and the high\n STA Y1                 \\ byte is in Y1\n\n AND #%01111111         \\ If |y_hi| >= 116 then jump to ST5 to recycle this\n CMP #116               \\ particle, as it's gone off the top or bottom of the\n BCS ST5                \\ screen, and rejoin at STC2 with the new particle\n\n.STC2\n\n JSR PIXEL2             \\ Draw a stardust particle at (X1,Y1) with distance ZZ,\n                        \\ i.e. draw the newly moved particle at (x_hi, y_hi)\n                        \\ with distance z_hi\n\n DEY                    \\ Decrement the loop counter to point to the next\n                        \\ stardust particle\n\n BEQ ST2                \\ If we have just done the last particle, skip the next\n                        \\ instruction to return from the subroutine\n\n JMP STL2               \\ We have more stardust to process, so jump back up to\n                        \\ STL2 for the next particle\n\n                        \\ Fall through into ST2 to restore the signs of the\n                        \\ following if this is the right view: ALPHA, ALP2,\n                        \\ ALP2+1, BET2 and BET2+1\n\n.ST2\n\n LDA ALPHA              \\ If this is the right view, flip the sign of ALPHA\n EOR RAT\n STA ALPHA\n\n LDA ALP2               \\ If this is the right view, flip the sign of ALP2\n EOR RAT\n STA ALP2\n\n EOR #%10000000         \\ If this is the right view, flip the sign of ALP2+1\n STA ALP2+1\n\n LDA BET2               \\ If this is the right view, flip the sign of BET2\n EOR RAT\n STA BET2\n\n EOR #%10000000         \\ If this is the right view, flip the sign of BET2+1\n STA BET2+1\n\n RTS                    \\ Return from the subroutine\n\n.KILL2\n\n JSR DORND              \\ Set A and X to random numbers\n\n STA Y1                 \\ Set y_hi and Y1 to random numbers, so the particle\n STA SY,Y               \\ starts anywhere along the y-axis\n\n LDA #115               \\ Make sure A is at least 115 and has the sign in RAT\n ORA RAT\n\n STA X1                 \\ Set x_hi and X1 to A, so this particle starts on the\n STA SX,Y               \\ correct edge of the screen for new particles\n\n BNE STF1               \\ Jump down to STF1 to set the z-coordinate (this BNE is\n                        \\ effectively a JMP as A will never be zero)\n\n.ST5\n\n JSR DORND              \\ Set A and X to random numbers\n\n STA X1                 \\ Set x_hi and X1 to random numbers, so the particle\n STA SX,Y               \\ starts anywhere along the x-axis\n\n LDA #110               \\ Make sure A is at least 110 and has the sign in AL2+1,\n ORA ALP2+1             \\ the flipped sign of the roll angle alpha\n\n STA Y1                 \\ Set y_hi and Y1 to A, so the particle starts at the\n STA SY,Y               \\ top or bottom edge, depending on the current roll\n                        \\ angle alpha\n\n.STF1\n\n JSR DORND              \\ Set A and X to random numbers\n\n ORA #8                 \\ Make sure A is at least 8 and store it in z_hi and\n STA ZZ                 \\ ZZ, so the new particle starts at any distance from\n STA SZ,Y               \\ us, but not too close\n\n BNE STC2               \\ Jump up to STC2 to draw this new particle (this BNE is\n                        \\ effectively a JMP as A will never be zero)\n\n\\ ******************************************************************************\n\\\n\\       Name: SNE\n\\       Type: Variable\n\\   Category: Maths (Geometry)\n\\    Summary: Sine/cosine table\n\\  Deep dive: The sine, cosine and arctan tables\n\\             Drawing circles\n\\             Drawing ellipses\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This lookup table contains sine values for the first half of a circle, from 0\n\\ to 180 degrees (0 to PI radians). In terms of circle or ellipse line segments,\n\\ there are 64 segments in a circle, so this contains sine values for segments\n\\ 0 to 31.\n\\\n\\ In terms of segments, to calculate the sine of the angle at segment x, we look\n\\ up the value in SNE + x, and to calculate the cosine of the angle we look up\n\\ the value in SNE + ((x + 16) mod 32).\n\\\n\\ In terms of radians, to calculate the following:\n\\\n\\   sin(theta) * 256\n\\\n\\ where theta is in radians, we look up the value in:\n\\\n\\   SNE + (theta * 10)\n\\\n\\ To calculate the following:\n\\\n\\   cos(theta) * 256\n\\\n\\ where theta is in radians, look up the value in:\n\\\n\\   SNE + ((theta * 10) + 16) mod 32\n\\\n\\ Theta must be between 0 and 3.1 radians, so theta * 10 is between 0 and 31.\n\\\n\\ ******************************************************************************\n\n.SNE\n\n FOR I%, 0, 31\n\n  N = ABS(SIN((I% / 64) * 2 * PI))\n\n  IF N >= 1\n   EQUB 255\n  ELSE\n   EQUB INT(256 * N + 0.5)\n  ENDIF\n\n NEXT\n\n\\ ******************************************************************************\n\\\n\\       Name: MU5\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Set K(3 2 1 0) = (A A A A) and clear the C flag\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ In practice this is only called via a BEQ following an AND instruction, in\n\\ which case A = 0, so this routine effectively does this:\n\\\n\\   K(3 2 1 0) = 0\n\\\n\\ ******************************************************************************\n\n.MU5\n\n STA K                  \\ Set K(3 2 1 0) to (A A A A)\n STA K+1\n STA K+2\n STA K+3\n\n CLC                    \\ Clear the C flag\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: MULT3\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate K(3 2 1 0) = (A P+1 P) * Q\n\\  Deep dive: Shift-and-add multiplication\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following multiplication between a signed 24-bit number and a\n\\ signed 8-bit number, returning the result as a signed 32-bit number:\n\\\n\\   K(3 2 1 0) = (A P+1 P) * Q\n\\\n\\ The algorithm is the same shift-and-add algorithm as in routine MULT1, but\n\\ extended to cope with more bits.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   C flag              The C flag is cleared\n\\\n\\ ******************************************************************************\n\n.MULT3\n\n STA R                  \\ Store the high byte of (A P+1 P) in R\n\n AND #%01111111         \\ Set K+2 to |A|, the high byte of K(2 1 0)\n STA K+2\n\n LDA Q                  \\ Set A to bits 0-6 of Q, so A = |Q|\n AND #%01111111\n\n BEQ MU5                \\ If |Q| = 0, jump to MU5 to set K(3 2 1 0) to 0,\n                        \\ returning from the subroutine using a tail call\n\n SEC                    \\ Set T = |Q| - 1\n SBC #1\n STA T\n\n                        \\ We now use the same shift-and-add algorithm as MULT1\n                        \\ to calculate the following:\n                        \\\n                        \\ K(2 1 0) = K(2 1 0) * |Q|\n                        \\\n                        \\ so we start with the first shift right, in which we\n                        \\ take (K+2 P+1 P) and shift it right, storing the\n                        \\ result in K(2 1 0), ready for the multiplication loop\n                        \\ (so the multiplication loop actually calculates\n                        \\ (|A| P+1 P) * |Q|, as the following sets K(2 1 0) to\n                        \\ (|A| P+1 P) shifted right)\n\n LDA P+1                \\ Set A = P+1\n\n LSR K+2                \\ Shift the high byte in K+2 to the right\n\n ROR A                  \\ Shift the middle byte in A to the right and store in\n STA K+1                \\ K+1 (so K+1 contains P+1 shifted right)\n\n LDA P                  \\ Shift the middle byte in P to the right and store in\n ROR A                  \\ K, so K(2 1 0) now contains (|A| P+1 P) shifted right\n STA K\n\n                        \\ We now use the same shift-and-add algorithm as MULT1\n                        \\ to calculate the following:\n                        \\\n                        \\ K(2 1 0) = K(2 1 0) * |Q|\n\n LDA #0                 \\ Set A = 0 so we can start building the answer in A\n\n LDX #24                \\ Set up a counter in X to count the 24 bits in K(2 1 0)\n\n.MUL2\n\n BCC P%+4               \\ If C (i.e. the next bit from K) is set, do the\n ADC T                  \\ addition for this bit of K:\n                        \\\n                        \\   A = A + T + C\n                        \\     = A + |Q| - 1 + 1\n                        \\     = A + |Q|\n\n ROR A                  \\ Shift A right by one place to catch the next digit\n ROR K+2                \\ next digit of our result in the left end of K(2 1 0),\n ROR K+1                \\ while also shifting K(2 1 0) right to fetch the next\n ROR K                  \\ bit for the calculation into the C flag\n                        \\\n                        \\ On the last iteration of this loop, the bit falling\n                        \\ off the end of K will be bit 0 of the original A, as\n                        \\ we did one shift before the loop and we are doing 24\n                        \\ iterations. We set A to 0 before looping, so this\n                        \\ means the loop exits with the C flag clear\n\n DEX                    \\ Decrement the loop counter\n\n BNE MUL2               \\ Loop back for the next bit until K(2 1 0) has been\n                        \\ rotated all the way\n\n                        \\ The result (|A| P+1 P) * |Q| is now in (A K+2 K+1 K),\n                        \\ but it is positive and doesn't have the correct sign\n                        \\ of the final result yet\n\n STA T                  \\ Save the high byte of the result into T\n\n LDA R                  \\ Fetch the sign byte from the original (A P+1 P)\n                        \\ argument that we stored in R\n\n EOR Q                  \\ EOR with Q so the sign bit is the same as that of\n                        \\ (A P+1 P) * Q\n\n AND #%10000000         \\ Extract the sign bit\n\n ORA T                  \\ Apply this to the high byte of the result in T, so\n                        \\ that A now has the correct sign for the result, and\n                        \\ (A K+2 K+1 K) therefore contains the correctly signed\n                        \\ result\n\n STA K+3                \\ Store A in K+3, so K(3 2 1 0) now contains the result\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: MLS2\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate (S R) = XX(1 0) and (A P) = A * ALP1\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following:\n\\\n\\   (S R) = XX(1 0)\n\\\n\\   (A P) = A * ALP1\n\\\n\\ where ALP1 is the magnitude of the current roll angle alpha, in the range\n\\ 0-31.\n\\\n\\ ******************************************************************************\n\n.MLS2\n\n LDX XX                 \\ Set (S R) = XX(1 0), starting with the low bytes\n STX R\n\n LDX XX+1               \\ And then doing the high bytes\n STX S\n\n                        \\ Fall through into MLS1 to calculate (A P) = A * ALP1\n\n\\ ******************************************************************************\n\\\n\\       Name: MLS1\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate (A P) = ALP1 * A\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following:\n\\\n\\   (A P) = ALP1 * A\n\\\n\\ where ALP1 is the magnitude of the current roll angle alpha, in the range\n\\ 0-31.\n\\\n\\ This routine uses an unrolled version of MU11. MU11 calculates P * X, so we\n\\ use the same algorithm but with P set to ALP1 and X set to A. The unrolled\n\\ version here can skip the bit tests for bits 5-7 of P as we know P < 32, so\n\\ only 5 shifts with bit tests are needed (for bits 0-4), while the other 3\n\\ shifts can be done without a test (for bits 5-7).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   MULTS-2             Calculate (A P) = X * A\n\\\n\\ ******************************************************************************\n\n.MLS1\n\n LDX ALP1               \\ Set P to the roll angle alpha magnitude in ALP1\n STX P                  \\ (0-31), so now we calculate P * A\n\n.MULTS\n\n TAX                    \\ Set X = A, so now we can calculate P * X instead of\n                        \\ P * A to get our result, and we can use the algorithm\n                        \\ from MU11 to do that, just unrolled (as MU11 returns\n                        \\ P * X)\n\n AND #%10000000         \\ Set T to the sign bit of A\n STA T\n\n TXA                    \\ Set A = |A|\n AND #127\n\n BEQ MU6                \\ If A = 0, jump to MU6 to set P(1 0) = 0 and return\n                        \\ from the subroutine using a tail call\n\n TAX                    \\ Set T1 = X - 1\n DEX                    \\\n STX T1                 \\ We subtract 1 as the C flag will be set when we want\n                        \\ to do an addition in the loop below\n\n LDA #0                 \\ Set A = 0 so we can start building the answer in A\n\n LSR P                  \\ Set P = P >> 1\n                        \\ and C flag = bit 0 of P\n\n                        \\ We are now going to work our way through the bits of\n                        \\ P, and do a shift-add for any bits that are set,\n                        \\ keeping the running total in A, but instead of using a\n                        \\ loop like MU11, we just unroll it, starting with bit 0\n\n BCC P%+4               \\ If C (i.e. the next bit from P) is set, do the\n ADC T1                 \\ addition for this bit of P:\n                        \\\n                        \\   A = A + T1 + C\n                        \\     = A + X - 1 + 1\n                        \\     = A + X\n\n ROR A                  \\ Shift A right to catch the next digit of our result,\n                        \\ which the next ROR sticks into the left end of P while\n                        \\ also extracting the next bit of P\n\n ROR P                  \\ Add the overspill from shifting A to the right onto\n                        \\ the start of P, and shift P right to fetch the next\n                        \\ bit for the calculation into the C flag\n\n BCC P%+4               \\ Repeat the shift-and-add loop for bit 1\n ADC T1\n ROR A\n ROR P\n\n BCC P%+4               \\ Repeat the shift-and-add loop for bit 2\n ADC T1\n ROR A\n ROR P\n\n BCC P%+4               \\ Repeat the shift-and-add loop for bit 3\n ADC T1\n ROR A\n ROR P\n\n BCC P%+4               \\ Repeat the shift-and-add loop for bit 4\n ADC T1\n ROR A\n ROR P\n\n LSR A                  \\ Just do the \"shift\" part for bit 5\n ROR P\n\n LSR A                  \\ Just do the \"shift\" part for bit 6\n ROR P\n\n LSR A                  \\ Just do the \"shift\" part for bit 7\n ROR P\n\n ORA T                  \\ Give A the sign bit of the original argument A that\n                        \\ we put into T above\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: SQUA\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Clear bit 7 of A and calculate (A P) = A * A\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Do the following multiplication of unsigned 8-bit numbers, after first\n\\ clearing bit 7 of A:\n\\\n\\   (A P) = A * A\n\\\n\\ ******************************************************************************\n\n.SQUA\n\n AND #%01111111         \\ Clear bit 7 of A and fall through into SQUA2 to set\n                        \\ (A P) = A * A\n\n\\ ******************************************************************************\n\\\n\\       Name: SQUA2\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate (A P) = A * A\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Do the following multiplication of unsigned 8-bit numbers:\n\\\n\\   (A P) = A * A\n\\\n\\ ******************************************************************************\n\n.SQUA2\n\n STA P                  \\ Copy A into P and X\n TAX\n\n BNE MU11               \\ If X = 0 fall through into MU1 to return a 0,\n                        \\ otherwise jump to MU11 to return P * X\n\n\\ ******************************************************************************\n\\\n\\       Name: MU1\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Copy X into P and A, and clear the C flag\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Used to return a 0 result quickly from MULTU below.\n\\\n\\ ******************************************************************************\n\n.MU1\n\n CLC                    \\ Clear the C flag\n\n STX P                  \\ Copy X into P and A\n TXA\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: MLU1\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate Y1 = y_hi and (A P) = |y_hi| * Q for Y-th stardust\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Do the following assignment, and multiply the Y-th stardust particle's\n\\ y-coordinate with an unsigned number Q:\n\\\n\\   Y1 = y_hi\n\\\n\\   (A P) = |y_hi| * Q\n\\\n\\ ******************************************************************************\n\n.MLU1\n\n LDA SY,Y               \\ Set Y1 the Y-th byte of SY\n STA Y1\n\n                        \\ Fall through into MLU2 to calculate:\n                        \\\n                        \\   (A P) = |A| * Q\n\n\\ ******************************************************************************\n\\\n\\       Name: MLU2\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate (A P) = |A| * Q\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Do the following multiplication of a sign-magnitude 8-bit number P with an\n\\ unsigned number Q:\n\\\n\\   (A P) = |A| * Q\n\\\n\\ ******************************************************************************\n\n.MLU2\n\n AND #%01111111         \\ Clear the sign bit in P, so P = |A|\n STA P\n\n                        \\ Fall through into MULTU to calculate:\n                        \\\n                        \\   (A P) = P * Q\n                        \\         = |A| * Q\n\n\\ ******************************************************************************\n\\\n\\       Name: MULTU\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate (A P) = P * Q\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Do the following multiplication of unsigned 8-bit numbers:\n\\\n\\   (A P) = P * Q\n\\\n\\ ******************************************************************************\n\n.MULTU\n\n LDX Q                  \\ Set X = Q\n\n BEQ MU1                \\ If X = Q = 0, jump to MU1 to copy X into P and A,\n                        \\ clear the C flag and return from the subroutine using\n                        \\ a tail call\n\n                        \\ Otherwise fall through into MU11 to set (A P) = P * X\n\n\\ ******************************************************************************\n\\\n\\       Name: MU11\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate (A P) = P * X\n\\  Deep dive: Shift-and-add multiplication\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Do the following multiplication of two unsigned 8-bit numbers:\n\\\n\\   (A P) = P * X\n\\\n\\ This uses the same shift-and-add approach as MULT1, but it's simpler as we\n\\ are dealing with unsigned numbers in P and X.\n\\\n\\ ******************************************************************************\n\n.MU11\n\n DEX                    \\ Set T = X - 1\n STX T                  \\\n                        \\ We subtract 1 as the C flag will be set when we want\n                        \\ to do an addition in the loop below\n\n LDA #0                 \\ Set A = 0 so we can start building the answer in A\n\n LDX #8                 \\ Set up a counter in X to count the 8 bits in P\n\n LSR P                  \\ Set P = P >> 1\n                        \\ and C flag = bit 0 of P\n\n                        \\ We are now going to work our way through the bits of\n                        \\ P, and do a shift-add for any bits that are set,\n                        \\ keeping the running total in A. We just did the first\n                        \\ shift right, so we now need to do the first add and\n                        \\ loop through the other bits in P\n\n.MUL6\n\n BCC P%+4               \\ If C (i.e. the next bit from P) is set, do the\n ADC T                  \\ addition for this bit of P:\n                        \\\n                        \\   A = A + T + C\n                        \\     = A + X - 1 + 1\n                        \\     = A + X\n\n ROR A                  \\ Shift A right to catch the next digit of our result,\n                        \\ which the next ROR sticks into the left end of P while\n                        \\ also extracting the next bit of P\n\n ROR P                  \\ Add the overspill from shifting A to the right onto\n                        \\ the start of P, and shift P right to fetch the next\n                        \\ bit for the calculation into the C flag\n\n DEX                    \\ Decrement the loop counter\n\n BNE MUL6               \\ Loop back for the next bit until P has been rotated\n                        \\ all the way\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: MU6\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Set P(1 0) = (A A)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ In practice this is only called via a BEQ following an AND instruction, in\n\\ which case A = 0, so this routine effectively does this:\n\\\n\\   P(1 0) = 0\n\\\n\\ ******************************************************************************\n\n.MU6\n\n STA P+1                \\ Set P(1 0) = (A A)\n STA P\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: FMLTU2\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate A = K * sin(A)\n\\  Deep dive: The sine, cosine and arctan tables\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following:\n\\\n\\   A = K * sin(A)\n\\\n\\ Because this routine uses the sine lookup table SNE, we can also call this\n\\ routine to calculate cosine multiplication. To calculate the following:\n\\\n\\   A = K * cos(B)\n\\\n\\ call this routine with B + 16 in the accumulator, as sin(B + 16) = cos(B).\n\\\n\\ ******************************************************************************\n\n.FMLTU2\n\n AND #%00011111         \\ Restrict A to bits 0-5 (so it's in the range 0-31)\n\n TAX                    \\ Set Q = sin(A) * 256\n LDA SNE,X\n STA Q\n\n LDA K                  \\ Set A to the radius in K\n\n                        \\ Fall through into FMLTU to do the following:\n                        \\\n                        \\   (A ?) = A * Q\n                        \\         = K * sin(A) * 256\n                        \\\n                        \\ which is equivalent to:\n                        \\\n                        \\   A = K * sin(A)\n\n\\ ******************************************************************************\n\\\n\\       Name: FMLTU\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate A = A * Q / 256\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Do the following multiplication of two unsigned 8-bit numbers, returning only\n\\ the high byte of the result:\n\\\n\\   (A ?) = A * Q\n\\\n\\ or, to put it another way:\n\\\n\\   A = A * Q / 256\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   C flag              The C flag is set\n\\\n\\ ******************************************************************************\n\n.FMLTU\n\n EOR #%11111111         \\ Flip the bits in A, set the C flag and rotate right,\n SEC                    \\ so the C flag now contains bit 0 of A inverted, and P\n ROR A                  \\ contains A inverted and shifted right by one, with bit\n STA P                  \\ 7 set to a 1. We can now use P as our source of bits\n                        \\ to shift right, just as in MU11, just with the logic\n                        \\ reversed\n\n LDA #0                 \\ Set A = 0 so we can start building the answer in A\n\n.MUL3\n\n BCS MU7                \\ If C (i.e. the next bit from P) is set, do not do the\n                        \\ addition for this bit of P, and instead skip to MU7\n                        \\ to just do the shifts\n\n ADC Q                  \\ Do the addition for this bit of P:\n                        \\\n                        \\   A = A + Q + C\n                        \\     = A + Q\n\n ROR A                  \\ Shift A right to catch the next digit of our result.\n                        \\ If we were interested in the low byte of the result we\n                        \\ would want to save the bit that falls off the end, but\n                        \\ we aren't, so we can ignore it\n\n LSR P                  \\ Shift P right to fetch the next bit for the\n                        \\ calculation into the C flag\n\n BNE MUL3               \\ Loop back to MUL3 if P still contains some set bits\n                        \\ (so we loop through the bits of P until we get to the\n                        \\ 1 we inserted before the loop, and then we stop)\n\n                        \\ If we get here then the C flag is set as we just\n                        \\ rotated a 1 out of the right end of P\n\n RTS                    \\ Return from the subroutine\n\n.MU7\n\n LSR A                  \\ Shift A right to catch the next digit of our result,\n                        \\ pushing a 0 into bit 7 as we aren't adding anything\n                        \\ here (we can't use a ROR here as the C flag is set, so\n                        \\ a ROR would push a 1 into bit 7)\n\n LSR P                  \\ Fetch the next bit from P into the C flag\n\n BNE MUL3               \\ Loop back to MUL3 if P still contains some set bits\n                        \\ (so we loop through the bits of P until we get to the\n                        \\ 1 we inserted before the loop, and then we stop)\n\n                        \\ If we get here then the C flag is set as we just\n                        \\ rotated a 1 out of the right end of P\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: Unused duplicate of MULTU\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: An unused duplicate of the MULTU routine\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This is a duplicate of the MULTU routine, but with no entry label, so it can't\n\\ be called by name. It is unused, and could have been culled to save a few\n\\ bytes (24 to be precise), but it's still here, unnamed, unloved and unvisited,\n\\ through no fault of its own.\n\\\n\\ ******************************************************************************\n\n LDX Q\n BEQ MU1\n DEX\n STX T\n LDA #0\n LDX #8\n LSR P\n\n.MUL6K                  \\ This label is a duplicate of a label in the MULTU\n                        \\ routine\n                        \\\n                        \\ In the original source this label is MUL6, but\n                        \\ because BeebAsm doesn't allow us to redefine labels,\n                        \\ I have renamed it to MUL6K\n\n BCC P%+4\n ADC T\n ROR A\n ROR P\n DEX\n BNE MUL6K\n RTS\n\n\\ ******************************************************************************\n\\\n\\       Name: MLTU2\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate (A P+1 P) = (A ~P) * Q\n\\  Deep dive: Shift-and-add multiplication\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Do the following multiplication of an unsigned 16-bit number and an unsigned\n\\ 8-bit number:\n\\\n\\   (A P+1 P) = (A ~P) * Q\n\\\n\\ where ~P means P EOR %11111111 (i.e. P with all its bits flipped). In other\n\\ words, if you wanted to calculate &1234 * &56, you would:\n\\\n\\   * Set A to &12\n\\   * Set P to &34 EOR %11111111 = &CB\n\\   * Set Q to &56\n\\\n\\ before calling MLTU2.\n\\\n\\ This routine is like a mash-up of MU11 and FMLTU. It uses part of FMLTU's\n\\ inverted argument trick to work out whether or not to do an addition, and like\n\\ MU11 it sets up a counter in X to extract bits from (P+1 P). But this time we\n\\ extract 16 bits from (P+1 P), so the result is a 24-bit number. The core of\n\\ the algorithm is still the shift-and-add approach explained in MULT1, just\n\\ with more bits.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   Q                   Q is preserved\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   MLTU2-2             Set Q to X, so this calculates (A P+1 P) = (A ~P) * X\n\\\n\\ ******************************************************************************\n\n STX Q                  \\ Store X in Q\n\n.MLTU2\n\n EOR #%11111111         \\ Flip the bits in A and rotate right, storing the\n LSR A                  \\ result in P+1, so we now calculate (P+1 P) * Q\n STA P+1\n\n LDA #0                 \\ Set A = 0 so we can start building the answer in A\n\n LDX #16                \\ Set up a counter in X to count the 16 bits in (P+1 P)\n\n ROR P                  \\ Set P = P >> 1 with bit 7 = bit 0 of A\n                        \\ and C flag = bit 0 of P\n\n.MUL7\n\n BCS MU21               \\ If C (i.e. the next bit from P) is set, do not do the\n                        \\ addition for this bit of P, and instead skip to MU21\n                        \\ to just do the shifts\n\n ADC Q                  \\ Do the addition for this bit of P:\n                        \\\n                        \\   A = A + Q + C\n                        \\     = A + Q\n\n ROR A                  \\ Rotate (A P+1 P) to the right, so we capture the next\n ROR P+1                \\ digit of the result in P+1, and extract the next digit\n ROR P                  \\ of (P+1 P) in the C flag\n\n DEX                    \\ Decrement the loop counter\n\n BNE MUL7               \\ Loop back for the next bit until P has been rotated\n                        \\ all the way\n\n RTS                    \\ Return from the subroutine\n\n.MU21\n\n LSR A                  \\ Shift (A P+1 P) to the right, so we capture the next\n ROR P+1                \\ digit of the result in P+1, and extract the next digit\n ROR P                  \\ of (P+1 P) in the C flag\n\n DEX                    \\ Decrement the loop counter\n\n BNE MUL7               \\ Loop back for the next bit until P has been rotated\n                        \\ all the way\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: MUT3\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: An unused routine that does the same as MUT2\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine is never actually called, but it is identical to MUT2, as the\n\\ extra instructions have no effect.\n\\\n\\ ******************************************************************************\n\n.MUT3\n\n LDX ALP1               \\ Set P = ALP1, though this gets overwritten by the\n STX P                  \\ following, so this has no effect\n\n                        \\ Fall through into MUT2 to do the following:\n                        \\\n                        \\   (S R) = XX(1 0)\n                        \\   (A P) = Q * A\n\n\\ ******************************************************************************\n\\\n\\       Name: MUT2\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate (S R) = XX(1 0) and (A P) = Q * A\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Do the following assignment, and multiplication of two signed 8-bit numbers:\n\\\n\\   (S R) = XX(1 0)\n\\   (A P) = Q * A\n\\\n\\ ******************************************************************************\n\n.MUT2\n\n LDX XX+1               \\ Set S = XX+1\n STX S\n\n                        \\ Fall through into MUT1 to do the following:\n                        \\\n                        \\   R = XX\n                        \\   (A P) = Q * A\n\n\\ ******************************************************************************\n\\\n\\       Name: MUT1\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate R = XX and (A P) = Q * A\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Do the following assignment, and multiplication of two signed 8-bit numbers:\n\\\n\\   R = XX\n\\   (A P) = Q * A\n\\\n\\ ******************************************************************************\n\n.MUT1\n\n LDX XX                 \\ Set R = XX\n STX R\n\n                        \\ Fall through into MULT1 to do the following:\n                        \\\n                        \\   (A P) = Q * A\n\n\\ ******************************************************************************\n\\\n\\       Name: MULT1\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate (A P) = Q * A\n\\  Deep dive: Shift-and-add multiplication\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Do the following multiplication of two 8-bit sign-magnitude numbers:\n\\\n\\   (A P) = Q * A\n\\\n\\ ******************************************************************************\n\n.MULT1\n\n TAX                    \\ Store A in X\n\n AND #%01111111         \\ Set P = |A| >> 1\n LSR A                  \\ and C flag = bit 0 of A\n STA P\n\n TXA                    \\ Restore argument A\n\n EOR Q                  \\ Set bit 7 of A and T if Q and A have different signs,\n AND #%10000000         \\ clear bit 7 if they have the same signs, 0 all other\n STA T                  \\ bits, i.e. T contains the sign bit of Q * A\n\n LDA Q                  \\ Set A = |Q|\n AND #%01111111\n\n BEQ mu10               \\ If |Q| = 0 jump to mu10 (with A set to 0)\n\n TAX                    \\ Set T1 = |Q| - 1\n DEX                    \\\n STX T1                 \\ We subtract 1 as the C flag will be set when we want\n                        \\ to do an addition in the loop below\n\n                        \\ We are now going to work our way through the bits of\n                        \\ P, and do a shift-add for any bits that are set,\n                        \\ keeping the running total in A. We already set up\n                        \\ the first shift at the start of this routine, as\n                        \\ P = |A| >> 1 and C = bit 0 of A, so we now need to set\n                        \\ up a loop to sift through the other 7 bits in P\n\n LDA #0                 \\ Set A = 0 so we can start building the answer in A\n\n LDX #7                 \\ Set up a counter in X to count the 7 bits remaining\n                        \\ in P\n\n.MUL4\n\n BCC P%+4               \\ If C (i.e. the next bit from P) is set, do the\n ADC T1                 \\ addition for this bit of P:\n                        \\\n                        \\   A = A + T1 + C\n                        \\     = A + |Q| - 1 + 1\n                        \\     = A + |Q|\n\n ROR A                  \\ As mentioned above, this ROR shifts A right and\n                        \\ catches bit 0 in C - giving another digit for our\n                        \\ result - and the next ROR sticks that bit into the\n                        \\ left end of P while also extracting the next bit of P\n                        \\ for the next addition\n\n ROR P                  \\ Add the overspill from shifting A to the right onto\n                        \\ the start of P, and shift P right to fetch the next\n                        \\ bit for the calculation\n\n DEX                    \\ Decrement the loop counter\n\n BNE MUL4               \\ Loop back for the next bit until P has been rotated\n                        \\ all the way\n\n LSR A                  \\ Rotate (A P) once more to get the final result, as\n ROR P                  \\ we only pushed 7 bits through the above process\n\n ORA T                  \\ Set the sign bit of the result that we stored in T\n\n RTS                    \\ Return from the subroutine\n\n.mu10\n\n STA P                  \\ If we get here, the result is 0 and A = 0, so set\n                        \\ P = 0 so (A P) = 0\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: MULT12\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate (S R) = Q * A\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate:\n\\\n\\   (S R) = Q * A\n\\\n\\ ******************************************************************************\n\n.MULT12\n\n JSR MULT1              \\ Set (A P) = Q * A\n\n STA S                  \\ Set (S R) = (A P)\n LDA P                  \\           = Q * A\n STA R\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: TAS3\n\\       Type: Subroutine\n\\   Category: Maths (Geometry)\n\\    Summary: Calculate the dot product of XX15 and an orientation vector\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the dot product of the vector in XX15 and one of the orientation\n\\ vectors, as determined by the value of Y. If vect is the orientation vector,\n\\ we calculate this:\n\\\n\\   (A X) = vect . XX15\n\\         = vect_x * XX15 + vect_y * XX15+1 + vect_z * XX15+2\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   Y                   The orientation vector:\n\\\n\\                         * If Y = 10, calculate nosev . XX15\n\\\n\\                         * If Y = 16, calculate roofv . XX15\n\\\n\\                         * If Y = 22, calculate sidev . XX15\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   (A X)               The result of the dot product\n\\\n\\ ******************************************************************************\n\n.TAS3\n\n LDX INWK,Y             \\ Set Q = the Y-th byte of INWK, i.e. vect_x\n STX Q\n\n LDA XX15               \\ Set A = XX15\n\n JSR MULT12             \\ Set (S R) = Q * A\n                        \\           = vect_x * XX15\n\n LDX INWK+2,Y           \\ Set Q = the Y+2-th byte of INWK, i.e. vect_y\n STX Q\n\n LDA XX15+1             \\ Set A = XX15+1\n\n JSR MAD                \\ Set (A X) = Q * A + (S R)\n                        \\           = vect_y * XX15+1 + vect_x * XX15\n\n STA S                  \\ Set (S R) = (A X)\n STX R\n\n LDX INWK+4,Y           \\ Set Q = the Y+2-th byte of INWK, i.e. vect_z\n STX Q\n\n LDA XX15+2             \\ Set A = XX15+2\n\n                        \\ Fall through into MAD to set:\n                        \\\n                        \\   (A X) = Q * A + (S R)\n                        \\           = vect_z * XX15+2 + vect_y * XX15+1 +\n                        \\             vect_x * XX15\n\n\\ ******************************************************************************\n\\\n\\       Name: MAD\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate (A X) = Q * A + (S R)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate\n\\\n\\   (A X) = Q * A + (S R)\n\\\n\\ ******************************************************************************\n\n.MAD\n\n JSR MULT1              \\ Call MULT1 to set (A P) = Q * A\n\n                        \\ Fall through into ADD to do:\n                        \\\n                        \\   (A X) = (A P) + (S R)\n                        \\         = Q * A + (S R)\n\n\\ ******************************************************************************\n\\\n\\       Name: ADD\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate (A X) = (A P) + (S R)\n\\  Deep dive: Adding sign-magnitude numbers\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Add two 16-bit sign-magnitude numbers together, calculating:\n\\\n\\   (A X) = (A P) + (S R)\n\\\n\\ ******************************************************************************\n\n.ADD\n\n STA T1                 \\ Store argument A in T1\n\n AND #%10000000         \\ Extract the sign (bit 7) of A and store it in T\n STA T\n\n EOR S                  \\ EOR bit 7 of A with S. If they have different bit 7s\n BMI MU8                \\ (i.e. they have different signs) then bit 7 in the\n                        \\ EOR result will be 1, which means the EOR result is\n                        \\ negative. So the AND, EOR and BMI together mean \"jump\n                        \\ to MU8 if A and S have different signs\"\n\n                        \\ If we reach here, then A and S have the same sign, so\n                        \\ we can add them and set the sign to get the result\n\n LDA R                  \\ Add the least significant bytes together into X:\n CLC                    \\\n ADC P                  \\   X = P + R\n TAX\n\n LDA S                  \\ Add the most significant bytes together into A. We\n ADC T1                 \\ stored the original argument A in T1 earlier, so we\n                        \\ can do this with:\n                        \\\n                        \\   A = A  + S + C\n                        \\     = T1 + S + C\n\n ORA T                  \\ If argument A was negative (and therefore S was also\n                        \\ negative) then make sure result A is negative by\n                        \\ OR'ing the result with the sign bit from argument A\n                        \\ (which we stored in T)\n\n RTS                    \\ Return from the subroutine\n\n.MU8\n\n                        \\ If we reach here, then A and S have different signs,\n                        \\ so we can subtract their absolute values and set the\n                        \\ sign to get the result\n\n LDA S                  \\ Clear the sign (bit 7) in S and store the result in\n AND #%01111111         \\ U, so U now contains |S|\n STA U\n\n LDA P                  \\ Subtract the least significant bytes into X:\n SEC                    \\\n SBC R                  \\   X = P - R\n TAX\n\n LDA T1                 \\ Restore the A of the argument (A P) from T1 and\n AND #%01111111         \\ clear the sign (bit 7), so A now contains |A|\n\n SBC U                  \\ Set A = |A| - |S|\n\n                        \\ At this point we have |A P| - |S R| in (A X), so we\n                        \\ need to check whether the subtraction above was the\n                        \\ right way round (i.e. that we subtracted the smaller\n                        \\ absolute value from the larger absolute value)\n\n BCS MU9                \\ If |A| >= |S|, our subtraction was the right way\n                        \\ round, so jump to MU9 to set the sign\n\n                        \\ If we get here, then |A| < |S|, so our subtraction\n                        \\ above was the wrong way round (we actually subtracted\n                        \\ the larger absolute value from the smaller absolute\n                        \\ value). So let's subtract the result we have in (A X)\n                        \\ from zero, so that the subtraction is the right way\n                        \\ round\n\n STA U                  \\ Store A in U\n\n TXA                    \\ Set X = 0 - X using two's complement (to negate a\n EOR #&FF               \\ number in two's complement, you can invert the bits\n ADC #1                 \\ and add one - and we know the C flag is clear as we\n TAX                    \\ didn't take the BCS branch above, so the ADC will do\n                        \\ the correct addition)\n\n LDA #0                 \\ Set A = 0 - A, which we can do this time using a\n SBC U                  \\ subtraction with the C flag clear\n\n ORA #%10000000         \\ We now set the sign bit of A, so that the EOR on the\n                        \\ next line will give the result the opposite sign to\n                        \\ argument A (as T contains the sign bit of argument\n                        \\ A). This is the same as giving the result the same\n                        \\ sign as argument S (as A and S have different signs),\n                        \\ which is what we want, as S has the larger absolute\n                        \\ value\n\n.MU9\n\n EOR T                  \\ If we get here from the BCS above, then |A| >= |S|,\n                        \\ so we want to give the result the same sign as\n                        \\ argument A, so if argument A was negative, we flip\n                        \\ the sign of the result with an EOR (to make it\n                        \\ negative)\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: TIS1\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate (A ?) = (-X * A + (S R)) / 96\n\\  Deep dive: Shift-and-subtract division\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following expression between sign-magnitude numbers, ignoring\n\\ the low byte of the result:\n\\\n\\   (A ?) = (-X * A + (S R)) / 96\n\\\n\\ This uses the same shift-and-subtract algorithm as TIS2, just with the\n\\ quotient A hard-coded to 96.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   Q                   Gets set to the value of argument X\n\\\n\\ ******************************************************************************\n\n.TIS1\n\n STX Q                  \\ Set Q = X\n\n EOR #%10000000         \\ Flip the sign bit in A\n\n JSR MAD                \\ Set (A X) = Q * A + (S R)\n                        \\           = X * -A + (S R)\n\n.DVID96\n\n TAX                    \\ Set T to the sign bit of the result\n AND #%10000000\n STA T\n\n TXA                    \\ Set A to the high byte of the result with the sign bit\n AND #%01111111         \\ cleared, so (A ?) = |X * A + (S R)|\n\n                        \\ The following is identical to TIS2, except Q is\n                        \\ hard-coded to 96, so this does A = A / 96\n\n LDX #254               \\ Set T1 to have bits 1-7 set, so we can rotate through\n STX T1                 \\ 7 loop iterations, getting a 1 each time, and then\n                        \\ getting a 0 on the 8th iteration... and we can also\n                        \\ use T1 to catch our result bits into bit 0 each time\n\n.DVL3\n\n ASL A                  \\ Shift A to the left\n\n CMP #96                \\ If A < 96 skip the following subtraction\n BCC DV4\n\n SBC #96                \\ Set A = A - 96\n                        \\\n                        \\ Going into this subtraction we know the C flag is\n                        \\ set as we passed through the BCC above, and we also\n                        \\ know that A >= 96, so the C flag will still be set\n                        \\ once we are done\n\n.DV4\n\n ROL T1                 \\ Rotate the counter in T1 to the left, and catch the\n                        \\ result bit into bit 0 (which will be a 0 if we didn't\n                        \\ do the subtraction, or 1 if we did)\n\n BCS DVL3               \\ If we still have set bits in T1, loop back to DVL3 to\n                        \\ do the next iteration of 7\n\n LDA T1                 \\ Fetch the result from T1 into A\n\n ORA T                  \\ Give A the sign of the result that we stored above\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: DV42\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate (P R) = 256 * DELTA / z_hi\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following division and remainder:\n\\\n\\   P = DELTA / (the Y-th stardust particle's z_hi coordinate)\n\\\n\\   R = remainder as a fraction of A, where 1.0 = 255\n\\\n\\ Another way of saying the above is this:\n\\\n\\   (P R) = 256 * DELTA / z_hi\n\\\n\\ DELTA is a value between 1 and 40, and the minimum z_hi is 16 (dust particles\n\\ are removed at lower values than this), so this means P is between 0 and 2\n\\ (as 40 / 16 = 2.5, so the maximum result is P = 2 and R = 128.\n\\\n\\ This uses the same shift-and-subtract algorithm as TIS2, but this time we\n\\ keep the remainder.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   Y                   The number of the stardust particle to process\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   C flag              The C flag is cleared\n\\\n\\ ******************************************************************************\n\n.DV42\n\n LDA SZ,Y               \\ Fetch the Y-th dust particle's z_hi coordinate into A\n\n                        \\ Fall through into DV41 to do:\n                        \\\n                        \\   (P R) = 256 * DELTA / A\n                        \\         = 256 * DELTA / Y-th stardust particle's z_hi\n\n\\ ******************************************************************************\n\\\n\\       Name: DV41\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate (P R) = 256 * DELTA / A\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following division and remainder:\n\\\n\\   P = DELTA / A\n\\\n\\   R = remainder as a fraction of A, where 1.0 = 255\n\\\n\\ Another way of saying the above is this:\n\\\n\\   (P R) = 256 * DELTA / A\n\\\n\\ This uses the same shift-and-subtract algorithm as TIS2, but this time we\n\\ keep the remainder.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   C flag              The C flag is cleared\n\\\n\\ ******************************************************************************\n\n.DV41\n\n STA Q                  \\ Store A in Q\n\n LDA DELTA              \\ Fetch the speed from DELTA into A\n\n                        \\ Fall through into DVID4 to do:\n                        \\\n                        \\   (P R) = 256 * A / Q\n                        \\         = 256 * DELTA / A\n\n\\ ******************************************************************************\n\\\n\\       Name: DVID4\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate (P R) = 256 * A / Q\n\\  Deep dive: Shift-and-subtract division\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following division and remainder:\n\\\n\\   P = A / Q\n\\\n\\   R = remainder as a fraction of Q, where 1.0 = 255\n\\\n\\ Another way of saying the above is this:\n\\\n\\   (P R) = 256 * A / Q\n\\\n\\ This uses the same shift-and-subtract algorithm as TIS2, but this time we\n\\ keep the remainder.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   C flag              The C flag is cleared\n\\\n\\ ******************************************************************************\n\n.DVID4\n\n LDX #8                 \\ Set a counter in X to count the 8 bits in A\n\n ASL A                  \\ Shift A left and store in P (we will build the result\n STA P                  \\ in P)\n\n LDA #0                 \\ Set A = 0 for us to build a remainder\n\n.DVL4\n\n ROL A                  \\ Shift A to the left\n\n BCS DV8                \\ If the C flag is set (i.e. bit 7 of A was set) then\n                        \\ skip straight to the subtraction\n\n CMP Q                  \\ If A < Q skip the following subtraction\n BCC DV5\n\n.DV8\n\n SBC Q                  \\ A >= Q, so set A = A - Q\n\n SEC                    \\ Set the C flag, so that P gets a 1 shifted into bit 0\n\n.DV5\n\n ROL P                  \\ Shift P to the left, pulling the C flag into bit 0\n\n DEX                    \\ Decrement the loop counter\n\n BNE DVL4               \\ Loop back for the next bit until we have done all 8\n                        \\ bits of P\n\n JMP LL28+4             \\ Jump to LL28+4 to convert the remainder in A into an\n                        \\ integer representation of the fractional value A / Q,\n                        \\ in R, where 1.0 = 255. LL28+4 always returns with the\n                        \\ C flag cleared, and we return from the subroutine\n                        \\ using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: DVID3B2\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate K(3 2 1 0) = (A P+1 P) / (z_sign z_hi z_lo)\n\\  Deep dive: Shift-and-subtract division\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following:\n\\\n\\   K(3 2 1 0) = (A P+1 P) / (z_sign z_hi z_lo)\n\\\n\\ The actual division here is done as an 8-bit calculation using LL31, but this\n\\ routine shifts both the numerator (the top part of the division) and the\n\\ denominator (the bottom part of the division) around to get the multi-byte\n\\ result we want.\n\\\n\\ Specifically, it shifts both of them to the left as far as possible, keeping a\n\\ tally of how many shifts get done in each one - and specifically, the\n\\ difference in the number of shifts between the top and bottom (as shifting\n\\ both of them once in the same direction won't change the result). It then\n\\ divides the two highest bytes with the simple 8-bit routine in LL31, and\n\\ shifts the result by the difference in the number of shifts, which acts as a\n\\ scale factor to get the correct result.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   K(3 2 1 0)          The result of the division\n\\\n\\   X                   X is preserved\n\\\n\\ ******************************************************************************\n\n.DVID3B2\n\n STA P+2                \\ Set P+2 = A\n\n LDA INWK+6             \\ Set Q = z_lo\n STA Q\n\n LDA INWK+7             \\ Set R = z_hi\n STA R\n\n LDA INWK+8             \\ Set S = z_sign\n STA S\n\n.DVID3B\n\n                        \\ Given the above assignments, we now want to calculate\n                        \\ the following to get the result we want:\n                        \\\n                        \\   K(3 2 1 0) = P(2 1 0) / (S R Q)\n\n LDA P                  \\ Make sure P(2 1 0) is at least 1\n ORA #1\n STA P\n\n LDA P+2                \\ Set T to the sign of P+2 * S (i.e. the sign of the\n EOR S                  \\ result) and store it in T\n AND #%10000000\n STA T\n\n LDY #0                 \\ Set Y = 0 to store the scale factor\n\n LDA P+2                \\ Clear the sign bit of P+2, so the division can be done\n AND #%01111111         \\ with positive numbers and we'll set the correct sign\n                        \\ below, once all the maths is done\n                        \\\n                        \\ This also leaves A = P+2, which we use below\n\n.DVL9\n\n                        \\ We now shift (A P+1 P) left until A >= 64, counting\n                        \\ the number of shifts in Y. This makes the top part of\n                        \\ the division as large as possible, thus retaining as\n                        \\ much accuracy as we can.  When we come to return the\n                        \\ final result, we shift the result by the number of\n                        \\ places in Y, and in the correct direction\n\n CMP #64                \\ If A >= 64, jump down to DV14\n BCS DV14\n\n ASL P                  \\ Shift (A P+1 P) to the left\n ROL P+1\n ROL A\n\n INY                    \\ Increment the scale factor in Y\n\n BNE DVL9               \\ Loop up to DVL9 (this BNE is effectively a JMP, as Y\n                        \\ will never be zero)\n\n.DV14\n\n                        \\ If we get here, A >= 64 and contains the highest byte\n                        \\ of the numerator, scaled up by the number of left\n                        \\ shifts in Y\n\n STA P+2                \\ Store A in P+2, so we now have the scaled value of\n                        \\ the numerator in P(2 1 0)\n\n LDA S                  \\ Set A = |S|\n AND #%01111111\n\n BMI DV9                \\ If bit 7 of A is set, jump down to DV9 to skip the\n                        \\ left-shifting of the denominator (though this branch\n                        \\ instruction has no effect as bit 7 of the above AND\n                        \\ can never be set, which is why this instruction was\n                        \\ removed from later versions)\n\n.DVL6\n\n                        \\ We now shift (S R Q) left until bit 7 of S is set,\n                        \\ reducing Y by the number of shifts. This makes the\n                        \\ bottom part of the division as large as possible, thus\n                        \\ retaining as much accuracy as we can. When we come to\n                        \\ return the final result, we shift the result by the\n                        \\ total number of places in Y, and in the correct\n                        \\ direction, to give us the correct result\n                        \\\n                        \\ We set A to |S| above, so the following actually\n                        \\ shifts (A R Q)\n\n DEY                    \\ Decrement the scale factor in Y\n\n ASL Q                  \\ Shift (A R Q) to the left\n ROL R\n ROL A\n\n BPL DVL6               \\ Loop up to DVL6 to do another shift, until bit 7 of A\n                        \\ is set and we can't shift left any further\n\n.DV9\n\n                        \\ We have now shifted both the numerator and denominator\n                        \\ left as far as they will go, keeping a tally of the\n                        \\ overall scale factor of the various shifts in Y. We\n                        \\ can now divide just the two highest bytes to get our\n                        \\ result\n\n STA Q                  \\ Set Q = A, the highest byte of the denominator\n\n LDA #254               \\ Set R to have bits 1-7 set, so we can pass this to\n STA R                  \\ LL31 to act as the bit counter in the division\n\n LDA P+2                \\ Set A to the highest byte of the numerator\n\n JSR LL31               \\ Call LL31 to calculate:\n                        \\\n                        \\   R = 256 * A / Q\n                        \\     = 256 * numerator / denominator\n\n                        \\ The result of our division is now in R, so we just\n                        \\ need to shift it back by the scale factor in Y\n\n LDA #0                 \\ Set K(3 2 1) = 0 to hold the result (we populate K\n STA K+1                \\ next)\n STA K+2\n STA K+3\n\n TYA                    \\ If Y is positive, jump to DV12\n BPL DV12\n\n                        \\ If we get here then Y is negative, so we need to shift\n                        \\ the result R to the left by Y places, and then set the\n                        \\ correct sign for the result\n\n LDA R                  \\ Set A = R\n\n.DVL8\n\n ASL A                  \\ Shift (K+3 K+2 K+1 A) left\n ROL K+1\n ROL K+2\n ROL K+3\n\n INY                    \\ Increment the scale factor in Y\n\n BNE DVL8               \\ Loop back to DVL8 until we have shifted left by Y\n                        \\ places\n\n STA K                  \\ Store A in K so the result is now in K(3 2 1 0)\n\n LDA K+3                \\ Set K+3 to the sign in T, which we set above to the\n ORA T                  \\ correct sign for the result\n STA K+3\n\n RTS                    \\ Return from the subroutine\n\n.DV13\n\n                        \\ If we get here then Y is zero, so we don't need to\n                        \\ shift the result R, we just need to set the correct\n                        \\ sign for the result\n\n LDA R                  \\ Store R in K so the result is now in K(3 2 1 0)\n STA K\n\n LDA T                  \\ Set K+3 to the sign in T, which we set above to the\n STA K+3                \\ correct sign for the result\n\n RTS                    \\ Return from the subroutine\n\n.DV12\n\n BEQ DV13               \\ We jumped here having set A to the scale factor in Y,\n                        \\ so this jumps up to DV13 if Y = 0\n\n                        \\ If we get here then Y is positive and non-zero, so we\n                        \\ need to shift the result R to the right by Y places\n                        \\ and then set the correct sign for the result. We also\n                        \\ know that K(3 2 1) will stay 0, as we are shifting the\n                        \\ lowest byte to the right, so no set bits will make\n                        \\ their way into the top three bytes\n\n LDA R                  \\ Set A = R\n\n.DVL10\n\n LSR A                  \\ Shift A right\n\n DEY                    \\ Decrement the scale factor in Y\n\n BNE DVL10              \\ Loop back to DVL10 until we have shifted right by Y\n                        \\ places\n\n STA K                  \\ Store the shifted A in K so the result is now in\n                        \\ K(3 2 1 0)\n\n LDA T                  \\ Set K+3 to the sign in T, which we set above to the\n STA K+3                \\ correct sign for the result\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: cntr\n\\       Type: Subroutine\n\\   Category: Dashboard\n\\    Summary: Apply damping to the pitch or roll dashboard indicator\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Apply damping to the value in X, where X ranges from 1 to 255 with 128 as the\n\\ centre point (so X represents a position on a centre-based dashboard slider,\n\\ such as pitch or roll). If the value is in the left-hand side of the slider\n\\ (1-127) then it bumps the value up by 1 so it moves towards the centre, and\n\\ if it's in the right-hand side, it reduces it by 1, also moving it towards the\n\\ centre.\n\\\n\\ ******************************************************************************\n\n.cntr\n\n LDA DAMP               \\ If DAMP is non-zero, then keyboard damping is not\n BNE RE1                \\ enabled, so jump to RE1 to return from the subroutine\n\n TXA                    \\ If X < 128, then it's in the left-hand side of the\n BPL BUMP               \\ dashboard slider, so jump to BUMP to bump it up by 1,\n                        \\ to move it closer to the centre\n\n DEX                    \\ Otherwise X >= 128, so it's in the right-hand side\n BMI RE1                \\ of the dashboard slider, so decrement X by 1, and if\n                        \\ it's still >= 128, jump to RE1 to return from the\n                        \\ subroutine, otherwise fall through to BUMP to undo\n                        \\ the bump and then return\n\n.BUMP\n\n INX                    \\ Bump X up by 1, and if it hasn't overshot the end of\n BNE RE1                \\ the dashboard slider, jump to RE1 to return from the\n                        \\ subroutine, otherwise fall through to REDU to drop\n                        \\ it down by 1 again\n\n.REDU\n\n DEX                    \\ Reduce X by 1, and if we have reached 0 jump up to\n BEQ BUMP               \\ BUMP to add 1, because we need the value to be in the\n                        \\ range 1 to 255\n\n.RE1\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: BUMP2\n\\       Type: Subroutine\n\\   Category: Dashboard\n\\    Summary: Bump up the value of the pitch or roll dashboard indicator\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Increase (\"bump up\") X by A, where X is either the current rate of pitch or\n\\ the current rate of roll.\n\\\n\\ The rate of pitch or roll ranges from 1 to 255 with 128 as the centre point.\n\\ This is the amount by which the pitch or roll is currently changing, so 1\n\\ means it is decreasing at the maximum rate, 128 means it is not changing,\n\\ and 255 means it is increasing at the maximum rate. These values correspond\n\\ to the line on the DC or RL indicators on the dashboard, with 1 meaning full\n\\ left, 128 meaning the middle, and 255 meaning full right.\n\\\n\\ If bumping up X would push it past 255, then X is set to 255.\n\\\n\\ If keyboard auto-recentre is configured and the result is less than 128, we\n\\ bump X up to the mid-point, 128. This is the equivalent of having a roll or\n\\ pitch in the left half of the indicator, when increasing the roll or pitch\n\\ should jump us straight to the mid-point.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   RE2+2               Restore A from T and return from the subroutine\n\\\n\\ ******************************************************************************\n\n.BUMP2\n\n STA T                  \\ Store argument A in T so we can restore it later\n\n TXA                    \\ Copy argument X into A\n\n CLC                    \\ Clear the C flag so we can do addition without the\n                        \\ C flag affecting the result\n\n ADC T                  \\ Set X = A = argument X + argument A\n TAX\n\n BCC RE2                \\ If the C flag is clear, then we didn't overflow, so\n                        \\ jump to RE2 to auto-recentre and return the result\n\n LDX #255               \\ We have an overflow, so set X to the maximum possible\n                        \\ value of 255\n\n.RE2\n\n BPL RE3+2              \\ If X has bit 7 clear (i.e. the result < 128), then\n                        \\ jump to RE3+2 in routine REDU2 to do an auto-recentre,\n                        \\ if configured, because the result is on the left side\n                        \\ of the centre point of 128\n\n                        \\ Jumps to RE2+2 end up here\n\n LDA T                  \\ Restore the original argument A from T into A\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: REDU2\n\\       Type: Subroutine\n\\   Category: Dashboard\n\\    Summary: Reduce the value of the pitch or roll dashboard indicator\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Reduce X by A, where X is either the current rate of pitch or the current\n\\ rate of roll.\n\\\n\\ The rate of pitch or roll ranges from 1 to 255 with 128 as the centre point.\n\\ This is the amount by which the pitch or roll is currently changing, so 1\n\\ means it is decreasing at the maximum rate, 128 means it is not changing,\n\\ and 255 means it is increasing at the maximum rate. These values correspond\n\\ to the line on the DC or RL indicators on the dashboard, with 1 meaning full\n\\ left, 128 meaning the middle, and 255 meaning full right.\n\\\n\\ If reducing X would bring it below 1, then X is set to 1.\n\\\n\\ If keyboard auto-recentre is configured and the result is greater than 128, we\n\\ reduce X down to the mid-point, 128. This is the equivalent of having a roll\n\\ or pitch in the right half of the indicator, when decreasing the roll or pitch\n\\ should jump us straight to the mid-point.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   RE3+2               Auto-recentre the value in X, if keyboard auto-recentre\n\\                       is configured\n\\\n\\ ******************************************************************************\n\n.REDU2\n\n STA T                  \\ Store argument A in T so we can restore it later\n\n TXA                    \\ Copy argument X into A\n\n SEC                    \\ Set the C flag so we can do subtraction without the\n                        \\ C flag affecting the result\n\n SBC T                  \\ Set X = A = argument X - argument A\n TAX\n\n BCS RE3                \\ If the C flag is set, then we didn't underflow, so\n                        \\ jump to RE3 to auto-recentre and return the result\n\n LDX #1                 \\ We have an underflow, so set X to the minimum possible\n                        \\ value, 1\n\n.RE3\n\n BPL RE2+2              \\ If X has bit 7 clear (i.e. the result < 128), then\n                        \\ jump to RE2+2 above to return the result as is,\n                        \\ because the result is on the left side of the centre\n                        \\ point of 128, so we don't need to auto-centre\n\n                        \\ Jumps to RE3+2 end up here\n\n                        \\ If we get here, then we need to apply auto-recentre,\n                        \\ if it is configured\n\n LDA DJD                \\ If keyboard auto-recentre is disabled, then jump to\n BNE RE2+2              \\ RE2+2 to restore A and return\n\n LDX #128               \\ If we get here then keyboard auto-recentre is enabled,\n BMI RE2+2              \\ so set X to 128 (the middle of our range) and jump to\n                        \\ RE2+2 to restore A and return from the subroutine\n                        \\ (this BMI is effectively a JMP as bit 7 of X is always\n                        \\ set)\n\n\\ ******************************************************************************\n\\\n\\       Name: ARCTAN\n\\       Type: Subroutine\n\\   Category: Maths (Geometry)\n\\    Summary: Calculate A = arctan(P / Q)\n\\  Deep dive: The sine, cosine and arctan tables\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following:\n\\\n\\   A = arctan(P / Q)\n\\\n\\ In other words, this finds the angle in the right-angled triangle where the\n\\ opposite side to angle A is length P and the adjacent side to angle A has\n\\ length Q, so:\n\\\n\\   tan(A) = P / Q\n\\\n\\ The result in A is an integer representing the angle in radians. The routine\n\\ returns values in the range 0 to 128, which covers 0 to 180 degrees (or 0 to\n\\ PI radians).\n\\\n\\ ******************************************************************************\n\n.ARCTAN\n\n LDA P                  \\ Set T1 = P EOR Q, which will have the sign of P * Q\n EOR Q                  \\\n\\AND #%10000000         \\ The AND is commented out in the original source\n STA T1\n\n LDA Q                  \\ If Q = 0, jump to AR2 to return a right angle\n BEQ AR2\n\n ASL A                  \\ Set Q = |Q| * 2 (this is a quick way of clearing the\n STA Q                  \\ sign bit, and we don't need to shift right again as we\n                        \\ only ever use this value in the division with |P| * 2,\n                        \\ which we set next)\n\n LDA P                  \\ Set A = |P| * 2\n ASL A\n\n CMP Q                  \\ If A >= Q, i.e. |P| > |Q|, jump to AR1 to swap P\n BCS AR1                \\ and Q around, so we can still use the lookup table\n\n JSR ARS1               \\ Call ARS1 to set the following from the lookup table:\n                        \\\n                        \\   A = arctan(A / Q)\n                        \\     = arctan(|P / Q|)\n\n SEC                    \\ Set the C flag so the SBC instruction in AR3 will be\n                        \\ correct, should we jump there\n\n.AR4\n\n LDX T1                 \\ If T1 is negative, i.e. P and Q have different signs,\n BMI AR3                \\ jump down to AR3 to return arctan(-|P / Q|)\n\n RTS                    \\ Otherwise P and Q have the same sign, so our result is\n                        \\ correct and we can return from the subroutine\n\n.AR1\n\n                        \\ We want to calculate arctan(t) where |t| > 1, so we\n                        \\ can use the calculation described in the documentation\n                        \\ for the ACT table, i.e. 64 - arctan(1 / t)\n\n LDX Q                  \\ Swap the values in Q and P, using the fact that we\n STA Q                  \\ called AR1 with A = P\n STX P                  \\\n TXA                    \\ This also sets A = P (which now contains the original\n                        \\ argument |Q|)\n\n JSR ARS1               \\ Call ARS1 to set the following from the lookup table:\n                        \\\n                        \\   A = arctan(A / Q)\n                        \\     = arctan(|Q / P|)\n                        \\     = arctan(1 / |P / Q|)\n\n STA T                  \\ Set T = 64 - T\n LDA #64\n SBC T\n\n BCS AR4                \\ Jump to AR4 to continue the calculation (this BCS is\n                        \\ effectively a JMP as the subtraction will never\n                        \\ underflow, as ARS1 returns values in the range 0-31)\n\n.AR2\n\n                        \\ If we get here then Q = 0, so tan(A) = infinity and\n                        \\ A is a right angle, or 0.25 of a circle. We allocate\n                        \\ 255 to a full circle, so we should return 63 for a\n                        \\ right angle\n\n LDA #63                \\ Set A to 63, to represent a right angle\n\n RTS                    \\ Return from the subroutine\n\n.AR3\n\n                        \\ A contains arctan(|P / Q|) but P and Q have different\n                        \\ signs, so we need to return arctan(-|P / Q|), using\n                        \\ the calculation described in the documentation for the\n                        \\ ACT table, i.e. 128 - A\n\n STA T                  \\ Set A = 128 - A\n LDA #128               \\\n\\SEC                    \\ The SEC instruction is commented out in the original\n SBC T                  \\ source, and isn't required as we did a SEC before\n                        \\ calling AR3\n\n RTS                    \\ Return from the subroutine\n\n.ARS1\n\n                        \\ This routine fetches arctan(A / Q) from the ACT table,\n                        \\ so A will be set to an integer in the range 0 to 31\n                        \\ that represents an angle from 0 to 45 degrees (or 0 to\n                        \\ PI / 4 radians)\n\n JSR LL28               \\ Call LL28 to calculate:\n                        \\\n                        \\   R = 256 * A / Q\n\n LDA R                  \\ Set X = R / 8\n LSR A                  \\       = 32 * A / Q\n LSR A                  \\\n LSR A                  \\ so X has the value t * 32 where t = A / Q, which is\n TAX                    \\ what we need to look up values in the ACT table\n\n LDA ACT,X              \\ Fetch ACT+X from the ACT table into A, so now:\n                        \\\n                        \\   A = value in ACT + X\n                        \\     = value in ACT + (32 * A / Q)\n                        \\     = arctan(A / Q)\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: ACT\n\\       Type: Variable\n\\   Category: Maths (Geometry)\n\\    Summary: Arctan table\n\\  Deep dive: The sine, cosine and arctan tables\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This table contains lookup values for arctangent calculations involving angles\n\\ in the range 0 to 45 degrees (or 0 to PI / 4 radians).\n\\\n\\ To calculate the value of theta in the following:\n\\\n\\   theta = arctan(t)\n\\\n\\ where 0 <= t < 1, we look up the value in:\n\\\n\\   ACT + (t * 32)\n\\\n\\ The result will be an integer representing the angle in radians, where 256\n\\ represents a full circle of 360 degrees (2 * PI radians). The result of the\n\\ lookup will therefore be an integer in the range 0 to 31, as this represents\n\\ 0 to 45 degrees (0 to PI / 4 radians).\n\\\n\\ The table does not support values of t >= 1 or t < 0 directly, so if we need\n\\ to calculate the arctangent for an angle greater than 45 degrees, we can apply\n\\ the following calculation to the result from the table:\n\\\n\\   * For t > 1, arctan(t) = 64 - arctan(1 / t)\n\\\n\\ For negative values of t where -1 < t < 0, we can apply the following\n\\ calculation to the result from the table:\n\\\n\\   * For t < 0, arctan(-t) = 128 - arctan(t)\n\\\n\\ Finally, if t < -1, we can do the first calculation to get arctan(|t|), and\n\\ the second to get arctan(-|t|).\n\\\n\\ ******************************************************************************\n\n.ACT\n\n FOR I%, 0, 31\n\n  EQUB INT((128 / PI) * ATN(I% / 32) + 0.5)\n\n NEXT\n\n\\ ******************************************************************************\n\\\n\\       Name: WARP\n\\       Type: Subroutine\n\\   Category: Flight\n\\    Summary: Perform an in-system jump\n\\  Deep dive: A sense of scale\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This is called when we press \"J\" during flight. The following checks are\n\\ performed:\n\\\n\\   * Make sure we don't have any ships or space stations in the vicinity\n\\\n\\   * Make sure we are not in witchspace\n\\\n\\   * If we are facing the planet, make sure we aren't too close\n\\\n\\   * If we are facing the sun, make sure we aren't too close\n\\\n\\ If the above checks are passed, then we perform an in-system jump by moving\n\\ the sun and planet in the opposite direction to travel, so we appear to jump\n\\ in space. This means that any asteroids, cargo canisters or escape pods get\n\\ dragged along for the ride.\n\\\n\\ ******************************************************************************\n\n.WARP\n\nIF _SOURCE_DISC\n\n LDA MANY+AST           \\ Set X to the total number of asteroids, escape pods\n CLC                    \\ and cargo canisters in the vicinity\n ADC MANY+ESC\n CLC                    \\ The second CLC instruction has no effect, as there is\n ADC MANY+OIL           \\ no way that adding the number of asteroids and the\n TAX                    \\ number escape pods will cause a carry\n\nELIF _TEXT_SOURCES OR _STH_CASSETTE\n\n LDA MANY+AST           \\ Set X to the total number of asteroids, escape pods\n CLC                    \\ and cargo canisters in the vicinity\n ADC MANY+ESC           \\\n ADC MANY+OIL           \\ This code saves one byte of memory over the code in\n TAX                    \\ the source disc version. The second CLC is not needed\n                        \\ as there is no way that adding the number of asteroids\n                        \\ and the number of escape pods will cause a carry\n\nENDIF\n\n LDA FRIN+2,X           \\ If the slot at FRIN+2+X is non-zero, then we have\n                        \\ something else in the vicinity besides asteroids,\n                        \\ escape pods and cargo canisters, so to check whether\n                        \\ we can jump, we first grab the slot contents into A\n\n ORA SSPR               \\ If there is a space station nearby, then SSPR will\n                        \\ be non-zero, so OR'ing with SSPR will produce a\n                        \\ non-zero result if either A or SSPR are non-zero\n\n ORA MJ                 \\ If we are in witchspace, then MJ will be non-zero, so\n                        \\ OR'ing with MJ will produce a non-zero result if\n                        \\ either A or SSPR or MJ are non-zero\n\n BNE WA1                \\ A is non-zero if we have either a ship or a space\n                        \\ station in the vicinity, or we are in witchspace, in\n                        \\ which case jump to WA1 to make a low beep to show that\n                        \\ we can't do an in-system jump\n\n LDY K%+8               \\ Otherwise we can do an in-system jump, so now we fetch\n                        \\ the byte at K%+8, which contains the z_sign for the\n                        \\ first ship slot, i.e. the distance of the planet\n\n BMI WA3                \\ If the planet's z_sign is negative, then the planet\n                        \\ is behind us, so jump to WA3 to skip the following\n\n TAY                    \\ Set A = Y = 0 (as we didn't BNE above) so the call\n                        \\ to MAS2 measures the distance to the planet\n\n JSR MAS2               \\ Call MAS2 to set A to the largest distance to the\n                        \\ planet in any of the three axes (we could also call\n                        \\ routine m to do the same thing, as A = 0)\n\nIF _SOURCE_DISC\n\n CMP #2                 \\ If A < 2 then jump to WA1 to abort the in-system jump\n BCC WA1                \\ with a low beep, as we are facing the planet and are\n                        \\ too close to jump in that direction\n\nELIF _TEXT_SOURCES OR _STH_CASSETTE\n\n LSR A                  \\ If A < 2 then jump to WA1 to abort the in-system jump\n BEQ WA1                \\ with a low beep, as we are facing the planet and are\n                        \\ too close to jump in that direction\n                        \\\n                        \\ These instructions between them save one byte of\n                        \\ memory over the CMP-based code in the source disc\n                        \\ version, as LSR A is a one-byte opcode, while CMP #2\n                        \\ takes up two bytes (though the code does exactly the\n                        \\ same thing)\n\nENDIF\n\n.WA3\n\n LDY K%+NI%+8           \\ Fetch the z_sign (byte #8) of the second ship in the\n                        \\ ship data workspace at K%, which is reserved for the\n                        \\ sun or the space station (in this case it's the\n                        \\ former, as we already confirmed there isn't a space\n                        \\ station in the vicinity)\n\n BMI WA2                \\ If the sun's z_sign is negative, then the sun is\n                        \\ behind us, so jump to WA2 to skip the following\n\n LDY #NI%               \\ Set Y to point to the offset of the ship data block\n                        \\ for the sun, which is NI% (as each block is NI% bytes\n                        \\ long, and the sun is the second block)\n\n JSR m                  \\ Call m to set A to the largest distance to the sun\n                        \\ in any of the three axes\n\nIF _SOURCE_DISC\n\n CMP #2                 \\ If A < 2 then jump to WA1 to abort the in-system jump\n BCC WA1                \\ with a low beep, as we are facing the planet and are\n                        \\ too close to jump in that direction\n\nELIF _TEXT_SOURCES OR _STH_CASSETTE\n\n LSR A                  \\ If A < 2 then jump to WA1 to abort the in-system jump\n BEQ WA1                \\ with a low beep, as we are facing the planet and are\n                        \\ too close to jump in that direction\n                        \\\n                        \\ These instructions between them save one byte of\n                        \\ memory over the CMP-based code in the source disc\n                        \\ version, as LSR A is a one-byte opcode, while CMP #2\n                        \\ takes up two bytes (though the code does exactly the\n                        \\ same thing)\n\nENDIF\n\n.WA2\n\n                        \\ If we get here, then we can do an in-system jump, as\n                        \\ we don't have any ships or space stations in the\n                        \\ vicinity, we are not in witchspace, and if we are\n                        \\ facing the planet or the sun, we aren't too close to\n                        \\ jump towards it\n                        \\\n                        \\ We do an in-system jump by moving the sun and planet,\n                        \\ rather than moving our own local bubble (this is why\n                        \\ in-system jumps drag asteroids, cargo canisters and\n                        \\ escape pods along for the ride). Specifically, we move\n                        \\ them in the z-axis by a fixed amount in the opposite\n                        \\ direction to travel, thus performing a jump towards\n                        \\ our destination\n\n LDA #&81               \\ Set R = R = P = &81\n STA S\n STA R\n STA P\n\n LDA K%+8               \\ Set A = z_sign for the planet\n\n JSR ADD                \\ Set (A X) = (A P) + (S R)\n                        \\           = (z_sign &81) + &8181\n                        \\           = (z_sign &81) - &0181\n                        \\\n                        \\ This moves the planet against the direction of travel\n                        \\ by reducing z_sign by 1, as the above maths is:\n                        \\\n                        \\         z_sign 00000000\n                        \\   +   00000000 10000001\n                        \\   -   00000001 10000001\n                        \\\n                        \\ or:\n                        \\\n                        \\         z_sign 00000000\n                        \\   +   00000000 00000000\n                        \\   -   00000001 00000000\n                        \\\n                        \\ i.e. the high byte is z_sign - 1, making sure the sign\n                        \\ is preserved\n\n STA K%+8               \\ Set the planet's z_sign to the high byte of the result\n\n LDA K%+NI%+8           \\ Set A = z_sign for the sun\n\n JSR ADD                \\ Set (A X) = (A P) + (S R)\n                        \\           = (z_sign &81) + &8181\n                        \\           = (z_sign &81) - &0181\n                        \\\n                        \\ which moves the sun against the direction of travel\n                        \\ by reducing z_sign by 1\n\n STA K%+NI%+8           \\ Set the planet's z_sign to the high byte of the result\n\n LDA #1                 \\ Temporarily set the view type to a non-zero value, so\n STA QQ11               \\ the call to LOOK1 below clears the screen before\n                        \\ switching to the space view\n\n STA MCNT               \\ Set the main loop counter to 1, so the next iteration\n                        \\ through the main loop will potentially spawn ships\n                        \\ (see part 2 of the main game loop at me3)\n\n LSR A                  \\ Set EV, the extra vessels spawning counter, to 0\n STA EV                 \\ (the LSR produces a 0 as A was previously 1)\n\n LDX VIEW               \\ Set X to the current view (front, rear, left or right)\n JMP LOOK1              \\ and jump to LOOK1 to initialise that view, returning\n                        \\ from the subroutine using a tail call\n\n.WA1\n\n LDA #40                \\ If we get here then we can't do an in-system jump, so\n JMP NOISE              \\ call the NOISE routine with A = 40 to make a long, low\n                        \\ beep and return from the subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: LASLI\n\\       Type: Subroutine\n\\   Category: Drawing lines\n\\    Summary: Draw the laser lines for when we fire our lasers\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Draw the laser lines, aiming them to slightly different place each time so\n\\ they appear to flicker and dance. Also heat up the laser temperature and drain\n\\ some energy.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   LASLI2              Just draw the current laser lines without moving the\n\\                       centre point, draining energy or heating up. This has\n\\                       the effect of removing the lines from the screen\n\\\n\\   LASLI-1             Contains an RTS\n\\\n\\ ******************************************************************************\n\n.LASLI\n\n JSR DORND              \\ Set A and X to random numbers\n\n AND #7                 \\ Restrict A to a random value in the range 0 to 7\n\n ADC #Y-4               \\ Set LASY to four pixels above the centre of the\n STA LASY               \\ screen (#Y), plus our random number, so the laser\n                        \\ dances above and below the centre point\n\n JSR DORND              \\ Set A and X to random numbers\n\n AND #7                 \\ Restrict A to a random value in the range 0 to 7\n\n ADC #X-4               \\ Set LASX to four pixels left of the centre of the\n STA LASX               \\ screen (#X), plus our random number, so the laser\n                        \\ dances to the left and right of the centre point\n\n LDA GNTMP              \\ Add 8 to the laser temperature in GNTMP\n ADC #8\n STA GNTMP\n\n JSR DENGY              \\ Call DENGY to deplete our energy banks by 1\n\n.LASLI2\n\n LDA QQ11               \\ If this is not a space view (i.e. QQ11 is non-zero)\n BNE PU1-1              \\ then jump to MA9 to return from the main flight loop\n                        \\ (as PU1-1 is an RTS)\n\n LDA #32                \\ Set A = 32 and Y = 224 for the first set of laser\n LDY #224               \\ lines (the wider pair of lines)\n\n JSR las                \\ Call las below to draw the first set of laser lines\n\n LDA #48                \\ Fall through into las with A = 48 and Y = 208 to draw\n LDY #208               \\ a second set of lines (the narrower pair)\n\n                        \\ The following routine draws two laser lines, one from\n                        \\ the centre point down to point A on the bottom row,\n                        \\ and the other from the centre point down to point Y\n                        \\ on the bottom row. We therefore get lines from the\n                        \\ centre point to points 32, 48, 208 and 224 along the\n                        \\ bottom row, giving us the triangular laser effect\n                        \\ we're after\n\n.las\n\n STA X2                 \\ Set X2 = A\n\n LDA LASX               \\ Set (X1, Y1) to the random centre point we set above\n STA X1\n LDA LASY\n STA Y1\n\n LDA #2*Y-1             \\ Set Y2 = 2 * #Y - 1. The constant #Y is 96, the\n STA Y2                 \\ y-coordinate of the mid-point of the space view, so\n                        \\ this sets Y2 to 191, the y-coordinate of the bottom\n                        \\ pixel row of the space view\n\n JSR LOIN               \\ Draw a line from (X1, Y1) to (X2, Y2), so that's from\n                        \\ the centre point to (A, 191)\n\n LDA LASX               \\ Set (X1, Y1) to the random centre point we set above\n STA X1\n LDA LASY\n STA Y1\n\n STY X2                 \\ Set X2 = Y\n\n LDA #2*Y-1             \\ Set Y2 = 2 * #Y - 1, the y-coordinate of the bottom\n STA Y2                 \\ pixel row of the space view (as before)\n\n JMP LOIN               \\ Draw a line from (X1, Y1) to (X2, Y2), so that's from\n                        \\ the centre point to (Y, 191), and return from\n                        \\ the subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: PLUT\n\\       Type: Subroutine\n\\   Category: Flight\n\\    Summary: Flip the coordinate axes for the four different views\n\\  Deep dive: Flipping axes between space views\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine flips the relevant geometric axes in INWK depending on which\n\\ view we are looking through (front, rear, left, right).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   PU1-1               Contains an RTS\n\\\n\\ ******************************************************************************\n\n.PLUT\n\n LDX VIEW               \\ Load the current view into X:\n                        \\\n                        \\   0 = front\n                        \\   1 = rear\n                        \\   2 = left\n                        \\   3 = right\n\n BNE PU1                \\ If the current view is the front view, return from the\n RTS                    \\ subroutine, as the geometry in INWK is already correct\n\n.PU1\n\n DEX                    \\ Decrement the view, so now:\n                        \\\n                        \\   0 = rear\n                        \\   1 = left\n                        \\   2 = right\n\n BNE PU2                \\ If the current view is left or right, jump to PU2,\n                        \\ otherwise this is the rear view, so continue on\n\n LDA INWK+2             \\ Flip the sign of x_sign\n EOR #%10000000\n STA INWK+2\n\n LDA INWK+8             \\ Flip the sign of z_sign\n EOR #%10000000\n STA INWK+8\n\n LDA INWK+10            \\ Flip the sign of nosev_x_hi\n EOR #%10000000\n STA INWK+10\n\n LDA INWK+14            \\ Flip the sign of nosev_z_hi\n EOR #%10000000\n STA INWK+14\n\n LDA INWK+16            \\ Flip the sign of roofv_x_hi\n EOR #%10000000\n STA INWK+16\n\n LDA INWK+20            \\ Flip the sign of roofv_z_hi\n EOR #%10000000\n STA INWK+20\n\n LDA INWK+22            \\ Flip the sign of sidev_x_hi\n EOR #%10000000\n STA INWK+22\n\n LDA INWK+26            \\ Flip the sign of roofv_z_hi\n EOR #%10000000\n STA INWK+26\n\n RTS                    \\ Return from the subroutine\n\n.PU2\n\n                        \\ We enter this with X set to the view, as follows:\n                        \\\n                        \\   1 = left\n                        \\   2 = right\n\n LDA #0                 \\ Set RAT2 = 0 (left view) or -1 (right view)\n CPX #2\n ROR A\n STA RAT2\n\n EOR #%10000000         \\ Set RAT = -1 (left view) or 0 (right view)\n STA RAT\n\n LDA INWK               \\ Swap x_lo and z_lo\n LDX INWK+6\n STA INWK+6\n STX INWK\n\n LDA INWK+1             \\ Swap x_hi and z_hi\n LDX INWK+7\n STA INWK+7\n STX INWK+1\n\n LDA INWK+2             \\ Swap x_sign and z_sign\n EOR RAT                \\ If left view, flip sign of new z_sign\n TAX                    \\ If right view, flip sign of new x_sign\n LDA INWK+8\n EOR RAT2\n STA INWK+2\n STX INWK+8\n\n LDY #9                 \\ Swap nosev_x_lo and nosev_z_lo\n JSR PUS1               \\ Swap nosev_x_hi and nosev_z_hi\n                        \\ If left view, flip sign of new nosev_z_hi\n                        \\ If right view, flip sign of new nosev_x_hi\n\n LDY #15                \\ Swap roofv_x_lo and roofv_z_lo\n JSR PUS1               \\ Swap roofv_x_hi and roofv_z_hi\n                        \\ If left view, flip sign of new roofv_z_hi\n                        \\ If right view, flip sign of new roofv_x_hi\n\n LDY #21                \\ Swap sidev_x_lo and sidev_z_lo\n                        \\ Swap sidev_x_hi and sidev_z_hi\n                        \\ If left view, flip sign of new sidev_z_hi\n                        \\ If right view, flip sign of new sidev_x_hi\n\n.PUS1\n\n LDA INWK,Y             \\ Swap the low x and z bytes for the vector in Y:\n LDX INWK+4,Y           \\\n STA INWK+4,Y           \\   * For Y =  9 swap nosev_x_lo and nosev_z_lo\n STX INWK,Y             \\   * For Y = 15 swap roofv_x_lo and roofv_z_lo\n                        \\   * For Y = 21 swap sidev_x_lo and sidev_z_lo\n\n LDA INWK+1,Y           \\ Swap the high x and z bytes for the offset in Y:\n EOR RAT                \\\n TAX                    \\   * If left view, flip sign of new z-coordinate\n LDA INWK+5,Y           \\   * If right view, flip sign of new x-coordinate\n EOR RAT2\n STA INWK+1,Y\n STX INWK+5,Y\n\n                        \\ Fall through into LOOK1 to return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: LOOK1\n\\       Type: Subroutine\n\\   Category: Flight\n\\    Summary: Initialise the space view\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Initialise the space view, with the direction of view given in X. This clears\n\\ the upper screen and draws the laser crosshairs, if the view in X has lasers\n\\ fitted. It also wipes all the ships from the scanner, so we can recalculate\n\\ ship positions for the new view (they get put back in the main flight loop).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   The space view to set:\n\\\n\\                         * 0 = front\n\\                         * 1 = rear\n\\                         * 2 = left\n\\                         * 3 = right\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   LO2                 Contains an RTS\n\\\n\\ ******************************************************************************\n\n.LO2\n\n RTS                    \\ Return from the subroutine\n\n.LQ\n\n STX VIEW               \\ Set the current space view to X\n\n JSR TT66               \\ Clear the top part of the screen, draw a border box,\n                        \\ and set the current view type in QQ11 to 0 (space\n                        \\ view)\n\n JSR SIGHT              \\ Draw the laser crosshairs\n\n JMP NWSTARS            \\ Set up a new stardust field and return from the\n                        \\ subroutine using a tail call\n\n.LOOK1\n\n LDA #0                 \\ Set A = 0, the type number of a space view\n\n LDY QQ11               \\ If the current view is not a space view, jump up to LQ\n BNE LQ                 \\ to set up a new space view\n\n CPX VIEW               \\ If the current view is already of type X, jump to LO2\n BEQ LO2                \\ to return from the subroutine (as LO2 contains an RTS)\n\n STX VIEW               \\ Change the current space view to X\n\n JSR TT66               \\ Clear the top part of the screen, draw a border box,\n                        \\ and set the current view type in QQ11 to 0 (space\n                        \\ view)\n\n JSR FLIP               \\ Swap the x- and y-coordinates of all the stardust\n                        \\ particles and redraw the stardust field\n\n JSR WPSHPS             \\ Wipe all the ships from the scanner and mark them all\n                        \\ as not being shown on-screen\n\n                        \\ And fall through into SIGHT to draw the laser\n                        \\ crosshairs\n\n\\ ******************************************************************************\n\\\n\\       Name: SIGHT\n\\       Type: Subroutine\n\\   Category: Flight\n\\    Summary: Draw the laser crosshairs\n\\\n\\ ******************************************************************************\n\n.SIGHT\n\n LDY VIEW               \\ Fetch the laser power for our new view\n LDA LASER,Y\n\n BEQ LO2                \\ If it is zero (i.e. there is no laser fitted to this\n                        \\ view), jump to LO2 to return from the subroutine (as\n                        \\ LO2 contains an RTS)\n\n LDA #128               \\ Set QQ19 to the x-coordinate of the centre of the\n STA QQ19               \\ screen\n\n LDA #Y-24              \\ Set QQ19+1 to the y-coordinate of the centre of the\n STA QQ19+1             \\ screen, minus 24 (because TT15 will add 24 to the\n                        \\ coordinate when it draws the crosshairs)\n\n LDA #20                \\ Set QQ19+2 to size 20 for the crosshairs size\n STA QQ19+2\n\n JSR TT15               \\ Call TT15 to draw crosshairs of size 20 just to the\n                        \\ left of the middle of the screen\n\n LDA #10                \\ Set QQ19+2 to size 10 for the crosshairs size\n STA QQ19+2\n\n JMP TT15               \\ Call TT15 to draw crosshairs of size 10 at the same\n                        \\ location, which will remove the centre part from the\n                        \\ laser crosshairs, leaving a gap in the middle, and\n                        \\ return from the subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: TT66\n\\       Type: Subroutine\n\\   Category: Drawing the screen\n\\    Summary: Clear the screen and set the current view type\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Clear the top part of the screen, draw a border box, and set the current\n\\ view type in QQ11 to A.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The type of the new current view (see QQ11 for a list of\n\\                       view types)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   TT66-2              Call TT66 with A = 1\n\\\n\\ ******************************************************************************\n\n LDA #1                 \\ Set the view type to 1 when this is called via the\n                        \\ TT66-2 entry point\n\n.TT66\n\n STA QQ11               \\ Set the current view type in QQ11 to A\n\n                        \\ Fall through into TTX66 to clear the screen and draw a\n                        \\ border box\n\n\\ ******************************************************************************\n\\\n\\       Name: TTX66\n\\       Type: Subroutine\n\\   Category: Drawing the screen\n\\    Summary: Clear the top part of the screen, draw a border box and configure\n\\             the specified view\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Clear the top part of the screen (the space view) and draw a border box\n\\ along the top and sides.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   BOX                 Just draw the border and (if this is a space view) the\n\\                       view name. This can be used to remove the border and\n\\                       view name, as it is drawn using EOR logic\n\\\n\\ ******************************************************************************\n\n.TTX66\n\n LDA #%10000000         \\ Set bit 7 of QQ17 to switch to Sentence Case\n STA QQ17\n\nIF _SOURCE_DISC\n\n ASL A                  \\ Set LASCT to 0, as 128 << 1 = %10000000 << 1 = 0. This\n STA LASCT              \\ stops any laser pulsing\n\nELIF _TEXT_SOURCES OR _STH_CASSETTE\n\n ASL A                  \\ Set LAS2 to 0, as 128 << 1 = %10000000 << 1 = 0. This\n STA LAS2               \\ stops any laser pulsing\n\nENDIF\n\n STA DLY                \\ Set the delay in DLY to 0, to indicate that we are\n                        \\ no longer showing an in-flight message, so any new\n                        \\ in-flight messages will be shown instantly\n\n STA de                 \\ Clear de, the flag that appends \" DESTROYED\" to the\n                        \\ end of the next text token, so that it doesn't\n\n LDX #&60               \\ Set X to the screen memory page for the top row of the\n                        \\ screen (as screen memory starts at &6000)\n\n.BOL1\n\n JSR ZES1               \\ Call ZES1 to zero-fill the page in X, which clears\n                        \\ that character row on the screen\n\n INX                    \\ Increment X to point to the next page, i.e. the next\n                        \\ character row\n\n CPX #&78               \\ Loop back to BOL1 until we have cleared page &7700,\n BNE BOL1               \\ the last character row in the space view part of the\n                        \\ screen (the top part)\n\n LDX QQ22+1             \\ Fetch into X the number that's shown on-screen during\n                        \\ the hyperspace countdown\n\n BEQ BOX                \\ If the counter is zero then we are not counting down\n                        \\ to hyperspace, so jump to BOX to skip the next\n                        \\ instruction\n\n JSR ee3                \\ Print the 8-bit number in X at text location (0, 1),\n                        \\ i.e. print the hyperspace countdown in the top-left\n                        \\ corner\n\n.BOX\n\n LDY #1                 \\ Move the text cursor to row 1\n STY YC\n\n LDA QQ11               \\ If this is not a space view, jump to tt66 to skip\n BNE tt66               \\ displaying the view name\n\n LDY #11                \\ Move the text cursor to row 11\n STY XC\n\n LDA VIEW               \\ Load the current view into A:\n                        \\\n                        \\   0 = front\n                        \\   1 = rear\n                        \\   2 = left\n                        \\   3 = right\n\n ORA #&60               \\ OR with &60 so we get a value of &60 to &63 (96 to 99)\n\n JSR TT27               \\ Print recursive token 96 to 99, which will be in the\n                        \\ range \"FRONT\" to \"RIGHT\"\n\n JSR TT162              \\ Print a space\n\n LDA #175               \\ Print recursive token 15 (\"VIEW \")\n JSR TT27\n\n.tt66\n\n LDX #0                 \\ Set (X1, Y1) to (0, 0)\n STX X1\n STX Y1\n\n STX QQ17               \\ Set QQ17 = 0 to switch to ALL CAPS\n\n DEX                    \\ Set X2 = 255\n STX X2\n\n JSR HLOIN              \\ Draw a horizontal line from (X1, Y1) to (X2, Y1), so\n                        \\ that's (0, 0) to (255, 0), along the very top of the\n                        \\ screen\n\n LDA #2                 \\ Set X1 = X2 = 2\n STA X1\n STA X2\n\n JSR BOS2               \\ Call BOS2 below, which will call BOS1 twice, and then\n                        \\ fall through into BOS2 again, so we effectively do\n                        \\ BOS1 four times, decrementing X1 and X2 each time\n                        \\ before calling LOIN, so this whole loop-within-a-loop\n                        \\ mind-bender ends up drawing these four lines:\n                        \\\n                        \\   (1, 0)   to (1, 191)\n                        \\   (0, 0)   to (0, 191)\n                        \\   (255, 0) to (255, 191)\n                        \\   (254, 0) to (254, 191)\n                        \\\n                        \\ So that's a two-pixel wide vertical border along the\n                        \\ left edge of the upper part of the screen, and a\n                        \\ two-pixel wide vertical border along the right edge\n\n.BOS2\n\n JSR BOS1               \\ Call BOS1 below and then fall through into it, which\n                        \\ ends up running BOS1 twice. This is all part of the\n                        \\ loop-the-loop border-drawing mind-bender explained\n                        \\ above\n\n.BOS1\n\n LDA #0                 \\ Set Y1 = 0\n STA Y1\n\n LDA #2*Y-1             \\ Set Y2 = 2 * #Y - 1. The constant #Y is 96, the\n STA Y2                 \\ y-coordinate of the mid-point of the space view, so\n                        \\ this sets Y2 to 191, the y-coordinate of the bottom\n                        \\ pixel row of the space view\n\n DEC X1                 \\ Decrement X1 and X2\n DEC X2\n\n JMP LOIN               \\ Draw a line from (X1, Y1) to (X2, Y2), and return from\n                        \\ the subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: DELAY\n\\       Type: Subroutine\n\\   Category: Utility routines\n\\    Summary: Wait for a specified time, in 1/50s of a second\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Wait for the number of vertical syncs given in Y, so this effectively waits\n\\ for Y/50 of a second (as the vertical sync occurs 50 times a second).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   Y                   The number of vertical sync events to wait for\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   DEL8                Wait for 8/50 of a second (0.16 seconds)\n\\\n\\   DELAY-5             Wait for 2/50 of a second (0.04 seconds)\n\\\n\\ ******************************************************************************\n\n LDY #2                 \\ Set Y to 2 vertical syncs\n\n EQUB &2C               \\ Skip the next instruction by turning it into\n                        \\ &2C &A0 &08, or BIT &08A0, which does nothing apart\n                        \\ from affect the flags\n\n.DEL8\n\n LDY #8                 \\ Set Y to 8 vertical syncs and fall through into DELAY\n                        \\ to wait for this long\n\n.DELAY\n\n JSR WSCAN              \\ Call WSCAN to wait for the vertical sync, so the whole\n                        \\ screen gets drawn\n\n DEY                    \\ Decrement the counter in Y\n\n BNE DELAY              \\ If Y isn't yet at zero, jump back to DELAY to wait\n                        \\ for another vertical sync\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: hm\n\\       Type: Subroutine\n\\   Category: Charts\n\\    Summary: Select the closest system and redraw the chart crosshairs\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Set the system closest to galactic coordinates (QQ9, QQ10) as the selected\n\\ system, redraw the crosshairs on the chart accordingly (if they are being\n\\ shown), and if this is not the space view, clear the bottom three text rows of\n\\ the screen.\n\\\n\\ ******************************************************************************\n\n.hm\n\n JSR TT103              \\ Draw small crosshairs at coordinates (QQ9, QQ10),\n                        \\ which will erase the crosshairs currently there\n\n JSR TT111              \\ Select the system closest to galactic coordinates\n                        \\ (QQ9, QQ10)\n\n JSR TT103              \\ Draw small crosshairs at coordinates (QQ9, QQ10),\n                        \\ which will draw the crosshairs at our current home\n                        \\ system\n\n LDA QQ11               \\ If this is a space view, return from the subroutine\n BEQ SC5                \\ (as SC5 contains an RTS)\n\n                        \\ Otherwise fall through into CLYNS to clear space at\n                        \\ the bottom of the screen\n\n\\ ******************************************************************************\n\\\n\\       Name: CLYNS\n\\       Type: Subroutine\n\\   Category: Drawing the screen\n\\    Summary: Clear the bottom three text rows of the space view\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine clears some space at the bottom of the screen and moves the text\n\\ cursor to column 1, row 20.\n\\\n\\ Specifically, it zeroes the following screen locations:\n\\\n\\   &7507 to &75F0\n\\   &7607 to &76F0\n\\   &7707 to &77F0\n\\\n\\ which clears the three bottom text rows of the mode 4 screen (rows 21 to 23),\n\\ clearing each row from text column 1 to 30 (so it doesn't overwrite the box\n\\ border in columns 0 and 32, or the last usable column in column 31).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   A                   A is set to 0\n\\\n\\   Y                   Y is set to 0\n\\\n\\ ******************************************************************************\n\n.CLYNS\n\n LDA #20                \\ Move the text cursor to row 20, near the bottom of\n STA YC                 \\ the screen\n\n LDA #&75               \\ Set the two-byte value in SC to &7507\n STA SC+1\n LDA #7\n STA SC\n\n JSR TT67               \\ Print a newline, which will move the text cursor down\n                        \\ a line (to row 21) and back to column 1\n\n LDA #0                 \\ Call LYN to clear the pixels from &7507 to &75F0\n JSR LYN\n\n INC SC+1               \\ Increment SC+1 so SC points to &7607\n\n JSR LYN                \\ Call LYN to clear the pixels from &7607 to &76F0\n\n INC SC+1               \\ Increment SC+1 so SC points to &7707\n\n INY                    \\ Move the text cursor to column 1 (as LYN sets Y to 0)\n STY XC\n\n                        \\ Fall through into LYN to clear the pixels from &7707\n                        \\ to &77F0\n\n\\ ******************************************************************************\n\\\n\\       Name: LYN\n\\       Type: Subroutine\n\\   Category: Drawing the screen\n\\    Summary: Clear most of a row of pixels\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Set pixels 0-233 to the value in A, starting at the pixel pointed to by SC.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The value to store in pixels 1-233 (the only value that\n\\                       is actually used is A = 0, which clears those pixels)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   Y                   Y is set to 0\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   SC5                 Contains an RTS\n\\\n\\ ******************************************************************************\n\n.LYN\n\n LDY #233               \\ Set up a counter in Y to count down from pixel 233\n\n.EE2\n\n STA (SC),Y             \\ Store A in the Y-th byte after the address pointed to\n                        \\ by SC\n\n DEY                    \\ Decrement Y\n\n BNE EE2                \\ Loop back until Y is zero\n\n.SC5\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: SCAN\n\\       Type: Subroutine\n\\   Category: Dashboard\n\\    Summary: Display the current ship on the scanner\n\\  Deep dive: The 3D scanner\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This is used both to display a ship on the scanner, and to erase it again.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   INWK                The ship's data block\n\\\n\\ ******************************************************************************\n\n.SCAN\n\n LDA INWK+31            \\ Fetch the ship's scanner flag from byte #31\n\n AND #%00010000         \\ If bit 4 is clear then the ship should not be shown\n BEQ SC5                \\ on the scanner, so return from the subroutine (as SC5\n                        \\ contains an RTS)\n\n LDA TYPE               \\ Fetch the ship's type from TYPE into A\n\n BMI SC5                \\ If this is the planet or the sun, then the type will\n                        \\ have bit 7 set and we don't want to display it on the\n                        \\ scanner, so return from the subroutine (as SC5\n                        \\ contains an RTS)\n\n LDX #&FF               \\ Set X to the default scanner colour of green/cyan\n                        \\ (a four-pixel mode 5 byte in colour 3)\n\n\\CMP #TGL               \\ These instructions are commented out in the original\n\\BEQ SC49               \\ source. Along with the block just below, they would\n                        \\ set X to colour 1 (red) for asteroids, cargo canisters\n                        \\ and escape pods, rather than green/cyan. Presumably\n                        \\ they decided it didn't work that well against the red\n                        \\ ellipse and took this code out for release\n\n CMP #MSL               \\ If this is not a missile, skip the following\n BNE P%+4               \\ instruction\n\n LDX #&F0               \\ This is a missile, so set X to colour 2 (yellow/white)\n\n\\CMP #AST               \\ These instructions are commented out in the original\n\\BCC P%+4               \\ source. See above for an explanation of what they do\n\\\n\\LDX #&0F\n\\\n\\.SC49\n\n STX COL                \\ Store X, the colour of this ship on the scanner, in\n                        \\ COL\n\n LDA INWK+1             \\ If any of x_hi, y_hi and z_hi have a 1 in bit 6 or 7,\n ORA INWK+4             \\ then the ship is too far away to be shown on the\n ORA INWK+7             \\ scanner, so return from the subroutine (as SC5\n AND #%11000000         \\ contains an RTS)\n BNE SC5\n\n                        \\ If we get here, we know x_hi, y_hi and z_hi are all\n                        \\ 63 (%00111111) or less\n\n                        \\ Now, we convert the x_hi coordinate of the ship into\n                        \\ the screen x-coordinate of the dot on the scanner,\n                        \\ using the following:\n                        \\\n                        \\   X1 = 123 + (x_sign x_hi)\n\n LDA INWK+1             \\ Set A = x_hi\n\n CLC                    \\ Clear the C flag so we can do addition below\n\n LDX INWK+2             \\ Set X = x_sign\n\n BPL SC2                \\ If x_sign is positive, skip the following\n\n EOR #%11111111         \\ x_sign is negative, so flip the bits in A and add 1\n ADC #1                 \\ to make it a negative number (bit 7 will now be set\n                        \\ as we confirmed above that bits 6 and 7 are clear). So\n                        \\ this gives A the sign of x_sign and gives it a value\n                        \\ range of -63 (%11000001) to 0\n\n.SC2\n\n ADC #123               \\ Set X1 = 123 + (x_sign x_hi)\n STA X1\n\n                        \\ Next, we convert the z_hi coordinate of the ship into\n                        \\ the y-coordinate of the base of the ship's stick,\n                        \\ like this:\n                        \\\n                        \\   SC = 220 - (z_sign z_hi) / 4\n                        \\\n                        \\ though the following code actually does it like this:\n                        \\\n                        \\   SC = 255 - (35 + z_hi / 4)\n\n LDA INWK+7             \\ Set A = z_hi / 4\n LSR A                  \\\n LSR A                  \\ So A is in the range 0-15\n\n CLC                    \\ Clear the C flag for the addition below\n\n LDX INWK+8             \\ Set X = z_sign\n\n BPL SC3                \\ If z_sign is positive, skip the following\n\n EOR #%11111111         \\ z_sign is negative, so flip the bits in A and set the\n SEC                    \\ C flag. As above, this makes A negative, this time\n                        \\ with a range of -16 (%11110000) to -1 (%11111111). And\n                        \\ as we are about to do an ADC, the SEC effectively adds\n                        \\ another 1 to that value, giving a range of -15 to 0\n\n.SC3\n\n ADC #35                \\ Set A = 35 + A to give a number in the range 20 to 50\n\n EOR #%11111111         \\ Flip all the bits and store in SC, so SC is in the\n STA SC                 \\ range 205 to 235, with a higher z_hi giving a lower SC\n\n                        \\ Now for the stick height, which we calculate using the\n                        \\ following:\n                        \\\n                        \\ A = - (y_sign y_hi) / 2\n\n LDA INWK+4             \\ Set A = y_hi / 2\n LSR A\n\n CLC                    \\ Clear the C flag\n\n LDX INWK+5             \\ Set X = y_sign\n\n BMI SCD6               \\ If y_sign is negative, skip the following, as we\n                        \\ already have a positive value in A\n\n EOR #%11111111         \\ y_sign is positive, so flip the bits in A and set the\n SEC                    \\ C flag. This makes A negative, and as we are about to\n                        \\ do an ADC below, the SEC effectively adds another 1 to\n                        \\ that value to implement two's complement negation, so\n                        \\ we don't need to add another 1 here\n\n.SCD6\n\n                        \\ We now have all the information we need to draw this\n                        \\ ship on the scanner, namely:\n                        \\\n                        \\   X1 = the screen x-coordinate of the ship's dot\n                        \\\n                        \\   SC = the screen y-coordinate of the base of the\n                        \\        stick\n                        \\\n                        \\   A = the screen height of the ship's stick, with the\n                        \\       correct sign for adding to the base of the stick\n                        \\       to get the dot's y-coordinate\n                        \\\n                        \\ First, though, we have to make sure the dot is inside\n                        \\ the dashboard, by moving it if necessary\n\n ADC SC                 \\ Set A = SC + A, so A now contains the y-coordinate of\n                        \\ the end of the stick, plus the length of the stick, to\n                        \\ give us the screen y-coordinate of the dot\n\n BPL ld246              \\ If the result has bit 0 clear, then the result has\n                        \\ overflowed and is bigger than 256, so jump to ld246 to\n                        \\ set A to the maximum allowed value of 246 (this\n                        \\ instruction isn't required as we test both the maximum\n                        \\ and minimum below, but it might save a few cycles)\n\n CMP #194               \\ If A >= 194, skip the following instruction, as 194 is\n BCS P%+4               \\ the minimum allowed value of A\n\n LDA #194               \\ A < 194, so set A to 194, the minimum allowed value\n                        \\ for the y-coordinate of our ship's dot\n\n CMP #247               \\ If A < 247, skip the following instruction, as 246 is\n BCC P%+4               \\ the maximum allowed value of A\n\n.ld246\n\n LDA #246               \\ A >= 247, so set A to 246, the maximum allowed value\n                        \\ for the y-coordinate of our ship's dot\n\n STA Y1                 \\ Store A in Y1, as it now contains the screen\n                        \\ y-coordinate for the ship's dot, clipped so that it\n                        \\ fits within the dashboard\n\n SEC                    \\ Set A = A - SC to get the stick length, by reversing\n SBC SC                 \\ the ADC SC we did above. This clears the C flag if the\n                        \\ result is negative (i.e. the stick length is negative)\n                        \\ and sets it if the result is positive (i.e. the stick\n                        \\ length is negative)\n\n                        \\ So now we have the following:\n                        \\\n                        \\   X1 = the screen x-coordinate of the ship's dot,\n                        \\        clipped to fit into the dashboard\n                        \\\n                        \\   Y1 = the screen y-coordinate of the ship's dot,\n                        \\        clipped to fit into the dashboard\n                        \\\n                        \\   SC = the screen y-coordinate of the base of the\n                        \\        stick\n                        \\\n                        \\   A = the screen height of the ship's stick, with the\n                        \\       correct sign for adding to the base of the stick\n                        \\       to get the dot's y-coordinate\n                        \\\n                        \\   C = 0 if A is negative, 1 if A is positive\n                        \\\n                        \\ and we can get on with drawing the dot and stick\n\n PHP                    \\ Store the flags (specifically the C flag) from the\n                        \\ above subtraction\n\n\\BCS SC48               \\ These instructions are commented out in the original\n\\EOR #&FF               \\ source. They would negate A if the C flag were set,\n\\ADC #1                 \\ which would reverse the direction of all the sticks,\n                        \\ so you could turn your joystick around. Perhaps one of\n                        \\ the authors' test sticks were easier to use upside\n                        \\ down? Who knows...\n\n.SC48\n\n PHA                    \\ Store the stick height in A on the stack\n\n JSR CPIX4              \\ Draw a double-height dot at (X1, Y1). This also leaves\n                        \\ the following variables set up for the dot's top-right\n                        \\ pixel, the last pixel to be drawn (as the dot gets\n                        \\ drawn from the bottom up):\n                        \\\n                        \\   SC(1 0) = screen address of the pixel's character\n                        \\             block\n                        \\\n                        \\   Y = number of the character row containing the pixel\n                        \\\n                        \\   X = the pixel's number (0-3) in that row\n                        \\\n                        \\ We can use there as the starting point for drawing the\n                        \\ stick, if there is one\n\n LDA CTWOS+1,X          \\ Load the same mode 5 one-pixel byte that we just used\n AND COL                \\ for the top-right pixel, and mask it with the same\n STA X1                 \\ colour, storing the result in X1, so we can use it as\n                        \\ the character row byte for the stick\n\n PLA                    \\ Restore the stick height from the stack into A\n\n PLP                    \\ Restore the flags from above, so the C flag once again\n                        \\ reflects the sign of the stick height\n\n TAX                    \\ Copy the stick height into X\n\n BEQ RTS                \\ If the stick height is zero, then there is no stick to\n                        \\ draw, so return from the subroutine (as RTS contains\n                        \\ an RTS)\n\n BCC RTS+1              \\ If the C flag is clear then the stick height in A is\n                        \\ negative, so jump down to RTS+1\n\n.VLL1\n\n                        \\ If we get here then the stick length is positive (so\n                        \\ the dot is below the ellipse and the stick is above\n                        \\ the dot, and we need to draw the stick upwards from\n                        \\ the dot)\n\n DEY                    \\ We want to draw the stick upwards, so decrement the\n                        \\ pixel row in Y\n\n BPL VL1                \\ If Y is still positive then it correctly points at the\n                        \\ line above, so jump to VL1 to skip the following\n\n LDY #7                 \\ We just decremented Y up through the top of the\n                        \\ character block, so we need to move it to the last row\n                        \\ in the character above, so set Y to 7, the number of\n                        \\ the last row\n\n DEC SC+1               \\ Decrement the high byte of the screen address to move\n                        \\ to the character block above\n\n.VL1\n\n LDA X1                 \\ Set A to the character row byte for the stick, which\n                        \\ we stored in X1 above, and which has the same pixel\n                        \\ pattern as the bottom-right pixel of the dot (so the\n                        \\ stick comes out of the right side of the dot)\n\n EOR (SC),Y             \\ Draw the stick on row Y of the character block using\n STA (SC),Y             \\ EOR logic\n\n DEX                    \\ Decrement the (positive) stick height in X\n\n BNE VLL1               \\ If we still have more stick to draw, jump up to VLL1\n                        \\ to draw the next pixel\n\n.RTS\n\n RTS                    \\ Return from the subroutine\n\n                        \\ If we get here then the stick length is negative (so\n                        \\ the dot is above the ellipse and the stick is below\n                        \\ the dot, and we need to draw the stick downwards from\n                        \\ the dot)\n\n INY                    \\ We want to draw the stick downwards, so we first\n                        \\ increment the row counter so that it's pointing to the\n                        \\ bottom-right pixel in the dot (as opposed to the top-\n                        \\ right pixel that the call to CPIX4 finished on)\n\n CPY #8                 \\ If the row number in Y is less than 8, then it\n BNE P%+6               \\ correctly points at the next line down, so jump to\n                        \\ VLL2 to skip the following\n\n LDY #0                 \\ We just incremented Y down through the bottom of the\n                        \\ character block, so we need to move it to the first\n                        \\ row in the character below, so set Y to 0, the number\n                        \\ of the first row\n\n INC SC+1               \\ Increment the high byte of the screen address to move\n                        \\ to the character block above\n\n.VLL2\n\n INY                    \\ We want to draw the stick itself, heading downwards,\n                        \\ so increment the pixel row in Y\n\n CPY #8                 \\ If the row number in Y is less than 8, then it\n BNE VL2                \\ correctly points at the next line down, so jump to\n                        \\ VL2 to skip the following\n\n LDY #0                 \\ We just incremented Y down through the bottom of the\n                        \\ character block, so we need to move it to the first\n                        \\ row in the character below, so set Y to 0, the number\n                        \\ of the first row\n\n INC SC+1               \\ Increment the high byte of the screen address to move\n                        \\ to the character block above\n\n.VL2\n\n LDA X1                 \\ Set A to the character row byte for the stick, which\n                        \\ we stored in X1 above, and which has the same pixel\n                        \\ pattern as the bottom-right pixel of the dot (so the\n                        \\ stick comes out of the right side of the dot)\n\n EOR (SC),Y             \\ Draw the stick on row Y of the character block using\n STA (SC),Y             \\ EOR logic\n\n INX                    \\ Increment the (negative) stick height in X\n\n BNE VLL2               \\ If we still have more stick to draw, jump up to VLL2\n                        \\ to draw the next pixel\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: WSCAN\n\\       Type: Subroutine\n\\   Category: Drawing the screen\n\\    Summary: Wait for the vertical sync\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Wait for vertical sync to occur on the video system - in other words, wait\n\\ for the screen to start its refresh cycle, which it does 50 times a second\n\\ (50Hz).\n\\\n\\ ******************************************************************************\n\n.WSCAN\n\n LDA #0                 \\ Set DL to 0\n STA DL\n\n LDA DL                 \\ Loop round these two instructions until DL is no\n BEQ P%-2               \\ longer 0 (DL gets set to 30 in the LINSCN routine,\n                        \\ which is run when vertical sync has occurred on the\n                        \\ video system, so DL will change to a non-zero value\n                        \\ at the start of each screen refresh)\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\ Save ELTC.bin\n\\\n\\ ******************************************************************************\n\n PRINT \"ELITE C\"\n PRINT \"Assembled at \", ~CODE_C%\n PRINT \"Ends at \", ~P%\n PRINT \"Code size is \", ~(P% - CODE_C%)\n PRINT \"Execute at \", ~LOAD%\n PRINT \"Reload at \", ~LOAD_C%\n\n PRINT \"S.ELTC \", ~CODE_C%, \" \", ~P%, \" \", ~LOAD%, \" \", ~LOAD_C%\n SAVE \"3-assembled-output/ELTC.bin\", CODE_C%, P%, LOAD%\n\n\\ ******************************************************************************\n\\\n\\ ELITE D FILE\n\\\n\\ Produces the binary file ELTD.bin that gets loaded by elite-bcfs.asm.\n\\\n\\ ******************************************************************************\n\n CODE_D% = P%\n\n LOAD_D% = LOAD% + P% - CODE%\n\n\\ ******************************************************************************\n\\\n\\       Name: tnpr\n\\       Type: Subroutine\n\\   Category: Market\n\\    Summary: Work out if we have space for a specific amount of cargo\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Given a market item and an amount, work out whether there is room in the\n\\ cargo hold for this item.\n\\\n\\ For standard tonne canisters, the limit is given by the type of cargo hold we\n\\ have, with a standard cargo hold having a capacity of 20t and an extended\n\\ cargo bay being 35t.\n\\\n\\ For items measured in kg (gold, platinum), g (gem-stones) and alien items,\n\\ the individual limit on each of these is 200 units.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The number of units of this market item\n\\\n\\   QQ29                The type of market item (see QQ23 for a list of market\n\\                       item numbers)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   A                   A is preserved\n\\\n\\   C flag              Returns the result:\n\\\n\\                         * Set if there is no room for this item\n\\\n\\                         * Clear if there is room for this item\n\\\n\\ ******************************************************************************\n\n.tnpr\n\n PHA                    \\ Store A on the stack\n\n LDX #12                \\ If QQ29 > 12 then jump to kg below, as this cargo\n CPX QQ29               \\ type is gold, platinum, gem-stones or alien items,\n BCC kg                 \\ and they have different cargo limits to the standard\n                        \\ tonne canisters\n\n.Tml\n\n                        \\ Here we count the tonne canisters we have in the hold\n                        \\ and add to A to see if we have enough room for A more\n                        \\ tonnes of cargo, using X as the loop counter, starting\n                        \\ with X = 12\n\n ADC QQ20,X             \\ Set A = A + the number of tonnes we have in the hold\n                        \\ of market item number X. Note that the first time we\n                        \\ go round this loop, the C flag is set (as we didn't\n                        \\ branch with the BCC above, so the effect of this loop\n                        \\ is to count the number of tonne canisters in the hold,\n                        \\ and add 1\n\n DEX                    \\ Decrement the loop counter\n\n BPL Tml                \\ Loop back to add in the next market item in the hold,\n                        \\ until we have added up all market items from 12\n                        \\ (minerals) down to 0 (food)\n\n CMP CRGO               \\ If A < CRGO then the C flag will be clear (we have\n                        \\ room in the hold)\n                        \\\n                        \\ If A >= CRGO then the C flag will be set (we do not\n                        \\ have room in the hold)\n                        \\\n                        \\ This works because A contains the number of canisters\n                        \\ plus 1, while CRGO contains our cargo capacity plus 2,\n                        \\ so if we actually have \"a\" canisters and a capacity\n                        \\ of \"c\", then:\n                        \\\n                        \\ A < CRGO means: a+1 <  c+2\n                        \\                 a   <  c+1\n                        \\                 a   <= c\n                        \\\n                        \\ So this is why the value in CRGO is 2 higher than the\n                        \\ actual cargo bay size, i.e. it's 22 for the standard\n                        \\ 20-tonne bay, and 37 for the large 35-tonne bay\n\n PLA                    \\ Restore A from the stack\n\n RTS                    \\ Return from the subroutine\n\n.kg\n\n                        \\ Here we count the number of items of this type that\n                        \\ we already have in the hold, and add to A to see if\n                        \\ we have enough room for A more units\n\n LDY QQ29               \\ Set Y to the item number we want to add\n\n ADC QQ20,Y             \\ Set A = A + the number of units of this item that we\n                        \\ already have in the hold\n\n CMP #200               \\ Is the result greater than 200 (the limit on\n                        \\ individual stocks of gold, platinum, gem-stones and\n                        \\ alien items)?\n                        \\\n                        \\ If so, this sets the C flag (no room)\n                        \\\n                        \\ Otherwise it is clear (we have room)\n\n PLA                    \\ Restore A from the stack\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: TT20\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Twist the selected system's seeds four times\n\\  Deep dive: Twisting the system seeds\n\\             Galaxy and system seeds\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Twist the three 16-bit seeds in QQ15 (selected system) four times, to\n\\ generate the next system.\n\\\n\\ ******************************************************************************\n\n.TT20\n\n JSR P%+3               \\ This line calls the line below as a subroutine, which\n                        \\ does two twists before returning here, and then we\n                        \\ fall through to the line below for another two\n                        \\ twists, so the net effect of these two consecutive\n                        \\ JSR calls is four twists, not counting the ones\n                        \\ inside your head as you try to follow this process\n\n JSR P%+3               \\ This line calls TT54 as a subroutine to do a twist,\n                        \\ and then falls through into TT54 to do another twist\n                        \\ before returning from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: TT54\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Twist the selected system's seeds\n\\  Deep dive: Twisting the system seeds\n\\             Galaxy and system seeds\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine twists the three 16-bit seeds in QQ15 once.\n\\\n\\ If we start with seeds s0, s1 and s2 and we want to work out their new values\n\\ after we perform a twist (let's call the new values s0´, s1´ and s2´), then:\n\\\n\\  s0´ = s1\n\\  s1´ = s2\n\\  s2´ = s0 + s1 + s2\n\\\n\\ So given an existing set of seeds in s0, s1 and s2, we can get the new values\n\\ s0´, s1´ and s2´ simply by doing the above sums. And if we want to do the\n\\ above in-place without creating three new s´ variables, then we can do the\n\\ following:\n\\\n\\  tmp = s0 + s1\n\\  s0 = s1\n\\  s1 = s2\n\\  s2 = tmp + s1\n\\\n\\ So this is what we do in this routine, where each seed is a 16-bit number.\n\\\n\\ ******************************************************************************\n\n.TT54\n\n LDA QQ15               \\ X = tmp_lo = s0_lo + s1_lo\n CLC\n ADC QQ15+2\n TAX\n\n LDA QQ15+1             \\ Y = tmp_hi = s1_hi + s1_hi + C\n ADC QQ15+3\n TAY\n\n LDA QQ15+2             \\ s0_lo = s1_lo\n STA QQ15\n\n LDA QQ15+3             \\ s0_hi = s1_hi\n STA QQ15+1\n\n LDA QQ15+5             \\ s1_hi = s2_hi\n STA QQ15+3\n\n LDA QQ15+4             \\ s1_lo = s2_lo\n STA QQ15+2\n\n CLC                    \\ s2_lo = X + s1_lo\n TXA\n ADC QQ15+2\n STA QQ15+4\n\n TYA                    \\ s2_hi = Y + s1_hi + C\n ADC QQ15+3\n STA QQ15+5\n\n RTS                    \\ The twist is complete so return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: TT146\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Print the distance to the selected system in light years\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ If it is non-zero, print the distance to the selected system in light years.\n\\ If it is zero, just move the text cursor down a line.\n\\\n\\ Specifically, if the distance in QQ8 is non-zero, print token 31 (\"DISTANCE\"),\n\\ then a colon, then the distance to one decimal place, then token 35 (\"LIGHT\n\\ YEARS\"). If the distance is zero, move the cursor down one line.\n\\\n\\ ******************************************************************************\n\n.TT146\n\n LDA QQ8                \\ Take the two bytes of the 16-bit value in QQ8 and\n ORA QQ8+1              \\ OR them together to check whether there are any\n BNE TT63               \\ non-zero bits, and if so, jump to TT63 to print the\n                        \\ distance\n\n INC YC                 \\ The distance is zero, so we just move the text cursor\n RTS                    \\ in YC down by one line and return from the subroutine\n\n.TT63\n\n LDA #191               \\ Print recursive token 31 (\"DISTANCE\") followed by\n JSR TT68               \\ a colon\n\n LDX QQ8                \\ Load (Y X) from QQ8, which contains the 16-bit\n LDY QQ8+1              \\ distance we want to show\n\n SEC                    \\ Set the C flag so that the call to pr5 will include a\n                        \\ decimal point, and display the value as (Y X) / 10\n\n JSR pr5                \\ Print (Y X) to 5 digits, including a decimal point\n\n LDA #195               \\ Set A to the recursive token 35 (\" LIGHT YEARS\") and\n                        \\ fall through into TT60 to print the token followed\n                        \\ by a paragraph break\n\n\\ ******************************************************************************\n\\\n\\       Name: TT60\n\\       Type: Subroutine\n\\   Category: Text\n\\    Summary: Print a text token and a paragraph break\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Print a text token (i.e. a character, control code, two-letter token or\n\\ recursive token). Then print a paragraph break (a blank line between\n\\ paragraphs) by moving the cursor down a line, setting Sentence Case, and then\n\\ printing a newline.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The text token to be printed\n\\\n\\ ******************************************************************************\n\n.TT60\n\n JSR TT27               \\ Print the text token in A and fall through into TTX69\n                        \\ to print the paragraph break\n\n\\ ******************************************************************************\n\\\n\\       Name: TTX69\n\\       Type: Subroutine\n\\   Category: Text\n\\    Summary: Print a paragraph break\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Print a paragraph break (a blank line between paragraphs) by moving the cursor\n\\ down a line, setting Sentence Case, and then printing a newline.\n\\\n\\ ******************************************************************************\n\n.TTX69\n\n INC YC                 \\ Move the text cursor down a line\n\n                        \\ Fall through into TT69 to set Sentence Case and print\n                        \\ a newline\n\n\\ ******************************************************************************\n\\\n\\       Name: TT69\n\\       Type: Subroutine\n\\   Category: Text\n\\    Summary: Set Sentence Case and print a newline\n\\\n\\ ******************************************************************************\n\n.TT69\n\n LDA #%10000000         \\ Set bit 7 of QQ17 to switch to Sentence Case\n STA QQ17\n\n                        \\ Fall through into TT67 to print a newline\n\n\\ ******************************************************************************\n\\\n\\       Name: TT67\n\\       Type: Subroutine\n\\   Category: Text\n\\    Summary: Print a newline\n\\\n\\ ******************************************************************************\n\n.TT67\n\n LDA #13                \\ Load a newline character into A\n\n JMP TT27               \\ Print the text token in A and return from the\n                        \\ subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: TT70\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Display \"MAINLY \" and jump to TT72\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This subroutine is called by TT25 when displaying a system's economy.\n\\\n\\ ******************************************************************************\n\n.TT70\n\n LDA #173               \\ Print recursive token 13 (\"MAINLY \")\n JSR TT27\n\n JMP TT72               \\ Jump to TT72 to continue printing system data as part\n                        \\ of routine TT25\n\n\\ ******************************************************************************\n\\\n\\       Name: spc\n\\       Type: Subroutine\n\\   Category: Text\n\\    Summary: Print a text token followed by a space\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Print a text token (i.e. a character, control code, two-letter token or\n\\ recursive token) followed by a space.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The text token to be printed\n\\\n\\ ******************************************************************************\n\n.spc\n\n JSR TT27               \\ Print the text token in A\n\n JMP TT162              \\ Print a space and return from the subroutine using a\n                        \\ tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: TT25\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Show the Data on System screen (red key f6)\n\\  Deep dive: Generating system data\n\\             Galaxy and system seeds\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   TT72                Used by TT70 to re-enter the routine after displaying\n\\                       \"MAINLY\" for the economy type\n\\\n\\ ******************************************************************************\n\n.TT25\n\n JSR TT66-2             \\ Clear the top part of the screen, draw a border box,\n                        \\ and set the current view type in QQ11 to 1\n\n LDA #9                 \\ Move the text cursor to column 9\n STA XC\n\n LDA #163               \\ Print recursive token 3 as a title in capitals at\n JSR TT27               \\ the top (\"DATA ON {selected system name}\")\n\n JSR NLIN               \\ Draw a horizontal line underneath the title\n\n JSR TTX69              \\ Print a paragraph break and set Sentence Case\n\n INC YC                 \\ Move the text cursor down one more line\n\n JSR TT146              \\ If the distance to this system is non-zero, print\n                        \\ \"DISTANCE\", then the distance, \"LIGHT YEARS\" and a\n                        \\ paragraph break, otherwise just move the cursor down\n                        \\ a line\n\n LDA #194               \\ Print recursive token 34 (\"ECONOMY\") followed by\n JSR TT68               \\ a colon\n\n LDA QQ3                \\ The system economy is determined by the value in QQ3,\n                        \\ so fetch it into A. First we work out the system's\n                        \\ prosperity as follows:\n                        \\\n                        \\   QQ3 = 0 or 5 = %000 or %101 = Rich\n                        \\   QQ3 = 1 or 6 = %001 or %110 = Average\n                        \\   QQ3 = 2 or 7 = %010 or %111 = Poor\n                        \\   QQ3 = 3 or 4 = %011 or %100 = Mainly\n\n CLC                    \\ If (QQ3 + 1) >> 1 = %10, i.e. if QQ3 = %011 or %100\n ADC #1                 \\ (3 or 4), then call TT70, which prints \"MAINLY \" and\n LSR A                  \\ jumps down to TT72 to print the type of economy\n CMP #%00000010\n BEQ TT70\n\n LDA QQ3                \\ If (QQ3 + 1) >> 1 < %10, i.e. if QQ3 = %000, %001 or\n BCC TT71               \\ %010 (0, 1 or 2), then jump to TT71 with A set to the\n                        \\ original value of QQ3\n\n SBC #5                 \\ Here QQ3 = %101, %110 or %111 (5, 6 or 7), so subtract\n CLC                    \\ 5 to bring it down to 0, 1 or 2 (the C flag is already\n                        \\ set so the SBC will be correct)\n\n.TT71\n\n ADC #170               \\ A is now 0, 1 or 2, so print recursive token 10 + A.\n JSR TT27               \\ This means that:\n                        \\\n                        \\   QQ3 = 0 or 5 prints token 10 (\"RICH \")\n                        \\   QQ3 = 1 or 6 prints token 11 (\"AVERAGE \")\n                        \\   QQ3 = 2 or 7 prints token 12 (\"POOR \")\n\n.TT72\n\n LDA QQ3                \\ Now to work out the type of economy, which is\n LSR A                  \\ determined by bit 2 of QQ3, as follows:\n LSR A                  \\\n                        \\   QQ3 bit 2 = 0 = Industrial\n                        \\   QQ3 bit 2 = 1 = Agricultural\n                        \\\n                        \\ So we fetch QQ3 into A and set A = bit 2 of QQ3 using\n                        \\ two right shifts (which will work as QQ3 is only a\n                        \\ 3-bit number)\n\n CLC                    \\ Print recursive token 8 + A, followed by a paragraph\n ADC #168               \\ break and Sentence Case, so:\n JSR TT60               \\\n                        \\   QQ3 bit 2 = 0 prints token 8 (\"INDUSTRIAL\")\n                        \\   QQ3 bit 2 = 1 prints token 9 (\"AGRICULTURAL\")\n\n LDA #162               \\ Print recursive token 2 (\"GOVERNMENT\") followed by\n JSR TT68               \\ a colon\n\n LDA QQ4                \\ The system's government is determined by the value in\n                        \\ QQ4, so fetch it into A\n\n CLC                    \\ Print recursive token 17 + A, followed by a paragraph\n ADC #177               \\ break and Sentence Case, so:\n JSR TT60               \\\n                        \\   QQ4 = 0 prints token 17 (\"ANARCHY\")\n                        \\   QQ4 = 1 prints token 18 (\"FEUDAL\")\n                        \\   QQ4 = 2 prints token 19 (\"MULTI-GOVERNMENT\")\n                        \\   QQ4 = 3 prints token 20 (\"DICTATORSHIP\")\n                        \\   QQ4 = 4 prints token 21 (\"COMMUNIST\")\n                        \\   QQ4 = 5 prints token 22 (\"CONFEDERACY\")\n                        \\   QQ4 = 6 prints token 23 (\"DEMOCRACY\")\n                        \\   QQ4 = 7 prints token 24 (\"CORPORATE STATE\")\n\n LDA #196               \\ Print recursive token 36 (\"TECH.LEVEL\") followed by a\n JSR TT68               \\ colon\n\n LDX QQ5                \\ Fetch the tech level from QQ5 and increment it, as it\n INX                    \\ is stored in the range 0-14 but the displayed range\n                        \\ should be 1-15\n\n CLC                    \\ Call pr2 to print the technology level as a\n JSR pr2                \\ three-digit number without a decimal point (by\n                        \\ clearing the C flag)\n\n JSR TTX69              \\ Print a paragraph break and set Sentence Case\n\n LDA #192               \\ Print recursive token 32 (\"POPULATION\") followed by a\n JSR TT68               \\ colon\n\n SEC                    \\ Call pr2 to print the population as a three-digit\n LDX QQ6                \\ number with a decimal point (by setting the C flag),\n JSR pr2                \\ so the number printed will be population / 10\n\n LDA #198               \\ Print recursive token 38 (\" BILLION\"), followed by a\n JSR TT60               \\ paragraph break and Sentence Case\n\n LDA #'('               \\ Print an opening bracket\n JSR TT27\n\n LDA QQ15+4             \\ Now to calculate the species, so first check bit 7 of\n BMI TT75               \\ s2_lo, and if it is set, jump to TT75 as this is an\n                        \\ alien species\n\n LDA #188               \\ Bit 7 of s2_lo is clear, so print recursive token 28\n JSR TT27               \\ (\"HUMAN COLONIAL\")\n\n JMP TT76               \\ Jump to TT76 to print \"S)\" and a paragraph break, so\n                        \\ the whole species string is \"(HUMAN COLONIALS)\"\n\n.TT75\n\n LDA QQ15+5             \\ This is an alien species, and we start with the first\n LSR A                  \\ adjective, so fetch bits 2-7 of s2_hi into A and push\n LSR A                  \\ onto the stack so we can use this later\n PHA\n\n AND #%00000111         \\ Set A = bits 0-2 of A (so that's bits 2-4 of s2_hi)\n\n CMP #3                 \\ If A >= 3, jump to TT205 to skip the first adjective,\n BCS TT205\n\n ADC #227               \\ Otherwise A = 0, 1 or 2, so print recursive token\n JSR spc                \\ 67 + A, followed by a space, so:\n                        \\\n                        \\   A = 0 prints token 67 (\"LARGE\") and a space\n                        \\   A = 1 prints token 68 (\"FIERCE\") and a space\n                        \\   A = 2 prints token 69 (\"SMALL\") and a space\n\n.TT205\n\n PLA                    \\ Now for the second adjective, so restore A to bits\n LSR A                  \\ 2-7 of s2_hi, and throw away bits 2-4 to leave\n LSR A                  \\ A = bits 5-7 of s2_hi\n LSR A\n\n CMP #6                 \\ If A >= 6, jump to TT206 to skip the second adjective\n BCS TT206\n\n ADC #230               \\ Otherwise A = 0 to 5, so print recursive token\n JSR spc                \\ 70 + A, followed by a space, so:\n                        \\\n                        \\   A = 0 prints token 70 (\"GREEN\") and a space\n                        \\   A = 1 prints token 71 (\"RED\") and a space\n                        \\   A = 2 prints token 72 (\"YELLOW\") and a space\n                        \\   A = 3 prints token 73 (\"BLUE\") and a space\n                        \\   A = 4 prints token 74 (\"BLACK\") and a space\n                        \\   A = 5 prints token 75 (\"HARMLESS\") and a space\n\n.TT206\n\n LDA QQ15+3             \\ Now for the third adjective, so EOR the high bytes of\n EOR QQ15+1             \\ s0 and s1 and extract bits 0-2 of the result:\n AND #%00000111         \\\n STA QQ19               \\   A = (s0_hi EOR s1_hi) AND %111\n                        \\\n                        \\ storing the result in QQ19 so we can use it later\n\n CMP #6                 \\ If A >= 6, jump to TT207 to skip the third adjective\n BCS TT207\n\n ADC #236               \\ Otherwise A = 0 to 5, so print recursive token\n JSR spc                \\ 76 + A, followed by a space, so:\n                        \\\n                        \\   A = 0 prints token 76 (\"SLIMY\") and a space\n                        \\   A = 1 prints token 77 (\"BUG-EYED\") and a space\n                        \\   A = 2 prints token 78 (\"HORNED\") and a space\n                        \\   A = 3 prints token 79 (\"BONY\") and a space\n                        \\   A = 4 prints token 80 (\"FAT\") and a space\n                        \\   A = 5 prints token 81 (\"FURRY\") and a space\n\n.TT207\n\n LDA QQ15+5             \\ Now for the actual species, so take bits 0-1 of\n AND #%00000011         \\ s2_hi, add this to the value of A that we used for\n CLC                    \\ the third adjective, and take bits 0-2 of the result\n ADC QQ19\n AND #%00000111\n\n ADC #242               \\ A = 0 to 7, so print recursive token 82 + A, so:\n JSR TT27               \\\n                        \\   A = 0 prints token 82 (\"RODENT\")\n                        \\   A = 1 prints token 83 (\"FROG\")\n                        \\   A = 2 prints token 84 (\"LIZARD\")\n                        \\   A = 3 prints token 85 (\"LOBSTER\")\n                        \\   A = 4 prints token 86 (\"BIRD\")\n                        \\   A = 5 prints token 87 (\"HUMANOID\")\n                        \\   A = 6 prints token 88 (\"FELINE\")\n                        \\   A = 7 prints token 89 (\"INSECT\")\n\n.TT76\n\n LDA #'S'               \\ Print an \"S\" to pluralise the species\n JSR TT27\n\n LDA #')'               \\ And finally, print a closing bracket, followed by a\n JSR TT60               \\ paragraph break and Sentence Case, to end the species\n                        \\ section\n\n LDA #193               \\ Print recursive token 33 (\"GROSS PRODUCTIVITY\"),\n JSR TT68               \\ followed by a colon\n\n LDX QQ7                \\ Fetch the 16-bit productivity value from QQ7 into\n LDY QQ7+1              \\ (Y X)\n\n JSR pr6                \\ Print (Y X) to 5 digits with no decimal point\n\n JSR TT162              \\ Print a space\n\n LDA #0                 \\ Set QQ17 = 0 to switch to ALL CAPS\n STA QQ17\n\n LDA #'M'               \\ Print \"M\"\n JSR TT27\n\n LDA #226               \\ Print recursive token 66 (\" CR\"), followed by a\n JSR TT60               \\ paragraph break and Sentence Case\n\n LDA #250               \\ Print recursive token 90 (\"AVERAGE RADIUS\"), followed\n JSR TT68               \\ by a colon\n\n                        \\ The average radius is calculated like this:\n                        \\\n                        \\   ((s2_hi AND %1111) + 11) * 256 + s1_hi\n                        \\\n                        \\ or, in terms of memory locations:\n                        \\\n                        \\   ((QQ15+5 AND %1111) + 11) * 256 + QQ15+3\n                        \\\n                        \\ Because the multiplication is by 256, this is the\n                        \\ same as saying a 16-bit number, with high byte:\n                        \\\n                        \\   (QQ15+5 AND %1111) + 11\n                        \\\n                        \\ and low byte:\n                        \\\n                        \\   QQ15+3\n                        \\\n                        \\ so we can set this up in (Y X) and call the pr5\n                        \\ routine to print it out\n\n LDA QQ15+5             \\ Set A = QQ15+5\n LDX QQ15+3             \\ Set X = QQ15+3\n\n AND #%00001111         \\ Set Y = (A AND %1111) + 11\n CLC\n ADC #11\n TAY\n\n JSR pr5                \\ Print (Y X) to 5 digits, not including a decimal\n                        \\ point, as the C flag will be clear (as the maximum\n                        \\ radius will always fit into 16 bits)\n\n JSR TT162              \\ Print a space\n\n LDA #'k'               \\ Print \"km\", returning from the subroutine using a\n JSR TT26               \\ tail call\n LDA #'m'\n JMP TT26\n\n\\ ******************************************************************************\n\\\n\\       Name: TT24\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Calculate system data from the system seeds\n\\  Deep dive: Generating system data\n\\             Galaxy and system seeds\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate system data from the seeds in QQ15 and store them in the relevant\n\\ locations. Specifically, this routine calculates the following from the three\n\\ 16-bit seeds in QQ15 (using only s0_hi, s1_hi and s1_lo):\n\\\n\\   QQ3 = economy (0-7)\n\\   QQ4 = government (0-7)\n\\   QQ5 = technology level (0-14)\n\\   QQ6 = population * 10 (1-71)\n\\   QQ7 = productivity (96-62480)\n\\\n\\ The ranges of the various values are shown in brackets. Note that the radius\n\\ and type of inhabitant are calculated on-the-fly in the TT25 routine when\n\\ the system data gets displayed, so they aren't calculated here.\n\\\n\\ ******************************************************************************\n\n.TT24\n\n LDA QQ15+1             \\ Fetch s0_hi and extract bits 0-2 to determine the\n AND #%00000111         \\ system's economy, and store in QQ3\n STA QQ3\n\n LDA QQ15+2             \\ Fetch s1_lo and extract bits 3-5 to determine the\n LSR A                  \\ system's government, and store in QQ4\n LSR A\n LSR A\n AND #%00000111\n STA QQ4\n\n LSR A                  \\ If government isn't anarchy or feudal, skip to TT77,\n BNE TT77               \\ as we need to fix the economy of anarchy and feudal\n                        \\ systems so they can't be rich\n\n LDA QQ3                \\ Set bit 1 of the economy in QQ3 to fix the economy\n ORA #%00000010         \\ for anarchy and feudal governments\n STA QQ3\n\n.TT77\n\n LDA QQ3                \\ Now to work out the tech level, which we do like this:\n EOR #%00000111         \\\n CLC                    \\   flipped_economy + (s1_hi AND %11) + (government / 2)\n STA QQ5                \\\n                        \\ or, in terms of memory locations:\n                        \\\n                        \\   QQ5 = (QQ3 EOR %111) + (QQ15+3 AND %11) + (QQ4 / 2)\n                        \\\n                        \\ We start by setting QQ5 = QQ3 EOR %111\n\n LDA QQ15+3             \\ We then take the first 2 bits of s1_hi (QQ15+3) and\n AND #%00000011         \\ add it into QQ5\n ADC QQ5\n STA QQ5\n\n LDA QQ4                \\ And finally we add QQ4 / 2 and store the result in\n LSR A                  \\ QQ5, using LSR then ADC to divide by 2, which rounds\n ADC QQ5                \\ up the result for odd-numbered government types\n STA QQ5\n\n ASL A                  \\ Now to work out the population, like so:\n ASL A                  \\\n ADC QQ3                \\   (tech level * 4) + economy + government + 1\n ADC QQ4                \\\n ADC #1                 \\ or, in terms of memory locations:\n STA QQ6                \\\n                        \\   QQ6 = (QQ5 * 4) + QQ3 + QQ4 + 1\n\n LDA QQ3                \\ Finally, we work out productivity, like this:\n EOR #%00000111         \\\n ADC #3                 \\  (flipped_economy + 3) * (government + 4)\n STA P                  \\                        * population\n LDA QQ4                \\                        * 8\n ADC #4                 \\\n STA Q                  \\ or, in terms of memory locations:\n JSR MULTU              \\\n                        \\   QQ7 = (QQ3 EOR %111 + 3) * (QQ4 + 4) * QQ6 * 8\n                        \\\n                        \\ We do the first step by setting P to the first\n                        \\ expression in brackets and Q to the second, and\n                        \\ calling MULTU, so now (A P) = P * Q. The highest this\n                        \\ can be is 10 * 11 (as the maximum values of economy\n                        \\ and government are 7), so the high byte of the result\n                        \\ will always be 0, so we actually have:\n                        \\\n                        \\   P = P * Q\n                        \\     = (flipped_economy + 3) * (government + 4)\n\n LDA QQ6                \\ We now take the result in P and multiply by the\n STA Q                  \\ population to get the productivity, by setting Q to\n JSR MULTU              \\ the population from QQ6 and calling MULTU again, so\n                        \\ now we have:\n                        \\\n                        \\   (A P) = P * population\n\n ASL P                  \\ Next we multiply the result by 8, as a 16-bit number,\n ROL A                  \\ so we shift both bytes to the left three times, using\n ASL P                  \\ the C flag to carry bits from bit 7 of the low byte\n ROL A                  \\ into bit 0 of the high byte\n ASL P\n ROL A\n\n STA QQ7+1              \\ Finally, we store the productivity in two bytes, with\n LDA P                  \\ the low byte in QQ7 and the high byte in QQ7+1\n STA QQ7\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: TT22\n\\       Type: Subroutine\n\\   Category: Charts\n\\    Summary: Show the Long-range Chart (red key f4)\n\\  Deep dive: A sense of scale\n\\\n\\ ******************************************************************************\n\n.TT22\n\n LDA #64                \\ Clear the top part of the screen, draw a border box,\n JSR TT66               \\ and set the current view type in QQ11 to 32 (Long-\n                        \\ range Chart)\n\n LDA #7                 \\ Move the text cursor to column 7\n STA XC\n\n JSR TT81               \\ Set the seeds in QQ15 to those of system 0 in the\n                        \\ current galaxy (i.e. copy the seeds from QQ21 to QQ15)\n\n LDA #199               \\ Print recursive token 39 (\"GALACTIC CHART{galaxy\n JSR TT27               \\ number right-aligned to width 3}\")\n\n JSR NLIN               \\ Draw a horizontal line at pixel row 23 to box in the\n                        \\ title and act as the top frame of the chart, and move\n                        \\ the text cursor down one line\n\n LDA #152               \\ Draw a screen-wide horizontal line at pixel row 152\n JSR NLIN2              \\ for the bottom edge of the chart, so the chart itself\n                        \\ is 128 pixels high, starting on row 24 and ending on\n                        \\ row 151\n\n JSR TT14               \\ Call TT14 to draw a circle with crosshairs at the\n                        \\ current system's galactic coordinates\n\n LDX #0                 \\ We're now going to plot each of the galaxy's systems,\n                        \\ so set up a counter in X for each system, starting at\n                        \\ 0 and looping through to 255\n\n.TT83\n\n STX XSAV               \\ Store the counter in XSAV\n\n LDX QQ15+3             \\ Fetch the s1_hi seed into X, which gives us the\n                        \\ galactic x-coordinate of this system\n\n LDY QQ15+4             \\ Fetch the s2_lo seed and set bits 4 and 6, storing the\n TYA                    \\ result in ZZ to give a random number between 80 and\n ORA #%01010000         \\ (but which will always be the same for this system).\n STA ZZ                 \\ We use this value to determine the size of the point\n                        \\ for this system on the chart by passing it as the\n                        \\ distance argument to the PIXEL routine below\n\n LDA QQ15+1             \\ Fetch the s0_hi seed into A, which gives us the\n                        \\ galactic y-coordinate of this system\n\n LSR A                  \\ We halve the y-coordinate because the galaxy in\n                        \\ in Elite is rectangular rather than square, and is\n                        \\ twice as wide (x-axis) as it is high (y-axis), so the\n                        \\ chart is 256 pixels wide and 128 high\n\n CLC                    \\ Add 24 to the halved y-coordinate and store in XX15+1\n ADC #24                \\ (as the top of the chart is on pixel row 24, just\n STA XX15+1             \\ below the line we drew on row 23 above)\n\n JSR PIXEL              \\ Call PIXEL to draw a point at (X, A), with the size of\n                        \\ the point dependent on the distance specified in ZZ\n                        \\ (so a high value of ZZ will produce a one-pixel point,\n                        \\ a medium value will produce a two-pixel dash, and a\n                        \\ small value will produce a four-pixel square)\n\n JSR TT20               \\ We want to move on to the next system, so call TT20\n                        \\ to twist the three 16-bit seeds in QQ15\n\n LDX XSAV               \\ Restore the loop counter from XSAV\n\n INX                    \\ Increment the counter\n\n BNE TT83               \\ If X > 0 then we haven't done all 256 systems yet, so\n                        \\ loop back up to TT83\n\n LDA QQ9                \\ Set QQ19 to the selected system's x-coordinate\n STA QQ19\n\n LDA QQ10               \\ Set QQ19+1 to the selected system's y-coordinate,\n LSR A                  \\ halved to fit it into the chart\n STA QQ19+1\n\n LDA #4                 \\ Set QQ19+2 to size 4 for the crosshairs size\n STA QQ19+2\n\n                        \\ Fall through into TT15 to draw crosshairs of size 4 at\n                        \\ the selected system's coordinates\n\n\\ ******************************************************************************\n\\\n\\       Name: TT15\n\\       Type: Subroutine\n\\   Category: Drawing lines\n\\    Summary: Draw a set of crosshairs\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ For all views except the Short-range Chart, the centre is drawn 24 pixels to\n\\ the right of the y-coordinate given.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   QQ19                The pixel x-coordinate of the centre of the crosshairs\n\\\n\\   QQ19+1              The pixel y-coordinate of the centre of the crosshairs\n\\\n\\   QQ19+2              The size of the crosshairs\n\\\n\\ ******************************************************************************\n\n.TT15\n\n LDA #24                \\ Set A to 24, which we will use as the minimum\n                        \\ screen indent for the crosshairs (i.e. the minimum\n                        \\ distance from the top-left corner of the screen)\n\n LDX QQ11               \\ If the current view is not the Short-range Chart,\n BPL P%+4               \\ which is the only view with bit 7 set, then skip the\n                        \\ following instruction\n\n LDA #0                 \\ This is the Short-range Chart, so set A to 0, so the\n                        \\ crosshairs can go right up against the screen edges\n\n STA QQ19+5             \\ Set QQ19+5 to A, which now contains the correct indent\n                        \\ for this view\n\n LDA QQ19               \\ Set A = crosshairs x-coordinate - crosshairs size\n SEC                    \\ to get the x-coordinate of the left edge of the\n SBC QQ19+2             \\ crosshairs\n\n BCS TT84               \\ If the above subtraction didn't underflow, then A is\n                        \\ positive, so skip the next instruction\n\n LDA #0                 \\ The subtraction underflowed, so set A to 0 so the\n                        \\ crosshairs don't spill out of the left of the screen\n\n.TT84\n\n                        \\ In the following, the authors have used XX15 for\n                        \\ temporary storage. XX15 shares location with X1, Y1,\n                        \\ X2 and Y2, so in the following, you can consider\n                        \\ the variables like this:\n                        \\\n                        \\   XX15   is the same as X1\n                        \\   XX15+1 is the same as Y1\n                        \\   XX15+2 is the same as X2\n                        \\   XX15+3 is the same as Y2\n                        \\\n                        \\ Presumably this routine was written at a different\n                        \\ time to the line-drawing routine, before the two\n                        \\ workspaces were merged to save space\n\n STA XX15               \\ Set XX15 (X1) = A (the x-coordinate of the left edge\n                        \\ of the crosshairs)\n\n LDA QQ19               \\ Set A = crosshairs x-coordinate + crosshairs size\n CLC                    \\ to get the x-coordinate of the right edge of the\n ADC QQ19+2             \\ crosshairs\n\n BCC P%+4               \\ If the above addition didn't overflow, then A is\n                        \\ correct, so skip the next instruction\n\n LDA #255               \\ The addition overflowed, so set A to 255 so the\n                        \\ crosshairs don't spill out of the right of the screen\n                        \\ (as 255 is the x-coordinate of the rightmost pixel\n                        \\ on-screen)\n\n STA XX15+2             \\ Set XX15+2 (X2) = A (the x-coordinate of the right\n                        \\ edge of the crosshairs)\n\n LDA QQ19+1             \\ Set XX15+1 (Y1) = crosshairs y-coordinate + indent\n CLC                    \\ to get the y-coordinate of the centre of the\n ADC QQ19+5             \\ crosshairs\n STA XX15+1\n\n JSR HLOIN              \\ Draw a horizontal line from (X1, Y1) to (X2, Y1),\n                        \\ which will draw from the left edge of the crosshairs\n                        \\ to the right edge, through the centre of the\n                        \\ crosshairs\n\n LDA QQ19+1             \\ Set A = crosshairs y-coordinate - crosshairs size\n SEC                    \\ to get the y-coordinate of the top edge of the\n SBC QQ19+2             \\ crosshairs\n\n BCS TT86               \\ If the above subtraction didn't underflow, then A is\n                        \\ correct, so skip the next instruction\n\n LDA #0                 \\ The subtraction underflowed, so set A to 0 so the\n                        \\ crosshairs don't spill out of the top of the screen\n\n.TT86\n\n CLC                    \\ Set XX15+1 (Y1) = A + indent to get the y-coordinate\n ADC QQ19+5             \\ of the top edge of the indented crosshairs\n STA XX15+1\n\n LDA QQ19+1             \\ Set A = crosshairs y-coordinate + crosshairs size\n CLC                    \\ + indent to get the y-coordinate of the bottom edge\n ADC QQ19+2             \\ of the indented crosshairs\n ADC QQ19+5\n\n CMP #152               \\ If A < 152 then skip the following, as the crosshairs\n BCC TT87               \\ won't spill out of the bottom of the screen\n\n LDX QQ11               \\ A >= 152, so we need to check whether this will fit in\n                        \\ this view, so fetch the view type\n\n BMI TT87               \\ If this is the Short-range Chart then the y-coordinate\n                        \\ is fine, so skip to TT87\n\n LDA #151               \\ Otherwise this is the Long-range Chart, so we need to\n                        \\ clip the crosshairs at a maximum y-coordinate of 151\n\n.TT87\n\n STA XX15+3             \\ Set XX15+3 (Y2) = A (the y-coordinate of the bottom\n                        \\ edge of the crosshairs)\n\n LDA QQ19               \\ Set XX15 (X1) = the x-coordinate of the centre of the\n STA XX15               \\ crosshairs\n\n STA XX15+2             \\ Set XX15+2 (X2) = the x-coordinate of the centre of\n                        \\ the crosshairs\n\n JMP LL30               \\ Draw a vertical line from (X1, Y1) to (X2, Y2), which\n                        \\ will draw from the top edge of the crosshairs to the\n                        \\ bottom edge, through the centre of the crosshairs,\n                        \\ and returning from the subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: TT14\n\\       Type: Subroutine\n\\   Category: Drawing circles\n\\    Summary: Draw a circle with crosshairs on a chart\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Draw a circle with crosshairs at the current system's galactic coordinates.\n\\\n\\ ******************************************************************************\n\n.TT126\n\n LDA #104               \\ Set QQ19 = 104, for the x-coordinate of the centre of\n STA QQ19               \\ the fixed circle on the Short-range Chart\n\n LDA #90                \\ Set QQ19+1 = 90, for the y-coordinate of the centre of\n STA QQ19+1             \\ the fixed circle on the Short-range Chart\n\n LDA #16                \\ Set QQ19+2 = 16, the size of the crosshairs on the\n STA QQ19+2             \\ Short-range Chart\n\n JSR TT15               \\ Draw the set of crosshairs defined in QQ19, at the\n                        \\ exact coordinates as this is the Short-range Chart\n\n LDA QQ14               \\ Set K to the fuel level from QQ14, so this can act as\n STA K                  \\ the circle's radius (70 being a full tank)\n\n JMP TT128              \\ Jump to TT128 to draw a circle with the centre at the\n                        \\ same coordinates as the crosshairs, (QQ19, QQ19+1),\n                        \\ and radius K that reflects the current fuel levels,\n                        \\ returning from the subroutine using a tail call\n\n.TT14\n\n LDA QQ11               \\ If the current view is the Short-range Chart, which\n BMI TT126              \\ is the only view with bit 7 set, then jump up to TT126\n                        \\ to draw the crosshairs and circle for that view\n\n                        \\ Otherwise this is the Long-range Chart, so we draw the\n                        \\ crosshairs and circle for that view instead\n\n LDA QQ14               \\ Set K to the fuel level from QQ14 divided by 4, so\n LSR A                  \\ this can act as the circle's radius (70 being a full\n LSR A                  \\ tank, which divides down to a radius of 17)\n STA K\n\n LDA QQ0                \\ Set QQ19 to the x-coordinate of the current system,\n STA QQ19               \\ which will be the centre of the circle and crosshairs\n                        \\ we draw\n\n LDA QQ1                \\ Set QQ19+1 to the y-coordinate of the current system,\n LSR A                  \\ halved because the galactic chart is half as high as\n STA QQ19+1             \\ it is wide, which will again be the centre of the\n                        \\ circle and crosshairs we draw\n\n LDA #7                 \\ Set QQ19+2 = 7, the size of the crosshairs on the\n STA QQ19+2             \\ Long-range Chart\n\n JSR TT15               \\ Draw the set of crosshairs defined in QQ19, which will\n                        \\ be drawn 24 pixels to the right of QQ19+1\n\n LDA QQ19+1             \\ Add 24 to the y-coordinate of the crosshairs in QQ19+1\n CLC                    \\ so that the centre of the circle matches the centre\n ADC #24                \\ of the crosshairs\n STA QQ19+1\n\n                        \\ Fall through into TT128 to draw a circle with the\n                        \\ centre at the same coordinates as the crosshairs,\n                        \\ (QQ19, QQ19+1), and radius K that reflects the\n                        \\ current fuel levels\n\n\\ ******************************************************************************\n\\\n\\       Name: TT128\n\\       Type: Subroutine\n\\   Category: Drawing circles\n\\    Summary: Draw a circle on a chart\n\\  Deep dive: Drawing circles\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Draw a circle with the centre at (QQ19, QQ19+1) and radius K.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   QQ19                The x-coordinate of the centre of the circle\n\\\n\\   QQ19+1              The y-coordinate of the centre of the circle\n\\\n\\   K                   The radius of the circle\n\\\n\\ ******************************************************************************\n\n.TT128\n\n LDA QQ19               \\ Set K3 = the x-coordinate of the centre\n STA K3\n\n LDA QQ19+1             \\ Set K4 = the y-coordinate of the centre\n STA K4\n\n LDX #0                 \\ Set the high bytes of K3(1 0) and K4(1 0) to 0\n STX K4+1\n STX K3+1\n\n\\STX LSX                \\ This instruction is commented out in the original\n                        \\ source\n\n INX                    \\ Set LSP = 1 to reset the ball line heap\n STX LSP\n\n LDX #2                 \\ Set STP = 2, the step size for the circle\n STX STP\n\n JSR CIRCLE2            \\ Call CIRCLE2 to draw a circle with the centre at\n                        \\ (K3(1 0), K4(1 0)) and radius K\n\n\\LDA #&FF               \\ These instructions are commented out in the original\n\\STA LSX                \\ source\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: TT219\n\\       Type: Subroutine\n\\   Category: Market\n\\    Summary: Show the Buy Cargo screen (red key f1)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   BAY2                Jump into the main loop at FRCE, setting the key\n\\                       \"pressed\" to red key f9 (so we show the Inventory\n\\                       screen)\n\\\n\\ ******************************************************************************\n\n.TT219\n\n\\LDA #2                 \\ This instruction is commented out in the original\n                        \\ source. Perhaps this view originally had a QQ11 value\n                        \\ of 2, but it turned out not to need its own unique ID,\n                        \\ so the authors found they could just use a view value\n                        \\ of 1 and save an instruction at the same time?\n\n JSR TT66-2             \\ Clear the top part of the screen, draw a border box,\n                        \\ and set the current view type in QQ11 to 1\n\n JSR TT163              \\ Print the column headers for the prices table\n\n LDA #%10000000         \\ Set bit 7 of QQ17 to switch to Sentence Case, with the\n STA QQ17               \\ next letter in capitals\n\n\\JSR FLKB               \\ This instruction is commented out in the original\n                        \\ source. It calls a routine to flush the keyboard\n                        \\ buffer (FLKB) that isn't present in the cassette\n                        \\ version but is in other versions\n\n LDA #0                 \\ We're going to loop through all the available market\n STA QQ29               \\ items, so we set up a counter in QQ29 to denote the\n                        \\ current item and start it at 0\n\n.TT220\n\n JSR TT151              \\ Call TT151 to print the item name, market price and\n                        \\ availability of the current item, and set QQ24 to the\n                        \\ item's price / 4, QQ25 to the quantity available and\n                        \\ QQ19+1 to byte #1 from the market prices table for\n                        \\ this item\n\n LDA QQ25               \\ If there are some of the current item available, jump\n BNE TT224              \\ to TT224 below to see if we want to buy any\n\n JMP TT222              \\ Otherwise there are none available, so jump down to\n                        \\ TT222 to skip this item\n\n.TQ4\n\n LDY #176               \\ Set Y to the recursive token 16 (\"QUANTITY\")\n\n.Tc\n\n JSR TT162              \\ Print a space\n\n TYA                    \\ Print the recursive token in Y followed by a question\n JSR prq                \\ mark\n\n.TTX224\n\n JSR dn2                \\ Call dn2 to make a short, high beep and delay for 1\n                        \\ second\n\n.TT224\n\n JSR CLYNS              \\ Clear the bottom three text rows of the upper screen,\n                        \\ and move the text cursor to the first cleared row\n\n LDA #204               \\ Print recursive token 44 (\"QUANTITY OF \")\n JSR TT27\n\n LDA QQ29               \\ Print recursive token 48 + QQ29, which will be in the\n CLC                    \\ range 48 (\"FOOD\") to 64 (\"ALIEN ITEMS\"), so this\n ADC #208               \\ prints the current item's name\n JSR TT27\n\n LDA #'/'               \\ Print \"/\"\n JSR TT27\n\n JSR TT152              \\ Print the unit (\"t\", \"kg\" or \"g\") for the current item\n                        \\ (as the call to TT151 above set QQ19+1 with the\n                        \\ appropriate value)\n\n LDA #'?'               \\ Print \"?\"\n JSR TT27\n\n JSR TT67               \\ Print a newline\n\n LDX #0                 \\ These instructions have no effect, as they are\n STX R                  \\ repeated at the start of gnum, which we call next.\n LDX #12                \\ Perhaps they were left behind when code was moved from\n STX T1                 \\ here into gnum, and weren't deleted?\n\n\\.TT223                 \\ This label is commented out in the original source,\n                        \\ and is a duplicate of a label in gnum, so this could\n                        \\ also be a remnant if the code in gnum was originally\n                        \\ here, but got moved into the gnum subroutine\n\n JSR gnum               \\ Call gnum to get a number from the keyboard, which\n                        \\ will be the quantity of this item we want to purchase,\n                        \\ returning the number entered in A and R\n\n BCS TQ4                \\ If gnum set the C flag, the number entered is greater\n                        \\ than the quantity available, so jump up to TQ4 to\n                        \\ display a \"Quantity?\" error, beep, clear the number\n                        \\ and try again\n\n STA P                  \\ Otherwise we have a valid purchase quantity entered,\n                        \\ so store the amount we want to purchase in P\n\n JSR tnpr               \\ Call tnpr to work out whether there is room in the\n                        \\ cargo hold for this item\n\n LDY #206               \\ Set Y to recursive token 46 (\" CARGO{sentence case}\")\n                        \\ to pass to the Tc routine if we call it\n\n BCS Tc                 \\ If the C flag is set, then there is no room in the\n                        \\ cargo hold, jump up to Tc to print a \"Cargo?\" error,\n                        \\ beep, clear the number and try again\n\n LDA QQ24               \\ There is room in the cargo hold, so now to check\n STA Q                  \\ whether we have enough cash, so fetch the item's\n                        \\ price / 4, which was returned in QQ24 by the call\n                        \\ to TT151 above and store it in Q\n\n JSR GCASH              \\ Call GCASH to calculate:\n                        \\\n                        \\   (Y X) = P * Q * 4\n                        \\\n                        \\ which will be the total price of this transaction\n                        \\ (as P contains the purchase quantity and Q contains\n                        \\ the item's price / 4)\n\n JSR LCASH              \\ Subtract (Y X) cash from the cash pot in CASH\n\n LDY #197               \\ If the C flag is clear, we didn't have enough cash,\n BCC Tc                 \\ so set Y to the recursive token 37 (\"CASH\") and jump\n                        \\ up to Tc to print a \"Cash?\" error, beep, clear the\n                        \\ number and try again\n\n LDY QQ29               \\ Fetch the current market item number from QQ29 into Y\n\n LDA R                  \\ Set A to the number of items we just purchased (this\n                        \\ was set by gnum above)\n\n PHA                    \\ Store the quantity just purchased on the stack\n\n CLC                    \\ Add the number purchased to the Y-th byte of QQ20,\n ADC QQ20,Y             \\ which contains the number of items of this type in\n STA QQ20,Y             \\ our hold (so this transfers the bought items into our\n                        \\ cargo hold)\n\n LDA AVL,Y              \\ Subtract the number of items from the Y-th byte of\n SEC                    \\ AVL, which contains the number of items of this type\n SBC R                  \\ that are available on the market\n STA AVL,Y\n\n PLA                    \\ Restore the quantity just purchased\n\n BEQ TT222              \\ If we didn't buy anything, jump to TT222 to skip the\n                        \\ following instruction\n\n JSR dn                 \\ Call dn to print the amount of cash left in the cash\n                        \\ pot, then make a short, high beep to confirm the\n                        \\ purchase, and delay for 1 second\n\n.TT222\n\n LDA QQ29               \\ Move the text cursor to row QQ29 + 5 (where QQ29 is\n CLC                    \\ the item number, starting from 0)\n ADC #5\n STA YC\n\n LDA #0                 \\ Move the text cursor to column 0\n STA XC\n\n INC QQ29               \\ Increment QQ29 to point to the next item\n\n LDA QQ29               \\ If QQ29 >= 17 then jump to BAY2 as we have done the\n CMP #17                \\ last item\n BCS BAY2\n\n JMP TT220              \\ Otherwise loop back to TT220 to print the next market\n                        \\ item\n\n.BAY2\n\n LDA #f9                \\ Jump into the main loop at FRCE, setting the key\n JMP FRCE               \\ \"pressed\" to red key f9 (so we show the Inventory\n                        \\ screen)\n\n\\ ******************************************************************************\n\\\n\\       Name: gnum\n\\       Type: Subroutine\n\\   Category: Market\n\\    Summary: Get a number from the keyboard\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Get a number from the keyboard, up to the maximum number in QQ25, for the\n\\ buying and selling of cargo and equipment.\n\\\n\\ Pressing a key with an ASCII code less than ASCII \"0\" will return a 0 in A (so\n\\ that includes pressing Space or Return), while pressing a key with an ASCII\n\\ code greater than ASCII \"9\" will jump to the Inventory screen (so that\n\\ includes all letters and most punctuation).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   QQ25                The maximum number allowed\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   A                   The number entered\n\\\n\\   R                   Also contains the number entered\n\\\n\\   C flag              Set if the number is too large (> QQ25), clear otherwise\n\\\n\\ ******************************************************************************\n\n.gnum\n\n LDX #0                 \\ We will build the number entered in R, so initialise\n STX R                  \\ it with 0\n\n LDX #12                \\ We will check for up to 12 key presses, so set a\n STX T1                 \\ counter in T1\n\n.TT223\n\n JSR TT217              \\ Scan the keyboard until a key is pressed, and return\n                        \\ the key's ASCII code in A (and X)\n\n STA Q                  \\ Store the key pressed in Q\n\n SEC                    \\ Subtract ASCII \"0\" from the key pressed, to leave the\n SBC #'0'               \\ numeric value of the key in A (if it was a number key)\n\n BCC OUT                \\ If A < 0, jump to OUT to load the current number and\n                        \\ return from the subroutine, as the key pressed was\n                        \\ RETURN (or some other character with a value less than\n                        \\ ASCII \"0\")\n\n CMP #10                \\ If A >= 10, jump to BAY2 to display the Inventory\n BCS BAY2               \\ screen, as the key pressed was a letter or other\n                        \\ non-digit and is greater than ASCII \"9\"\n\n STA S                  \\ Store the numeric value of the key pressed in S\n\n LDA R                  \\ Fetch the result so far into A\n\n CMP #26                \\ If A >= 26, where A is the number entered so far, then\n BCS OUT                \\ adding a further digit will make it bigger than 256,\n                        \\ so jump to OUT to return from the subroutine with the\n                        \\ result in R (i.e. ignore the last key press)\n\n ASL A                  \\ Set A = (A * 2) + (A * 8) = A * 10\n STA T\n ASL A\n ASL A\n ADC T\n\n ADC S                  \\ Add the pressed digit to A and store in R, so R now\n STA R                  \\ contains its previous value with the new key press\n                        \\ tacked onto the end\n\n CMP QQ25               \\ If the result in R = the maximum allowed in QQ25, jump\n BEQ TT226              \\ to TT226 to print the key press and keep looping (the\n                        \\ BEQ is needed because the BCS below would jump to OUT\n                        \\ if R >= QQ25, which we don't want)\n\n BCS OUT                \\ If the result in R > QQ25, jump to OUT to return from\n                        \\ the subroutine with the result in R\n\n.TT226\n\n LDA Q                  \\ Print the character in Q (i.e. the key that was\n JSR TT26               \\ pressed, as we stored the ASCII value in Q earlier)\n\n DEC T1                 \\ Decrement the loop counter\n\n BNE TT223              \\ Loop back to TT223 until we have checked for 12 digits\n\n.OUT\n\n LDA R                  \\ Set A to the result we have been building in R\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: TT208\n\\       Type: Subroutine\n\\   Category: Market\n\\    Summary: Show the Sell Cargo screen (red key f2)\n\\\n\\ ******************************************************************************\n\n.TT208\n\n LDA #4                 \\ Clear the top part of the screen, draw a border box,\n JSR TT66               \\ and set the current view type in QQ11 to 4 (Sell\n                        \\ Cargo screen)\n\n LDA #4                 \\ Move the text cursor to row 4, column 4\n STA YC\n STA XC\n\n\\JSR FLKB               \\ This instruction is commented out in the original\n                        \\ source. It calls a routine to flush the keyboard\n                        \\ buffer (FLKB) that isn't present in the cassette\n                        \\ version but is in other versions\n\n LDA #205               \\ Print recursive token 45 (\"SELL\")\n JSR TT27\n\n LDA #206               \\ Print recursive token 46 (\" CARGO{sentence case}\")\n JSR TT68               \\ followed by a colon\n\n                        \\ Fall through into TT210 to show the Inventory screen\n                        \\ with the option to sell\n\n\\ ******************************************************************************\n\\\n\\       Name: TT210\n\\       Type: Subroutine\n\\   Category: Market\n\\    Summary: Show a list of current cargo in our hold, optionally to sell\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Show a list of current cargo in our hold, either with the ability to sell (the\n\\ Sell Cargo screen) or without (the Inventory screen), depending on the current\n\\ view.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   QQ11                The current view:\n\\\n\\                           * 4 = Sell Cargo\n\\\n\\                           * 8 = Inventory\n\\\n\\ ******************************************************************************\n\n.TT210\n\n LDY #0                 \\ We're going to loop through all the available market\n                        \\ items and check whether we have any in the hold (and,\n                        \\ if we are in the Sell Cargo screen, whether we want\n                        \\ to sell any items), so we set up a counter in Y to\n                        \\ denote the current item and start it at 0\n\n.TT211\n\n STY QQ29               \\ Store the current item number in QQ29\n\n LDX QQ20,Y             \\ Fetch into X the amount of the current item that we\n BEQ TT212              \\ have in our cargo hold, which is stored in QQ20+Y,\n                        \\ and if there are no items of this type in the hold,\n                        \\ jump down to TT212 to skip to the next item\n\n TYA                    \\ Set Y = Y * 4, so this will act as an index into the\n ASL A                  \\ market prices table at QQ23 for this item (as there\n ASL A                  \\ are four bytes per item in the table)\n TAY\n\n LDA QQ23+1,Y           \\ Fetch byte #1 from the market prices table for the\n STA QQ19+1             \\ current item and store it in QQ19+1, for use by the\n                        \\ call to TT152 below\n\n TXA                    \\ Store the amount of item in the hold (in X) on the\n PHA                    \\ stack\n\n JSR TT69               \\ Call TT69 to set Sentence Case and print a newline\n\n CLC                    \\ Print recursive token 48 + QQ29, which will be in the\n LDA QQ29               \\ range 48 (\"FOOD\") to 64 (\"ALIEN ITEMS\"), so this\n ADC #208               \\ prints the current item's name\n JSR TT27\n\n LDA #14                \\ Move the text cursor to column 14, for the item's\n STA XC                 \\ quantity\n\n PLA                    \\ Restore the amount of item in the hold into X\n TAX\n\n CLC                    \\ Print the 8-bit number in X to 3 digits, without a\n JSR pr2                \\ decimal point\n\n JSR TT152              \\ Print the unit (\"t\", \"kg\" or \"g\") for the market item\n                        \\ whose byte #1 from the market prices table is in\n                        \\ QQ19+1 (which we set up above)\n\n LDA QQ11               \\ If the current view type in QQ11 is not 4 (Sell Cargo\n CMP #4                 \\ screen), jump to TT212 to skip the option to sell\n BNE TT212              \\ items\n\n LDA #205               \\ Set A to recursive token 45 (\"SELL\")\n\n JSR TT214              \\ Call TT214 to print \"Sell(Y/N)?\" and return the\n                        \\ response in the C flag\n\n BCC TT212              \\ If the response was \"no\", jump to TT212 to move on to\n                        \\ the next item\n\n LDA QQ29               \\ We are selling this item, so fetch the item number\n                        \\ from QQ29\n\n LDX #255               \\ Set QQ17 = 255 to disable printing\n STX QQ17\n\n JSR TT151              \\ Call TT151 to set QQ24 to the item's price / 4 (the\n                        \\ routine doesn't print the item details, as we just\n                        \\ disabled printing)\n\n LDY QQ29               \\ Set P to the amount of this item we have in our cargo\n LDA QQ20,Y             \\ hold (which is the amount to sell)\n STA P\n\n LDA QQ24               \\ Set Q to the item's price / 4\n STA Q\n\n JSR GCASH              \\ Call GCASH to calculate\n                        \\\n                        \\   (Y X) = P * Q * 4\n                        \\\n                        \\ which will be the total price we make from this sale\n                        \\ (as P contains the quantity we're selling and Q\n                        \\ contains the item's price / 4)\n\n JSR MCASH              \\ Add (Y X) cash to the cash pot in CASH\n\n LDA #0                 \\ We've made the sale, so set the amount\n LDY QQ29\n STA QQ20,Y\n\n STA QQ17               \\ Set QQ17 = 0, which enables printing again\n\n.TT212\n\n LDY QQ29               \\ Fetch the item number from QQ29 into Y, and increment\n INY                    \\ Y to point to the next item\n\n CPY #17                \\ If Y >= 17 then skip the next instruction as we have\n BCS P%+5               \\ done the last item\n\n JMP TT211              \\ Otherwise loop back to TT211 to print the next item\n                        \\ in the hold\n\n LDA QQ11               \\ If the current view type in QQ11 is not 4 (Sell Cargo\n CMP #4                 \\ screen), skip the next two instructions and just\n BNE P%+8               \\ return from the subroutine\n\n JSR dn2                \\ This is the Sell Cargo screen, so call dn2 to make a\n                        \\ short, high beep and delay for 1 second\n\n JMP BAY2               \\ And then jump to BAY2 to display the Inventory\n                        \\ screen, as we have finished selling cargo\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: TT213\n\\       Type: Subroutine\n\\   Category: Market\n\\    Summary: Show the Inventory screen (red key f9)\n\\\n\\ ******************************************************************************\n\n.TT213\n\n LDA #8                 \\ Clear the top part of the screen, draw a border box,\n JSR TT66               \\ and set the current view type in QQ11 to 8 (Inventory\n                        \\ screen)\n\n LDA #11                \\ Move the text cursor to column 11 to print the screen\n STA XC                 \\ title\n\n LDA #164               \\ Print recursive token 4 (\"INVENTORY{crlf}\") followed\n JSR TT60               \\ by a paragraph break and Sentence Case\n\n JSR NLIN4              \\ Draw a horizontal line at pixel row 19 to box in the\n                        \\ title. The authors could have used a call to NLIN3\n                        \\ instead and saved the above call to TT60, but you\n                        \\ just can't optimise everything\n\n JSR fwl                \\ Call fwl to print the fuel and cash levels on two\n                        \\ separate lines\n\n LDA CRGO               \\ If our ship's cargo capacity is < 26 (i.e. we do not\n CMP #26                \\ have a cargo bay extension), skip the following two\n BCC P%+7               \\ instructions\n\n LDA #107               \\ We do have a cargo bay extension, so print recursive\n JSR TT27               \\ token 107 (\"LARGE CARGO{sentence case} BAY\")\n\n JMP TT210              \\ Jump to TT210 to print the contents of our cargo bay\n                        \\ and return from the subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: TT214\n\\       Type: Subroutine\n\\   Category: Keyboard\n\\    Summary: Ask a question with a \"Y/N?\" prompt and return the response\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The text token to print before the \"Y/N?\" prompt\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   C flag              Set if the response was \"yes\", clear otherwise\n\\\n\\ ******************************************************************************\n\n.TT214\n\n PHA                    \\ Print a space, using the stack to preserve the value\n JSR TT162              \\ of A\n PLA\n\n.TT221\n\n JSR TT27               \\ Print the text token in A\n\n LDA #225               \\ Print recursive token 65 (\"(Y/N)?\")\n JSR TT27\n\n JSR TT217              \\ Scan the keyboard until a key is pressed, and return\n                        \\ the key's ASCII code in A and X\n\n ORA #%00100000         \\ Set bit 5 in the value of the key pressed, which\n                        \\ converts it to lower case\n\n CMP #'y'               \\ If \"y\" was pressed, jump to TT218\n BEQ TT218\n\n LDA #'n'               \\ Otherwise jump to TT26 to print \"n\" and return from\n JMP TT26               \\ the subroutine using a tail call (so all other\n                        \\ responses apart from \"y\" indicate a no)\n\n.TT218\n\n JSR TT26               \\ Print the character in A, i.e. print \"y\"\n\n SEC                    \\ Set the C flag to indicate a \"yes\" response\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: TT16\n\\       Type: Subroutine\n\\   Category: Charts\n\\    Summary: Move the crosshairs on a chart\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Move the chart crosshairs by the amount in X and Y.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   The amount to move the crosshairs in the x-axis\n\\\n\\   Y                   The amount to move the crosshairs in the y-axis\n\\\n\\ ******************************************************************************\n\n.TT16\n\n TXA                    \\ Push the change in X onto the stack (let's call this\n PHA                    \\ the x-delta)\n\n DEY                    \\ Negate the change in Y and push it onto the stack\n TYA                    \\ (let's call this the y-delta)\n EOR #&FF\n PHA\n\n JSR WSCAN              \\ Call WSCAN to wait for the vertical sync, so the whole\n                        \\ screen gets drawn and we can move the crosshairs with\n                        \\ no screen flicker\n\n JSR TT103              \\ Draw small crosshairs at coordinates (QQ9, QQ10),\n                        \\ which will erase the crosshairs currently there\n\n PLA                    \\ Store the y-delta in QQ19+3 and fetch the current\n STA QQ19+3             \\ y-coordinate of the crosshairs from QQ10 into A, ready\n LDA QQ10               \\ for the call to TT123\n\n JSR TT123              \\ Call TT123 to move the selected system's galactic\n                        \\ y-coordinate by the y-delta, putting the new value in\n                        \\ QQ19+4\n\n LDA QQ19+4             \\ Store the updated y-coordinate in QQ10 (the current\n STA QQ10               \\ y-coordinate of the crosshairs)\n\n STA QQ19+1             \\ This instruction has no effect, as QQ19+1 is\n                        \\ overwritten below, both in TT103 and TT105\n\n PLA                    \\ Store the x-delta in QQ19+3 and fetch the current\n STA QQ19+3             \\ x-coordinate of the crosshairs from QQ10 into A, ready\n LDA QQ9                \\ for the call to TT123\n\n JSR TT123              \\ Call TT123 to move the selected system's galactic\n                        \\ x-coordinate by the x-delta, putting the new value in\n                        \\ QQ19+4\n\n LDA QQ19+4             \\ Store the updated x-coordinate in QQ9 (the current\n STA QQ9                \\ x-coordinate of the crosshairs)\n\n STA QQ19               \\ This instruction has no effect, as QQ19 is overwritten\n                        \\ below, both in TT103 and TT105\n\n                        \\ Now we've updated the coordinates of the crosshairs,\n                        \\ fall through into TT103 to redraw them at their new\n                        \\ location\n\n\\ ******************************************************************************\n\\\n\\       Name: TT103\n\\       Type: Subroutine\n\\   Category: Charts\n\\    Summary: Draw a small set of crosshairs on a chart\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Draw a small set of crosshairs on a galactic chart at the coordinates in\n\\ (QQ9, QQ10).\n\\\n\\ ******************************************************************************\n\n.TT103\n\n LDA QQ11               \\ Fetch the current view type into A\n\n BEQ TT180              \\ If this is a space view, return from the subroutine\n                        \\ (as TT180 contains an RTS), as there are no moveable\n                        \\ crosshairs in space\n\n BMI TT105              \\ If this is the Short-range Chart screen, jump to TT105\n\n LDA QQ9                \\ Store the crosshairs x-coordinate in QQ19\n STA QQ19\n\n LDA QQ10               \\ Halve the crosshairs y-coordinate and store it in QQ19\n LSR A                  \\ (we halve it because the Long-range Chart is half as\n STA QQ19+1             \\ high as it is wide)\n\n LDA #4                 \\ Set QQ19+2 to 4 denote crosshairs of size 4\n STA QQ19+2\n\n JMP TT15               \\ Jump to TT15 to draw crosshairs of size 4 at the\n                        \\ crosshairs coordinates, returning from the subroutine\n                        \\ using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: TT123\n\\       Type: Subroutine\n\\   Category: Charts\n\\    Summary: Move galactic coordinates by a signed delta\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Move an 8-bit galactic coordinate by a certain distance in either direction\n\\ (i.e. a signed 8-bit delta), but only if it doesn't cause the coordinate to\n\\ overflow. The coordinate is in a single axis, so it's either an x-coordinate\n\\ or a y-coordinate.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The galactic coordinate to update\n\\\n\\   QQ19+3              The delta (can be positive or negative)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   QQ19+4              The updated coordinate after moving by the delta (this\n\\                       will be the same as A if moving by the delta overflows)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   TT180               Contains an RTS\n\\\n\\ ******************************************************************************\n\n.TT123\n\n STA QQ19+4             \\ Store the original coordinate in temporary storage at\n                        \\ QQ19+4\n\n CLC                    \\ Set A = A + QQ19+3, so A now contains the original\n ADC QQ19+3             \\ coordinate, moved by the delta\n\n LDX QQ19+3             \\ If the delta is negative, jump to TT124\n BMI TT124\n\n BCC TT125              \\ If the C flag is clear, then the above addition didn't\n                        \\ overflow, so jump to TT125 to return the updated value\n\n RTS                    \\ Otherwise the C flag is set and the above addition\n                        \\ overflowed, so do not update the return value\n\n.TT124\n\n BCC TT180              \\ If the C flag is clear, then because the delta is\n                        \\ negative, this indicates the addition (which is\n                        \\ effectively a subtraction) underflowed, so jump to\n                        \\ TT180 to return from the subroutine without updating\n                        \\ the return value\n\n.TT125\n\n STA QQ19+4             \\ Store the updated coordinate in QQ19+4\n\n.TT180\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: TT105\n\\       Type: Subroutine\n\\   Category: Charts\n\\    Summary: Draw crosshairs on the Short-range Chart, with clipping\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Check whether the crosshairs are close enough to the current system to appear\n\\ on the Short-range Chart, and if so, draw them.\n\\\n\\ ******************************************************************************\n\n.TT105\n\n LDA QQ9                \\ Set A = QQ9 - QQ0, the horizontal distance between the\n SEC                    \\ crosshairs (QQ9) and the current system (QQ0)\n SBC QQ0\n\n CMP #38                \\ If the horizontal distance in A < 38, then the\n BCC TT179              \\ crosshairs are close enough to the current system to\n                        \\ appear in the Short-range Chart, so jump to TT179 to\n                        \\ check the vertical distance\n\n CMP #230               \\ If the horizontal distance in A < -26, then the\n BCC TT180              \\ crosshairs are too far from the current system to\n                        \\ appear in the Short-range Chart, so jump to TT180 to\n                        \\ return from the subroutine (as TT180 contains an RTS)\n\n.TT179\n\n ASL A                  \\ Set QQ19 = 104 + A * 4\n ASL A                  \\\n CLC                    \\ 104 is the x-coordinate of the centre of the chart,\n ADC #104               \\ so this sets QQ19 to the screen pixel x-coordinate\n STA QQ19               \\ of the crosshairs\n\n LDA QQ10               \\ Set A = QQ10 - QQ1, the vertical distance between the\n SEC                    \\ crosshairs (QQ10) and the current system (QQ1)\n SBC QQ1\n\n CMP #38                \\ If the vertical distance in A is < 38, then the\n BCC P%+6               \\ crosshairs are close enough to the current system to\n                        \\ appear in the Short-range Chart, so skip the next two\n                        \\ instructions\n\n CMP #220               \\ If the horizontal distance in A is < -36, then the\n BCC TT180              \\ crosshairs are too far from the current system to\n                        \\ appear in the Short-range Chart, so jump to TT180 to\n                        \\ return from the subroutine (as TT180 contains an RTS)\n\n ASL A                  \\ Set QQ19+1 = 90 + A * 2\n CLC                    \\\n ADC #90                \\ 90 is the y-coordinate of the centre of the chart,\n STA QQ19+1             \\ so this sets QQ19+1 to the screen pixel x-coordinate\n                        \\ of the crosshairs\n\n LDA #8                 \\ Set QQ19+2 to 8 denote crosshairs of size 8\n STA QQ19+2\n\n JMP TT15               \\ Jump to TT15 to draw crosshairs of size 8 at the\n                        \\ crosshairs coordinates, returning from the subroutine\n                        \\ using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: TT23\n\\       Type: Subroutine\n\\   Category: Charts\n\\    Summary: Show the Short-range Chart (red key f5)\n\\\n\\ ******************************************************************************\n\n.TT23\n\n LDA #128               \\ Clear the top part of the screen, draw a border box,\n JSR TT66               \\ and set the current view type in QQ11 to 128 (Short-\n                        \\ range Chart)\n\n LDA #7                 \\ Move the text cursor to column 7\n STA XC\n\n LDA #190               \\ Print recursive token 30 (\"SHORT RANGE CHART\") and\n JSR NLIN3              \\ draw a horizontal line at pixel row 19 to box in the\n                        \\ title\n\n JSR TT14               \\ Call TT14 to draw a circle with crosshairs at the\n                        \\ current system's galactic coordinates\n\n JSR TT103              \\ Draw small crosshairs at coordinates (QQ9, QQ10),\n                        \\ i.e. at the selected system\n\n JSR TT81               \\ Set the seeds in QQ15 to those of system 0 in the\n                        \\ current galaxy (i.e. copy the seeds from QQ21 to QQ15)\n\n LDA #0                 \\ Set A = 0, which we'll use below to zero out the INWK\n                        \\ workspace\n\n STA XX20               \\ We're about to start working our way through each of\n                        \\ the galaxy's systems, so set up a counter in XX20 for\n                        \\ each system, starting at 0 and looping through to 255\n\n LDX #24                \\ First, though, we need to zero out the 25 bytes at\n                        \\ INWK so we can use them to work out which systems have\n                        \\ room for a label, so set a counter in X for 25 bytes\n\n.EE3\n\n STA INWK,X             \\ Set the X-th byte of INWK to zero\n\n DEX                    \\ Decrement the counter\n\n BPL EE3                \\ Loop back to EE3 for the next byte until we've zeroed\n                        \\ all 25 bytes\n\n                        \\ We now loop through every single system in the galaxy\n                        \\ and check the distance from the current system whose\n                        \\ coordinates are in (QQ0, QQ1). We get the galactic\n                        \\ coordinates of each system from the system's seeds,\n                        \\ like this:\n                        \\\n                        \\   x = s1_hi (which is stored in QQ15+3)\n                        \\   y = s0_hi (which is stored in QQ15+1)\n                        \\\n                        \\ so the following loops through each system in the\n                        \\ galaxy in turn and calculates the distance between\n                        \\ (QQ0, QQ1) and (s1_hi, s0_hi) to find the closest one\n\n.TT182\n\n LDA QQ15+3             \\ Set A = s1_hi - QQ0, the horizontal distance between\n SEC                    \\ (s1_hi, s0_hi) and (QQ0, QQ1)\n SBC QQ0\n\n BCS TT184              \\ If a borrow didn't occur, i.e. s1_hi >= QQ0, then the\n                        \\ result is positive, so jump to TT184 and skip the\n                        \\ following two instructions\n\n EOR #&FF               \\ Otherwise negate the result in A, so A is always\n ADC #1                 \\ positive (i.e. A = |s1_hi - QQ0|)\n\n.TT184\n\n CMP #20                \\ If the horizontal distance in A is >= 20, then this\n BCS TT187              \\ system is too far away from the current system to\n                        \\ appear in the Short-range Chart, so jump to TT187 to\n                        \\ move on to the next system\n\n LDA QQ15+1             \\ Set A = s0_hi - QQ1, the vertical distance between\n SEC                    \\ (s1_hi, s0_hi) and (QQ0, QQ1)\n SBC QQ1\n\n BCS TT186              \\ If a borrow didn't occur, i.e. s0_hi >= QQ1, then the\n                        \\ result is positive, so jump to TT186 and skip the\n                        \\ following two instructions\n\n EOR #&FF               \\ Otherwise negate the result in A, so A is always\n ADC #1                 \\ positive (i.e. A = |s0_hi - QQ1|)\n\n.TT186\n\n CMP #38                \\ If the vertical distance in A is >= 38, then this\n BCS TT187              \\ system is too far away from the current system to\n                        \\ appear in the Short-range Chart, so jump to TT187 to\n                        \\ move on to the next system\n\n                        \\ This system should be shown on the Short-range Chart,\n                        \\ so now we need to work out where the label should go,\n                        \\ and set up the various variables we need to draw the\n                        \\ system's filled circle on the chart\n\n LDA QQ15+3             \\ Set A = s1_hi - QQ0, the horizontal distance between\n SEC                    \\ this system and the current system, where |A| < 20.\n SBC QQ0                \\ Let's call this the x-delta, as it's the horizontal\n                        \\ difference between the current system at the centre of\n                        \\ the chart, and this system (and this time we keep the\n                        \\ sign of A, so it can be negative if it's to the left\n                        \\ of the chart's centre, or positive if it's to the\n                        \\ right)\n\n ASL A                  \\ Set XX12 = 104 + x-delta * 4\n ASL A                  \\\n ADC #104               \\ 104 is the x-coordinate of the centre of the chart,\n STA XX12               \\ so this sets XX12 to the centre 104 +/- 76, the pixel\n                        \\ x-coordinate of this system\n\n LSR A                  \\ Move the text cursor to column x-delta / 2 + 1\n LSR A                  \\ which will be in the range 1-10\n LSR A\n STA XC\n INC XC\n\n LDA QQ15+1             \\ Set A = s0_hi - QQ1, the vertical distance between\n SEC                    \\ this system and the current system, where |A| < 38.\n SBC QQ1                \\ Let's call this the y-delta, as it's the vertical\n                        \\ difference between the current system at the centre of\n                        \\ the chart, and this system (and this time we keep the\n                        \\ sign of A, so it can be negative if it's above the\n                        \\ chart's centre, or positive if it's below)\n\n ASL A                  \\ Set K4 = 90 + y-delta * 2\n ADC #90                \\\n STA K4                 \\ 90 is the y-coordinate of the centre of the chart,\n                        \\ so this sets K4 to the centre 90 +/- 74, the pixel\n                        \\ y-coordinate of this system\n\n LSR A                  \\ Set Y = A >> 3\n LSR A                  \\       = K4 div 8\n LSR A                  \\\n TAY                    \\ So Y now contains the number of the character row\n                        \\ that contains this system\n\n                        \\ Now to see if there is room for this system's label.\n                        \\ Ideally we would print the system name on the same\n                        \\ text row as the system, but we only want to print one\n                        \\ label per row, to prevent overlap, so now we check\n                        \\ this system's row, and if that's already occupied,\n                        \\ the row above, and if that's already occupied, the\n                        \\ row below... and if that's already occupied, we give\n                        \\ up and don't print a label for this system\n\n LDX INWK,Y             \\ If the value in INWK+Y is 0 (i.e. the text row\n BEQ EE4                \\ containing this system does not already have another\n                        \\ system's label on it), jump to EE4 to store this\n                        \\ system's label on this row\n\n INY                    \\ If the value in INWK+Y+1 is 0 (i.e. the text row below\n LDX INWK,Y             \\ the one containing this system does not already have\n BEQ EE4                \\ another system's label on it), jump to EE4 to store\n                        \\ this system's label on this row\n\n DEY                    \\ If the value in INWK+Y-1 is 0 (i.e. the text row above\n DEY                    \\ the one containing this system does not already have\n LDX INWK,Y             \\ another system's label on it), fall through into to\n BNE ee1                \\ EE4 to store this system's label on this row,\n                        \\ otherwise jump to ee1 to skip printing a label for\n                        \\ this system (as there simply isn't room)\n\n.EE4\n\n STY YC                 \\ Now to print the label, so move the text cursor to row\n                        \\ Y (which contains the row where we can print this\n                        \\ system's label)\n\n CPY #3                 \\ If Y < 3, then the system would clash with the chart\n BCC TT187              \\ title, so jump to TT187 to skip showing the system\n\n DEX                    \\ We entered the EE4 routine with X = 0, so this stores\n STX INWK,Y             \\ &FF in INWK+Y, to denote that this row is now occupied\n                        \\ so we don't try to print another system's label on\n                        \\ this row\n\n LDA #%10000000         \\ Set bit 7 of QQ17 to switch to Sentence Case\n STA QQ17\n\n JSR cpl                \\ Call cpl to print out the system name for the seeds\n                        \\ in QQ15 (which now contains the seeds for the current\n                        \\ system)\n\n.ee1\n\n LDA #0                 \\ Now to plot the star, so set the high bytes of K, K3\n STA K3+1               \\ and K4 to 0\n STA K4+1\n STA K+1\n\n LDA XX12               \\ Set the low byte of K3 to XX12, the pixel x-coordinate\n STA K3                 \\ of this system\n\n LDA QQ15+5             \\ Fetch s2_hi for this system from QQ15+5, extract bit 0\n AND #1                 \\ and add 2 to get the size of the star, which we store\n ADC #2                 \\ in K. This will be either 2, 3 or 4, depending on the\n STA K                  \\ value of bit 0, and whether the C flag is set (which\n                        \\ will vary depending on what happens in the above call\n                        \\ to cpl). Incidentally, the planet's average radius\n                        \\ also uses s2_hi, bits 0-3 to be precise, but that\n                        \\ doesn't mean the two sizes affect each other\n\n                        \\ We now have the following:\n                        \\\n                        \\   K(1 0)  = radius of star (2, 3 or 4)\n                        \\\n                        \\   K3(1 0) = pixel x-coordinate of system\n                        \\\n                        \\   K4(1 0) = pixel y-coordinate of system\n                        \\\n                        \\ which we can now pass to the SUN routine to draw a\n                        \\ small \"sun\" on the Short-range Chart for this system\n\n JSR FLFLLS             \\ Call FLFLLS to reset the LSO block\n\n JSR SUN                \\ Call SUN to plot a sun with radius K at pixel\n                        \\ coordinate (K3, K4)\n\n JSR FLFLLS             \\ Call FLFLLS to reset the LSO block\n\n.TT187\n\n JSR TT20               \\ We want to move on to the next system, so call TT20\n                        \\ to twist the three 16-bit seeds in QQ15\n\n INC XX20               \\ Increment the counter\n\n BEQ TT111-1            \\ If X = 0 then we have done all 256 systems, so return\n                        \\ from the subroutine (as TT111-1 contains an RTS)\n\n JMP TT182              \\ Otherwise jump back up to TT182 to process the next\n                        \\ system\n\n\\ ******************************************************************************\n\\\n\\       Name: TT81\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Set the selected system's seeds to those of system 0\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Copy the three 16-bit seeds for the current galaxy's system 0 (QQ21) into the\n\\ seeds for the selected system (QQ15) - in other words, set the selected\n\\ system's seeds to those of system 0.\n\\\n\\ ******************************************************************************\n\n.TT81\n\n LDX #5                 \\ Set up a counter in X to copy six bytes (for three\n                        \\ 16-bit numbers)\n\n LDA QQ21,X             \\ Copy the X-th byte in QQ21 to the X-th byte in QQ15\n STA QQ15,X\n\n DEX                    \\ Decrement the counter\n\n BPL TT81+2             \\ Loop back up to the LDA instruction if we still have\n                        \\ more bytes to copy\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: TT111\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Set the current system to the nearest system to a point\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Given a set of galactic coordinates in (QQ9, QQ10), find the nearest system\n\\ to this point in the galaxy, and set this as the currently selected system.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   QQ9                 The x-coordinate near which we want to find a system\n\\\n\\   QQ10                The y-coordinate near which we want to find a system\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   QQ8(1 0)            The distance from the current system to the nearest\n\\                       system to the original coordinates\n\\\n\\   QQ9                 The x-coordinate of the nearest system to the original\n\\                       coordinates\n\\\n\\   QQ10                The y-coordinate of the nearest system to the original\n\\                       coordinates\n\\\n\\   QQ15 to QQ15+5      The three 16-bit seeds of the nearest system to the\n\\                       original coordinates\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   TT111-1             Contains an RTS\n\\\n\\ ******************************************************************************\n\n.TT111\n\n JSR TT81               \\ Set the seeds in QQ15 to those of system 0 in the\n                        \\ current galaxy (i.e. copy the seeds from QQ21 to QQ15)\n\n                        \\ We now loop through every single system in the galaxy\n                        \\ and check the distance from (QQ9, QQ10). We get the\n                        \\ galactic coordinates of each system from the system's\n                        \\ seeds, like this:\n                        \\\n                        \\   x = s1_hi (which is stored in QQ15+3)\n                        \\   y = s0_hi (which is stored in QQ15+1)\n                        \\\n                        \\ so the following loops through each system in the\n                        \\ galaxy in turn and calculates the distance between\n                        \\ (QQ9, QQ10) and (s1_hi, s0_hi) to find the closest one\n\n LDY #127               \\ Set Y = T = 127 to hold the shortest distance we've\n STY T                  \\ found so far, which we initially set to half the\n                        \\ distance across the galaxy, or 127, as our coordinate\n                        \\ system ranges from (0,0) to (255, 255)\n\n LDA #0                 \\ Set A = U = 0 to act as a counter for each system in\n STA U                  \\ the current galaxy, which we start at system 0 and\n                        \\ loop through to 255, the last system\n\n.TT130\n\n LDA QQ15+3             \\ Set A = s1_hi - QQ9, the horizontal distance between\n SEC                    \\ (s1_hi, s0_hi) and (QQ9, QQ10)\n SBC QQ9\n\n BCS TT132              \\ If a borrow didn't occur, i.e. s1_hi >= QQ9, then the\n                        \\ result is positive, so jump to TT132 and skip the\n                        \\ following two instructions\n\n EOR #&FF               \\ Otherwise negate the result in A, so A is always\n ADC #1                 \\ positive (i.e. A = |s1_hi - QQ9|)\n\n.TT132\n\n LSR A                  \\ Set S = A / 2\n STA S                  \\       = |s1_hi - QQ9| / 2\n\n LDA QQ15+1             \\ Set A = s0_hi - QQ10, the vertical distance between\n SEC                    \\ (s1_hi, s0_hi) and (QQ9, QQ10)\n SBC QQ10\n\n BCS TT134              \\ If a borrow didn't occur, i.e. s0_hi >= QQ10, then the\n                        \\ result is positive, so jump to TT134 and skip the\n                        \\ following two instructions\n\n EOR #&FF               \\ Otherwise negate the result in A, so A is always\n ADC #1                 \\ positive (i.e. A = |s0_hi - QQ10|)\n\n.TT134\n\n LSR A                  \\ Set A = S + A / 2\n CLC                    \\       = |s1_hi - QQ9| / 2 + |s0_hi - QQ10| / 2\n ADC S                  \\\n                        \\ So A now contains the sum of the horizontal and\n                        \\ vertical distances, both divided by 2 so the result\n                        \\ fits into one byte, and although this doesn't contain\n                        \\ the actual distance between the systems, it's a good\n                        \\ enough approximation to use for comparing distances\n\n CMP T                  \\ If A >= T, then this system's distance is bigger than\n BCS TT135              \\ our \"minimum distance so far\" stored in T, so it's no\n                        \\ closer than the systems we have already found, so\n                        \\ skip to TT135 to move on to the next system\n\n STA T                  \\ This system is the closest to (QQ9, QQ10) so far, so\n                        \\ update T with the new \"distance\" approximation\n\n LDX #5                 \\ As this system is the closest we have found yet, we\n                        \\ want to store the system's seeds in case it ends up\n                        \\ being the closest of all, so we set up a counter in X\n                        \\ to copy six bytes (for three 16-bit numbers)\n\n.TT136\n\n LDA QQ15,X             \\ Copy the X-th byte in QQ15 to the X-th byte in QQ19,\n STA QQ19,X             \\ where QQ15 contains the seeds for the system we just\n                        \\ found to be the closest so far, and QQ19 is temporary\n                        \\ storage\n\n DEX                    \\ Decrement the counter\n\n BPL TT136              \\ Loop back to TT136 if we still have more bytes to\n                        \\ copy\n\n.TT135\n\n JSR TT20               \\ We want to move on to the next system, so call TT20\n                        \\ to twist the three 16-bit seeds in QQ15\n\n INC U                  \\ Increment the system counter in U\n\n BNE TT130              \\ If U > 0 then we haven't done all 256 systems yet, so\n                        \\ loop back up to TT130\n\n                        \\ We have now finished checking all the systems in the\n                        \\ galaxy, and the seeds for the closest system are in\n                        \\ QQ19, so now we want to copy these seeds to QQ15,\n                        \\ to set the selected system to this closest system\n\n LDX #5                 \\ So we set up a counter in X to copy six bytes (for\n                        \\ three 16-bit numbers)\n\n.TT137\n\n LDA QQ19,X             \\ Copy the X-th byte in QQ19 to the X-th byte in QQ15\n STA QQ15,X\n\n DEX                    \\ Decrement the counter\n\n BPL TT137              \\ Loop back to TT137 if we still have more bytes to\n                        \\ copy\n\n LDA QQ15+1             \\ The y-coordinate of the system described by the seeds\n STA QQ10               \\ in QQ15 is in QQ15+1 (s0_hi), so we copy this to QQ10\n                        \\ as this is where we store the selected system's\n                        \\ y-coordinate\n\n LDA QQ15+3             \\ The x-coordinate of the system described by the seeds\n STA QQ9                \\ in QQ15 is in QQ15+3 (s1_hi), so we copy this to QQ9\n                        \\ as this is where we store the selected system's\n                        \\ x-coordinate\n\n                        \\ We have now found the closest system to (QQ9, QQ10)\n                        \\ and have set it as the selected system, so now we\n                        \\ need to work out the distance between the selected\n                        \\ system and the current system\n\n SEC                    \\ Set A = QQ9 - QQ0, the horizontal distance between\n SBC QQ0                \\ the selected system's x-coordinate (QQ9) and the\n                        \\ current system's x-coordinate (QQ0)\n\n BCS TT139              \\ If a borrow didn't occur, i.e. QQ9 >= QQ0, then the\n                        \\ result is positive, so jump to TT139 and skip the\n                        \\ following two instructions\n\n EOR #&FF               \\ Otherwise negate the result in A, so A is always\n ADC #1                 \\ positive (i.e. A = |QQ9 - QQ0|)\n\n                        \\ A now contains the difference between the two\n                        \\ systems' x-coordinates, with the sign removed. We\n                        \\ will refer to this as the x-delta (\"delta\" means\n                        \\ change or difference in maths)\n\n.TT139\n\n JSR SQUA2              \\ Set (A P) = A * A\n                        \\           = |QQ9 - QQ0| ^ 2\n                        \\           = x_delta ^ 2\n\n STA K+1                \\ Store (A P) in K(1 0)\n LDA P\n STA K\n\n LDA QQ10               \\ Set A = QQ10 - QQ1, the vertical distance between the\n SEC                    \\ selected system's y-coordinate (QQ10) and the current\n SBC QQ1                \\ system's y-coordinate (QQ1)\n\n BCS TT141              \\ If a borrow didn't occur, i.e. QQ10 >= QQ1, then the\n                        \\ result is positive, so jump to TT141 and skip the\n                        \\ following two instructions\n\n EOR #&FF               \\ Otherwise negate the result in A, so A is always\n ADC #1                 \\ positive (i.e. A = |QQ10 - QQ1|)\n\n.TT141\n\n LSR A                  \\ Set A = A / 2\n\n                        \\ A now contains the difference between the two\n                        \\ systems' y-coordinates, with the sign removed, and\n                        \\ halved. We halve the value because the galaxy in\n                        \\ in Elite is rectangular rather than square, and is\n                        \\ twice as wide (x-axis) as it is high (y-axis), so to\n                        \\ get a distance that matches the shape of the\n                        \\ long-range galaxy chart, we need to halve the\n                        \\ distance between the vertical y-coordinates. We will\n                        \\ refer to this as the y-delta\n\n JSR SQUA2              \\ Set (A P) = A * A\n                        \\           = (|QQ10 - QQ1| / 2) ^ 2\n                        \\           = y_delta ^ 2\n\n                        \\ By this point we have the following results:\n                        \\\n                        \\   K(1 0) = x_delta ^ 2\n                        \\    (A P) = y_delta ^ 2\n                        \\\n                        \\ so to find the distance between the two points, we\n                        \\ can use Pythagoras - so first we need to add the two\n                        \\ results together, and then take the square root\n\n PHA                    \\ Store the high byte of the y-axis value on the stack,\n                        \\ so we can use A for another purpose\n\n LDA P                  \\ Set Q = P + K, which adds the low bytes of the two\n CLC                    \\ calculated values\n ADC K\n STA Q\n\n PLA                    \\ Restore the high byte of the y-axis value from the\n                        \\ stack into A again\n\n ADC K+1                \\ Set R = A + K+1, which adds the high bytes of the two\n STA R                  \\ calculated values, so we now have:\n                        \\\n                        \\   (R Q) = K(1 0) + (A P)\n                        \\         = (x_delta ^ 2) + (y_delta ^ 2)\n\n JSR LL5                \\ Set Q = SQRT(R Q), so Q now contains the distance\n                        \\ between the two systems, in terms of coordinates\n\n                        \\ We now store the distance to the selected system * 4\n                        \\ in the two-byte location QQ8, by taking (0 Q) and\n                        \\ shifting it left twice, storing it in QQ8(1 0)\n\n LDA Q                  \\ First we shift the low byte left by setting\n ASL A                  \\ A = Q * 2, with bit 7 of A going into the C flag\n\n LDX #0                 \\ Now we set the high byte in QQ8+1 to 0 and rotate\n STX QQ8+1              \\ the C flag into bit 0 of QQ8+1\n ROL QQ8+1\n\n ASL A                  \\ And then we repeat the shift left of (QQ8+1 A)\n ROL QQ8+1\n\n STA QQ8                \\ And store A in the low byte, QQ8, so QQ8(1 0) now\n                        \\ contains Q * 4. Given that the width of the galaxy is\n                        \\ 256 in coordinate terms, the width of the galaxy\n                        \\ would be 1024 in the units we store in QQ8\n\n JMP TT24               \\ Call TT24 to calculate system data from the seeds in\n                        \\ QQ15 and store them in the relevant locations, so our\n                        \\ new selected system is fully set up, and return from\n                        \\ the subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: hy6\n\\       Type: Subroutine\n\\   Category: Flight\n\\    Summary: Print a message to say there is no hyperspacing allowed inside the\n\\             station\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Print \"Docked\" at the bottom of the screen to indicate we can't hyperspace\n\\ when docked.\n\\\n\\ ******************************************************************************\n\n.hy6\n\n JSR CLYNS              \\ Clear the bottom three text rows of the upper screen,\n                        \\ and move the text cursor to the first cleared row\n\n LDA #15                \\ Move the text cursor to column 15 (the middle of the\n STA XC                 \\ screen), setting A to 15 at the same time for the\n                        \\ following call to TT27\n\n JMP TT27               \\ Print recursive token 129 (\"{sentence case}DOCKED\")\n                        \\ and return from the subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: hyp\n\\       Type: Subroutine\n\\   Category: Flight\n\\    Summary: Start the hyperspace process\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Called when \"H\" or CTRL-H is pressed during flight. Checks the following:\n\\\n\\   * We are in space\n\\\n\\   * We are not already in a hyperspace countdown\n\\\n\\ If CTRL is being held down, we jump to Ghy to engage the galactic hyperdrive,\n\\ otherwise we check that:\n\\\n\\   * The selected system is not the current system\n\\\n\\   * We have enough fuel to make the jump\n\\\n\\ and if all the pre-jump checks are passed, we print the destination on-screen\n\\ and start the countdown.\n\\\n\\ ******************************************************************************\n\n.hyp\n\n LDA QQ12               \\ If we are docked (QQ12 = &FF) then jump to hy6 to\n BNE hy6                \\ print an error message and return from the subroutine\n                        \\ using a tail call (as we can't hyperspace when docked)\n\n LDA QQ22+1             \\ Fetch QQ22+1, which contains the number that's shown\n                        \\ on-screen during hyperspace countdown\n\n BNE zZ+1               \\ If it is non-zero, return from the subroutine (as zZ+1\n                        \\ contains an RTS), as there is already a countdown in\n                        \\ progress\n\n JSR CTRL               \\ Scan the keyboard to see if CTRL is currently pressed\n\n BMI Ghy                \\ If it is, then the galactic hyperdrive has been\n                        \\ activated, so jump to Ghy to process it\n\n JSR hm                 \\ This is a chart view, so call hm to redraw the chart\n                        \\ crosshairs\n\n LDA QQ8                \\ If both bytes of the distance to the selected system\n ORA QQ8+1              \\ in QQ8 are zero, return from the subroutine (as zZ+1\n BEQ zZ+1               \\ contains an RTS), as the selected system is the\n                        \\ current system\n\n LDA #7                 \\ Move the text cursor to column 7, row 23 (in the\n STA XC                 \\ middle of the bottom text row)\n LDA #23\n STA YC\n\n LDA #0                 \\ Set QQ17 = 0 to switch to ALL CAPS\n STA QQ17\n\n LDA #189               \\ Print recursive token 29 (\"HYPERSPACE \")\n JSR TT27\n\n LDA QQ8+1              \\ If the high byte of the distance to the selected\n BNE TT147              \\ system in QQ8 is > 0, then it is definitely too far to\n                        \\ jump (as our maximum range is 7.0 light years, or a\n                        \\ value of 70 in QQ8(1 0)), so jump to TT147 to print\n                        \\ \"RANGE?\" and return from the subroutine using a tail\n                        \\ call\n\n LDA QQ14               \\ Fetch our current fuel level from Q114 into A\n\n CMP QQ8                \\ If our fuel reserves are less than the distance to the\n BCC TT147              \\ selected system, then we don't have enough fuel for\n                        \\ this jump, so jump to TT147 to print \"RANGE?\" and\n                        \\ return from the subroutine using a tail call\n\n LDA #'-'               \\ Print a hyphen\n JSR TT27\n\n JSR cpl                \\ Call cpl to print the name of the selected system\n\n                        \\ Fall through into wW to start the hyperspace countdown\n\n\\ ******************************************************************************\n\\\n\\       Name: wW\n\\       Type: Subroutine\n\\   Category: Flight\n\\    Summary: Start a hyperspace countdown\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Start the hyperspace countdown (for both inter-system hyperspace and the\n\\ galactic hyperdrive).\n\\\n\\ ******************************************************************************\n\n.wW\n\n LDA #15                \\ The hyperspace countdown starts from 15, so set A to\n                        \\ 15 so we can set the two hyperspace counters\n\n STA QQ22+1             \\ Set the number in QQ22+1 to A, which is the number\n                        \\ that's shown on-screen during the hyperspace countdown\n\n STA QQ22               \\ Set the number in QQ22 to 15, which is the internal\n                        \\ counter that counts down by 1 each iteration of the\n                        \\ main game loop, and each time it reaches zero, the\n                        \\ on-screen counter gets decremented, and QQ22 gets set\n                        \\ to 5, so setting QQ22 to 15 here makes the first tick\n                        \\ of the hyperspace counter longer than subsequent ticks\n\n TAX                    \\ Print the 8-bit number in X (i.e. 15) at text location\n JMP ee3                \\ (0, 1), padded to 5 digits, so it appears in the top\n                        \\ left corner of the screen, and return from the\n                        \\ subroutine using a tail call\n\n\\.hy5                   \\ This instruction and the hy5 label are commented out\n\\                       \\ in the original - they can actually be found at the\n\\RTS                    \\ end of the jmp routine below, so perhaps this is where\n                        \\ they were originally, but the authors realised they\n                        \\ could save a byte by using a tail call instead of an\n                        \\ RTS?\n\n\\ ******************************************************************************\n\\\n\\       Name: Ghy\n\\       Type: Subroutine\n\\   Category: Flight\n\\    Summary: Perform a galactic hyperspace jump\n\\  Deep dive: Twisting the system seeds\n\\             Galaxy and system seeds\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Engage the galactic hyperdrive. Called from the hyp routine above if CTRL-H is\n\\ being pressed.\n\\\n\\ This routine also updates the galaxy seeds to point to the next galaxy. Using\n\\ a galactic hyperdrive rotates each seed byte to the left, rolling each byte\n\\ left within itself like this:\n\\\n\\   01234567 -> 12345670\n\\\n\\ to get the seeds for the next galaxy. So after 8 galactic jumps, the seeds\n\\ roll round to those of the first galaxy again.\n\\\n\\ We always arrive in a new galaxy at galactic coordinates (96, 96), and then\n\\ find the nearest system and set that as our location.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   zZ+1                Contains an RTS\n\\\n\\ ******************************************************************************\n\n.Ghy\n\nIF _TEXT_SOURCES\n\n JSR TT111              \\ Call TT111 to set the current system to the nearest\n                        \\ system to (QQ9, QQ10), and put the seeds of the\n                        \\ nearest system into QQ15 to QQ15+5\n                        \\\n                        \\ This appears to be a failed attempt to fix a bug in\n                        \\ the cassette version, where the galactic hyperdrive\n                        \\ will take us to coordinates (96, 96) in the new\n                        \\ galaxy, even if there isn't actually a system there,\n                        \\ so if we jump when you are low on fuel, it is\n                        \\ possible to get stuck in the middle of nowhere when\n                        \\ changing galaxy\n                        \\\n                        \\ All the other versions contain a fix for this bug that\n                        \\ involves adding an extra JSR TT111 instruction after\n                        \\ the coordinates are set to (96, 96) below, which finds\n                        \\ the nearest system to those coordinates  and sets that\n                        \\ as the current system\n                        \\\n                        \\ The cassette version on the original source disc\n                        \\ doesn't contain this instruction, and although the\n                        \\ text sources do, it's in the wrong place at the start\n                        \\ of the Ghy routine, as the fix only works if it's done\n                        \\ after the new coordinates are set, not before\n\nENDIF\n\n LDX GHYP               \\ Fetch GHYP, which tells us whether we own a galactic\n BEQ hy5                \\ hyperdrive, and if it is zero, which means we don't,\n                        \\ return from the subroutine (as hy5 contains an RTS)\n\n INX                    \\ We own a galactic hyperdrive, so X is &FF, so this\n                        \\ instruction sets X = 0\n\nIF _SOURCE_DISC OR _TEXT_SOURCES\n\n STX QQ8                \\ Set the distance to the selected system in QQ8(1 0)\n STX QQ8+1              \\ to 0\n\nENDIF\n\n STX GHYP               \\ The galactic hyperdrive is a one-use item, so set GHYP\n                        \\ to 0 so we no longer have one fitted\n\n STX FIST               \\ Changing galaxy also clears our criminal record, so\n                        \\ set our legal status in FIST to 0 (\"clean\")\n\n JSR wW                 \\ Call wW to start the hyperspace countdown\n\n LDX #5                 \\ To move galaxy, we rotate the galaxy's seeds left, so\n                        \\ set a counter in X for the 6 seed bytes\n\n INC GCNT               \\ Increment the current galaxy number in GCNT\n\n LDA GCNT               \\ Set GCNT = GCNT mod 8, so we jump from galaxy 7 back\n AND #7                 \\ to galaxy 0 (shown in-game as going from galaxy 8 back\n STA GCNT               \\ to the starting point in galaxy 1)\n\n.G1\n\n LDA QQ21,X             \\ Load the X-th seed byte into A\n\n ASL A                  \\ Set the C flag to bit 7 of the seed\n\n ROL QQ21,X             \\ Rotate the seed in memory, which will add bit 7 back\n                        \\ in as bit 0, so this rolls the seed around on itself\n\n DEX                    \\ Decrement the counter\n\n BPL G1                 \\ Loop back for the next seed byte, until we have\n                        \\ rotated them all\n\n\\JSR DORND              \\ This instruction is commented out in the original\n                        \\ source, and would set A and X to random numbers, so\n                        \\ perhaps the original plan was to arrive in each new\n                        \\ galaxy in a random place?\n\n.zZ\n\n LDA #96                \\ Set (QQ9, QQ10) to (96, 96), which is where we always\n STA QQ9                \\ arrive in a new galaxy (the selected system will be\n STA QQ10               \\ set to the nearest actual system later on)\n\n JSR TT110              \\ Call TT110 to show the front space view\n\nIF _STH_CASSETTE\n\n JSR TT111              \\ Call TT111 to set the current system to the nearest\n                        \\ system to (QQ9, QQ10), and put the seeds of the\n                        \\ nearest system into QQ15 to QQ15+5\n                        \\\n                        \\ This call fixes a bug in the early cassette versions,\n                        \\ where the galactic hyperdrive will take us to\n                        \\ coordinates (96, 96) in the new galaxy, even if there\n                        \\ isn't actually a system there, so if we jump when we\n                        \\ are low on fuel, it is possible to get stuck in the\n                        \\ middle of nowhere when changing galaxy\n                        \\\n                        \\ This call sets the current system correctly, so we\n                        \\ always arrive at the nearest system to (96, 96)\n\nENDIF\n\nIF _STH_CASSETTE\n\n LDX #0                 \\ Set the distance to the selected system in QQ8(1 0)\n STX QQ8                \\ to 0\n STX QQ8+1\n\nENDIF\n\n LDA #116               \\ Print recursive token 116 (GALACTIC HYPERSPACE \")\n JSR MESS               \\ as an in-flight message\n\n                        \\ Fall through into jmp to set the system to the\n                        \\ current system and return from the subroutine there\n\n\\ ******************************************************************************\n\\\n\\       Name: jmp\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Set the current system to the selected system\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   (QQ0, QQ1)          The galactic coordinates of the new system\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   hy5                 Contains an RTS\n\\\n\\ ******************************************************************************\n\n.jmp\n\n LDA QQ9                \\ Set the current system's galactic x-coordinate to the\n STA QQ0                \\ x-coordinate of the selected system\n\n LDA QQ10               \\ Set the current system's galactic y-coordinate to the\n STA QQ1                \\ y-coordinate of the selected system\n\n.hy5\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: ee3\n\\       Type: Subroutine\n\\   Category: Flight\n\\    Summary: Print the hyperspace countdown in the top-left of the screen\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Print the 8-bit number in X at text location (0, 1). Print the number to\n\\ 5 digits, left-padding with spaces for numbers with fewer than 3 digits (so\n\\ numbers < 10000 are right-aligned), with no decimal point.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   The number to print\n\\\n\\ ******************************************************************************\n\n.ee3\n\n LDY #1                 \\ Move the text cursor to row 1\n STY YC\n\n DEY                    \\ Decrement Y to 0 for the high byte in pr6\n\n STY XC                 \\ Move the text cursor to column 0\n\n                        \\ Fall through into pr6 to print X to 5 digits, as the\n                        \\ high byte in Y is 0\n\n\\ ******************************************************************************\n\\\n\\       Name: pr6\n\\       Type: Subroutine\n\\   Category: Text\n\\    Summary: Print 16-bit number, left-padded to 5 digits, no point\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Print the 16-bit number in (Y X) to 5 digits, left-padding with spaces for\n\\ numbers with fewer than 3 digits (so numbers < 10000 are right-aligned),\n\\ with no decimal point.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   The low byte of the number to print\n\\\n\\   Y                   The high byte of the number to print\n\\\n\\ ******************************************************************************\n\n.pr6\n\n CLC                    \\ Do not display a decimal point when printing\n\n                        \\ Fall through into pr5 to print X to 5 digits\n\n\\ ******************************************************************************\n\\\n\\       Name: pr5\n\\       Type: Subroutine\n\\   Category: Text\n\\    Summary: Print a 16-bit number, left-padded to 5 digits, and optional point\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Print the 16-bit number in (Y X) to 5 digits, left-padding with spaces for\n\\ numbers with fewer than 3 digits (so numbers < 10000 are right-aligned).\n\\ Optionally include a decimal point.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   The low byte of the number to print\n\\\n\\   Y                   The high byte of the number to print\n\\\n\\   C flag              If set, include a decimal point\n\\\n\\ ******************************************************************************\n\n.pr5\n\n LDA #5                 \\ Set the number of digits to print to 5\n\n JMP TT11               \\ Call TT11 to print (Y X) to 5 digits and return from\n                        \\ the subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: TT147\n\\       Type: Subroutine\n\\   Category: Flight\n\\    Summary: Print an error when a system is out of hyperspace range\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Print \"RANGE?\" for when the hyperspace distance is too far\n\\\n\\ ******************************************************************************\n\n.TT147\n\n LDA #202               \\ Load A with token 42 (\"RANGE\") and fall through into\n                        \\ prq to print it, followed by a question mark\n\n\\ ******************************************************************************\n\\\n\\       Name: prq\n\\       Type: Subroutine\n\\   Category: Text\n\\    Summary: Print a text token followed by a question mark\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The text token to be printed\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   prq+3               Print a question mark\n\\\n\\ ******************************************************************************\n\n.prq\n\n JSR TT27               \\ Print the text token in A\n\n LDA #'?'               \\ Print a question mark and return from the\n JMP TT27               \\ subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: TT151\n\\       Type: Subroutine\n\\   Category: Market\n\\    Summary: Print the name, price and availability of a market item\n\\  Deep dive: Market item prices and availability\n\\             Galaxy and system seeds\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The number of the market item to print, 0-16 (see QQ23\n\\                       for details of item numbers)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   QQ19+1              Byte #1 from the market prices table for this item\n\\\n\\   QQ24                The item's price / 4\n\\\n\\   QQ25                The item's availability\n\\\n\\ ******************************************************************************\n\n.TT151\n\n PHA                    \\ Store the item number on the stack and in QQ19+4\n STA QQ19+4\n\n ASL A                  \\ Store the item number * 4 in QQ19, so this will act as\n ASL A                  \\ an index into the market prices table at QQ23 for this\n STA QQ19               \\ item (as there are four bytes per item in the table)\n\n LDA #1                 \\ Move the text cursor to column 1, for the item's name\n STA XC\n\n PLA                    \\ Restore the item number\n\n ADC #208               \\ Print recursive token 48 + A, which will be in the\n JSR TT27               \\ range 48 (\"FOOD\") to 64 (\"ALIEN ITEMS\"), so this\n                        \\ prints the item's name\n\n LDA #14                \\ Move the text cursor to column 14, for the price\n STA XC\n\n LDX QQ19               \\ Fetch byte #1 from the market prices table (units and\n LDA QQ23+1,X           \\ economic_factor) for this item and store in QQ19+1\n STA QQ19+1\n\n LDA QQ26               \\ Fetch the random number for this system visit and\n AND QQ23+3,X           \\ AND with byte #3 from the market prices table (mask)\n                        \\ to give:\n                        \\\n                        \\   A = random AND mask\n\n CLC                    \\ Add byte #0 from the market prices table (base_price),\n ADC QQ23,X             \\ so we now have:\n STA QQ24               \\\n                        \\   A = base_price + (random AND mask)\n\n JSR TT152              \\ Call TT152 to print the item's unit (\"t\", \"kg\" or\n                        \\ \"g\"), padded to a width of two characters\n\n JSR var                \\ Call var to set QQ19+3 = economy * |economic_factor|\n                        \\ (and set the availability of alien items to 0)\n\n LDA QQ19+1             \\ Fetch the byte #1 that we stored above and jump to\n BMI TT155              \\ TT155 if it is negative (i.e. if the economic_factor\n                        \\ is negative)\n\n LDA QQ24               \\ Set A = QQ24 + QQ19+3\n ADC QQ19+3             \\\n                        \\       = base_price + (random AND mask)\n                        \\         + (economy * |economic_factor|)\n                        \\\n                        \\ which is the result we want, as the economic_factor\n                        \\ is positive\n\n JMP TT156              \\ Jump to TT156 to multiply the result by 4\n\n.TT155\n\n LDA QQ24               \\ Set A = QQ24 - QQ19+3\n SEC                    \\\n SBC QQ19+3             \\       = base_price + (random AND mask)\n                        \\         - (economy * |economic_factor|)\n                        \\\n                        \\ which is the result we want, as economic_factor\n                        \\ is negative\n\n.TT156\n\n STA QQ24               \\ Store the result in QQ24 and P\n STA P\n\n LDA #0                 \\ Set A = 0 and call GC2 to calculate (Y X) = (A P) * 4,\n JSR GC2                \\ which is the same as (Y X) = P * 4 because A = 0\n\n SEC                    \\ We now have our final price, * 10, so we can call pr5\n JSR pr5                \\ to print (Y X) to 5 digits, including a decimal\n                        \\ point, as the C flag is set\n\n LDY QQ19+4             \\ We now move on to availability, so fetch the market\n                        \\ item number that we stored in QQ19+4 at the start\n\n LDA #5                 \\ Set A to 5 so we can print the availability to 5\n                        \\ digits (right-padded with spaces)\n\n LDX AVL,Y              \\ Set X to the item's availability, which is given in\n                        \\ the AVL table\n\n STX QQ25               \\ Store the availability in QQ25\n\n CLC                    \\ Clear the C flag\n\n BEQ TT172              \\ If none are available, jump to TT172 to print a tab\n                        \\ and a \"-\"\n\n JSR pr2+2              \\ Otherwise print the 8-bit number in X to 5 digits,\n                        \\ right-aligned with spaces. This works because we set\n                        \\ A to 5 above, and we jump into the pr2 routine just\n                        \\ after the first instruction, which would normally\n                        \\ set the number of digits to 3\n\n JMP TT152              \\ Print the unit (\"t\", \"kg\" or \"g\") for the market item,\n                        \\ with a following space if required to make it two\n                        \\ characters long, and return from the subroutine using\n                        \\ a tail call\n\n.TT172\n\n LDA XC                 \\ Move the text cursor in XC to the right by 4 columns,\n ADC #4                 \\ so the cursor is where the last digit would be if we\n STA XC                 \\ were printing a five-digit availability number\n\n LDA #'-'               \\ Print a \"-\" character by jumping to TT162+2, which\n BNE TT162+2            \\ contains JMP TT27 (this BNE is effectively a JMP as A\n                        \\ will never be zero), and return from the subroutine\n                        \\ using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: TT152\n\\       Type: Subroutine\n\\   Category: Market\n\\    Summary: Print the unit (\"t\", \"kg\" or \"g\") for a market item\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Print the unit (\"t\", \"kg\" or \"g\") for the market item whose byte #1 from the\n\\ market prices table is in QQ19+1, right-padded with spaces to a width of two\n\\ characters (so that's \"t \", \"kg\" or \"g \").\n\\\n\\ ******************************************************************************\n\n.TT152\n\n LDA QQ19+1             \\ Fetch the economic_factor from QQ19+1\n\n AND #96                \\ If bits 5 and 6 are both clear, jump to TT160 to\n BEQ TT160              \\ print \"t\" for tonne, followed by a space, and return\n                        \\ from the subroutine using a tail call\n\n CMP #32                \\ If bit 5 is set, jump to TT161 to print \"kg\" for\n BEQ TT161              \\ kilograms, and return from the subroutine using a tail\n                        \\ call\n\n JSR TT16a              \\ Otherwise call TT16a to print \"g\" for grams, and fall\n                        \\ through into TT162 to print a space and return from\n                        \\ the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: TT162\n\\       Type: Subroutine\n\\   Category: Text\n\\    Summary: Print a space\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   TT162+2             Jump to TT27 to print the text token in A\n\\\n\\ ******************************************************************************\n\n.TT162\n\n LDA #' '               \\ Load a space character into A\n\n JMP TT27               \\ Print the text token in A and return from the\n                        \\ subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: TT160\n\\       Type: Subroutine\n\\   Category: Market\n\\    Summary: Print \"t\" (for tonne) and a space\n\\\n\\ ******************************************************************************\n\n.TT160\n\n LDA #'t'               \\ Load a \"t\" character into A\n\n JSR TT26               \\ Print the character, using TT216 so that it doesn't\n                        \\ change the character case\n\n BCC TT162              \\ Jump to TT162 to print a space and return from the\n                        \\ subroutine using a tail call (this BCC is effectively\n                        \\ a JMP as the C flag is cleared by TT26)\n\n\\ ******************************************************************************\n\\\n\\       Name: TT161\n\\       Type: Subroutine\n\\   Category: Market\n\\    Summary: Print \"kg\" (for kilograms)\n\\\n\\ ******************************************************************************\n\n.TT161\n\n LDA #'k'               \\ Load a \"k\" character into A\n\n JSR TT26               \\ Print the character, using TT216 so that it doesn't\n                        \\ change the character case, and fall through into\n                        \\ TT16a to print a \"g\" character\n\n\\ ******************************************************************************\n\\\n\\       Name: TT16a\n\\       Type: Subroutine\n\\   Category: Market\n\\    Summary: Print \"g\" (for grams)\n\\\n\\ ******************************************************************************\n\n.TT16a\n\n LDA #'g'               \\ Load a \"g\" character into A\n\n JMP TT26               \\ Print the character, using TT216 so that it doesn't\n                        \\ change the character case, and return from the\n                        \\ subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: TT163\n\\       Type: Subroutine\n\\   Category: Market\n\\    Summary: Print the headers for the table of market prices\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Print the column headers for the prices table in the Buy Cargo and Market\n\\ Price screens.\n\\\n\\ ******************************************************************************\n\n.TT163\n\n LDA #17                \\ Move the text cursor in XC to column 17\n STA XC\n\n LDA #255               \\ Print recursive token 95 token (\"UNIT  QUANTITY\n BNE TT162+2            \\ {crlf} PRODUCT   UNIT PRICE FOR SALE{crlf}{lf}\") by\n                        \\ jumping to TT162+2, which contains JMP TT27 (this BNE\n                        \\ is effectively a JMP as A will never be zero), and\n                        \\ return from the subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: TT167\n\\       Type: Subroutine\n\\   Category: Market\n\\    Summary: Show the Market Price screen (red key f7)\n\\\n\\ ******************************************************************************\n\n.TT167\n\n LDA #16                \\ Clear the top part of the screen, draw a border box,\n JSR TT66               \\ and set the current view type in QQ11 to 16 (Market\n                        \\ Price screen)\n\n LDA #5                 \\ Move the text cursor to column 5\n STA XC\n\n LDA #167               \\ Print recursive token 7 (\"{current system name} MARKET\n JSR NLIN3              \\ PRICES\") and draw a horizontal line at pixel row 19\n                        \\ to box in the title\n\n LDA #3                 \\ Move the text cursor to row 3\n STA YC\n\n JSR TT163              \\ Print the column headers for the prices table\n\n LDA #0                 \\ We're going to loop through all the available market\n STA QQ29               \\ items, so we set up a counter in QQ29 to denote the\n                        \\ current item and start it at 0\n\n.TT168\n\n LDX #%10000000         \\ Set bit 7 of QQ17 to switch to Sentence Case, with the\n STX QQ17               \\ next letter in capitals\n\n JSR TT151              \\ Call TT151 to print the item name, market price and\n                        \\ availability of the current item, and set QQ24 to the\n                        \\ item's price / 4, QQ25 to the quantity available and\n                        \\ QQ19+1 to byte #1 from the market prices table for\n                        \\ this item\n\n INC YC                 \\ Move the text cursor down one row\n\n INC QQ29               \\ Increment QQ29 to point to the next item\n\n LDA QQ29               \\ If QQ29 >= 17 then jump to TT168 as we have done the\n CMP #17                \\ last item\n BCC TT168\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: var\n\\       Type: Subroutine\n\\   Category: Market\n\\    Summary: Calculate QQ19+3 = economy * |economic_factor|\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Set QQ19+3 = economy * |economic_factor|, given byte #1 of the market prices\n\\ table for an item. Also sets the availability of alien items to 0.\n\\\n\\ This routine forms part of the calculations for market item prices (TT151)\n\\ and availability (GVL).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   QQ19+1              Byte #1 of the market prices table for this market item\n\\                       (which contains the economic_factor in bits 0-5, and the\n\\                       sign of the economic_factor in bit 7)\n\\\n\\ ******************************************************************************\n\n.var\n\n LDA QQ19+1             \\ Extract bits 0-5 from QQ19+1 into A, to get the\n AND #31                \\ economic_factor without its sign, in other words:\n                        \\\n                        \\   A = |economic_factor|\n\n LDY QQ28               \\ Set Y to the economy byte of the current system\n\n STA QQ19+2             \\ Store A in QQ19+2\n\n CLC                    \\ Clear the C flag so we can do additions below\n\n LDA #0                 \\ Set AVL+16 (availability of alien items) to 0,\n STA AVL+16             \\ setting A to 0 in the process\n\n.TT153\n\n                        \\ We now do the multiplication by doing a series of\n                        \\ additions in a loop, building the result in A. Each\n                        \\ loop adds QQ19+2 (|economic_factor|) to A, and it\n                        \\ loops the number of times given by the economy byte;\n                        \\ in other words, because A starts at 0, this sets:\n                        \\\n                        \\   A = economy * |economic_factor|\n\n DEY                    \\ Decrement the economy in Y, exiting the loop when it\n BMI TT154              \\ becomes negative\n\n ADC QQ19+2             \\ Add QQ19+2 to A\n\n JMP TT153              \\ Loop back to TT153 to do another addition\n\n.TT154\n\n STA QQ19+3             \\ Store the result in QQ19+3\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: hyp1\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Process a jump to the system closest to (QQ9, QQ10)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Do a hyperspace jump to the system closest to galactic coordinates\n\\ (QQ9, QQ10), and set up the current system's state to those of the new system.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   (QQ0, QQ1)          The galactic coordinates of the new system\n\\\n\\   QQ2 to QQ2+6        The seeds of the new system\n\\\n\\   EV                  Set to 0\n\\\n\\   QQ28                The new system's economy\n\\\n\\   tek                 The new system's tech level\n\\\n\\   gov                 The new system's government\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   hyp1+3              Jump straight to the system at (QQ9, QQ10) without\n\\                       first calculating which system is closest. We do this\n\\                       if we already know that (QQ9, QQ10) points to a system\n\\\n\\ ******************************************************************************\n\n.hyp1\n\n JSR TT111              \\ Select the system closest to galactic coordinates\n                        \\ (QQ9, QQ10)\n\n JSR jmp                \\ Set the current system to the selected system\n\n LDX #5                 \\ We now want to copy the seeds for the selected system\n                        \\ in QQ15 into QQ2, where we store the seeds for the\n                        \\ current system, so set up a counter in X for copying\n                        \\ 6 bytes (for three 16-bit seeds)\n\n.TT112\n\n LDA QQ15,X             \\ Copy the X-th byte in QQ15 to the X-th byte in QQ2, to\n STA QQ2,X              \\ update the selected system to the new one. Note that\n                        \\ this approach has a minor bug associated with it: if\n                        \\ your hyperspace counter hits 0 just as you're docking,\n                        \\ then you will magically appear in the station in your\n                        \\ hyperspace destination, without having to go to the\n                        \\ effort of actually flying there. This bug was fixed in\n                        \\ later versions by saving the destination seeds in a\n                        \\ separate location called safehouse, and using those\n                        \\ instead... but that isn't the case in this version\n\n DEX                    \\ Decrement the counter\n\n BPL TT112              \\ Loop back to TT112 if we still have more bytes to\n                        \\ copy\n\n INX                    \\ Set X = 0 (as we ended the above loop with X = &FF)\n\n STX EV                 \\ Set EV, the extra vessels spawning counter, to 0, as\n                        \\ we are entering a new system with no extra vessels\n                        \\ spawned\n\n LDA QQ3                \\ Set the current system's economy in QQ28 to the\n STA QQ28               \\ selected system's economy from QQ3\n\n LDA QQ5                \\ Set the current system's tech level in tek to the\n STA tek                \\ selected system's economy from QQ5\n\n LDA QQ4                \\ Set the current system's government in gov to the\n STA gov                \\ selected system's government from QQ4\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: GVL\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Calculate the availability of market items\n\\  Deep dive: Market item prices and availability\n\\             Galaxy and system seeds\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the availability for each market item and store it in AVL. This is\n\\ called on arrival in a new system.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   hyR                 Contains an RTS\n\\\n\\ ******************************************************************************\n\n.GVL\n\n JSR DORND              \\ Set A and X to random numbers\n\n STA QQ26               \\ Set QQ26 to the random byte that's used in the market\n                        \\ calculations\n\n LDX #0                 \\ We are now going to loop through the market item\n STX XX4                \\ availability table in AVL, so set a counter in XX4\n                        \\ (and X) for the market item number, starting with 0\n\n.hy9\n\n LDA QQ23+1,X           \\ Fetch byte #1 from the market prices table (units and\n STA QQ19+1             \\ economic_factor) for item number X and store it in\n                        \\ QQ19+1\n\n JSR var                \\ Call var to set QQ19+3 = economy * |economic_factor|\n                        \\ (and set the availability of alien items to 0)\n\n LDA QQ23+3,X           \\ Fetch byte #3 from the market prices table (mask) and\n AND QQ26               \\ AND with the random number for this system visit\n                        \\ to give:\n                        \\\n                        \\   A = random AND mask\n\n CLC                    \\ Add byte #2 from the market prices table\n ADC QQ23+2,X           \\ (base_quantity) so we now have:\n                        \\\n                        \\   A = base_quantity + (random AND mask)\n\n LDY QQ19+1             \\ Fetch the byte #1 that we stored above and jump to\n BMI TT157              \\ TT157 if it is negative (i.e. if the economic_factor\n                        \\ is negative)\n\n SEC                    \\ Set A = A - QQ19+3\n SBC QQ19+3             \\\n                        \\       = base_quantity + (random AND mask)\n                        \\         - (economy * |economic_factor|)\n                        \\\n                        \\ which is the result we want, as the economic_factor\n                        \\ is positive\n\n JMP TT158              \\ Jump to TT158 to skip TT157\n\n.TT157\n\n CLC                    \\ Set A = A + QQ19+3\n ADC QQ19+3             \\\n                        \\       = base_quantity + (random AND mask)\n                        \\         + (economy * |economic_factor|)\n                        \\\n                        \\ which is the result we want, as the economic_factor\n                        \\ is negative\n\n.TT158\n\n BPL TT159              \\ If A < 0, then set A = 0, so we don't have negative\n LDA #0                 \\ availability\n\n.TT159\n\n LDY XX4                \\ Fetch the counter (the market item number) into Y\n\n AND #%00111111         \\ Take bits 0-5 of A, i.e. A mod 64, and store this as\n STA AVL,Y              \\ this item's availability in the Y=th byte of AVL, so\n                        \\ each item has a maximum availability of 63t\n\n INY                    \\ Increment the counter into XX44, Y and A\n TYA\n STA XX4\n\n ASL A                  \\ Set X = counter * 4, so that X points to the next\n ASL A                  \\ item's entry in the four-byte market prices table,\n TAX                    \\ ready for the next loop\n\n CMP #63                \\ If A < 63, jump back up to hy9 to set the availability\n BCC hy9                \\ for the next market item\n\n.hyR\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: GTHG\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Spawn a Thargoid ship and a Thargon companion\n\\  Deep dive: Fixing ship positions\n\\             Aggression and hostility in ship tactics\n\\\n\\ ******************************************************************************\n\n.GTHG\n\n JSR Ze                 \\ Call Ze to initialise INWK to a fairly aggressive\n                        \\ ship (though we increase this below)\n                        \\\n                        \\ Note that because Ze uses the value of X returned by\n                        \\ DORND, and X contains the value of A returned by the\n                        \\ previous call to DORND, this does not set the new ship\n                        \\ to a totally random location\n\n LDA #%11111111         \\ Set the AI flag in byte #32 so that the ship has AI,\n STA INWK+32            \\ an aggression level of 63 out of 63, and E.C.M.\n\n LDA #THG               \\ Call NWSHP to add a new Thargoid ship to our local\n JSR NWSHP              \\ bubble of universe\n\n LDA #TGL               \\ Call NWSHP to add a new Thargon ship to our local\n JMP NWSHP              \\ bubble of universe, and return from the subroutine\n                        \\ using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: MJP\n\\       Type: Subroutine\n\\   Category: Flight\n\\    Summary: Process a mis-jump into witchspace\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Process a mis-jump into witchspace (which happens very rarely). Witchspace has\n\\ a strange, almost dust-free aspect to it, and it is populated by aggressive\n\\ Thargoids. Using our escape pod will be fatal, and our position on the\n\\ galactic chart is in-between systems. It is a scary place...\n\\\n\\ There is a 0.78% chance that this routine is called from TT18 instead of doing\n\\ a normal hyperspace, or we can manually trigger a mis-jump by holding down\n\\ CTRL after first enabling the \"author display\" configuration option (\"X\") when\n\\ paused.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   ptg                 Called when the user manually forces a mis-jump\n\\\n\\ ******************************************************************************\n\n.ptg\n\n LSR COK                \\ Set bit 0 of the competition flags in COK, so that the\n SEC                    \\ competition code will include the fact that we have\n ROL COK                \\ manually forced a mis-jump into witchspace\n\n.MJP\n\n\\LDA #1                 \\ This instruction is commented out in the original\n                        \\ source - it is not required as a call to TT66-2 sets\n                        \\ A to 1 for us. This is presumably an example of the\n                        \\ authors saving a couple of bytes by calling TT66-2\n                        \\ instead of TT66, while leaving the original LDA\n                        \\ instruction in place\n\n JSR TT66-2             \\ Clear the top part of the screen, draw a border box,\n                        \\ and set the current view type in QQ11 to 1\n\n JSR LL164              \\ Call LL164 to show the hyperspace tunnel and make the\n                        \\ hyperspace sound for a second time (as we already\n                        \\ called LL164 in TT18)\n\n JSR RES2               \\ Reset a number of flight variables and workspaces, as\n                        \\ well as setting Y to &FF\n\n STY MJ                 \\ Set the mis-jump flag in MJ to &FF, to indicate that\n                        \\ we are now in witchspace\n\n.MJP1\n\n JSR GTHG               \\ Call GTHG to spawn a Thargoid ship and a Thargon\n                        \\ companion\n\n LDA #3                 \\ Fetch the number of Thargoid ships from MANY+THG, and\n CMP MANY+THG           \\ if it is less than or equal to 3, loop back to MJP1 to\n BCS MJP1               \\ spawn another one, until we have four Thargoids\n\n STA NOSTM              \\ Set NOSTM (the maximum number of stardust particles)\n                        \\ to 3, so there are fewer bits of stardust in\n                        \\ witchspace (normal space has a maximum of 18)\n\n LDX #0                 \\ Initialise the front space view\n JSR LOOK1\n\n LDA QQ1                \\ Fetch the current system's galactic y-coordinate in\n EOR #%00011111         \\ QQ1 and flip bits 0-5, so we end up somewhere in the\n STA QQ1                \\ vicinity of our original destination, but above or\n                        \\ below it in the galactic chart\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: TT18\n\\       Type: Subroutine\n\\   Category: Flight\n\\    Summary: Try to initiate a jump into hyperspace\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Try to go through hyperspace. Called from TT102 in the main loop when the\n\\ hyperspace countdown has finished.\n\\\n\\ ******************************************************************************\n\n.TT18\n\n LDA QQ14               \\ Subtract the distance to the selected system (in QQ8)\n SEC                    \\ from the amount of fuel in our tank (in QQ14) into A\n SBC QQ8\n\n STA QQ14               \\ Store the updated fuel amount in QQ14\n\n LDA QQ11               \\ If the current view is not a space view, jump to ee5\n BNE ee5                \\ to skip the following\n\n JSR TT66               \\ Clear the top part of the screen, draw a border box,\n                        \\ and set the current view type in QQ11 to 0 (space\n                        \\ view)\n\n JSR LL164              \\ Call LL164 to show the hyperspace tunnel and make the\n                        \\ hyperspace sound\n\n.ee5\n\n JSR CTRL               \\ Scan the keyboard to see if CTRL is currently pressed,\n                        \\ returning a negative value in A if it is\n\n AND PATG               \\ If the game is configured to show the author's names\n                        \\ on the start-up screen, then PATG will contain &FF,\n                        \\ otherwise it will be 0\n\n BMI ptg                \\ By now, A will be negative if we are holding down CTRL\n                        \\ and author names are configured, which is what we have\n                        \\ to do in order to trigger a manual mis-jump, so jump\n                        \\ to ptg to do a mis-jump (ptg not only mis-jumps, but\n                        \\ updates the competition flags, so Acornsoft could tell\n                        \\ from the competition code whether this feature had\n                        \\ been used)\n\n JSR DORND              \\ Set A and X to random numbers\n\n CMP #253               \\ If A >= 253 (0.78% chance) then jump to MJP to trigger\n BCS MJP                \\ a mis-jump into witchspace\n\n\\JSR TT111              \\ This instruction is commented out in the original\n                        \\ source. It finds the closest system to coordinates\n                        \\ (QQ9, QQ10), but we don't need to do this as the\n                        \\ crosshairs will already be on a system by this point\n\n JSR hyp1+3             \\ Jump straight to the system at (QQ9, QQ10) without\n                        \\ first calculating which system is closest\n\n JSR GVL                \\ Calculate the availability for each market item in the\n                        \\ new system\n\n JSR RES2               \\ Reset a number of flight variables and workspaces\n\n JSR SOLAR              \\ Halve our legal status, update the missile indicators,\n                        \\ and set up data blocks and slots for the planet and\n                        \\ sun\n\n LDA QQ11               \\ If the current view in QQ11 is not a space view (0) or\n AND #%00111111         \\ one of the charts (64 or 128), return from the\n BNE hyR                \\ subroutine (as hyR contains an RTS)\n\n JSR TTX66              \\ Otherwise clear the screen and draw a border box\n\n LDA QQ11               \\ If the current view is one of the charts, jump to\n BNE TT114              \\ TT114 (from which we jump to the correct routine to\n                        \\ display the chart)\n\n INC QQ11               \\ This is a space view, so increment QQ11 to 1\n\n                        \\ Fall through into TT110 to show the front space view\n\n\\ ******************************************************************************\n\\\n\\       Name: TT110\n\\       Type: Subroutine\n\\   Category: Flight\n\\    Summary: Launch from a station or show the front space view\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Launch the ship (if we are docked), or show the front space view (if we are\n\\ already in space).\n\\\n\\ Called when red key f0 is pressed while docked (launch), after we arrive in a\n\\ new galaxy, or after a hyperspace if the current view is a space view.\n\\\n\\ ******************************************************************************\n\n.TT110\n\n LDX QQ12               \\ If we are not docked (QQ12 = 0) then jump to NLUNCH\n BEQ NLUNCH             \\ to skip the launch tunnel and setup process\n\n JSR LAUN               \\ Show the space station launch tunnel\n\n JSR RES2               \\ Reset a number of flight variables and workspaces\n\n JSR TT111              \\ Select the system closest to galactic coordinates\n                        \\ (QQ9, QQ10)\n\n INC INWK+8             \\ Increment z_sign ready for the call to SOS, so the\n                        \\ planet appears at a z_sign of 1 in front of us when\n                        \\ we launch\n\n JSR SOS1               \\ Call SOS1 to set up the planet's data block and add it\n                        \\ to FRIN, where it will get put in the first slot as\n                        \\ it's the first one to be added to our local bubble of\n                        \\ universe following the call to RES2 above\n\n LDA #128               \\ For the space station, set z_sign to &80, so it's\n STA INWK+8             \\ behind us (&80 is negative)\n\n INC INWK+7             \\ And increment z_hi, so it's only just behind us\n\n JSR NWSPS              \\ Add a new space station to our local bubble of\n                        \\ universe\n\n LDA #12                \\ Set our launch speed in DELTA to 12\n STA DELTA\n\n JSR BAD                \\ Call BAD to work out how much illegal contraband we\n                        \\ are carrying in our hold (A is up to 40 for a\n                        \\ standard hold crammed with contraband, up to 70 for\n                        \\ an extended cargo hold full of narcotics and slaves)\n\n ORA FIST               \\ OR the value in A with our legal status in FIST to\n                        \\ get a new value that is at least as high as both\n                        \\ values, to reflect the fact that launching with a\n                        \\ hold full of contraband can only make matters worse\n\n STA FIST               \\ Update our legal status with the new value\n\n.NLUNCH\n\n LDX #0                 \\ Set QQ12 to 0 to indicate we are not docked\n STX QQ12\n\n JMP LOOK1              \\ Jump to LOOK1 to switch to the front view (X = 0),\n                        \\ returning from the subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: TT114\n\\       Type: Subroutine\n\\   Category: Charts\n\\    Summary: Display either the Long-range or Short-range Chart\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Display either the Long-range or Short-range Chart, depending on the current\n\\ view setting. Called from TT18 once we know the current view is one of the\n\\ charts.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The current view, loaded from QQ11\n\\\n\\ ******************************************************************************\n\n.TT114\n\n BMI TT115              \\ If bit 7 of the current view is set (i.e. the view is\n                        \\ the Short-range Chart, 128), skip to TT115 below to\n                        \\ jump to TT23 to display the chart\n\n JMP TT22               \\ Otherwise the current view is the Long-range Chart, so\n                        \\ jump to TT22 to display it\n\n.TT115\n\n JMP TT23               \\ Jump to TT23 to display the Short-range Chart\n\n\\ ******************************************************************************\n\\\n\\       Name: LCASH\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Subtract an amount of cash from the cash pot\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Subtract (Y X) cash from the cash pot in CASH, but only if there is enough\n\\ cash in the pot. As CASH is a four-byte number, this calculates:\n\\\n\\   CASH(0 1 2 3) = CASH(0 1 2 3) - (0 0 Y X)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   C flag              If set, there was enough cash to do the subtraction\n\\\n\\                       If clear, there was not enough cash to do the\n\\                       subtraction\n\\\n\\ ******************************************************************************\n\n.LCASH\n\n STX T1                 \\ Subtract the least significant bytes:\n LDA CASH+3             \\\n SEC                    \\   CASH+3 = CASH+3 - X\n SBC T1\n STA CASH+3\n\n STY T1                 \\ Then the second most significant bytes:\n LDA CASH+2             \\\n SBC T1                 \\   CASH+2 = CASH+2 - Y\n STA CASH+2\n\n LDA CASH+1             \\ Then the third most significant bytes (which are 0):\n SBC #0                 \\\n STA CASH+1             \\   CASH+1 = CASH+1 - 0\n\n LDA CASH               \\ And finally the most significant bytes (which are 0):\n SBC #0                 \\\n STA CASH               \\   CASH = CASH - 0\n\n BCS TT113              \\ If the C flag is set then the subtraction didn't\n                        \\ underflow, so the value in CASH is correct and we can\n                        \\ jump to TT113 to return from the subroutine with the\n                        \\ C flag set to indicate success (as TT113 contains an\n                        \\ RTS)\n\n                        \\ Otherwise we didn't have enough cash in CASH to\n                        \\ subtract (Y X) from it, so fall through into\n                        \\ MCASH to reverse the sum and restore the original\n                        \\ value in CASH, and returning with the C flag clear\n\n\\ ******************************************************************************\n\\\n\\       Name: MCASH\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Add an amount of cash to the cash pot\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Add (Y X) cash to the cash pot in CASH. As CASH is a four-byte number, this\n\\ calculates:\n\\\n\\   CASH(0 1 2 3) = CASH(0 1 2 3) + (Y X)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   TT113               Contains an RTS\n\\\n\\ ******************************************************************************\n\n.MCASH\n\n TXA                    \\ Add the least significant bytes:\n CLC                    \\\n ADC CASH+3             \\   CASH+3 = CASH+3 + X\n STA CASH+3\n\n TYA                    \\ Then the second most significant bytes:\n ADC CASH+2             \\\n STA CASH+2             \\   CASH+2 = CASH+2 + Y\n\n LDA CASH+1             \\ Then the third most significant bytes (which are 0):\n ADC #0                 \\\n STA CASH+1             \\   CASH+1 = CASH+1 + 0\n\n LDA CASH               \\ And finally the most significant bytes (which are 0):\n ADC #0                 \\\n STA CASH               \\   CASH = CASH + 0\n\n CLC                    \\ Clear the C flag, so if the above was done following\n                        \\ a failed LCASH call, the C flag correctly indicates\n                        \\ failure\n\n.TT113\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: GCASH\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate (Y X) = P * Q * 4\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following multiplication of unsigned 8-bit numbers:\n\\\n\\   (Y X) = P * Q * 4\n\\\n\\ ******************************************************************************\n\n.GCASH\n\n JSR MULTU              \\ Call MULTU to calculate (A P) = P * Q\n\n\\ ******************************************************************************\n\\\n\\       Name: GC2\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate (Y X) = (A P) * 4\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following multiplication of unsigned 16-bit numbers:\n\\\n\\   (Y X) = (A P) * 4\n\\\n\\ ******************************************************************************\n\n.GC2\n\n ASL P                  \\ Set (A P) = (A P) * 4\n ROL A\n ASL P\n ROL A\n\n TAY                    \\ Set (Y X) = (A P)\n LDX P\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: EQSHP\n\\       Type: Subroutine\n\\   Category: Equipment\n\\    Summary: Show the Equip Ship screen (red key f3)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   err                 Beep, pause and go to the docking bay (i.e. show the\n\\                       Status Mode screen)\n\\\n\\   pres                Given an item number A with the item name in recursive\n\\                       token Y, show an error to say that the item is already\n\\                       present, refund the cost of the item, and then beep and\n\\                       exit to the docking bay (i.e. show the Status Mode\n\\                       screen)\n\\\n\\ ******************************************************************************\n\n.bay\n\n JMP BAY                \\ Go to the docking bay (i.e. show the Status Mode\n                        \\ screen)\n\n.EQSHP\n\n JSR DIALS              \\ Call DIALS to update the dashboard\n\n LDA #32                \\ Clear the top part of the screen, draw a border box,\n JSR TT66               \\ and set the current view type in QQ11 to 32 (Equip\n                        \\ Ship screen)\n\n LDA #12                \\ Move the text cursor to column 12\n STA XC\n\n LDA #207               \\ Print recursive token 47 (\"EQUIP\") followed by a space\n JSR spc\n\n LDA #185               \\ Print recursive token 25 (\"SHIP\") and draw a\n JSR NLIN3              \\ horizontal line at pixel row 19 to box in the title\n\n LDA #%10000000         \\ Set bit 7 of QQ17 to switch to Sentence Case, with the\n STA QQ17               \\ next letter in capitals\n\n INC YC                 \\ Move the text cursor down one line\n\n LDA tek                \\ Fetch the tech level of the current system from tek\n CLC                    \\ and add 3 (the tech level is stored as 0-14, so A is\n ADC #3                 \\ now set to between 3 and 17)\n\n CMP #12                \\ If A >= 12 then set A = 12, so A is now set to between\n BCC P%+4               \\ 3 and 12\n LDA #12\n\n STA Q                  \\ Set QQ25 = A (so QQ25 is in the range 3-12 and\n STA QQ25               \\ represents the number of the most advanced item\n INC Q                  \\ available in this system, which we can pass to gnum\n                        \\ below when asking which item we want to buy)\n                        \\\n                        \\ Set Q = A + 1 (so Q is in the range 4-13 and contains\n                        \\ QQ25 + 1, i.e. the highest item number on sale + 1)\n\n LDA #70                \\ Set A = 70 - QQ14, where QQ14 contains the current\n SEC                    \\ fuel in light years * 10, so this leaves the amount\n SBC QQ14               \\ of fuel we need to fill 'er up (in light years * 10)\n\n ASL A                  \\ The price of fuel is always 2 Cr per light year, so we\n STA PRXS               \\ double A and store it in PRXS, as the first price in\n                        \\ the price list (which is reserved for fuel), and\n                        \\ because the table contains prices as price * 10, it's\n                        \\ in the right format (so tank containing 7.0 light\n                        \\ years of fuel would be 14.0 Cr, or a PRXS value of\n                        \\ 140)\n\n LDX #1                 \\ We are now going to work our way through the equipment\n                        \\ price list at PRXS, printing out the equipment that is\n                        \\ available at this station, so set a counter in X,\n                        \\ starting at 1, to hold the number of the current item\n                        \\ plus 1 (so the item number in X loops through 1-13)\n\n.EQL1\n\n STX XX13               \\ Store the current item number + 1 in XX13\n\n JSR TT67               \\ Print a newline\n\n LDX XX13               \\ Print the current item number + 1 to 3 digits, left-\n CLC                    \\ padding with spaces, and with no decimal point, so the\n JSR pr2                \\ items are numbered from 1\n\n JSR TT162              \\ Print a space\n\n LDA XX13               \\ Print recursive token 104 + XX13, which will be in the\n CLC                    \\ range 105 (\"FUEL\") to 116 (\"GALACTIC HYPERSPACE \")\n ADC #104               \\ so this prints the current item's name\n JSR TT27\n\n LDA XX13               \\ Call prx-3 to set (Y X) to the price of the item with\n JSR prx-3              \\ number XX13 - 1 (as XX13 contains the item number + 1)\n\n SEC                    \\ Set the C flag so we will print a decimal point when\n                        \\ we print the price\n\n LDA #25                \\ Move the text cursor to column 25\n STA XC\n\n LDA #6                 \\ Print the number in (Y X) to 6 digits, left-padding\n JSR TT11               \\ with spaces and including a decimal point, which will\n                        \\ be the correct price for this item as (Y X) contains\n                        \\ the price * 10, so the trailing zero will go after the\n                        \\ decimal point (i.e. 5250 will be printed as 525.0)\n\n LDX XX13               \\ Increment the current item number in XX13\n INX\n\n CPX Q                  \\ If X < Q, loop back up to print the next item on the\n BCC EQL1               \\ list of equipment available at this station\n\n JSR CLYNS              \\ Clear the bottom three text rows of the upper screen,\n                        \\ and move the text cursor to the first cleared row\n\n LDA #127               \\ Print recursive token 127 (\"ITEM\") followed by a\n JSR prq                \\ question mark\n\n JSR gnum               \\ Call gnum to get a number from the keyboard, which\n                        \\ will be the number of the item we want to purchase,\n                        \\ returning the number entered in A and R, and setting\n                        \\ the C flag if the number is bigger than the highest\n                        \\ item number in QQ25\n\n BEQ bay                \\ If no number was entered, jump up to bay to go to the\n                        \\ docking bay (i.e. show the Status Mode screen)\n\n BCS bay                \\ If the number entered was too big, jump up to bay to\n                        \\ go to the docking bay (i.e. show the Status Mode\n                        \\ screen)\n\n SBC #0                 \\ Set A to the number entered - 1 (because the C flag is\n                        \\ clear), which will be the actual item number we want\n                        \\ to buy\n\n LDX #2                 \\ Move the text cursor to column 2\n STX XC\n\n INC YC                 \\ Move the text cursor down one line\n\n PHA                    \\ While preserving the value in A, call eq to subtract\n JSR eq                 \\ the price of the item we want to buy (which is in A)\n PLA                    \\ from our cash pot, but only if we have enough cash in\n                        \\ the pot. If we don't have enough cash, exit to the\n                        \\ docking bay (i.e. show the Status Mode screen)\n\n BNE et0                \\ If A is not 0 (i.e. the item we've just bought is not\n                        \\ fuel), skip to et0\n\n STA MCNT               \\ We just bought fuel, so we zero the main loop counter\n\n LDX #70                \\ Set the current fuel level * 10 in QQ14 to 70, or 7.0\n STX QQ14               \\ light years (a full tank)\n\n.et0\n\n CMP #1                 \\ If A is not 1 (i.e. the item we've just bought is not\n BNE et1                \\ a missile), skip to et1\n\n LDX NOMSL              \\ Fetch the current number of missiles from NOMSL into X\n\n INX                    \\ Increment X to the new number of missiles\n\n LDY #117               \\ Set Y to recursive token 117 (\"ALL\")\n\n CPX #5                 \\ If buying this missile would give us 5 missiles, this\n BCS pres               \\ is more than the maximum of 4 missiles that we can\n                        \\ fit, so jump to pres to show the error \"All Present\",\n                        \\ beep and exit to the docking bay (i.e. show the Status\n                        \\ Mode screen)\n\n STX NOMSL              \\ Otherwise update the number of missiles in NOMSL\n\n JSR msblob             \\ Reset the dashboard's missile indicators so none of\n                        \\ them are targeted\n\n.et1\n\n LDY #107               \\ Set Y to recursive token 107 (\"LARGE CARGO{sentence\n                        \\ case} BAY\")\n\n CMP #2                 \\ If A is not 2 (i.e. the item we've just bought is not\n BNE et2                \\ a large cargo bay), skip to et2\n\n LDX #37                \\ If our current cargo capacity in CRGO is 37, then we\n CPX CRGO               \\ already have a large cargo bay fitted, so jump to pres\n BEQ pres               \\ to show the error \"Large Cargo Bay Present\", beep and\n                        \\ exit to the docking bay (i.e. show the Status Mode\n                        \\ screen)\n\n STX CRGO               \\ Otherwise we just scored ourselves a large cargo bay,\n                        \\ so update our current cargo capacity in CRGO to 37\n\n.et2\n\n CMP #3                 \\ If A is not 3 (i.e. the item we've just bought is not\n BNE et3                \\ an E.C.M. system), skip to et3\n\n INY                    \\ Increment Y to recursive token 108 (\"E.C.M.SYSTEM\")\n\n LDX ECM                \\ If we already have an E.C.M. fitted (i.e. ECM is\n BNE pres               \\ non-zero), jump to pres to show the error \"E.C.M.\n                        \\ System Present\", beep and exit to the docking bay\n                        \\ (i.e. show the Status Mode screen)\n\n DEC ECM                \\ Otherwise we just took delivery of a brand new E.C.M.\n                        \\ system, so set ECM to &FF (as ECM was 0 before the DEC\n                        \\ instruction)\n\n.et3\n\n CMP #4                 \\ If A is not 4 (i.e. the item we've just bought is not\n BNE et4                \\ an extra pulse laser), skip to et4\n\n JSR qv                 \\ Print a menu listing the four views, with a \"View ?\"\n                        \\ prompt, and ask for a view number, which is returned\n                        \\ in X (which now contains 0-3)\n\n LDA #4                 \\ This instruction doesn't appear to do anything, as we\n                        \\ either don't need it (if we already have this laser)\n                        \\ or we set A to 4 below (if we buy it)\n\n LDY LASER,X            \\ If there is no laser mounted in the chosen view (i.e.\n BEQ ed4                \\ LASER+X, which contains the laser power for view X, is\n                        \\ zero), jump to ed4 to buy a pulse laser\n\n.ed7\n\n LDY #187               \\ Otherwise we already have a laser mounted in this\n BNE pres               \\ view, so jump to pres with Y set to token 27\n                        \\ (\" LASER\") to show the error \"Laser Present\", beep\n                        \\ and exit to the docking bay (i.e. show the Status\n                        \\ Mode screen)\n\n.ed4\n\n LDA #POW               \\ We just bought a pulse laser for view X, so we need\n STA LASER,X            \\ to fit it by storing the laser power for a pulse laser\n                        \\ (given in POW) in LASER+X\n\n LDA #4                 \\ Set A to 4 as we just overwrote the original value,\n                        \\ and we still need it set correctly so we can continue\n                        \\ through the conditional statements for all the other\n                        \\ equipment\n\n.et4\n\n CMP #5                 \\ If A is not 5 (i.e. the item we've just bought is not\n BNE et5                \\ an extra beam laser), skip to et5\n\n JSR qv                 \\ Print a menu listing the four views, with a \"View ?\"\n                        \\ prompt, and ask for a view number, which is returned\n                        \\ in X (which now contains 0-3)\n\n STX T1                 \\ Store the view in T1 so we can retrieve it below\n\n LDA #5                 \\ Set A to 5 as the call to qv will have overwritten\n                        \\ the original value, and we still need it set\n                        \\ correctly so we can continue through the conditional\n                        \\ statements for all the other equipment\n\n LDY LASER,X            \\ If there is no laser mounted in the chosen view (i.e.\n BEQ ed5                \\ LASER+X, which contains the laser power for view X,\n                        \\ is zero), jump to ed5 to buy a beam laser\n\n\\BPL P%+4               \\ This instruction is commented out in the original\n                        \\ source, though it would have no effect (it would\n                        \\ simply skip the BMI if A is positive, which is what\n                        \\ BMI does anyway)\n\n BMI ed7                \\ If there is a beam laser already mounted in the chosen\n                        \\ view (i.e. LASER+X has bit 7 set, which indicates a\n                        \\ beam laser rather than a pulse laser), skip back to\n                        \\ ed7 to print a \"Laser Present\" error, beep and exit\n                        \\ to the docking bay (i.e. show the Status Mode screen)\n\n LDA #4                 \\ If we get here then we already have a pulse laser in\n JSR prx                \\ the selected view, so we call prx to set (Y X) to the\n                        \\ price of equipment item number 4 (extra pulse laser)\n                        \\ so we can give a refund of the pulse laser\n\n JSR MCASH              \\ Add (Y X) cash to the cash pot in CASH, so we refund\n                        \\ the price of the pulse laser we are exchanging for a\n                        \\ new beam laser\n\n.ed5\n\n LDA #POW+128           \\ We just bought a beam laser for view X, so we need\n LDX T1                 \\ to fit it by storing the laser power for a beam laser\n STA LASER,X            \\ (given in POW+128) in LASER+X, using the view number\n                        \\ we stored in T1 earlier, as the call to prx will have\n                        \\ overwritten the original value in X\n\n.et5\n\n LDY #111               \\ Set Y to recursive token 111 (\"FUEL SCOOPS\")\n\n CMP #6                 \\ If A is not 6 (i.e. the item we've just bought is not\n BNE et6                \\ a fuel scoop), skip to et6\n\n LDX BST                \\ If we already have fuel scoops fitted (i.e. BST is\n BEQ ed9                \\ zero), jump to ed9, otherwise fall through into pres\n                        \\ to show the error \"Fuel Scoops Present\", beep and\n                        \\ exit to the docking bay (i.e. show the Status Mode\n                        \\ screen)\n\n.pres\n\n                        \\ If we get here we need to show an error to say that\n                        \\ the item whose name is in recursive token Y is already\n                        \\ present, and then process a refund for the cost of\n                        \\ item number A\n\n STY K                  \\ Store the item's name in K\n\n JSR prx                \\ Call prx to set (Y X) to the price of equipment item\n                        \\ number A\n\n JSR MCASH              \\ Add (Y X) cash to the cash pot in CASH, as the station\n                        \\ already took the money for this item in the JSR eq\n                        \\ instruction above, but we can't fit the item, so need\n                        \\ our money back\n\n LDA K                  \\ Print the recursive token in K (the item's name)\n JSR spc                \\ followed by a space\n\n LDA #31                \\ Print recursive token 145 (\"PRESENT\")\n JSR TT27\n\n.err\n\n JSR dn2                \\ Call dn2 to make a short, high beep and delay for 1\n                        \\ second\n\n JMP BAY                \\ Jump to BAY to go to the docking bay (i.e. show the\n                        \\ Status Mode screen)\n\n.ed9\n\n DEC BST                \\ We just bought a shiny new fuel scoop, so set BST to\n                        \\ &FF (as BST was 0 before the jump to ed9 above)\n\n.et6\n\n INY                    \\ Increment Y to recursive token 112 (\"E.C.M.SYSTEM\")\n\n CMP #7                 \\ If A is not 7 (i.e. the item we've just bought is not\n BNE et7                \\ an escape pod), skip to et7\n\n LDX ESCP               \\ If we already have an escape pod fitted (i.e. ESCP is\n BNE pres               \\ non-zero), jump to pres to show the error \"Escape Pod\n                        \\ Present\", beep and exit to the docking bay (i.e. show\n                        \\ the Status Mode screen)\n\n DEC ESCP               \\ Otherwise we just bought an escape pod, so set ESCP\n                        \\ to &FF (as ESCP was 0 before the DEC instruction)\n\n.et7\n\n INY                    \\ Increment Y to recursive token 113 (\"ENERGY BOMB\")\n\n CMP #8                 \\ If A is not 8 (i.e. the item we've just bought is not\n BNE et8                \\ an energy bomb), skip to et8\n\n LDX BOMB               \\ If we already have an energy bomb fitted (i.e. BOMB\n BNE pres               \\ is non-zero), jump to pres to show the error \"Energy\n                        \\ Bomb Present\", beep and exit to the docking bay (i.e.\n                        \\ show the Status Mode screen)\n\n LDX #&7F               \\ Otherwise we just bought an energy bomb, so set BOMB\n STX BOMB               \\ to &7F\n\n.et8\n\n INY                    \\ Increment Y to recursive token 114 (\"ENERGY UNIT\")\n\n CMP #9                 \\ If A is not 9 (i.e. the item we've just bought is not\n BNE etA                \\ an energy unit), skip to etA\n\n LDX ENGY               \\ If we already have an energy unit fitted (i.e. ENGY is\n BNE pres               \\ non-zero), jump to pres to show the error \"Energy Unit\n                        \\ Present\", beep and exit to the docking bay (i.e. show\n                        \\ the Status Mode screen)\n\n INC ENGY               \\ Otherwise we just picked up an energy unit, so set\n                        \\ ENGY to 1 (as ENGY was 0 before the INC instruction)\n\n.etA\n\n INY                    \\ Increment Y to recursive token 115 (\"DOCKING\n                        \\ COMPUTERS\")\n\n CMP #10                \\ If A is not 10 (i.e. the item we've just bought is not\n BNE etB                \\ a docking computer), skip to etB\n\n LDX DKCMP              \\ If we already have a docking computer fitted (i.e.\n BNE pres               \\ DKCMP is non-zero), jump to pres to show the error\n                        \\ \"Docking Computer Present\", beep and exit to the\n                        \\ docking bay (i.e. show the Status Mode screen)\n\n DEC DKCMP              \\ Otherwise we just got hold of a docking computer, so\n                        \\ set DKCMP to &FF (as DKCMP was 0 before the DEC\n                        \\ instruction)\n\n.etB\n\n INY                    \\ Increment Y to recursive token 116 (\"GALACTIC\n                        \\ HYPERSPACE \")\n\n CMP #11                \\ If A is not 11 (i.e. the item we've just bought is not\n BNE et9                \\ a galactic hyperdrive), skip to et9\n\n LDX GHYP               \\ If we already have a galactic hyperdrive fitted (i.e.\n BNE pres               \\ GHYP is non-zero), jump to pres to show the error\n                        \\ \"Galactic Hyperspace Present\", beep and exit to the\n                        \\ docking bay (i.e. show the Status Mode screen)\n\n DEC GHYP               \\ Otherwise we just splashed out on a galactic\n                        \\ hyperdrive, so set GHYP to &FF (as GHYP was 0 before\n                        \\ the DEC instruction)\n\n.et9\n\n JSR dn                 \\ We are done buying equipment, so print the amount of\n                        \\ cash left in the cash pot, then make a short, high\n                        \\ beep to confirm the purchase, and delay for 1 second\n\n JMP EQSHP              \\ Jump back up to EQSHP to show the Equip Ship screen\n                        \\ again and see if we can't track down another bargain\n\n\\ ******************************************************************************\n\\\n\\       Name: dn\n\\       Type: Subroutine\n\\   Category: Market\n\\    Summary: Print the amount of money we have left in the cash pot, then make\n\\             a short, high beep and delay for 1 second\n\\\n\\ ******************************************************************************\n\n.dn\n\n JSR TT162              \\ Print a space\n\n LDA #119               \\ Print recursive token 119 (\"CASH:{cash} CR{crlf}\")\n JSR spc                \\ followed by a space\n\n                        \\ Fall through into dn2 to make a beep and delay for\n                        \\ 1 second before returning from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: dn2\n\\       Type: Subroutine\n\\   Category: Text\n\\    Summary: Make a short, high beep and delay for 1 second\n\\\n\\ ******************************************************************************\n\n.dn2\n\n JSR BEEP               \\ Call the BEEP subroutine to make a short, high beep\n\n LDY #50                \\ Wait for 50/50 of a second (1 second) and return\n JMP DELAY              \\ from the subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: eq\n\\       Type: Subroutine\n\\   Category: Equipment\n\\    Summary: Subtract the price of equipment from the cash pot\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ If we have enough cash, subtract the price of a specified piece of equipment\n\\ from our cash pot and return from the subroutine. If we don't have enough\n\\ cash, exit to the docking bay (i.e. show the Status Mode screen).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The item number of the piece of equipment (0-11) as\n\\                       shown in the table at PRXS\n\\\n\\ ******************************************************************************\n\n.eq\n\n JSR prx                \\ Call prx to set (Y X) to the price of equipment item\n                        \\ number A\n\n JSR LCASH              \\ Subtract (Y X) cash from the cash pot, but only if\n                        \\ we have enough cash\n\n BCS c                  \\ If the C flag is set then we did have enough cash for\n                        \\ the transaction, so jump to c to return from the\n                        \\ subroutine (as c contains an RTS)\n\n LDA #197               \\ Otherwise we don't have enough cash to buy this piece\n JSR prq                \\ of equipment, so print recursive token 37 (\"CASH\")\n                        \\ followed by a question mark\n\n JMP err                \\ Jump to err to beep, pause and go to the docking bay\n                        \\ (i.e. show the Status Mode screen)\n\n\\ ******************************************************************************\n\\\n\\       Name: prx\n\\       Type: Subroutine\n\\   Category: Equipment\n\\    Summary: Return the price of a piece of equipment\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine returns the price of equipment as listed in the table at PRXS.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The item number of the piece of equipment (0-11) as\n\\                       shown in the table at PRXS\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   (Y X)               The item price in Cr * 10 (Y = high byte, X = low byte)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   prx-3               Return the price of the item with number A - 1\n\\\n\\   c                   Contains an RTS\n\\\n\\ ******************************************************************************\n\n SEC                    \\ Decrement A (for when this routine is called via\n SBC #1                 \\ prx-3)\n\n.prx\n\n ASL A                  \\ Set Y = A * 2, so it can act as an index into the\n TAY                    \\ PRXS table, which has two bytes per entry\n\n LDX PRXS,Y             \\ Fetch the low byte of the price into X\n\n LDA PRXS+1,Y           \\ Fetch the high byte of the price into A and transfer\n TAY                    \\ it to X, so the price is now in (Y X)\n\n.c\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: qv\n\\       Type: Subroutine\n\\   Category: Equipment\n\\    Summary: Print a menu of the four space views, for buying lasers\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Print a menu in the bottom-middle of the screen, at row 16, column 12, that\n\\ lists the four available space views, like this:\n\\\n\\                 0 Front\n\\                 1 Rear\n\\                 2 Left\n\\                 3 Right\n\\\n\\ Also print a \"View ?\" prompt and ask for a view number. The menu is shown\n\\ when we choose to buy a new laser in the Equip Ship screen.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   X                   The chosen view number (0-3)\n\\\n\\ ******************************************************************************\n\n.qv\n\n LDY #16                \\ Move the text cursor to row 16, and at the same time\n STY YC                 \\ set Y to a counter going from 16 to 19 in the loop\n                        \\ below\n\n.qv1\n\n LDX #12                \\ Move the text cursor to column 12\n STX XC\n\n TYA                    \\ Transfer the counter value from Y to A\n\n CLC                    \\ Print ASCII character \"0\" - 16 + A, so as A goes from\n ADC #'0'-16            \\ 16 to 19, this prints \"0\" through \"3\" followed by a\n JSR spc                \\ space\n\n LDA YC                 \\ Print recursive text token 80 + YC, so as YC goes from\n CLC                    \\ 16 to 19, this prints \"FRONT\", \"REAR\", \"LEFT\" and\n ADC #80                \\ \"RIGHT\"\n JSR TT27\n\n INC YC                 \\ Move the text cursor down a row, and increment the\n                        \\ counter in YC at the same time\n\n LDY YC                 \\ Update Y with the incremented counter in YC\n\n CPY #20                \\ If Y < 20 then loop back up to qv1 to print the next\n BCC qv1                \\ view in the menu\n\n.qv3\n\n JSR CLYNS              \\ Clear the bottom three text rows of the upper screen,\n                        \\ and move the text cursor to the first cleared row\n\n.qv2\n\n LDA #175               \\ Print recursive text token 15 (\"VIEW \") followed by\n JSR prq                \\ a question mark\n\n JSR TT217              \\ Scan the keyboard until a key is pressed, and return\n                        \\ the key's ASCII code in A (and X)\n\n SEC                    \\ Subtract ASCII \"0\" from the key pressed, to leave the\n SBC #'0'               \\ numeric value of the key in A (if it was a number key)\n\n CMP #4                 \\ If the number entered in A >= 4, then it is not a\n BCS qv3                \\ valid view number, so jump back to qv3 to try again\n\n TAX                    \\ We have a valid view number, so transfer it to X\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\ Save ELTD.bin\n\\\n\\ ******************************************************************************\n\n PRINT \"ELITE D\"\n PRINT \"Assembled at \", ~CODE_D%\n PRINT \"Ends at \", ~P%\n PRINT \"Code size is \", ~(P% - CODE_D%)\n PRINT \"Execute at \", ~LOAD%\n PRINT \"Reload at \", ~LOAD_D%\n\n PRINT \"S.ELTD \", ~CODE_D%, \" \", ~P%, \" \", ~LOAD%, \" \", ~LOAD_D%\n SAVE \"3-assembled-output/ELTD.bin\", CODE_D%, P%, LOAD%\n\n\\ ******************************************************************************\n\\\n\\ ELITE E FILE\n\\\n\\ Produces the binary file ELTE.bin that gets loaded by elite-bcfs.asm.\n\\\n\\ ******************************************************************************\n\n CODE_E% = P%\n\n LOAD_E% = LOAD% + P% - CODE%\n\n\\ ******************************************************************************\n\\\n\\       Name: Authors' names\n\\       Type: Variable\n\\   Category: Copy protection\n\\    Summary: The authors' names and a copyright notice, buried in the code\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This copyright notice is not used anywhere and it is obfuscated by EOR'ing\n\\ each character with 164, but presumably the authors wanted their names buried\n\\ in the code somewhere. Though they do also have recursive token 94, which\n\\ reads \"BY D.BRABEN & I.BELL\" and can be displayed on the title screen using\n\\ the \"X\" configuration option, so this isn't the only author name easter egg\n\\ in the game. It contains the following text:\n\\\n\\   (C)Bell/Braben1984\n\\\n\\ ******************************************************************************\n\n EQUB '(' EOR 164\n EQUB 'C' EOR 164\n EQUB ')' EOR 164\n EQUB 'B' EOR 164\n EQUB 'e' EOR 164\n EQUB 'l' EOR 164\n EQUB 'l' EOR 164\n EQUB '/' EOR 164\n EQUB 'B' EOR 164\n EQUB 'r' EOR 164\n EQUB 'a' EOR 164\n EQUB 'b' EOR 164\n EQUB 'e' EOR 164\n EQUB 'n' EOR 164\n EQUB '1' EOR 164\n EQUB '9' EOR 164\n EQUB '8' EOR 164\n EQUB '4' EOR 164\n\n\\ ******************************************************************************\n\\\n\\       Name: cpl\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Print the selected system name\n\\  Deep dive: Generating system names\n\\             Galaxy and system seeds\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Print control code 3 (the selected system name, i.e. the one in the crosshairs\n\\ in the Short-range Chart).\n\\\n\\ ******************************************************************************\n\n.cpl\n\n LDX #5                 \\ First we need to back up the seeds in QQ15, so set up\n                        \\ a counter in X to cover three 16-bit seeds (i.e.\n                        \\ 6 bytes)\n\n.TT53\n\n LDA QQ15,X             \\ Copy byte X from QQ15 to QQ19\n STA QQ19,X\n\n DEX                    \\ Decrement the loop counter\n\n BPL TT53               \\ Loop back for the next byte to back up\n\n LDY #3                 \\ Step 1: Now that the seeds are backed up, we can\n                        \\ start the name-generation process. We will either\n                        \\ need to loop three or four times, so for now set\n                        \\ up a counter in Y to loop four times\n\n BIT QQ15               \\ Check bit 6 of s0_lo, which is stored in QQ15\n\n BVS P%+3               \\ If bit 6 is set then skip over the next instruction\n\n DEY                    \\ Bit 6 is clear, so we only want to loop three times,\n                        \\ so decrement the loop counter in Y\n\n STY T                  \\ Store the loop counter in T\n\n.TT55\n\n LDA QQ15+5             \\ Step 2: Load s2_hi, which is stored in QQ15+5, and\n AND #%00011111         \\ extract bits 0-4 by AND'ing with %11111\n\n BEQ P%+7               \\ If all those bits are zero, then skip the following\n                        \\ two instructions to go to step 3\n\n ORA #%10000000         \\ We now have a number in the range 1-31, which we can\n                        \\ easily convert into a two-letter token, but first we\n                        \\ need to add 128 (or set bit 7) to get a range of\n                        \\ 129-159\n\n JSR TT27               \\ Print the two-letter token in A\n\n JSR TT54               \\ Step 3: twist the seeds in QQ15\n\n DEC T                  \\ Decrement the loop counter\n\n BPL TT55               \\ Loop back for the next two letters\n\n LDX #5                 \\ We have printed the system name, so we can now\n                        \\ restore the seeds we backed up earlier. Set up a\n                        \\ counter in X to cover three 16-bit seeds (i.e. 6\n                        \\ bytes)\n\n.TT56\n\n LDA QQ19,X             \\ Copy byte X from QQ19 to QQ15\n STA QQ15,X\n\n DEX                    \\ Decrement the loop counter\n\n BPL TT56               \\ Loop back for the next byte to restore\n\n RTS                    \\ Once all the seeds are restored, return from the\n                        \\ subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: cmn\n\\       Type: Subroutine\n\\   Category: Status\n\\    Summary: Print the commander's name\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Print control code 4 (the commander's name).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   cmn-1               Contains an RTS\n\\\n\\ ******************************************************************************\n\n.cmn\n\n LDY #0                 \\ Set up a counter in Y, starting from 0\n\n.QUL4\n\n LDA NA%,Y              \\ The commander's name is stored at NA%, so load the\n                        \\ Y-th character from NA%\n\n CMP #13                \\ If we have reached the end of the name, return from\n BEQ ypl-1              \\ the subroutine (ypl-1 points to the RTS below)\n\n JSR TT26               \\ Print the character we just loaded\n\n INY                    \\ Increment the loop counter\n\n BNE QUL4               \\ Loop back for the next character\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: ypl\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Print the current system name\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Print control code 2 (the current system name).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   ypl-1               Contains an RTS\n\\\n\\ ******************************************************************************\n\n.ypl\n\n LDA MJ                 \\ Check the mis-jump flag at MJ, and if it is non-zero\n BNE cmn-1              \\ then we are in witchspace, and witchspace doesn't have\n                        \\ a system name, so return from the subroutine (cmn-1\n                        \\ contains an RTS)\n\n JSR TT62               \\ Call TT62 below to swap the three 16-bit seeds in\n                        \\ QQ2 and QQ15 (before the swap, QQ2 contains the seeds\n                        \\ for the current system, while QQ15 contains the seeds\n                        \\ for the selected system)\n\n JSR cpl                \\ Call cpl to print out the system name for the seeds\n                        \\ in QQ15 (which now contains the seeds for the current\n                        \\ system)\n\n                        \\ Now we fall through into the TT62 subroutine, which\n                        \\ will swap QQ2 and QQ15 once again, so everything goes\n                        \\ back into the right place, and the RTS at the end of\n                        \\ TT62 will return from the subroutine\n\n.TT62\n\n LDX #5                 \\ Set up a counter in X for the three 16-bit seeds we\n                        \\ want to swap (i.e. 6 bytes)\n\n.TT78\n\n LDA QQ15,X             \\ Swap byte X between QQ2 and QQ15\n LDY QQ2,X\n STA QQ2,X\n STY QQ15,X\n\n DEX                    \\ Decrement the loop counter\n\n BPL TT78               \\ Loop back for the next byte to swap\n\n RTS                    \\ Once all bytes are swapped, return from the\n                        \\ subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: tal\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Print the current galaxy number\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Print control code 1 (the current galaxy number, right-aligned to width 3).\n\\\n\\ ******************************************************************************\n\n.tal\n\n CLC                    \\ We don't want to print the galaxy number with a\n                        \\ decimal point, so clear the C flag for pr2 to take as\n                        \\ an argument\n\n LDX GCNT               \\ Load the current galaxy number from GCNT into X\n\n INX                    \\ Add 1 to the galaxy number, as the galaxy numbers\n                        \\ are 0-7 internally, but we want to display them as\n                        \\ galaxy 1 through 8\n\n JMP pr2                \\ Jump to pr2, which prints the number in X to a width\n                        \\ of 3 figures, left-padding with spaces to a width of\n                        \\ 3, and return from the subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: fwl\n\\       Type: Subroutine\n\\   Category: Status\n\\    Summary: Print fuel and cash levels\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Print control code 5 (\"FUEL: \", fuel level, \" LIGHT YEARS\", newline, \"CASH:\",\n\\ control code 0).\n\\\n\\ ******************************************************************************\n\n.fwl\n\n LDA #105               \\ Print recursive token 105 (\"FUEL\") followed by a\n JSR TT68               \\ colon\n\n LDX QQ14               \\ Load the current fuel level from QQ14\n\n SEC                    \\ We want to print the fuel level with a decimal point,\n                        \\ so set the C flag for pr2 to take as an argument\n\n JSR pr2                \\ Call pr2, which prints the number in X to a width of\n                        \\ 3 figures (i.e. in the format x.x, which will always\n                        \\ be exactly 3 characters as the maximum fuel is 7.0)\n\n LDA #195               \\ Print recursive token 35 (\"LIGHT YEARS\") followed by\n JSR plf                \\ a newline\n\n.PCASH\n\n LDA #119               \\ Print recursive token 119 (\"CASH:\" then control code\n BNE TT27               \\ 0, which prints cash levels, then \" CR\" and newline)\n\n\\ ******************************************************************************\n\\\n\\       Name: csh\n\\       Type: Subroutine\n\\   Category: Status\n\\    Summary: Print the current amount of cash\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Print control code 0 (the current amount of cash, right-aligned to width 9,\n\\ followed by \" CR\" and a newline).\n\\\n\\ ******************************************************************************\n\n.csh\n\n LDX #3                 \\ We are going to use the BPRNT routine to print out\n                        \\ the current amount of cash, which is stored as a\n                        \\ 32-bit number at location CASH. BPRNT prints out\n                        \\ the 32-bit number stored in K, so before we call\n                        \\ BPRNT, we need to copy the four bytes from CASH into\n                        \\ K, so first we set up a counter in X for the 4 bytes\n\n.pc1\n\n LDA CASH,X             \\ Copy byte X from CASH to K\n STA K,X\n\n DEX                    \\ Decrement the loop counter\n\n BPL pc1                \\ Loop back for the next byte to copy\n\n LDA #9                 \\ We want to print the cash amount using up to 9 digits\n STA U                  \\ (including the decimal point), so store this in U\n                        \\ for BRPNT to take as an argument\n\n SEC                    \\ We want to print the cash amount with a decimal point,\n                        \\ so set the C flag for BRPNT to take as an argument\n\n JSR BPRNT              \\ Print the amount of cash to 9 digits with a decimal\n                        \\ point\n\n LDA #226               \\ Print recursive token 66 (\" CR\") followed by a\n                        \\ newline by falling through into plf\n\n\\ ******************************************************************************\n\\\n\\       Name: plf\n\\       Type: Subroutine\n\\   Category: Text\n\\    Summary: Print a text token followed by a newline\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The text token to be printed\n\\\n\\ ******************************************************************************\n\n.plf\n\n JSR TT27               \\ Print the text token in A\n\n JMP TT67               \\ Jump to TT67 to print a newline and return from the\n                        \\ subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: TT68\n\\       Type: Subroutine\n\\   Category: Text\n\\    Summary: Print a text token followed by a colon\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The text token to be printed\n\\\n\\ ******************************************************************************\n\n.TT68\n\n JSR TT27               \\ Print the text token in A and fall through into TT73\n                        \\ to print a colon\n\n\\ ******************************************************************************\n\\\n\\       Name: TT73\n\\       Type: Subroutine\n\\   Category: Text\n\\    Summary: Print a colon\n\\\n\\ ******************************************************************************\n\n.TT73\n\n LDA #':'               \\ Set A to ASCII \":\" and fall through into TT27 to\n                        \\ actually print the colon\n\n\\ ******************************************************************************\n\\\n\\       Name: TT27\n\\       Type: Subroutine\n\\   Category: Text\n\\    Summary: Print a text token\n\\  Deep dive: Printing text tokens\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Print a text token (i.e. a character, control code, two-letter token or\n\\ recursive token).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The text token to be printed\n\\\n\\ ******************************************************************************\n\n.TT27\n\n TAX                    \\ Copy the token number from A to X. We can then keep\n                        \\ decrementing X and testing it against zero, while\n                        \\ keeping the original token number intact in A; this\n                        \\ effectively implements a switch statement on the\n                        \\ value of the token\n\n BEQ csh                \\ If token = 0, this is control code 0 (current amount\n                        \\ of cash and newline), so jump to csh to print the\n                        \\ amount of cash and return from the subroutine using\n                        \\ a tail call\n\n BMI TT43               \\ If token > 127, this is either a two-letter token\n                        \\ (128-159) or a recursive token (160-255), so jump\n                        \\ to TT43 to process tokens\n\n DEX                    \\ If token = 1, this is control code 1 (current galaxy\n BEQ tal                \\ number), so jump to tal to print the galaxy number and\n                        \\ return from the subroutine using a tail call\n\n DEX                    \\ If token = 2, this is control code 2 (current system\n BEQ ypl                \\ name), so jump to ypl to print the current system name\n                        \\ and return from the subroutine using a tail call\n\n DEX                    \\ If token > 3, skip the following instruction\n BNE P%+5\n\n JMP cpl                \\ This token is control code 3 (selected system name)\n                        \\ so jump to cpl to print the selected system name\n                        \\ and return from the subroutine using a tail call\n\n DEX                    \\ If token = 4, this is control code 4 (commander\n BEQ cmn                \\ name), so jump to cmn to print the commander name\n                        \\ and return from the subroutine using a tail call\n\n DEX                    \\ If token = 5, this is control code 5 (fuel, newline,\n BEQ fwl                \\ cash, newline), so jump to fwl to print the fuel level\n                        \\ and return from the subroutine using a tail call\n\n DEX                    \\ If token > 6, skip the following three instructions\n BNE P%+7\n\n LDA #%10000000         \\ This token is control code 6 (switch to Sentence\n STA QQ17               \\ Case), so set bit 7 of QQ17 to switch to Sentence Case\n RTS                    \\ and return from the subroutine as we are done\n\n DEX                    \\ If token > 8, skip the following two instructions\n DEX\n BNE P%+5\n\n STX QQ17               \\ This token is control code 8 (switch to ALL CAPS), so\n RTS                    \\ set QQ17 to 0 to switch to ALL CAPS and return from\n                        \\ the subroutine as we are done\n\n DEX                    \\ If token = 9, this is control code 9 (tab to column\n BEQ crlf               \\ 21 and print a colon), so jump to crlf\n\n CMP #96                \\ By this point, token is either 7, or in 10-127.\n BCS ex                 \\ Check token number in A and if token >= 96, then the\n                        \\ token is in 96-127, which is a recursive token, so\n                        \\ jump to ex, which prints recursive tokens in this\n                        \\ range (i.e. where the recursive token number is\n                        \\ correct and doesn't need correcting)\n\n CMP #14                \\ If token < 14, skip the following two instructions\n BCC P%+6\n\n CMP #32                \\ If token < 32, then this means token is in 14-31, so\n BCC qw                 \\ this is a recursive token that needs 114 adding to it\n                        \\ to get the recursive token number, so jump to qw\n                        \\ which will do this\n\n                        \\ By this point, token is either 7 (beep) or in 10-13\n                        \\ (line feeds and carriage returns), or in 32-95\n                        \\ (ASCII letters, numbers and punctuation)\n\n LDX QQ17               \\ Fetch QQ17, which controls letter case, into X\n\n BEQ TT74               \\ If QQ17 = 0, then ALL CAPS is set, so jump to TT74\n                        \\ to print this character as is (i.e. as a capital)\n\n BMI TT41               \\ If QQ17 has bit 7 set, then we are using Sentence\n                        \\ Case, so jump to TT41, which will print the\n                        \\ character in upper or lower case, depending on\n                        \\ whether this is the first letter in a word\n\n BIT QQ17               \\ If we get here, QQ17 is not 0 and bit 7 is clear, so\n BVS TT46               \\ either it is bit 6 that is set, or some other flag in\n                        \\ QQ17 is set (bits 0-5). So check whether bit 6 is set.\n                        \\ If it is, then ALL CAPS has been set (as bit 7 is\n                        \\ clear) but bit 6 is still indicating that the next\n                        \\ character should be printed in lower case, so we need\n                        \\ to fix this. We do this with a jump to TT46, which\n                        \\ will print this character in upper case and clear bit\n                        \\ 6, so the flags are consistent with ALL CAPS going\n                        \\ forward\n\n                        \\ If we get here, some other flag is set in QQ17 (one\n                        \\ of bits 0-5 is set), which shouldn't happen in this\n                        \\ version of Elite. If this were the case, then we\n                        \\ would fall through into TT42 to print in lower case,\n                        \\ which is how printing all words in lower case could\n                        \\ be supported (by setting QQ17 to 1, say)\n\n\\ ******************************************************************************\n\\\n\\       Name: TT42\n\\       Type: Subroutine\n\\   Category: Text\n\\    Summary: Print a letter in lower case\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The character to be printed. Can be one of the\n\\                       following:\n\\\n\\                         * 7 (beep)\n\\\n\\                         * 10-13 (line feeds and carriage returns)\n\\\n\\                         * 32-95 (ASCII capital letters, numbers and\n\\                           punctuation)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   TT44                Jumps to TT26 to print the character in A (used to\n\\                       enable us to use a branch instruction to jump to TT26)\n\\\n\\ ******************************************************************************\n\n.TT42\n\n CMP #'A'               \\ If A < ASCII \"A\", then this is punctuation, so jump\n BCC TT44               \\ to TT26 (via TT44) to print the character as is, as\n                        \\ we don't care about the character's case\n\n CMP #'Z'+1             \\ If A >= (ASCII \"Z\" + 1), then this is also\n BCS TT44               \\ punctuation, so jump to TT26 (via TT44) to print the\n                        \\ character as is, as we don't care about the\n                        \\ character's case\n\n ADC #32                \\ Add 32 to the character, to convert it from upper to\n                        \\ lower case\n\n.TT44\n\n JMP TT26               \\ Print the character in A\n\n\\ ******************************************************************************\n\\\n\\       Name: TT41\n\\       Type: Subroutine\n\\   Category: Text\n\\    Summary: Print a letter according to Sentence Case\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The rules for printing in Sentence Case are as follows:\n\\\n\\   * If QQ17 bit 6 is set, print lower case (via TT45)\n\\\n\\   * If QQ17 bit 6 is clear, then:\n\\\n\\       * If character is punctuation, just print it\n\\\n\\       * If character is a letter, set QQ17 bit 6 and print letter as a capital\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The character to be printed. Can be one of the\n\\                       following:\n\\\n\\                         * 7 (beep)\n\\\n\\                         * 10-13 (line feeds and carriage returns)\n\\\n\\                         * 32-95 (ASCII capital letters, numbers and\n\\                           punctuation)\n\\\n\\   X                   Contains the current value of QQ17\n\\\n\\   QQ17                Bit 7 is set\n\\\n\\ ******************************************************************************\n\n.TT41\n\n                        \\ If we get here, then QQ17 has bit 7 set, so we are in\n                        \\ Sentence Case\n\n BIT QQ17               \\ If QQ17 also has bit 6 set, jump to TT45 to print\n BVS TT45               \\ this character in lower case\n\n                        \\ If we get here, then QQ17 has bit 6 clear and bit 7\n                        \\ set, so we are in Sentence Case and we need to print\n                        \\ the next letter in upper case\n\n CMP #'A'               \\ If A < ASCII \"A\", then this is punctuation, so jump\n BCC TT74               \\ to TT26 (via TT44) to print the character as is, as\n                        \\ we don't care about the character's case\n\n PHA                    \\ Otherwise this is a letter, so store the token number\n\n TXA                    \\ Set bit 6 in QQ17 (X contains the current QQ17)\n ORA #%1000000          \\ so the next letter after this one is printed in lower\n STA QQ17               \\ case\n\n PLA                    \\ Restore the token number into A\n\n BNE TT44               \\ Jump to TT26 (via TT44) to print the character in A\n                        \\ (this BNE is effectively a JMP as A will never be\n                        \\ zero)\n\n\\ ******************************************************************************\n\\\n\\       Name: qw\n\\       Type: Subroutine\n\\   Category: Text\n\\    Summary: Print a recursive token in the range 128-145\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Print a recursive token where the token number is in 128-145 (so the value\n\\ passed to TT27 is in the range 14-31).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   A value from 128-145, which refers to a recursive token\n\\                       in the range 14-31\n\\\n\\ ******************************************************************************\n\n.qw\n\n ADC #114               \\ This is a recursive token in the range 0-95, so add\n BNE ex                 \\ 114 to the argument to get the token number 128-145\n                        \\ and jump to ex to print it\n\n\\ ******************************************************************************\n\\\n\\       Name: crlf\n\\       Type: Subroutine\n\\   Category: Text\n\\    Summary: Tab to column 21 and print a colon\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Print control code 9 (tab to column 21 and print a colon). The subroutine\n\\ name is pretty misleading, as it doesn't have anything to do with carriage\n\\ returns or line feeds.\n\\\n\\ ******************************************************************************\n\n.crlf\n\n LDA #21                \\ Set the X-column in XC to 21\n STA XC\n\n BNE TT73               \\ Jump to TT73, which prints a colon (this BNE is\n                        \\ effectively a JMP as A will never be zero)\n\n\\ ******************************************************************************\n\\\n\\       Name: TT45\n\\       Type: Subroutine\n\\   Category: Text\n\\    Summary: Print a letter in lower case\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine prints a letter in lower case. Specifically:\n\\\n\\   * If QQ17 = 255, abort printing this character as printing is disabled\n\\\n\\   * If this is a letter then print in lower case\n\\\n\\   * Otherwise this is punctuation, so clear bit 6 in QQ17 and print\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The character to be printed. Can be one of the\n\\                       following:\n\\\n\\                         * 7 (beep)\n\\\n\\                         * 10-13 (line feeds and carriage returns)\n\\\n\\                         * 32-95 (ASCII capital letters, numbers and\n\\                           punctuation)\n\\\n\\   X                   Contains the current value of QQ17\n\\\n\\   QQ17                Bits 6 and 7 are set\n\\\n\\ ******************************************************************************\n\n.TT45\n\n                        \\ If we get here, then QQ17 has bit 6 and 7 set, so we\n                        \\ are in Sentence Case and we need to print the next\n                        \\ letter in lower case\n\n CPX #255               \\ If QQ17 = 255 then printing is disabled, so return\n BEQ TT48               \\ from the subroutine (as TT48 contains an RTS)\n\n CMP #'A'               \\ If A >= ASCII \"A\", then jump to TT42, which will\n BCS TT42               \\ print the letter in lowercase\n\n                        \\ Otherwise this is not a letter, it's punctuation, so\n                        \\ this is effectively a word break. We therefore fall\n                        \\ through to TT46 to print the character and set QQ17\n                        \\ to ensure the next word starts with a capital letter\n\n\\ ******************************************************************************\n\\\n\\       Name: TT46\n\\       Type: Subroutine\n\\   Category: Text\n\\    Summary: Print a character and switch to capitals\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Print a character and clear bit 6 in QQ17, so that the next letter that gets\n\\ printed after this will start with a capital letter.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The character to be printed. Can be one of the\n\\                       following:\n\\\n\\                         * 7 (beep)\n\\\n\\                         * 10-13 (line feeds and carriage returns)\n\\\n\\                         * 32-95 (ASCII capital letters, numbers and\n\\                           punctuation)\n\\\n\\   X                   Contains the current value of QQ17\n\\\n\\   QQ17                Bits 6 and 7 are set\n\\\n\\ ******************************************************************************\n\n.TT46\n\n PHA                    \\ Store the token number\n\n TXA                    \\ Clear bit 6 in QQ17 (X contains the current QQ17) so\n AND #%10111111         \\ the next letter after this one is printed in upper\n STA QQ17               \\ case\n\n PLA                    \\ Restore the token number into A\n\n                        \\ Now fall through into TT74 to print the character\n\n\\ ******************************************************************************\n\\\n\\       Name: TT74\n\\       Type: Subroutine\n\\   Category: Text\n\\    Summary: Print a character\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The character to be printed\n\\\n\\ ******************************************************************************\n\n.TT74\n\n JMP TT26               \\ Print the character in A\n\n\\ ******************************************************************************\n\\\n\\       Name: TT43\n\\       Type: Subroutine\n\\   Category: Text\n\\    Summary: Print a two-letter token or recursive token 0-95\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Print a two-letter token, or a recursive token where the token number is in\n\\ 0-95 (so the value passed to TT27 is in the range 160-255).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   One of the following:\n\\\n\\                         * 128-159 (two-letter token)\n\\\n\\                         * 160-255 (the argument to TT27 that refers to a\n\\                           recursive token in the range 0-95)\n\\\n\\ ******************************************************************************\n\n.TT43\n\n CMP #160               \\ If token >= 160, then this is a recursive token, so\n BCS TT47               \\ jump to TT47 below to process it\n\n AND #127               \\ This is a two-letter token with number 128-159. The\n ASL A                  \\ set of two-letter tokens is stored in a lookup table\n                        \\ at QQ16, with each token taking up two bytes, so to\n                        \\ convert this into the token's position in the table,\n                        \\ we subtract 128 (or just clear bit 7) and multiply\n                        \\ by 2 (or shift left)\n\n TAY                    \\ Transfer the token's position into Y so we can look\n                        \\ up the token using absolute indexed mode\n\n LDA QQ16,Y             \\ Get the first letter of the token and print it\n JSR TT27\n\n LDA QQ16+1,Y           \\ Get the second letter of the token\n\n CMP #'?'               \\ If the second letter of the token is a question mark\n BEQ TT48               \\ then this is a one-letter token, so just return from\n                        \\ the subroutine without printing (as TT48 contains an\n                        \\ RTS)\n\n JMP TT27               \\ Print the second letter and return from the\n                        \\ subroutine\n\n.TT47\n\n SBC #160               \\ This is a recursive token in the range 160-255, so\n                        \\ subtract 160 from the argument to get the token\n                        \\ number 0-95 and fall through into ex to print it\n\n\\ ******************************************************************************\n\\\n\\       Name: ex\n\\       Type: Subroutine\n\\   Category: Text\n\\    Summary: Print a recursive token\n\\  Deep dive: Printing text tokens\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine works its way through the recursive text tokens that are stored\n\\ in tokenised form in the table at QQ18, and when it finds token number A,\n\\ it prints it. Tokens are null-terminated in memory and fill three pages,\n\\ but there is no lookup table as that would consume too much memory, so the\n\\ only way to find the correct token is to start at the beginning and look\n\\ through the table byte by byte, counting tokens as we go until we are in the\n\\ right place. This approach might not be terribly speed efficient, but it is\n\\ certainly memory-efficient.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The recursive token to be printed, in the range 0-148\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   TT48                Contains an RTS\n\\\n\\ ******************************************************************************\n\n.ex\n\n TAX                    \\ Copy the token number into X\n\n LDA #LO(QQ18)          \\ Set V(1 0) to point to the recursive token table at\n STA V                  \\ location QQ18\n LDA #HI(QQ18)\n STA V+1\n\n LDY #0                 \\ Set a counter Y to point to the character offset\n                        \\ as we scan through the table\n\n TXA                    \\ Copy the token number back into A, so both A and X\n                        \\ now contain the token number we want to print\n\n BEQ TT50               \\ If the token number we want is 0, then we have\n                        \\ already found the token we are looking for, so jump\n                        \\ to TT50, otherwise start working our way through the\n                        \\ null-terminated token table until we find the X-th\n                        \\ token\n\n.TT51\n\n LDA (V),Y              \\ Fetch the Y-th character from the token table page\n                        \\ we are currently scanning\n\n BEQ TT49               \\ If the character is null, we've reached the end of\n                        \\ this token, so jump to TT49\n\n INY                    \\ Increment character pointer and loop back around for\n BNE TT51               \\ the next character in this token, assuming Y hasn't\n                        \\ yet wrapped around to 0\n\n INC V+1                \\ If it has wrapped round to 0, we have just crossed\n BNE TT51               \\ into a new page, so increment V+1 so that V points\n                        \\ to the start of the new page\n\n.TT49\n\n INY                    \\ Increment the character pointer\n\n BNE TT59               \\ If Y hasn't just wrapped around to 0, skip the next\n                        \\ instruction\n\n INC V+1                \\ We have just crossed into a new page, so increment\n                        \\ V+1 so that V points to the start of the new page\n\n.TT59\n\n DEX                    \\ We have just reached a new token, so decrement the\n                        \\ token number we are looking for\n\n BNE TT51               \\ Assuming we haven't yet reached the token number in\n                        \\ X, look back up to keep fetching characters\n\n.TT50\n\n                        \\ We have now reached the correct token in the token\n                        \\ table, with Y pointing to the start of the token as\n                        \\ an offset within the page pointed to by V, so let's\n                        \\ print the recursive token. Because recursive tokens\n                        \\ can contain other recursive tokens, we need to store\n                        \\ our current state on the stack, so we can retrieve\n                        \\ it after printing each character in this token\n\n TYA                    \\ Store the offset in Y on the stack\n PHA\n\n LDA V+1                \\ Store the high byte of V (the page containing the\n PHA                    \\ token we have found) on the stack, so the stack now\n                        \\ contains the address of the start of this token\n\n LDA (V),Y              \\ Load the character at offset Y in the token table,\n                        \\ which is the next character of this token that we\n                        \\ want to print\n\n EOR #RE                \\ Tokens are stored in memory having been EOR'd with the\n                        \\ value of RE - which is 35 for all versions of Elite\n                        \\ except for NES, where RE is 62 - so we repeat the\n                        \\ EOR to get the actual character to print\n\n JSR TT27               \\ Print the text token in A, which could be a letter,\n                        \\ number, control code, two-letter token or another\n                        \\ recursive token\n\n PLA                    \\ Restore the high byte of V (the page containing the\n STA V+1                \\ token we have found) into V+1\n\n PLA                    \\ Restore the offset into Y\n TAY\n\n INY                    \\ Increment Y to point to the next character in the\n                        \\ token we are printing\n\n BNE P%+4               \\ If Y is zero then we have just crossed into a new\n INC V+1                \\ page, so increment V+1 so that V points to the start\n                        \\ of the new page\n\n LDA (V),Y              \\ Load the next character we want to print into A\n\n BNE TT50               \\ If this is not the null character at the end of the\n                        \\ token, jump back up to TT50 to print the next\n                        \\ character, otherwise we are done printing\n\n.TT48\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: DOEXP\n\\       Type: Subroutine\n\\   Category: Drawing ships\n\\    Summary: Draw an exploding ship\n\\  Deep dive: Drawing explosion clouds\n\\             Generating random numbers\n\\\n\\ ******************************************************************************\n\n.EX2\n\n LDA INWK+31            \\ Set bits 5 and 7 of the ship's byte #31 to denote that\n ORA #%10100000         \\ the ship is exploding and has been killed\n STA INWK+31\n\n RTS                    \\ Return from the subroutine\n\n.DOEXP\n\n LDA INWK+31            \\ If bit 6 of the ship's byte #31 is clear, then the\n AND #%01000000         \\ ship is not already exploding so there is no existing\n BEQ P%+5               \\ explosion cloud to remove, so skip the following\n                        \\ instruction\n\n JSR PTCLS              \\ Call PTCLS to remove the existing cloud by drawing it\n                        \\ again\n\n LDA INWK+6             \\ Set T = z_lo\n STA T\n\n LDA INWK+7             \\ Set A = z_hi, so (A T) = z\n\n CMP #32                \\ If z_hi < 32, skip the next two instructions\n BCC P%+6\n\n LDA #&FE               \\ Set A = 254 and jump to yy (this BNE is effectively a\n BNE yy                 \\ JMP, as A is never zero)\n\n ASL T                  \\ Shift (A T) left twice\n ROL A\n ASL T\n ROL A\n\n SEC                    \\ And then shift A left once more, inserting a 1 into\n ROL A                  \\ bit 0\n\n                        \\ Overall, the above multiplies A by 8 and makes sure it\n                        \\ is at least 1, to leave a one-byte distance in A. We\n                        \\ can use this as the distance for our cloud, to ensure\n                        \\ that the explosion cloud is visible even for ships\n                        \\ that blow up a long way away\n\n.yy\n\n STA Q                  \\ Store the distance to the explosion in Q\n\n LDY #1                 \\ Fetch byte #1 of the ship line heap, which contains\n LDA (XX19),Y           \\ the cloud counter\n\n ADC #4                 \\ Add 4 to the cloud counter, so it ticks onwards every\n                        \\ we redraw it\n\n BCS EX2                \\ If the addition overflowed, jump up to EX2 to update\n                        \\ the explosion flags and return from the subroutine\n\n STA (XX19),Y           \\ Store the updated cloud counter in byte #1 of the ship\n                        \\ line heap\n\n JSR DVID4              \\ Calculate the following:\n                        \\\n                        \\   (P R) = 256 * A / Q\n                        \\         = 256 * cloud counter / distance\n                        \\\n                        \\ We are going to use this as our cloud size, so the\n                        \\ further away the cloud, the smaller it is, and as the\n                        \\ cloud counter ticks onward, the cloud expands\n\n LDA P                  \\ Set A = P, so we now have:\n                        \\\n                        \\   (A R) = 256 * cloud counter / distance\n\n CMP #&1C               \\ If A < 28, skip the next two instructions\n BCC P%+6\n\n LDA #&FE               \\ Set A = 254 and skip the following (this BNE is\n BNE LABEL_1            \\ effectively a JMP as A is never zero)\n\n ASL R                  \\ Shift (A R) left three times to multiply by 8\n ROL A\n ASL R\n ROL A\n ASL R\n ROL A\n\n                        \\ Overall, the above multiplies (A R) by 8 to leave a\n                        \\ one-byte cloud size in A, given by the following:\n                        \\\n                        \\   A = 8 * cloud counter / distance\n\n.LABEL_1\n\n DEY                    \\ Decrement Y to 0\n\n STA (XX19),Y           \\ Store the cloud size in byte #0 of the ship line heap\n\n LDA INWK+31            \\ Clear bit 6 of the ship's byte #31 to denote that the\n AND #%10111111         \\ explosion has not yet been drawn\n STA INWK+31\n\n AND #%00001000         \\ If bit 3 of the ship's byte #31 is clear, then nothing\n BEQ TT48               \\ is being drawn on-screen for this ship anyway, so\n                        \\ return from the subroutine (as TT48 contains an RTS)\n\n LDY #2                 \\ Otherwise it's time to draw an explosion cloud, so\n LDA (XX19),Y           \\ fetch byte #2 of the ship line heap into Y, which we\n TAY                    \\ set to the explosion count for this ship (i.e. the\n                        \\ number of vertices used as origins for explosion\n                        \\ clouds)\n                        \\\n                        \\ The explosion count is stored as 4 * n + 6, where n is\n                        \\ the number of vertices, so the following loop copies\n                        \\ the coordinates of the first n vertices from the heap\n                        \\ at XX3, which is where we stored all the visible\n                        \\ vertex coordinates in part 8 of the LL9 routine, and\n                        \\ sticks them in the ship line heap pointed to by XX19,\n                        \\ starting at byte #7 (so it leaves the first 6 bytes of\n                        \\ the ship line heap alone)\n\n.EXL1\n\n LDA XX3-7,Y            \\ Copy byte Y-7 from the XX3 heap, into the Y-th byte of\n STA (XX19),Y           \\ the ship line heap\n\n DEY                    \\ Decrement the loop counter\n\n CPY #6                 \\ Keep copying vertex coordinates into the ship line\n BNE EXL1               \\ heap until Y = 6 (which will copy n vertices, where n\n                        \\ is the number of vertices we should be exploding)\n\n LDA INWK+31            \\ Set bit 6 of the ship's byte #31 to denote that the\n ORA #%01000000         \\ explosion has been drawn (as it's about to be)\n STA INWK+31\n\n.PTCLS\n\n                        \\ This part of the routine actually draws the explosion\n                        \\ cloud\n\n LDY #0                 \\ Fetch byte #0 of the ship line heap, which contains\n LDA (XX19),Y           \\ the cloud size we stored above, and store it in Q\n STA Q\n\n INY                    \\ Increment the index in Y to point to byte #1\n\n LDA (XX19),Y           \\ Fetch byte #1 of the ship line heap, which contains\n                        \\ the cloud counter. We are now going to process this\n                        \\ into the number of particles in each vertex's cloud\n\n BPL P%+4               \\ If the cloud counter < 128, then we are in the first\n                        \\ half of the cloud's existence, so skip the next\n                        \\ instruction\n\n EOR #&FF               \\ Flip the value of A so that in the second half of the\n                        \\ cloud's existence, A counts down instead of up\n\n LSR A                  \\ Divide A by 8 so that is has a maximum value of 15\n LSR A\n LSR A\n\n ORA #1                 \\ Make sure A is at least 1 and store it in U, to\n STA U                  \\ give us the number of particles in the explosion for\n                        \\ each vertex\n\n INY                    \\ Increment the index in Y to point to byte #2\n\n LDA (XX19),Y           \\ Fetch byte #2 of the ship line heap, which contains\n STA TGT                \\ the explosion count for this ship (i.e. the number of\n                        \\ vertices used as origins for explosion clouds) and\n                        \\ store it in TGT\n\n LDA RAND+1             \\ Fetch the current random number seed in RAND+1 and\n PHA                    \\ store it on the stack, so we can re-randomise the\n                        \\ seeds when we are done\n\n LDY #6                 \\ Set Y = 6 to point to the byte before the first vertex\n                        \\ coordinate we stored on the ship line heap above (we\n                        \\ increment it below so it points to the first vertex)\n\n.EXL5\n\n LDX #3                 \\ We are about to fetch a pair of coordinates from the\n                        \\ ship line heap, so set a counter in X for 4 bytes\n\n.EXL3\n\n INY                    \\ Increment the index in Y so it points to the next byte\n                        \\ from the coordinate we are copying\n\n LDA (XX19),Y           \\ Copy the Y-th byte from the ship line heap to the X-th\n STA K3,X               \\ byte of K3\n\n DEX                    \\ Decrement the X index\n\n BPL EXL3               \\ Loop back to EXL3 until we have copied all four bytes\n\n                        \\ The above loop copies the vertex coordinates from the\n                        \\ ship line heap to K3, reversing them as we go, so it\n                        \\ sets the following:\n                        \\\n                        \\   K3+3 = x_lo\n                        \\   K3+2 = x_hi\n                        \\   K3+1 = y_lo\n                        \\   K3+0 = y_hi\n\n STY CNT                \\ Set CNT to the index that points to the next vertex on\n                        \\ the ship line heap\n\n LDY #2                 \\ Set Y = 2, which we will use to point to bytes #3 to\n                        \\ #6, after incrementing it\n\n                        \\ This next loop copies bytes #3 to #6 from the ship\n                        \\ line heap into the four random number seeds in RAND to\n                        \\ RAND+3, EOR'ing them with the vertex index so they are\n                        \\ different for every vertex. This enables us to\n                        \\ generate random numbers for drawing each vertex that\n                        \\ are random but repeatable, which we need when we\n                        \\ redraw the cloud to remove it\n                        \\\n                        \\ Note that we haven't actually set the values of bytes\n                        \\ #3 to #6 in the ship line heap, so we have no idea\n                        \\ what they are, we just use what's already there. But\n                        \\ the fact that those bytes are stored for this ship\n                        \\ means we can repeat the random generation of the\n                        \\ cloud, which is the important bit\n\n.EXL2\n\n INY                    \\ Increment the index in Y so it points to the next\n                        \\ random number seed to copy\n\n LDA (XX19),Y           \\ Fetch the Y-th byte from the ship line heap\n\n EOR CNT                \\ EOR with the vertex index, so the seeds are different\n                        \\ for each vertex\n\n STA &FFFD,Y            \\ Y is going from 3 to 6, so this stores the four bytes\n                        \\ in memory locations &00, &01, &02 and &03, which are\n                        \\ the memory locations of RAND through RAND+3\n\n CPY #6                 \\ Loop back to EXL2 until Y = 6, which means we have\n BNE EXL2               \\ copied four bytes\n\n LDY U                  \\ Set Y to the number of particles in the explosion for\n                        \\ each vertex, which we stored in U above. We will now\n                        \\ use this as a loop counter to iterate through all the\n                        \\ particles in the explosion\n\n.EXL4\n\n JSR DORND2             \\ Set ZZ to a random number, making sure the C flag\n STA ZZ                 \\ doesn't affect the outcome\n\n LDA K3+1               \\ Set (A R) = (y_hi y_lo)\n STA R                  \\           = y\n LDA K3\n\n JSR EXS1               \\ Set (A X) = (A R) +/- random * cloud size\n                        \\           = y +/- random * cloud size\n\n BNE EX11               \\ If A is non-zero, the particle is off-screen as the\n                        \\ coordinate is bigger than 255), so jump to EX11 to do\n                        \\ the next particle\n\n CPX #2*Y-1             \\ If X > the y-coordinate of the bottom of the screen,\n BCS EX11               \\ the particle is off the bottom of the screen, so jump\n                        \\ to EX11 to do the next particle\n\n                        \\ Otherwise X contains a random y-coordinate within the\n                        \\ cloud\n\n STX Y1                 \\ Set Y1 = our random y-coordinate within the cloud\n\n LDA K3+3               \\ Set (A R) = (x_hi x_lo)\n STA R\n LDA K3+2\n\n JSR EXS1               \\ Set (A X) = (A R) +/- random * cloud size\n                        \\           = x +/- random * cloud size\n\n BNE EX4                \\ If A is non-zero, the particle is off-screen as the\n                        \\ coordinate is bigger than 255), so jump to EX4 to do\n                        \\ the next particle\n\n                        \\ Otherwise X contains a random x-coordinate within the\n                        \\ cloud\n\n LDA Y1                 \\ Set A = our random y-coordinate within the cloud\n\n JSR PIXEL              \\ Draw a point at screen coordinate (X, A) with the\n                        \\ point size determined by the distance in ZZ\n\n.EX4\n\n DEY                    \\ Decrement the loop counter for the next particle\n\n BPL EXL4               \\ Loop back to EXL4 until we have done all the particles\n                        \\ in the cloud\n\n LDY CNT                \\ Set Y to the index that points to the next vertex on\n                        \\ the ship line heap\n\n CPY TGT                \\ If Y < TGT, which we set to the explosion count for\n BCC EXL5               \\ this ship (i.e. the number of vertices used as origins\n                        \\ for explosion clouds), loop back to EXL5 to do a cloud\n                        \\ for the next vertex\n\n PLA                    \\ Restore the current random number seed to RAND+1 that\n STA RAND+1             \\ we stored at the start of the routine\n\n LDA K%+6               \\ Store the z_lo coordinate for the planet (which will\n STA RAND+3             \\ be pretty random) in the RAND+3 seed\n\n RTS                    \\ Return from the subroutine\n\n.EX11\n\n JSR DORND2             \\ Set A and X to random numbers, making sure the C flag\n                        \\ doesn't affect the outcome\n\n JMP EX4                \\ We just skipped a particle, so jump up to EX4 to do\n                        \\ the next one\n\n.EXS1\n\n                        \\ This routine calculates the following:\n                        \\\n                        \\   (A X) = (A R) +/- random * cloud size\n                        \\\n                        \\ returning with the flags set for the high byte in A\n\n STA S                  \\ Store A in S so we can use it later\n\n JSR DORND2             \\ Set A and X to random numbers, making sure the C flag\n                        \\ doesn't affect the outcome\n\n ROL A                  \\ Set A = A * 2\n\n BCS EX5                \\ If bit 7 of A was set (50% chance), jump to EX5\n\n JSR FMLTU              \\ Set A = A * Q / 256\n                        \\       = random << 1 * projected cloud size / 256\n\n ADC R                  \\ Set (A X) = (S R) + A\n TAX                    \\           = (S R) + random * projected cloud size\n                        \\\n                        \\ where S contains the argument A, starting with the low\n                        \\ bytes\n\n LDA S                  \\ And then the high bytes\n ADC #0\n\n RTS                    \\ Return from the subroutine\n\n.EX5\n\n JSR FMLTU              \\ Set T = A * Q / 256\n STA T                  \\       = random << 1 * projected cloud size / 256\n\n LDA R                  \\ Set (A X) = (S R) - T\n SBC T                  \\\n TAX                    \\ where S contains the argument A, starting with the low\n                        \\ bytes\n\n LDA S                  \\ And then the high bytes\n SBC #0\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: SOS1\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Update the missile indicators, set up the planet data block\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Update the missile indicators, and set up a data block for the planet, but\n\\ only setting the pitch and roll counters to 127 (no damping).\n\\\n\\ ******************************************************************************\n\n.SOS1\n\n JSR msblob             \\ Reset the dashboard's missile indicators so none of\n                        \\ them are targeted\n\n LDA #127               \\ Set the pitch and roll counters to 127, so that's a\n STA INWK+29            \\ clockwise roll and a diving pitch with no damping, so\n STA INWK+30            \\ the planet's rotation doesn't slow down\n\n LDA tek                \\ Set A = 128 or 130 depending on bit 1 of the system's\n AND #%00000010         \\ tech level in tek\n ORA #%10000000\n\n JMP NWSHP              \\ Add a new planet to our local bubble of universe,\n                        \\ with the planet type defined by A (128 is a planet\n                        \\ with an equator and meridian, 130 is a planet with\n                        \\ a crater)\n\n\\ ******************************************************************************\n\\\n\\       Name: SOLAR\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Set up various aspects of arriving in a new system\n\\  Deep dive: A sense of scale\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Halve our legal status, update the missile indicators, and set up data blocks\n\\ and slots for the planet and sun.\n\\\n\\ ******************************************************************************\n\n.SOLAR\n\n LSR FIST               \\ Halve our legal status in FIST, making us less bad,\n                        \\ and moving bit 0 into the C flag (so every time we\n                        \\ arrive in a new system, our legal status improves a\n                        \\ bit)\n\n JSR ZINF               \\ Call ZINF to reset the INWK ship workspace, which\n                        \\ doesn't affect the C flag\n\n LDA QQ15+1             \\ Fetch s0_hi\n\n AND #%00000111         \\ Extract bits 0-2 (which also happen to determine the\n                        \\ economy), which will be between 0 and 7\n\n ADC #6                 \\ Add 6 + C, and divide by 2, to get a result between 3\n LSR A                  \\ and 7, at the same time shifting bit 0 of the result\n                        \\ of the addition into the C flag\n\n STA INWK+8             \\ Store the result in z_sign in byte #6\n\n ROR A                  \\ Halve A, rotating in the C flag, which was previously\n STA INWK+2             \\ bit 0 of s0_hi + 6 + C, so when this is stored in both\n STA INWK+5             \\ x_sign and y_sign, it moves the planet to the upper\n                        \\ right or lower left\n\n JSR SOS1               \\ Call SOS1 to set up the planet's data block and add it\n                        \\ to FRIN, where it will get put in the first slot as\n                        \\ it's the first one to be added to our local bubble of\n                        \\ this new system's universe\n\n LDA QQ15+3             \\ Fetch s1_hi, extract bits 0-2, set bits 0 and 7 and\n AND #%00000111         \\ store in z_sign, so the sun is behind us at a distance\n ORA #%10000001         \\ of 1 to 7\n STA INWK+8\n\n LDA QQ15+5             \\ Fetch s2_hi, extract bits 0-1 and store in x_sign and\n AND #%00000011         \\ y_sign, so the sun is either dead centre in our rear\n STA INWK+2             \\ laser crosshairs, or off to the top left by a distance\n STA INWK+1             \\ of 1 or 2 when we look out the back\n\n LDA #0                 \\ Set the pitch and roll counters to 0 (no rotation)\n STA INWK+29\n STA INWK+30\n\n LDA #129               \\ Set A = 129, the ship type for the sun\n\n JSR NWSHP              \\ Call NWSHP to set up the sun's data block and add it\n                        \\ to FRIN, where it will get put in the second slot as\n                        \\ it's the second one to be added to our local bubble\n                        \\ of this new system's universe\n\n\\ ******************************************************************************\n\\\n\\       Name: NWSTARS\n\\       Type: Subroutine\n\\   Category: Stardust\n\\    Summary: Initialise the stardust field\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine is called when the space view is initialised in routine LOOK1.\n\\\n\\ ******************************************************************************\n\n.NWSTARS\n\n LDA QQ11               \\ If this is not a space view, jump to WPSHPS to skip\n\\ORA MJ                 \\ the initialisation of the SX, SY and SZ tables. The OR\n BNE WPSHPS             \\ instruction is commented out in the original source,\n                        \\ but it would have the effect of also skipping the\n                        \\ initialisation if we had mis-jumped into witchspace\n\n\\ ******************************************************************************\n\\\n\\       Name: nWq\n\\       Type: Subroutine\n\\   Category: Stardust\n\\    Summary: Create a random cloud of stardust\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Create a random cloud of stardust containing the correct number of dust\n\\ particles, i.e. NOSTM of them, which is 3 in witchspace and 18 (#NOST) in\n\\ normal space. Also clears the scanner and initialises the LSO block.\n\\\n\\ This is called by the DEATH routine when it displays our untimely demise.\n\\\n\\ ******************************************************************************\n\n.nWq\n\n LDY NOSTM              \\ Set Y to the current number of stardust particles, so\n                        \\ we can use it as a counter through all the stardust\n\n.SAL4\n\n JSR DORND              \\ Set A and X to random numbers\n\n ORA #8                 \\ Set A so that it's at least 8\n\n STA SZ,Y               \\ Store A in the Y-th particle's z_hi coordinate at\n                        \\ SZ+Y, so the particle appears in front of us\n\n STA ZZ                 \\ Set ZZ to the particle's z_hi coordinate\n\n JSR DORND              \\ Set A and X to random numbers\n\n STA SX,Y               \\ Store A in the Y-th particle's x_hi coordinate at\n                        \\ SX+Y, so the particle appears in front of us\n\n STA X1                 \\ Set X1 to the particle's x_hi coordinate\n\n JSR DORND              \\ Set A and X to random numbers\n\n STA SY,Y               \\ Store A in the Y-th particle's y_hi coordinate at\n                        \\ SY+Y, so the particle appears in front of us\n\n STA Y1                 \\ Set Y1 to the particle's y_hi coordinate\n\n JSR PIXEL2             \\ Draw a stardust particle at (X1,Y1) with distance ZZ\n\n DEY                    \\ Decrement the counter to point to the next particle of\n                        \\ stardust\n\n BNE SAL4               \\ Loop back to SAL4 until we have randomised all the\n                        \\ stardust particles\n\n                        \\ Fall through into WPSHPS to clear the scanner and\n                        \\ reset the LSO block\n\n\\ ******************************************************************************\n\\\n\\       Name: WPSHPS\n\\       Type: Subroutine\n\\   Category: Dashboard\n\\    Summary: Clear the scanner, reset the ball line and sun line heaps\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Remove all ships from the scanner, reset the sun line heap at LSO, and reset\n\\ the ball line heap at LSX2 and LSY2.\n\\\n\\ ******************************************************************************\n\n.WPSHPS\n\n LDX #0                 \\ Set up a counter in X to work our way through all the\n                        \\ ship slots in FRIN\n\n.WSL1\n\n LDA FRIN,X             \\ Fetch the ship type in slot X\n\n BEQ WS2                \\ If the slot contains 0 then it is empty and we have\n                        \\ checked all the slots (as they are always shuffled\n                        \\ down in the main loop to close up and gaps), so jump\n                        \\ to WS2 as we are done\n\n BMI WS1                \\ If the slot contains a ship type with bit 7 set, then\n                        \\ it contains the planet or the sun, so jump down to WS1\n                        \\ to skip this slot, as the planet and sun don't appear\n                        \\ on the scanner\n\n STA TYPE               \\ Store the ship type in TYPE\n\n JSR GINF               \\ Call GINF to get the address of the data block for\n                        \\ ship slot X and store it in INF\n\n LDY #31                \\ We now want to copy the first 32 bytes from the ship's\n                        \\ data block into INWK, so set a counter in Y\n\n.WSL2\n\n LDA (INF),Y            \\ Copy the Y-th byte from the data block pointed to by\n STA INWK,Y             \\ INF into the Y-th byte of INWK workspace\n\n DEY                    \\ Decrement the counter to point at the next byte\n\n BPL WSL2               \\ Loop back to WSL2 until we have copied all 32 bytes\n\n STX XSAV               \\ Store the ship slot number in XSAV while we call SCAN\n\n JSR SCAN               \\ Call SCAN to plot this ship on the scanner, which will\n                        \\ remove it as it's plotted with EOR logic\n\n LDX XSAV               \\ Restore the ship slot number from XSAV into X\n\n LDY #31                \\ Clear bits 3, 4 and 6 in the ship's byte #31, which\n LDA (INF),Y            \\ stops drawing the ship on-screen (bit 3), hides it\n AND #%10100111         \\ from the scanner (bit 4) and stops any lasers firing\n STA (INF),Y            \\ (bit 6)\n\n.WS1\n\n INX                    \\ Increment X to point to the next ship slot\n\n BNE WSL1               \\ Loop back up to process the next slot (this BNE is\n                        \\ effectively a JMP as X will never be zero)\n\n.WS2\n\n LDX #&FF               \\ Set LSX2 = LSY2 = &FF to clear the ball line heap\n STX LSX2\n STX LSY2\n\n                        \\ Fall through into FLFLLS to reset the LSO block\n\n\\ ******************************************************************************\n\\\n\\       Name: FLFLLS\n\\       Type: Subroutine\n\\   Category: Drawing suns\n\\    Summary: Reset the sun line heap\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Reset the sun line heap at LSO by zero-filling it and setting the first byte\n\\ to &FF.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   A                   A is set to 0\n\\\n\\ ******************************************************************************\n\n.FLFLLS\n\n LDY #2*Y-1             \\ #Y is the y-coordinate of the centre of the space\n                        \\ view, so this sets Y as a counter for the number of\n                        \\ lines in the space view (i.e. 191), which is also the\n                        \\ number of lines in the LSO block\n\n LDA #0                 \\ Set A to 0 so we can zero-fill the LSO block\n\n.SAL6\n\n STA LSO,Y              \\ Set the Y-th byte of the LSO block to 0\n\n DEY                    \\ Decrement the counter\n\n BNE SAL6               \\ Loop back until we have filled all the way to LSO+1\n\n DEY                    \\ Decrement Y to value of &FF (as we exit the above loop\n                        \\ with Y = 0)\n\n STY LSX                \\ Set the first byte of the LSO block, which has its own\n                        \\ label LSX, to &FF, to indicate that the sun line heap\n                        \\ is empty\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: DET1\n\\       Type: Subroutine\n\\   Category: Drawing the screen\n\\    Summary: Show or hide the dashboard (for when we die)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine sets the screen to show the number of text rows given in X.\n\\\n\\ It is used when we are killed, as reducing the number of rows from the usual\n\\ 31 to 24 has the effect of hiding the dashboard, leaving a monochrome image\n\\ of ship debris and explosion clouds. Increasing the rows back up to 31 makes\n\\ the dashboard reappear, as the dashboard's screen memory doesn't get touched\n\\ by this process.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   The number of text rows to display on the screen (24\n\\                       will hide the dashboard, 31 will make it reappear)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   A                   A is set to 6\n\\\n\\ ******************************************************************************\n\n.DET1\n\n LDA #6                 \\ Set A to 6 so we can update 6845 register R6 below\n\n SEI                    \\ Disable interrupts so we can update the 6845\n\n STA VIA+&00            \\ Set 6845 register R6 to the value in X. Register R6\n STX VIA+&01            \\ is the \"vertical displayed\" register, which sets the\n                        \\ number of rows shown on the screen\n\n CLI                    \\ Re-enable interrupts\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: SHD\n\\       Type: Subroutine\n\\   Category: Flight\n\\    Summary: Charge a shield and drain some energy from the energy banks\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Charge up a shield, and if it needs charging, drain some energy from the\n\\ energy banks.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   The value of the shield to recharge\n\\\n\\ ******************************************************************************\n\n DEX                    \\ If we get here then we just incremented the shield\n                        \\ value back around to zero, so decrement it back down\n                        \\ to 255 so it stays at the maximum value of 255\n\n RTS                    \\ Return from the subroutine\n\n.SHD\n\n INX                    \\ Increment the shield value\n\n BEQ SHD-2              \\ If the shield value is 0 then this means it was 255\n                        \\ before, which is the maximum value, so jump to SHD-2\n                        \\ to bring it back down to 255 and return without\n                        \\ draining our energy banks\n\n                        \\ Otherwise fall through into DENGY to drain our energy\n                        \\ to pay for all this shield charging\n\n\\ ******************************************************************************\n\\\n\\       Name: DENGY\n\\       Type: Subroutine\n\\   Category: Flight\n\\    Summary: Drain some energy from the energy banks\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   Z flag              Set if we have no energy left, clear otherwise\n\\\n\\ ******************************************************************************\n\n.DENGY\n\n DEC ENERGY             \\ Decrement the energy banks in ENERGY\n\n PHP                    \\ Save the flags on the stack\n\n BNE P%+5               \\ If the energy levels are not yet zero, skip the\n                        \\ following instruction\n\n INC ENERGY             \\ The minimum allowed energy level is 1, and we just\n                        \\ reached 0, so increment ENERGY back to 1\n\n PLP                    \\ Restore the flags from the stack, so we return with\n                        \\ the Z flag from the DEC instruction above\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: COMPAS\n\\       Type: Subroutine\n\\   Category: Dashboard\n\\    Summary: Update the compass\n\\\n\\ ******************************************************************************\n\n.COMPAS\n\n JSR DOT                \\ Call DOT to redraw (i.e. remove) the current compass\n                        \\ dot\n\n LDA SSPR               \\ If we are inside the space station safe zone, jump to\n BNE SP1                \\ SP1 to draw the space station on the compass\n\n JSR SPS1               \\ Otherwise we need to draw the planet on the compass,\n                        \\ so first call SPS1 to calculate the vector to the\n                        \\ planet and store it in XX15\n\n JMP SP2                \\ Jump to SP2 to draw XX15 on the compass, returning\n                        \\ from the subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: SPS2\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate (Y X) = A / 10\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following, where A is a sign-magnitude 8-bit integer and the\n\\ result is a signed 16-bit integer:\n\\\n\\   (Y X) = A / 10\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   C flag              The C flag is cleared\n\\\n\\ ******************************************************************************\n\n.SPS2\n\n ASL A                  \\ Set X = |A| * 2, and set the C flag to the sign bit of\n TAX                    \\ A\n\n LDA #0                 \\ Set Y to have the sign bit from A in bit 7, with the\n ROR A                  \\ rest of its bits zeroed, so Y now contains the sign of\n TAY                    \\ the original argument\n\n LDA #20                \\ Set Q = 20\n STA Q\n\n TXA                    \\ Copy X into A, so A now contains the argument A * 2\n\n JSR DVID4              \\ Calculate the following:\n                        \\\n                        \\   P = A / Q\n                        \\     = |argument A| * 2 / 20\n                        \\     = |argument A| / 10\n\n LDX P                  \\ Set X to the result\n\n TYA                    \\ If the sign of the original argument A is negative,\n BMI LL163              \\ jump to LL163 to flip the sign of the result\n\n LDY #0                 \\ Set the high byte of the result to 0, as the result is\n                        \\ positive\n\n RTS                    \\ Return from the subroutine\n\n.LL163\n\n LDY #&FF               \\ The result is negative, so set the high byte to &FF\n\n TXA                    \\ Flip the low byte and add 1 to get the negated low\n EOR #&FF               \\ byte, using two's complement\n TAX\n INX\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: SPS4\n\\       Type: Subroutine\n\\   Category: Maths (Geometry)\n\\    Summary: Calculate the vector to the space station\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the vector between our ship and the space station and store it in\n\\ XX15.\n\\\n\\ ******************************************************************************\n\n.SPS4\n\n LDX #8                 \\ First we need to copy the space station's coordinates\n                        \\ into K3, so set a counter to copy the first 9 bytes\n                        \\ (the three-byte x, y and z coordinates) from the\n                        \\ station's data block at K% + NI% into K3\n\n.SPL1\n\n LDA K%+NI%,X           \\ Copy the X-th byte from the station's data block at\n STA K3,X               \\ K% + NI% to the X-th byte of K3\n\n DEX                    \\ Decrement the loop counter\n\n BPL SPL1               \\ Loop back to SPL1 until we have copied all 9 bytes\n\n JMP TAS2               \\ Call TAS2 to build XX15 from K3, returning from the\n                        \\ subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: SP1\n\\       Type: Subroutine\n\\   Category: Dashboard\n\\    Summary: Draw the space station on the compass\n\\\n\\ ******************************************************************************\n\n.SP1\n\n JSR SPS4               \\ Call SPS4 to calculate the vector to the space station\n                        \\ and store it in XX15\n\n                        \\ Fall through into SP2 to draw XX15 on the compass\n\n\\ ******************************************************************************\n\\\n\\       Name: SP2\n\\       Type: Subroutine\n\\   Category: Dashboard\n\\    Summary: Draw a dot on the compass, given the planet/station vector\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Draw a dot on the compass to represent the planet or station, whose normalised\n\\ vector is in XX15.\n\\\n\\   XX15 to XX15+2      The normalised vector to the planet or space station,\n\\                       stored as x in XX15, y in XX15+1 and z in XX15+2\n\\\n\\ ******************************************************************************\n\n.SP2\n\n LDA XX15               \\ Set A to the x-coordinate of the planet or station to\n                        \\ show on the compass, which will be in the range -96 to\n                        \\ +96 as the vector has been normalised\n\n JSR SPS2               \\ Set (Y X) = A / 10, so X will be from -9 to +9, which\n                        \\ is the x-offset from the centre of the compass of the\n                        \\ dot we want to draw. Returns with the C flag clear\n\n TXA                    \\ Set COMX = 195 + X, as 186 is the pixel x-coordinate\n ADC #195               \\ of the leftmost dot possible on the compass, and X can\n STA COMX               \\ be -9, which would be 195 - 9 = 186. This also means\n                        \\ that the highest value for COMX is 195 + 9 = 204,\n                        \\ which is the pixel x-coordinate of the rightmost dot\n                        \\ in the compass... but the compass dot is actually two\n                        \\ pixels wide, so the compass dot can overlap the right\n                        \\ edge of the compass, but not the left edge\n\n LDA XX15+1             \\ Set A to the y-coordinate of the planet or station to\n                        \\ show on the compass, which will be in the range -96 to\n                        \\ +96 as the vector has been normalised\n\n JSR SPS2               \\ Set (Y X) = A / 10, so X will be from -9 to +9, which\n                        \\ is the x-offset from the centre of the compass of the\n                        \\ dot we want to draw. Returns with the C flag clear\n\n STX T                  \\ Set COMY = 204 - X, as 203 is the pixel y-coordinate\n LDA #204               \\ of the centre of the compass, the C flag is clear,\n SBC T                  \\ and the y-axis needs to be flipped around (because\n STA COMY               \\ when the planet or station is above us, and the\n                        \\ vector is therefore positive, we want to show the dot\n                        \\ higher up on the compass, which has a smaller pixel\n                        \\ y-coordinate). So this calculation does this:\n                        \\\n                        \\   COMY = 204 - X - (1 - 0) = 203 - X\n\n LDA #&F0               \\ Set A to a four-pixel mode 5 byte row in colour 2\n                        \\ (yellow/white), the colour for when the planet or\n                        \\ station in the compass is in front of us\n\n LDX XX15+2             \\ If the z-coordinate of the XX15 vector is positive,\n BPL P%+4               \\ skip the following instruction\n\n LDA #&FF               \\ The z-coordinate of XX15 is negative, so the planet or\n                        \\ station is behind us and the compass dot should be in\n                        \\ green/cyan, so set A to a four-pixel mode 5 byte row\n                        \\ in colour 3\n\n STA COMC               \\ Store the compass colour in COMC\n\n                        \\ Fall through into DOT to draw the dot on the compass\n\n\\ ******************************************************************************\n\\\n\\       Name: DOT\n\\       Type: Subroutine\n\\   Category: Dashboard\n\\    Summary: Draw a dash on the compass\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   COMX                The screen pixel x-coordinate of the dash\n\\\n\\   COMY                The screen pixel y-coordinate of the dash\n\\\n\\   COMC                The colour and thickness of the dash:\n\\\n\\                         * &F0 = a double-height dash in yellow/white, for when\n\\                           the object in the compass is in front of us\n\\\n\\                         * &FF = a single-height dash in green/cyan, for when\n\\                           the object in the compass is behind us\n\\\n\\ ******************************************************************************\n\n.DOT\n\n LDA COMY               \\ Set Y1 = COMY, the y-coordinate of the dash\n STA Y1\n\n LDA COMX               \\ Set X1 = COMX, the x-coordinate of the dash\n STA X1\n\n LDA COMC               \\ Set COL = COMC, the mode 5 colour byte for the dash\n STA COL\n\n CMP #&F0               \\ If COL is &F0 then the planet/station is in front of\n BNE CPIX2              \\ us and we want to draw a double-height dash, so if it\n                        \\ isn't &F0 jump to CPIX2 to draw a single-height dash\n\n                        \\ Otherwise fall through into CPIX4 to draw a double-\n                        \\ height dash\n\n\\ ******************************************************************************\n\\\n\\       Name: CPIX4\n\\       Type: Subroutine\n\\   Category: Drawing pixels\n\\    Summary: Draw a double-height dot on the dashboard\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Draw a double-height mode 5 dot (2 pixels high, 2 pixels wide).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X1                  The screen pixel x-coordinate of the bottom-left corner\n\\                       of the dot\n\\\n\\   Y1                  The screen pixel y-coordinate of the bottom-left corner\n\\                       of the dot\n\\\n\\   COL                 The colour of the dot as a mode 5 character row byte\n\\\n\\ ******************************************************************************\n\n.CPIX4\n\n JSR CPIX2              \\ Call CPIX2 to draw a single-height dash at (X1, Y1)\n\n DEC Y1                 \\ Decrement Y1\n\n                        \\ Fall through into CPIX2 to draw a second single-height\n                        \\ dash on the pixel row above the first one, to create a\n                        \\ double-height dot\n\n\\ ******************************************************************************\n\\\n\\       Name: CPIX2\n\\       Type: Subroutine\n\\   Category: Drawing pixels\n\\    Summary: Draw a single-height dash on the dashboard\n\\  Deep dive: Drawing colour pixels on the BBC Micro\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Draw a single-height mode 5 dash (1 pixel high, 2 pixels wide).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X1                  The screen pixel x-coordinate of the dash\n\\\n\\   Y1                  The screen pixel y-coordinate of the dash\n\\\n\\   COL                 The colour of the dash as a mode 5 character row byte\n\\\n\\ ******************************************************************************\n\n.CPIX2\n\n LDA Y1                 \\ Fetch the y-coordinate into A\n\n\\.CPIX                  \\ This label is commented out in the original source. It\n                        \\ would provide a new entry point with A specifying the\n                        \\ y-coordinate instead of Y1, but it isn't used anywhere\n\n TAY                    \\ Store the y-coordinate in Y\n\n LSR A                  \\ Set A = A / 8, so A now contains the character row we\n LSR A                  \\ need to draw in (as each character row contains 8\n LSR A                  \\ pixel rows)\n\n ORA #&60               \\ Each character row in Elite's screen mode takes up one\n                        \\ page in memory (256 bytes), so we now OR with &60 to\n                        \\ get the page containing the dash (see the comments in\n                        \\ routine TT26 for more discussion about calculating\n                        \\ screen memory addresses)\n\n STA SCH                \\ Store the screen page in the high byte of SC(1 0)\n\n LDA X1                 \\ Each character block contains 8 pixel rows, so to get\n AND #%11111000         \\ the address of the first byte in the character block\n                        \\ that we need to draw into, as an offset from the start\n                        \\ of the row, we clear bits 0-2\n\n STA SC                 \\ Store the address of the character block in the low\n                        \\ byte of SC(1 0), so now SC(1 0) points to the\n                        \\ character block we need to draw into\n\n TYA                    \\ Set Y to the y-coordinate mod 8, which will be the\n AND #7                 \\ number of the pixel row we need to draw within the\n TAY                    \\ character block\n\n LDA X1                 \\ Copy bits 0-1 of X1 to bits 1-2 of X, and clear the C\n AND #%00000110         \\ flag in the process (using the LSR). X will now be\n LSR A                  \\ a value between 0 and 3, and will be the pixel number\n TAX                    \\ in the character row for the left pixel in the dash.\n                        \\ This is because each character row is one byte that\n                        \\ contains 4 pixels, but covers 8 screen coordinates, so\n                        \\ this effectively does the division by 2 that we need\n\n LDA CTWOS,X            \\ Fetch a mode 5 one-pixel byte with the pixel position\n AND COL                \\ at X, and AND with the colour byte so that pixel takes\n                        \\ on the colour we want to draw (i.e. A is acting as a\n                        \\ mask on the colour byte)\n\n EOR (SC),Y             \\ Draw the pixel on-screen using EOR logic, so we can\n STA (SC),Y             \\ remove it later without ruining the background that's\n                        \\ already on-screen\n\n LDA CTWOS+1,X          \\ Fetch a mode 5 one-pixel byte with the pixel position\n                        \\ at X+1, so we can draw the right pixel of the dash\n\n BPL CP1                \\ The CTWOS table has an extra row at the end of it that\n                        \\ repeats the first value, %10001000, so if we have not\n                        \\ fetched that value, then the right pixel of the dash\n                        \\ is in the same character block as the left pixel, so\n                        \\ jump to CP1 to draw it\n\n LDA SC                 \\ Otherwise the left pixel we drew was at the last\n ADC #8                 \\ position of four in this character block, so we add\n STA SC                 \\ 8 to the screen address to move onto the next block\n                        \\ along (as there are 8 bytes in a character block).\n                        \\ The C flag was cleared above, so this ADC is correct\n\n LDA CTWOS+1,X          \\ Re-fetch the mode 5 one-pixel byte, as we just\n                        \\ overwrote A (the byte will still be the fifth byte\n                        \\ from the table, which is correct as we want to draw\n                        \\ the leftmost pixel in the next character along as the\n                        \\ dash's right pixel)\n\n.CP1\n\n AND COL                \\ Apply the colour mask to the pixel byte, as above\n\n EOR (SC),Y             \\ Draw the dash's right pixel according to the mask in\n STA (SC),Y             \\ A, with the colour in COL, using EOR logic, just as\n                        \\ above\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: OOPS\n\\       Type: Subroutine\n\\   Category: Flight\n\\    Summary: Take some damage\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ We just took some damage, so reduce the shields if we have any, or reduce the\n\\ energy levels and potentially take some damage to the cargo if we don't.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The amount of damage to take\n\\\n\\   INF                 The address of the ship block for the ship that attacked\n\\                       us, or the ship that we just ran into\n\\\n\\ ******************************************************************************\n\n.OOPS\n\n STA T                  \\ Store the amount of damage in T\n\n LDY #8                 \\ Fetch byte #8 (z_sign) for the ship attacking us, and\n LDX #0                 \\ set X = 0\n LDA (INF),Y\n\n BMI OO1                \\ If A is negative, then we got hit in the rear, so jump\n                        \\ to OO1 to process damage to the aft shield\n\n LDA FSH                \\ Otherwise the forward shield was damaged, so fetch the\n SBC T                  \\ shield strength from FSH and subtract the damage in T\n\n BCC OO2                \\ If the C flag is clear then this amount of damage was\n                        \\ too much for the shields, so jump to OO2 to set the\n                        \\ shield level to 0 and start taking damage directly\n                        \\ from the energy banks\n\n STA FSH                \\ Store the new value of the forward shield in FSH\n\n RTS                    \\ Return from the subroutine\n\n.OO2\n\n\\LDX #0                 \\ This instruction is commented out in the original\n                        \\ source, and isn't required as X is set to 0 above\n\n STX FSH                \\ Set the forward shield to 0\n\n BCC OO3                \\ Jump to OO3 to start taking damage directly from the\n                        \\ energy banks (this BCC is effectively a JMP as the C\n                        \\ flag is clear, as we jumped to OO2 with a BCC)\n\n.OO1\n\n LDA ASH                \\ The aft shield was damaged, so fetch the shield\n SBC T                  \\ strength from ASH and subtract the damage in T\n\n BCC OO5                \\ If the C flag is clear then this amount of damage was\n                        \\ too much for the shields, so jump to OO5 to set the\n                        \\ shield level to 0 and start taking damage directly\n                        \\ from the energy banks\n\n STA ASH                \\ Store the new value of the aft shield in ASH\n\n RTS                    \\ Return from the subroutine\n\n.OO5\n\n\\LDX #0                 \\ This instruction is commented out in the original\n                        \\ source, and isn't required as X is set to 0 above\n\n STX ASH                \\ Set the aft shield to 0\n\n.OO3\n\n ADC ENERGY             \\ A is negative and contains the amount by which the\n STA ENERGY             \\ damage overwhelmed the shields, so this drains the\n                        \\ energy banks by that amount (and because the energy\n                        \\ banks are shown over four indicators rather than one,\n                        \\ but with the same value range of 0-255, energy will\n                        \\ appear to drain away four times faster than the\n                        \\ shields did)\n\n BEQ P%+4               \\ If we have just run out of energy, skip the next\n                        \\ instruction to jump straight to our death\n\n BCS P%+5               \\ If the C flag is set, then subtracting the damage from\n                        \\ the energy banks didn't underflow, so we had enough\n                        \\ energy to survive, and we can skip the next\n                        \\ instruction to make a sound and take some damage\n\n JMP DEATH              \\ Otherwise our energy levels are either 0 or negative,\n                        \\ and in either case that means we jump to our DEATH,\n                        \\ returning from the subroutine using a tail call\n\n JSR EXNO3              \\ We didn't die, so call EXNO3 to make the sound of a\n                        \\ collision\n\n JMP OUCH               \\ And jump to OUCH to take damage and return from the\n                        \\ subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: SPS3\n\\       Type: Subroutine\n\\   Category: Maths (Geometry)\n\\    Summary: Copy a space coordinate from the K% block into K3\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Copy one of the planet's coordinates into the corresponding location in the\n\\ temporary variable K3. The high byte and absolute value of the sign byte are\n\\ copied into the first two K3 bytes, and the sign of the sign byte is copied\n\\ into the highest K3 byte.\n\\\n\\ The comments below are written for copying the planet's x-coordinate into\n\\ K3(2 1 0).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   Determines which coordinate to copy, and to where:\n\\\n\\                         * X = 0 copies (x_sign, x_hi) into K3(2 1 0)\n\\\n\\                         * X = 3 copies (y_sign, y_hi) into K3(5 4 3)\n\\\n\\                         * X = 6 copies (z_sign, z_hi) into K3(8 7 6)\n\\\n\\ ******************************************************************************\n\n.SPS3\n\n LDA K%+1,X             \\ Copy x_hi into K3+X\n STA K3,X\n\n LDA K%+2,X             \\ Set A = Y = x_sign\n TAY\n\n AND #%01111111         \\ Set K3+1 = |x_sign|\n STA K3+1,X\n\n TYA                    \\ Set K3+2 = the sign of x_sign\n AND #%10000000\n STA K3+2,X\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: GINF\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Fetch the address of a ship's data block into INF\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Get the address of the data block for ship slot X and store it in INF. This\n\\ address is fetched from the UNIV table, which stores the addresses of the 13\n\\ ship data blocks in workspace K%.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   The ship slot number for which we want the data block\n\\                       address\n\\\n\\ ******************************************************************************\n\n.GINF\n\n TXA                    \\ Set Y = X * 2\n ASL A\n TAY\n\n LDA UNIV,Y             \\ Get the high byte of the address of the X-th ship\n STA INF                \\ from UNIV and store it in INF\n\n LDA UNIV+1,Y           \\ Get the low byte of the address of the X-th ship\n STA INF+1              \\ from UNIV and store it in INF\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: NWSPS\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Add a new space station to our local bubble of universe\n\\\n\\ ******************************************************************************\n\n.NWSPS\n\n JSR SPBLB              \\ Light up the space station bulb on the dashboard\n\n LDX #%00000001         \\ Set the AI flag in byte #32 to %00000001 (friendly,\n STX INWK+32            \\ has an E.C.M.)\n\n DEX                    \\ Set pitch counter to 0 (no pitch, roll only)\n STX INWK+30\n\n\\STX INWK+31            \\ This instruction is commented out in the original\n                        \\ source. It would set the exploding state and missile\n                        \\ count to 0\n\n STX FRIN+1             \\ Set the second slot in the FRIN table to 0, so when we\n                        \\ fall through into NWSHP below, the new station that\n                        \\ gets created will go into slot FRIN+1, as this will be\n                        \\ the first empty slot that the routine finds\n\n DEX                    \\ Set the roll counter to 255 (maximum anti-clockwise\n STX INWK+29            \\ roll with no damping)\n\n LDX #10                \\ Call NwS1 to flip the sign of nosev_x_hi (byte #10)\n JSR NwS1\n\n JSR NwS1               \\ And again to flip the sign of nosev_y_hi (byte #12)\n\n JSR NwS1               \\ And again to flip the sign of nosev_z_hi (byte #14)\n\n LDA #LO(LSO)           \\ Set bytes #33 and #34 to point to LSO for the ship\n STA INWK+33            \\ line heap for the space station\n LDA #HI(LSO)\n STA INWK+34\n\n LDA #SST               \\ Set A to the space station type, and fall through\n                        \\ into NWSHP to finish adding the space station to the\n                        \\ universe\n\n\\ ******************************************************************************\n\\\n\\       Name: NWSHP\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Add a new ship to our local bubble of universe\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This creates a new block of ship data in the K% workspace, allocates a new\n\\ block in the ship line heap at WP, adds the new ship's type into the first\n\\ empty slot in FRIN, and adds a pointer to the ship data into UNIV. If there\n\\ isn't enough free memory for the new ship, it isn't added.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The type of the ship to add (see variable XX21 for a\n\\                       list of ship types)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   C flag              Set if the ship was successfully added, clear if it\n\\                       wasn't (as there wasn't enough free memory)\n\\\n\\   INF                 Points to the new ship's data block in K%\n\\\n\\ ******************************************************************************\n\n.NWSHP\n\n STA T                  \\ Store the ship type in location T\n\n LDX #0                 \\ Before we can add a new ship, we need to check\n                        \\ whether we have an empty slot we can put it in. To do\n                        \\ this, we need to loop through all the slots to look\n                        \\ for an empty one, so set a counter in X that starts\n                        \\ from the first slot at 0. When ships are killed, then\n                        \\ the slots are shuffled down by the KILLSHP routine, so\n                        \\ the first empty slot will always come after the last\n                        \\ filled slot. This allows us to tack the new ship's\n                        \\ data block and ship line heap onto the end of the\n                        \\ existing ship data and heap, as shown in the memory\n                        \\ map below\n\n.NWL1\n\n LDA FRIN,X             \\ Load the ship type for the X-th slot\n\n BEQ NW1                \\ If it is zero, then this slot is empty and we can use\n                        \\ it for our new ship, so jump down to NW1\n\n INX                    \\ Otherwise increment X to point to the next slot\n\n CPX #NOSH              \\ If we haven't reached the last slot yet, loop back up\n BCC NWL1               \\ to NWL1 to check the next slot (note that this means\n                        \\ only slots from 0 to #NOSH - 1 are populated by this\n                        \\ routine, but there is one more slot reserved in FRIN,\n                        \\ which is used to identify the end of the slot list\n                        \\ when shuffling the slots down in the KILLSHP routine)\n\n.NW3\n\n CLC                    \\ Otherwise we don't have an empty slot, so we can't\n RTS                    \\ add a new ship, so clear the C flag to indicate that\n                        \\ we have not managed to create the new ship, and return\n                        \\ from the subroutine\n\n.NW1\n\n                        \\ If we get here, then we have found an empty slot at\n                        \\ index X, so we can go ahead and create our new ship.\n                        \\ We do that by creating a ship data block at INWK and,\n                        \\ when we are done, copying the block from INWK into\n                        \\ the K% workspace (specifically, to INF)\n\n JSR GINF               \\ Get the address of the data block for ship slot X\n                        \\ (which is in workspace K%) and store it in INF\n\n LDA T                  \\ If the type of ship that we want to create is\n BMI NW2                \\ negative, then this indicates a planet or sun, so\n                        \\ jump down to NW2, as the next section sets up a ship\n                        \\ data block, which doesn't apply to planets and suns,\n                        \\ as they don't have things like shields, missiles,\n                        \\ vertices and edges\n\n                        \\ This is a ship, so first we need to set up various\n                        \\ pointers to the ship blueprint we will need. The\n                        \\ blueprints for each ship type in Elite are stored\n                        \\ in a table at location XX21, so refer to the comments\n                        \\ on that variable for more details on the data we're\n                        \\ about to access\n\n ASL A                  \\ Set Y = ship type * 2\n TAY\n\n LDA XX21-2,Y           \\ The ship blueprints at XX21 start with a lookup\n STA XX0                \\ table that points to the individual ship blueprints,\n                        \\ so this fetches the low byte of this particular ship\n                        \\ type's blueprint and stores it in XX0\n\n LDA XX21-1,Y           \\ Fetch the high byte of this particular ship type's\n STA XX0+1              \\ blueprint and store it in XX0+1, so XX0(1 0) now\n                        \\ contains the address of this ship's blueprint\n\n CPY #2*SST             \\ If the ship type is a space station (SST), then jump\n BEQ NW6                \\ to NW6, skipping the heap space steps below, as the\n                        \\ space station has its own line heap at LSO (which it\n                        \\ shares with the sun)\n\n                        \\ We now want to allocate space for a heap that we can\n                        \\ use to store the lines we draw for our new ship (so it\n                        \\ can easily be erased from the screen again). SLSP\n                        \\ points to the start of the current heap space, and we\n                        \\ can extend it downwards with the heap for our new ship\n                        \\ (as the heap space always ends just before the WP\n                        \\ workspace)\n\n LDY #5                 \\ Fetch ship blueprint byte #5, which contains the\n LDA (XX0),Y            \\ maximum heap size required for plotting the new ship,\n STA T1                 \\ and store it in T1\n\n LDA SLSP               \\ Take the 16-bit address in SLSP and subtract T1,\n SEC                    \\ storing the 16-bit result in INWK(34 33), so this now\n SBC T1                 \\ points to the start of the line heap for our new ship\n STA INWK+33\n LDA SLSP+1\n SBC #0\n STA INWK+34\n\n                        \\ We now need to check that there is enough free space\n                        \\ for both this new line heap and the new data block\n                        \\ for our ship. In memory, this is the layout of the\n                        \\ ship data blocks and ship line heaps:\n                        \\\n                        \\   +-----------------------------------+   &0F34\n                        \\   |                                   |\n                        \\   | WP workspace                      |\n                        \\   |                                   |\n                        \\   +-----------------------------------+   &0D40 = WP\n                        \\   |                                   |\n                        \\   | Current ship line heap            |\n                        \\   |                                   |\n                        \\   +-----------------------------------+   SLSP\n                        \\   |                                   |\n                        \\   | Proposed heap for new ship        |\n                        \\   |                                   |\n                        \\   +-----------------------------------+   INWK(34 33)\n                        \\   |                                   |\n                        \\   .                                   .\n                        \\   .                                   .\n                        \\   .                                   .\n                        \\   .                                   .\n                        \\   .                                   .\n                        \\   |                                   |\n                        \\   +-----------------------------------+   INF + NI%\n                        \\   |                                   |\n                        \\   | Proposed data block for new ship  |\n                        \\   |                                   |\n                        \\   +-----------------------------------+   INF\n                        \\   |                                   |\n                        \\   | Existing ship data blocks         |\n                        \\   |                                   |\n                        \\   +-----------------------------------+   &0900 = K%\n                        \\\n                        \\ So, to work out if we have enough space, we have to\n                        \\ make sure there is room between the end of our new\n                        \\ ship data block at INF + NI%, and the start of the\n                        \\ proposed heap for our new ship at the address we\n                        \\ stored in INWK(34 33). Or, to put it another way, we\n                        \\ and to make sure that:\n                        \\\n                        \\   INWK(34 33) > INF + NI%\n                        \\\n                        \\ which is the same as saying:\n                        \\\n                        \\   INWK+33 - INF > NI%\n                        \\\n                        \\ because INWK is in zero page, so INWK+34 = 0\n\n LDA INWK+33            \\ Calculate INWK+33 - INF, again using 16-bit\n\\SEC                    \\ arithmetic, and put the result in (A Y), so the high\n SBC INF                \\ byte is in A and the low byte in Y. The SEC\n TAY                    \\ instruction is commented out in the original source;\n LDA INWK+34            \\ as the previous subtraction will never underflow, it\n SBC INF+1              \\ is superfluous\n\n BCC NW3+1              \\ If we have an underflow from the subtraction, then\n                        \\ INF > INWK+33 and we definitely don't have enough\n                        \\ room for this ship, so jump to NW3+1, which returns\n                        \\ from the subroutine (with the C flag already cleared)\n\n BNE NW4                \\ If the subtraction of the high bytes in A is not\n                        \\ zero, and we don't have underflow, then we definitely\n                        \\ have enough space, so jump to NW4 to continue setting\n                        \\ up the new ship\n\n CPY #NI%               \\ Otherwise the high bytes are the same in our\n BCC NW3+1              \\ subtraction, so now we compare the low byte of the\n                        \\ result (which is in Y) with NI%. This is the same as\n                        \\ doing INWK+33 - INF > NI% (see above). If this isn't\n                        \\ true, the C flag will be clear and we don't have\n                        \\ enough space, so we jump to NW3+1, which returns\n                        \\ from the subroutine (with the C flag already cleared)\n\n.NW4\n\n LDA INWK+33            \\ If we get here then we do have enough space for our\n STA SLSP               \\ new ship, so store the new bottom of the ship line\n LDA INWK+34            \\ heap (i.e. INWK+33) in SLSP, doing both the high and\n STA SLSP+1             \\ low bytes\n\n.NW6\n\n LDY #14                \\ Fetch ship blueprint byte #14, which contains the\n LDA (XX0),Y            \\ ship's energy, and store it in byte #35\n STA INWK+35\n\n LDY #19                \\ Fetch ship blueprint byte #19, which contains the\n LDA (XX0),Y            \\ number of missiles and laser power, and AND with %111\n AND #%00000111         \\ to extract the number of missiles before storing in\n STA INWK+31            \\ byte #31\n\n LDA T                  \\ Restore the ship type we stored above\n\n.NW2\n\n STA FRIN,X             \\ Store the ship type in the X-th byte of FRIN, so the\n                        \\ slot is now shown as occupied in the index table\n\n TAX                    \\ Copy the ship type into X\n\n BMI P%+5               \\ If the ship type is negative (planet or sun), then\n                        \\ skip the following instruction\n\n INC MANY,X             \\ Increment the total number of ships of type X\n\n LDY #NI%-1             \\ The final step is to copy the new ship's data block\n                        \\ from INWK to INF, so set up a counter for NI% bytes\n                        \\ in Y\n\n.NWL3\n\n LDA INWK,Y             \\ Load the Y-th byte of INWK and store in the Y-th byte\n STA (INF),Y            \\ of the workspace pointed to by INF\n\n DEY                    \\ Decrement the loop counter\n\n BPL NWL3               \\ Loop back for the next byte until we have copied them\n                        \\ all over\n\n SEC                    \\ We have successfully created our new ship, so set the\n                        \\ C flag to indicate success\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: NwS1\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Flip the sign and double an INWK byte\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Flip the sign of the INWK byte at offset X, and increment X by 2. This is\n\\ used by the space station creation routine at NWSPS.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   The offset of the INWK byte to be flipped\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   X                   X is incremented by 2\n\\\n\\ ******************************************************************************\n\n.NwS1\n\n LDA INWK,X             \\ Load the X-th byte of INWK into A and flip bit 7,\n EOR #%10000000         \\ storing the result back in the X-th byte of INWK\n STA INWK,X\n\n INX                    \\ Add 2 to X\n INX\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: ABORT\n\\       Type: Subroutine\n\\   Category: Dashboard\n\\    Summary: Disarm missiles and update the dashboard indicators\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   Y                   The new colour of the missile indicator:\n\\\n\\                         * &00 = black (no missile)\n\\\n\\                         * &0E = red (armed and locked)\n\\\n\\                         * &E0 = yellow/white (armed)\n\\\n\\                         * &EE = green/cyan (disarmed)\n\\\n\\ ******************************************************************************\n\n.ABORT\n\n LDX #&FF               \\ Set X to &FF, which is the value of MSTG when we have\n                        \\ no target lock for our missile\n\n                        \\ Fall through into ABORT2 to set the missile lock to\n                        \\ the value in X, which effectively disarms the missile\n\n\\ ******************************************************************************\n\\\n\\       Name: ABORT2\n\\       Type: Subroutine\n\\   Category: Dashboard\n\\    Summary: Set/unset the lock target for a missile and update the dashboard\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Set the lock target for the leftmost missile and update the dashboard.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   The slot number of the ship to lock our missile onto, or\n\\                       &FF to remove missile lock\n\\\n\\   Y                   The new colour of the missile indicator:\n\\\n\\                         * &00 = black (no missile)\n\\\n\\                         * &0E = red (armed and locked)\n\\\n\\                         * &E0 = yellow/white (armed)\n\\\n\\                         * &EE = green/cyan (disarmed)\n\\\n\\ ******************************************************************************\n\n.ABORT2\n\n STX MSTG               \\ Store the target of our missile lock in MSTG\n\n LDX NOMSL              \\ Call MSBAR to update the leftmost indicator in the\n JSR MSBAR              \\ dashboard's missile bar, which returns with Y = 0\n\n STY MSAR               \\ Set MSAR = 0 to indicate that the leftmost missile\n                        \\ is no longer seeking a target lock\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: ECBLB2\n\\       Type: Subroutine\n\\   Category: Dashboard\n\\    Summary: Start up the E.C.M. (light up the indicator, start the countdown\n\\             and make the E.C.M. sound)\n\\\n\\ ******************************************************************************\n\n.ECBLB2\n\n LDA #32                \\ Set the E.C.M. countdown timer in ECMA to 32\n STA ECMA\n\n ASL A                  \\ Call the NOISE routine with A = 64 to make the sound\n JSR NOISE              \\ of the E.C.M. being switched on\n\n                        \\ Fall through into ECBLB to light up the E.C.M. bulb\n\n\\ ******************************************************************************\n\\\n\\       Name: ECBLB\n\\       Type: Subroutine\n\\   Category: Dashboard\n\\    Summary: Light up the E.C.M. indicator bulb (\"E\") on the dashboard\n\\\n\\ ******************************************************************************\n\n.ECBLB\n\n LDA #7*8               \\ The E.C.M. bulb is in character block number 7\n                        \\ with each character taking 8 bytes, so this sets the\n                        \\ low byte of the screen address of the character block\n                        \\ we want to draw to\n\n LDX #LO(ECBT)          \\ Set (Y X) to point to the character definition in\n LDY #HI(ECBT)          \\ ECBT. The LDY has no effect, as we overwrite Y with\n                        \\ the jump to BULB-2, which writes the high byte of SPBT\n                        \\ into Y. This works as long as ECBT and SPBT are in\n                        \\ the same page of memory, so perhaps the BNE below got\n                        \\ changed from BULB to BULB-2 so they could remove the\n                        \\ LDY, but for some reason it didn't get culled? Who\n                        \\ knows...\n\n BNE BULB-2             \\ Jump down to BULB-2 (this BNE is effectively a JMP as\n                        \\ A will never be zero)\n\n\\ ******************************************************************************\n\\\n\\       Name: SPBLB\n\\       Type: Subroutine\n\\   Category: Dashboard\n\\    Summary: Light up the space station indicator (\"S\") on the dashboard\n\\\n\\ ******************************************************************************\n\n.SPBLB\n\n LDA #24*8              \\ The space station bulb is in character block number 24\n                        \\ with each character taking 8 bytes, so this sets the\n                        \\ low byte of the screen address of the character block\n                        \\ we want to draw to\n\n LDX #LO(SPBT)          \\ Set (Y X) to point to the character definition in SPBT\n LDY #HI(SPBT)\n\n                        \\ Fall through into BULB to draw the space station bulb\n\n\\ ******************************************************************************\n\\\n\\       Name: BULB\n\\       Type: Subroutine\n\\   Category: Dashboard\n\\    Summary: Draw an indicator bulb on the dashboard\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The y-coordinate of the bulb as a low-byte screen\n\\                       address offset within screen page &7D (as both bulbs\n\\                       are on this character row in the dashboard)\n\\\n\\   (Y X)               The address of the character definition of the bulb to\n\\                       be drawn (i.e. ECBT for the E.C.M. bulb, or SPBT for the\n\\                       space station bulb)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   BULB-2              Set the Y screen address\n\\\n\\ ******************************************************************************\n\n.BULB\n\n STA SC                 \\ Store the low byte of the screen address in SC\n\n STX P+1                \\ Set P(2 1) = (Y X)\n STY P+2\n\n LDA #&7D               \\ Set A to the high byte of the screen address, which is\n                        \\ &7D as the bulbs are both in the character row from\n                        \\ &7D00 to &7DFF\n\n JMP RREN               \\ Call RREN to print the character definition pointed to\n                        \\ by P(2 1) at the screen address pointed to by (A SC),\n                        \\ returning from the subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: ECBT\n\\       Type: Variable\n\\   Category: Dashboard\n\\    Summary: The character bitmap for the E.C.M. indicator bulb\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The character bitmap for the E.C.M. indicator's \"E\" bulb that gets displayed\n\\ on the dashboard.\n\\\n\\ The E.C.M. indicator uses the first 5 rows of the space station's \"S\" bulb\n\\ below, as the bottom 5 rows of the \"E\" match the top 5 rows of the \"S\".\n\\\n\\ Each pixel is in mode 5 colour 2 (%10), which is yellow/white.\n\\\n\\ ******************************************************************************\n\n.ECBT\n\n EQUB %11100000         \\ x x x .\n EQUB %11100000         \\ x x x .\n EQUB %10000000         \\ x . . .\n                        \\ x x x .\n                        \\ x x x .\n                        \\ x . . .\n                        \\ x x x .\n                        \\ x x x .\n\n\\ ******************************************************************************\n\\\n\\       Name: SPBT\n\\       Type: Variable\n\\   Category: Dashboard\n\\    Summary: The bitmap definition for the space station indicator bulb\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The bitmap definition for the space station indicator's \"S\" bulb that gets\n\\ displayed on the dashboard.\n\\\n\\ Each pixel is in mode 5 colour 2 (%10), which is yellow/white.\n\\\n\\ ******************************************************************************\n\n.SPBT\n\n EQUB %11100000         \\ x x x .\n EQUB %11100000         \\ x x x .\n EQUB %10000000         \\ x . . .\n EQUB %11100000         \\ x x x .\n EQUB %11100000         \\ x x x .\n EQUB %00100000         \\ . . x .\n EQUB %11100000         \\ x x x .\n EQUB %11100000         \\ x x x .\n\n\\ ******************************************************************************\n\\\n\\       Name: MSBAR\n\\       Type: Subroutine\n\\   Category: Dashboard\n\\    Summary: Draw a specific indicator in the dashboard's missile bar\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Each indicator is a rectangle that's 3 pixels wide and 5 pixels high. If the\n\\ indicator is set to black, this effectively removes a missile.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   The number of the missile indicator to update (counting\n\\                       from right to left, so indicator NOMSL is the leftmost\n\\                       indicator)\n\\\n\\   Y                   The colour of the missile indicator:\n\\\n\\                         * &00 = black (no missile)\n\\\n\\                         * &0E = red (armed and locked)\n\\\n\\                         * &E0 = yellow/white (armed)\n\\\n\\                         * &EE = green/cyan (disarmed)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   X                   X is preserved\n\\\n\\   Y                   Y is set to 0\n\\\n\\ ******************************************************************************\n\n.MSBAR\n\n TXA                    \\ Set T = X * 8\n ASL A\n ASL A\n ASL A\n STA T\n\n LDA #49                \\ Set SC = 49 - T\n SBC T                  \\        = 48 + 1 - (X * 8)\n STA SC\n\n                        \\ So the low byte of SC(1 0) contains the row address\n                        \\ for the rightmost missile indicator, made up as\n                        \\ follows:\n                        \\\n                        \\   * 48 (character block 7, as byte #7 * 8 = 48), the\n                        \\     character block of the rightmost missile\n                        \\\n                        \\   * 1 (so we start drawing on the second row of the\n                        \\     character block)\n                        \\\n                        \\   * Move left one character (8 bytes) for each count\n                        \\     of X, so when X = 0 we are drawing the rightmost\n                        \\     missile, for X = 1 we hop to the left by one\n                        \\     character, and so on\n\n LDA #&7E               \\ Set the high byte of SC(1 0) to &7E, the character row\n STA SCH                \\ that contains the missile indicators (i.e. the bottom\n                        \\ row of the screen)\n\n TYA                    \\ Set A to the correct colour, which is a three-pixel\n                        \\ wide mode 5 character row in the correct colour (for\n                        \\ example, a green block has Y = &EE, or %11101110, so\n                        \\ the missile blocks are 3 pixels wide, with the\n                        \\ fourth pixel on the character row being empty)\n\n LDY #5                 \\ We now want to draw this line five times, so set a\n                        \\ counter in Y\n\n.MBL1\n\n STA (SC),Y             \\ Draw the three-pixel row, and as we do not use EOR\n                        \\ logic, this will overwrite anything that is already\n                        \\ there (so drawing a black missile will delete what's\n                        \\ there)\n\n DEY                    \\ Decrement the counter for the next row\n\n BNE MBL1               \\ Loop back to MBL1 if have more rows to draw\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: PROJ\n\\       Type: Subroutine\n\\   Category: Maths (Geometry)\n\\    Summary: Project the current ship or planet onto the screen\n\\  Deep dive: Extended screen coordinates\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Project the current ship's location or the planet onto the screen, either\n\\ returning the screen coordinates of the projection (if it's on-screen), or\n\\ returning an error via the C flag.\n\\\n\\ In this context, \"on-screen\" means that the point is projected into the\n\\ following range:\n\\\n\\   centre of screen - 1024 < x < centre of screen + 1024\n\\   centre of screen - 1024 < y < centre of screen + 1024\n\\\n\\ This is to cater for ships (and, more likely, planets and suns) whose centres\n\\ are off-screen but whose edges may still be visible.\n\\\n\\ The projection calculation is:\n\\\n\\   K3(1 0) = #X + x / z\n\\   K4(1 0) = #Y + y / z\n\\\n\\ where #X and #Y are the pixel x-coordinate and y-coordinate of the centre of\n\\ the screen.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   INWK                The ship data block for the ship to project on-screen\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   K3(1 0)             The x-coordinate of the ship's projection on-screen\n\\\n\\   K4(1 0)             The y-coordinate of the ship's projection on-screen\n\\\n\\   C flag              Set if the ship's projection doesn't fit on the screen,\n\\                       clear if it does project onto the screen\n\\\n\\   A                   Contains K4+1, the high byte of the y-coordinate\n\\\n\\ ******************************************************************************\n\n.PROJ\n\n LDA INWK               \\ Set P(1 0) = (x_hi x_lo)\n STA P                  \\            = x\n LDA INWK+1\n STA P+1\n\n LDA INWK+2             \\ Set A = x_sign\n\n JSR PLS6               \\ Call PLS6 to calculate:\n                        \\\n                        \\   (X K) = (A P+1 P) / (z_sign z_hi z_lo)\n                        \\         = (x_sign x_hi x_lo) / (z_sign z_hi z_lo)\n                        \\         = x / z\n\n BCS PL2-1              \\ If the C flag is set then the result overflowed and\n                        \\ the coordinate doesn't fit on the screen, so return\n                        \\ from the subroutine with the C flag set (as PL2-1\n                        \\ contains an RTS)\n\n LDA K                  \\ Set K3(1 0) = (X K) + #X\n ADC #X                 \\             = #X + x / z\n STA K3                 \\\n                        \\ first doing the low bytes\n\n TXA                    \\ And then the high bytes. #X is the x-coordinate of\n ADC #0                 \\ the centre of the space view, so this converts the\n STA K3+1               \\ space x-coordinate into a screen x-coordinate\n\n LDA INWK+3             \\ Set P(1 0) = (y_hi y_lo)\n STA P\n LDA INWK+4\n STA P+1\n\n LDA INWK+5             \\ Set A = -y_sign\n EOR #%10000000\n\n JSR PLS6               \\ Call PLS6 to calculate:\n                        \\\n                        \\   (X K) = (A P+1 P) / (z_sign z_hi z_lo)\n                        \\         = -(y_sign y_hi y_lo) / (z_sign z_hi z_lo)\n                        \\         = -y / z\n\n BCS PL2-1              \\ If the C flag is set then the result overflowed and\n                        \\ the coordinate doesn't fit on the screen, so return\n                        \\ from the subroutine with the C flag set (as PL2-1\n                        \\ contains an RTS)\n\n LDA K                  \\ Set K4(1 0) = (X K) + #Y\n ADC #Y                 \\             = #Y - y / z\n STA K4                 \\\n                        \\ first doing the low bytes\n\n TXA                    \\ And then the high bytes. #Y is the y-coordinate of\n ADC #0                 \\ the centre of the space view, so this converts the\n STA K4+1               \\ space y-coordinate into a screen y-coordinate\n\n CLC                    \\ Clear the C flag to indicate success\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: PL2\n\\       Type: Subroutine\n\\   Category: Drawing planets\n\\    Summary: Remove the planet or sun from the screen\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   PL2-1               Contains an RTS\n\\\n\\ ******************************************************************************\n\n.PL2\n\n LDA TYPE               \\ Shift bit 0 of the planet/sun's type into the C flag\n LSR A\n\n BCS P%+5               \\ If the planet/sun's type has bit 0 clear, then it's\n                        \\ either 128 or 130, which is a planet; meanwhile, the\n                        \\ sun has type 129, which has bit 0 set. So if this is\n                        \\ the sun, skip the following instruction\n\n JMP WPLS2              \\ This is the planet, so jump to WPLS2 to remove it from\n                        \\ screen, returning from the subroutine using a tail\n                        \\ call\n\n JMP WPLS               \\ This is the sun, so jump to WPLS to remove it from\n                        \\ screen, returning from the subroutine using a tail\n                        \\ call\n\n\\ ******************************************************************************\n\\\n\\       Name: PLANET\n\\       Type: Subroutine\n\\   Category: Drawing planets\n\\    Summary: Draw the planet or sun\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   INWK                The planet or sun's ship data block\n\\\n\\ ******************************************************************************\n\n.PLANET\n\n LDA INWK+8             \\ Set A = z_sign (the highest byte in the planet/sun's\n                        \\ coordinates)\n\n BMI PL2                \\ If A is negative then the planet/sun is behind us, so\n                        \\ jump to PL2 to remove it from the screen, returning\n                        \\ from the subroutine using a tail call\n\n CMP #48                \\ If A >= 48 then the planet/sun is too far away to be\n BCS PL2                \\ seen, so jump to PL2 to remove it from the screen,\n                        \\ returning from the subroutine using a tail call\n\n ORA INWK+7             \\ Set A to 0 if both z_sign and z_hi are 0\n\n BEQ PL2                \\ If both z_sign and z_hi are 0, then the planet/sun is\n                        \\ too close to be shown, so jump to PL2 to remove it\n                        \\ from the screen, returning from the subroutine using a\n                        \\ tail call\n\n JSR PROJ               \\ Project the planet/sun onto the screen, returning the\n                        \\ centre's coordinates in K3(1 0) and K4(1 0)\n\n BCS PL2                \\ If the C flag is set by PROJ then the planet/sun is\n                        \\ not visible on-screen, so jump to PL2 to remove it\n                        \\ from the screen, returning from the subroutine using\n                        \\ a tail call\n\n LDA #96                \\ Set (A P+1 P) = (0 96 0) = 24576\n STA P+1                \\\n LDA #0                 \\ This represents the planet/sun's radius at a distance\n STA P                  \\ of z = 1\n\n JSR DVID3B2            \\ Call DVID3B2 to calculate:\n                        \\\n                        \\   K(3 2 1 0) = (A P+1 P) / (z_sign z_hi z_lo)\n                        \\              = (0 96 0) / z\n                        \\              = 24576 / z\n                        \\\n                        \\ so K now contains the planet/sun's radius, reduced by\n                        \\ the actual distance to the planet/sun. We know that\n                        \\ K+3 and K+2 will be 0, as the number we are dividing,\n                        \\ (0 96 0), fits into the two bottom bytes, so the\n                        \\ result is actually in K(1 0)\n\n LDA K+1                \\ If the high byte of the reduced radius is zero, jump\n BEQ PL82               \\ to PL82, as K contains the radius on its own\n\n LDA #248               \\ Otherwise set K = 248, to round up the radius in\n STA K                  \\ K(1 0) to the nearest integer (if we consider the low\n                        \\ byte to be the fractional part)\n\n.PL82\n\n LDA TYPE               \\ If the planet/sun's type has bit 0 clear, then it's\n LSR A                  \\ either 128 or 130, which is a planet (the sun has type\n BCC PL9                \\ 129, which has bit 0 set). So jump to PL9 to draw the\n                        \\ planet with radius K, returning from the subroutine\n                        \\ using a tail call\n\n JMP SUN                \\ Otherwise jump to SUN to draw the sun with radius K,\n                        \\ returning from the subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: PL9 (Part 1 of 3)\n\\       Type: Subroutine\n\\   Category: Drawing planets\n\\    Summary: Draw the planet, with either an equator and meridian, or a crater\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Draw the planet with radius K at pixel coordinate (K3, K4), and with either an\n\\ equator and meridian, or a crater.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   K(1 0)              The planet's radius\n\\\n\\   K3(1 0)             Pixel x-coordinate of the centre of the planet\n\\\n\\   K4(1 0)             Pixel y-coordinate of the centre of the planet\n\\\n\\   INWK                The planet's ship data block\n\\\n\\ ******************************************************************************\n\n.PL9\n\n JSR WPLS2              \\ Call WPLS2 to remove the planet from the screen\n\n JSR CIRCLE             \\ Call CIRCLE to draw the planet's new circle\n\n BCS PL20               \\ If the call to CIRCLE returned with the C flag set,\n                        \\ then the circle does not fit on-screen, so jump to\n                        \\ PL20 to return from the subroutine\n\n LDA K+1                \\ If K+1 is zero, jump to PL25 as K(1 0) < 256, so the\n BEQ PL25               \\ planet fits on the screen and we can draw meridians or\n                        \\ craters\n\n.PL20\n\n RTS                    \\ The planet doesn't fit on-screen, so return from the\n                        \\ subroutine\n\n.PL25\n\n LDA TYPE               \\ If the planet type is 128 then it has an equator and\n CMP #128               \\ a meridian, so this jumps to PL26 if this is not a\n BNE PL26               \\ planet with an equator - in other words, if it is a\n                        \\ planet with a crater\n\n                        \\ Otherwise this is a planet with an equator and\n                        \\ meridian, so fall through into the following to draw\n                        \\ them\n\n\\ ******************************************************************************\n\\\n\\       Name: PL9 (Part 2 of 3)\n\\       Type: Subroutine\n\\   Category: Drawing planets\n\\    Summary: Draw the planet's equator and meridian\n\\  Deep dive: Drawing meridians and equators\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Draw the planet's equator and meridian.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   K(1 0)              The planet's radius\n\\\n\\   K3(1 0)             Pixel x-coordinate of the centre of the planet\n\\\n\\   K4(1 0)             Pixel y-coordinate of the centre of the planet\n\\\n\\   INWK                The planet's ship data block\n\\\n\\ ******************************************************************************\n\n LDA K                  \\ If the planet's radius is less than 6, the planet is\n CMP #6                 \\ too small to show a meridian, so jump to PL20 to\n BCC PL20               \\ return from the subroutine\n\n LDA INWK+14            \\ Set P = -nosev_z_hi\n EOR #%10000000\n STA P\n\n LDA INWK+20            \\ Set A = roofv_z_hi\n\n JSR PLS4               \\ Call PLS4 to calculate the following:\n                        \\\n                        \\   CNT2 = arctan(P / A) / 4\n                        \\        = arctan(-nosev_z_hi / roofv_z_hi) / 4\n                        \\\n                        \\ and do the following if nosev_z_hi >= 0:\n                        \\\n                        \\   CNT2 = CNT2 + PI\n\n LDX #9                 \\ Set X to 9 so the call to PLS1 divides nosev_x\n\n JSR PLS1               \\ Call PLS1 to calculate the following:\n STA K2                 \\\n STY XX16               \\   (XX16 K2) = nosev_x / z\n                        \\\n                        \\ and increment X to point to nosev_y for the next call\n\n JSR PLS1               \\ Call PLS1 to calculate the following:\n STA K2+1               \\\n STY XX16+1             \\   (XX16+1 K2+1) = nosev_y / z\n\n LDX #15                \\ Set X to 15 so the call to PLS5 divides roofv_x\n\n JSR PLS5               \\ Call PLS5 to calculate the following:\n                        \\\n                        \\   (XX16+2 K2+2) = roofv_x / z\n                        \\\n                        \\   (XX16+3 K2+3) = roofv_y / z\n\n JSR PLS2               \\ Call PLS2 to draw the first meridian\n\n LDA INWK+14            \\ Set P = -nosev_z_hi\n EOR #%10000000\n STA P\n\n LDA INWK+26            \\ Set A = sidev_z_hi, so the second meridian will be at\n                        \\ 90 degrees to the first\n\n JSR PLS4               \\ Call PLS4 to calculate the following:\n                        \\\n                        \\   CNT2 = arctan(P / A) / 4\n                        \\        = arctan(-nosev_z_hi / sidev_z_hi) / 4\n                        \\\n                        \\ and do the following if nosev_z_hi >= 0:\n                        \\\n                        \\   CNT2 = CNT2 + PI\n\n LDX #21                \\ Set X to 21 so the call to PLS5 divides sidev_x\n\n JSR PLS5               \\ Call PLS5 to calculate the following:\n                        \\\n                        \\   (XX16+2 K2+2) = sidev_x / z\n                        \\\n                        \\   (XX16+3 K2+3) = sidev_y / z\n\n JMP PLS2               \\ Jump to PLS2 to draw the second meridian, returning\n                        \\ from the subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: PL9 (Part 3 of 3)\n\\       Type: Subroutine\n\\   Category: Drawing planets\n\\    Summary: Draw the planet's crater\n\\  Deep dive: Drawing craters\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Draw the planet's crater.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   K(1 0)              The planet's radius\n\\\n\\   K3(1 0)             Pixel x-coordinate of the centre of the planet\n\\\n\\   K4(1 0)             Pixel y-coordinate of the centre of the planet\n\\\n\\   INWK                The planet's ship data block\n\\\n\\ ******************************************************************************\n\n.PL26\n\n LDA INWK+20            \\ Set A = roofv_z_hi\n\n BMI PL20               \\ If A is negative, the crater is on the far side of the\n                        \\ planet, so return from the subroutine (as PL2\n                        \\ contains an RTS)\n\n LDX #15                \\ Set X = 15, so the following call to PLS3 operates on\n                        \\ roofv\n\n JSR PLS3               \\ Call PLS3 to calculate:\n                        \\\n                        \\   (Y A P) = 222 * roofv_x / z\n                        \\\n                        \\ to give the x-coordinate of the crater offset and\n                        \\ increment X to point to roofv_y for the next call\n\n CLC                    \\ Calculate:\n ADC K3                 \\\n STA K3                 \\   K3(1 0) = (Y A) + K3(1 0)\n                        \\           = 222 * roofv_x / z + x-coordinate of planet\n                        \\             centre\n                        \\\n                        \\ starting with the high bytes\n\n TYA                    \\ And then doing the low bytes, so now K3(1 0) contains\n ADC K3+1               \\ the x-coordinate of the crater offset plus the planet\n STA K3+1               \\ centre to give the x-coordinate of the crater's centre\n\n JSR PLS3               \\ Call PLS3 to calculate:\n                        \\\n                        \\   (Y A P) = 222 * roofv_y / z\n                        \\\n                        \\ to give the y-coordinate of the crater offset\n\n STA P                  \\ Calculate:\n LDA K4                 \\\n SEC                    \\   K4(1 0) = K4(1 0) - (Y A)\n SBC P                  \\           = 222 * roofv_y / z - y-coordinate of planet\n STA K4                 \\             centre\n                        \\\n                        \\ starting with the low bytes\n\n STY P                  \\ And then doing the low bytes, so now K4(1 0) contains\n LDA K4+1               \\ the y-coordinate of the crater offset plus the planet\n SBC P                  \\ centre to give the y-coordinate of the crater's centre\n STA K4+1\n\n LDX #9                 \\ Set X = 9, so the following call to PLS1 operates on\n                        \\ nosev\n\n JSR PLS1               \\ Call PLS1 to calculate the following:\n                        \\\n                        \\   (Y A) = nosev_x / z\n                        \\\n                        \\ and increment X to point to nosev_y for the next call\n\n LSR A                  \\ Set (XX16 K2) = (Y A) / 2\n STA K2\n STY XX16\n\n JSR PLS1               \\ Call PLS1 to calculate the following:\n                        \\\n                        \\   (Y A) = nosev_y / z\n                        \\\n                        \\ and increment X to point to nosev_z for the next call\n\n LSR A                  \\ Set (XX16+1 K2+1) = (Y A) / 2\n STA K2+1\n STY XX16+1\n\n LDX #21                \\ Set X = 21, so the following call to PLS1 operates on\n                        \\ sidev\n\n JSR PLS1               \\ Call PLS1 to calculate the following:\n                        \\\n                        \\   (Y A) = sidev_x / z\n                        \\\n                        \\ and increment X to point to sidev_y for the next call\n\n LSR A                  \\ Set (XX16+2 K2+2) = (Y A) / 2\n STA K2+2\n STY XX16+2\n\n JSR PLS1               \\ Call PLS1 to calculate the following:\n                        \\\n                        \\   (Y A) = sidev_y / z\n                        \\\n                        \\ and increment X to point to sidev_z for the next call\n\n LSR A                  \\ Set (XX16+3 K2+3) = (Y A) / 2\n STA K2+3\n STY XX16+3\n\n LDA #64                \\ Set TGT = 64, so we draw a full ellipse in the call to\n STA TGT                \\ PLS22 below\n\n LDA #0                 \\ Set CNT2 = 0 as we are drawing a full ellipse, so we\n STA CNT2               \\ don't need to apply an offset\n\n JMP PLS22              \\ Jump to PLS22 to draw the crater, returning from the\n                        \\ subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: PLS1\n\\       Type: Subroutine\n\\   Category: Drawing planets\n\\    Summary: Calculate (Y A) = nosev_x / z\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following division of a specified value from one of the\n\\ orientation vectors (in this example, nosev_x):\n\\\n\\   (Y A) = nosev_x / z\n\\\n\\ where z is the z-coordinate of the planet from INWK. The result is an 8-bit\n\\ magnitude in A, with maximum value 254, and just a sign bit (bit 7) in Y.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   Determines which of the INWK orientation vectors to\n\\                       divide:\n\\\n\\                         * X = 9, 11, 13: divides nosev_x, nosev_y, nosev_z\n\\\n\\                         * X = 15, 17, 19: divides roofv_x, roofv_y, roofv_z\n\\\n\\                         * X = 21, 23, 25: divides sidev_x, sidev_y, sidev_z\n\\\n\\   INWK                The planet's ship data block\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   A                   The result as an 8-bit magnitude with maximum value 254\n\\\n\\   Y                   The sign of the result in bit 7\n\\\n\\   K+3                 Also the sign of the result in bit 7\n\\\n\\   X                   X gets incremented by 2 so it points to the next\n\\                       coordinate in this orientation vector (so consecutive\n\\                       calls to the routine will start with x, then move onto y\n\\                       and then z)\n\\\n\\ ******************************************************************************\n\n.PLS1\n\n LDA INWK,X             \\ Set P = nosev_x_lo\n STA P\n\n LDA INWK+1,X           \\ Set P+1 = |nosev_x_hi|\n AND #%01111111\n STA P+1\n\n LDA INWK+1,X           \\ Set A = sign bit of nosev_x_lo\n AND #%10000000\n\n JSR DVID3B2            \\ Call DVID3B2 to calculate:\n                        \\\n                        \\   K(3 2 1 0) = (A P+1 P) / (z_sign z_hi z_lo)\n\n LDA K                  \\ Fetch the lowest byte of the result into A\n\n LDY K+1                \\ Fetch the second byte of the result into Y\n\n BEQ P%+4               \\ If the second byte is 0, skip the next instruction\n\n LDA #254               \\ The second byte is non-zero, so the result won't fit\n                        \\ into one byte, so set A = 254 as our maximum one-byte\n                        \\ value to return\n\n LDY K+3                \\ Fetch the sign of the result from K+3 into Y\n\n INX                    \\ Add 2 to X so the index points to the next coordinate\n INX                    \\ in this orientation vector (so consecutive calls to\n                        \\ the routine will start with x, then move onto y and z)\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: PLS2\n\\       Type: Subroutine\n\\   Category: Drawing planets\n\\    Summary: Draw a half-ellipse\n\\  Deep dive: Drawing ellipses\n\\             Drawing meridians and equators\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Draw a half-ellipse, used for the planet's equator and meridian.\n\\\n\\ ******************************************************************************\n\n.PLS2\n\n LDA #31                \\ Set TGT = 31, so we only draw half an ellipse\n STA TGT\n\n                        \\ Fall through into PLS22 to draw the half-ellipse\n\n\\ ******************************************************************************\n\\\n\\       Name: PLS22\n\\       Type: Subroutine\n\\   Category: Drawing planets\n\\    Summary: Draw an ellipse or half-ellipse\n\\  Deep dive: Drawing ellipses\n\\             Drawing meridians and equators\n\\             Drawing craters\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Draw an ellipse or half-ellipse, to be used for the planet's equator and\n\\ meridian (in which case we draw half an ellipse), or crater (in which case we\n\\ draw a full ellipse).\n\\\n\\ The ellipse is defined by a centre point, plus two conjugate radius vectors,\n\\ u and v, where:\n\\\n\\   u = [ u_x ]       v = [ v_x ]\n\\       [ u_y ]           [ v_y ]\n\\\n\\ The individual components of these 2D vectors (i.e. u_x, u_y etc.) are 16-bit\n\\ sign-magnitude numbers, where the high bytes contain only the sign bit (in\n\\ bit 7), with bits 0 to 6 being clear. This means that as we store u_x as\n\\ (XX16 K2), for example, we know that |u_x| = K2.\n\\\n\\ This routine calls BLINE to draw each line segment in the ellipse, passing the\n\\ coordinates as follows:\n\\\n\\   K6(1 0) = K3(1 0) + u_x * cos(CNT2) + v_x * sin(CNT2)\n\\\n\\   K6(3 2) = K4(1 0) - u_y * cos(CNT2) - v_y * sin(CNT2)\n\\\n\\ The y-coordinates are negated because BLINE expects pixel coordinates but the\n\\ u and v vectors are extracted from the orientation vector. The y-axis runs\n\\ in the opposite direction in 3D space to that on the screen, so we need to\n\\ negate the 3D space coordinates before we can combine them with the ellipse's\n\\ centre coordinates.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   K(1 0)              The planet's radius\n\\\n\\   K3(1 0)             The pixel x-coordinate of the centre of the ellipse\n\\\n\\   K4(1 0)             The pixel y-coordinate of the centre of the ellipse\n\\\n\\   (XX16 K2)           The x-component of u (i.e. u_x), where XX16 contains\n\\                       just the sign of the sign-magnitude number\n\\\n\\   (XX16+1 K2+1)       The y-component of u (i.e. u_y), where XX16+1 contains\n\\                       just the sign of the sign-magnitude number\n\\\n\\   (XX16+2 K2+2)       The x-component of v (i.e. v_x), where XX16+2 contains\n\\                       just the sign of the sign-magnitude number\n\\\n\\   (XX16+3 K2+3)       The y-component of v (i.e. v_y), where XX16+3 contains\n\\                       just the sign of the sign-magnitude number\n\\\n\\   TGT                 The number of segments to draw:\n\\\n\\                         * 32 for a half ellipse (a meridian)\n\\\n\\                         * 64 for a full ellipse (a crater)\n\\\n\\   CNT2                The starting segment for drawing the half-ellipse\n\\\n\\ ******************************************************************************\n\n.PLS22\n\n LDX #0                 \\ Set CNT = 0\n STX CNT\n\n DEX                    \\ Set FLAG = &FF to start a new line in the ball line\n STX FLAG               \\ heap when calling BLIN below, so the crater or\n                        \\ meridian is separate from any previous ellipses\n\n.PLL4\n\n LDA CNT2               \\ Set X = CNT2 mod 32\n AND #31                \\\n TAX                    \\ So X is the starting segment, reduced to the range 0\n                        \\ to 32, so as there are 64 segments in the circle, this\n                        \\ reduces the starting angle to 0 to 180 degrees, so we\n                        \\ can use X as an index into the sine table (which only\n                        \\ contains values for segments 0 to 31)\n                        \\\n                        \\ Also, because CNT2 mod 32 is in the range 0 to 180\n                        \\ degrees, we know that sin(CNT2 mod 32) is always\n                        \\ positive, or to put it another way:\n                        \\\n                        \\   sin(CNT2 mod 32) = |sin(CNT2)|\n\n LDA SNE,X              \\ Set Q = sin(X)\n STA Q                  \\       = sin(CNT2 mod 32)\n                        \\       = |sin(CNT2)|\n\n LDA K2+2               \\ Set A = K2+2\n                        \\       = |v_x|\n\n JSR FMLTU              \\ Set R = A * Q / 256\n STA R                  \\       = |v_x| * |sin(CNT2)|\n\n LDA K2+3               \\ Set A = K2+3\n                        \\       = |v_y|\n\n JSR FMLTU              \\ Set K = A * Q / 256\n STA K                  \\       = |v_y| * |sin(CNT2)|\n\n LDX CNT2               \\ If CNT2 >= 33 then this sets the C flag, otherwise\n CPX #33                \\ it's clear, so this means that:\n                        \\\n                        \\   * C is clear if the segment starts in the first half\n                        \\     of the circle, 0 to 180 degrees\n                        \\\n                        \\   * C is set if the segment starts in the second half\n                        \\     of the circle, 180 to 360 degrees\n                        \\\n                        \\ In other words, the C flag contains the sign bit for\n                        \\ sin(CNT2), which is positive for 0 to 180 degrees\n                        \\ and negative for 180 to 360 degrees\n\n LDA #0                 \\ Shift the C flag into the sign bit of XX16+5, so\n ROR A                  \\ XX16+5 has the correct sign for sin(CNT2)\n STA XX16+5             \\\n                        \\ Because we set the following above:\n                        \\\n                        \\   K = |v_y| * |sin(CNT2)|\n                        \\   R = |v_x| * |sin(CNT2)|\n                        \\\n                        \\ we can add XX16+5 as the high byte to give us the\n                        \\ following:\n                        \\\n                        \\   (XX16+5 K) = |v_y| * sin(CNT2)\n                        \\   (XX16+5 R) = |v_x| * sin(CNT2)\n\n LDA CNT2               \\ Set X = (CNT2 + 16) mod 32\n CLC                    \\\n ADC #16                \\ So we can use X as a lookup index into the SNE table\n AND #31                \\ to get the cosine (as there are 16 segments in a\n TAX                    \\ quarter-circle)\n                        \\\n                        \\ Also, because the sine table only contains positive\n                        \\ values, we know that sin((CNT2 + 16) mod 32) will\n                        \\ always be positive, or to put it another way:\n                        \\\n                        \\   sin((CNT2 + 16) mod 32) = |cos(CNT2)|\n\n LDA SNE,X              \\ Set Q = sin(X)\n STA Q                  \\       = sin((CNT2 + 16) mod 32)\n                        \\       = |cos(CNT2)|\n\n LDA K2+1               \\ Set A = K2+1\n                        \\       = |u_y|\n\n JSR FMLTU              \\ Set K+2 = A * Q / 256\n STA K+2                \\         = |u_y| * |cos(CNT2)|\n\n LDA K2                 \\ Set A = K2\n                        \\       = |u_x|\n\n JSR FMLTU              \\ Set P = A * Q / 256\n STA P                  \\       = |u_x| * |cos(CNT2)|\n                        \\\n                        \\ The call to FMLTU also sets the C flag, so in the\n                        \\ following, ADC #15 adds 16 rather than 15\n\n LDA CNT2               \\ If (CNT2 + 16) mod 64 >= 33 then this sets the C flag,\n ADC #15                \\ otherwise it's clear, so this means that:\n AND #63                \\\n CMP #33                \\   * C is clear if the segment starts in the first or\n                        \\     last quarter of the circle, 0 to 90 degrees or 270\n                        \\     to 360 degrees\n                        \\\n                        \\   * C is set if the segment starts in the second or\n                        \\     third quarter of the circle, 90 to 270 degrees\n                        \\\n                        \\ In other words, the C flag contains the sign bit for\n                        \\ cos(CNT2), which is positive for 0 to 90 degrees or\n                        \\ 270 to 360 degrees, and negative for 90 to 270 degrees\n\n LDA #0                 \\ Shift the C flag into the sign bit of XX16+4, so:\n ROR A                  \\ XX16+4 has the correct sign for cos(CNT2)\n STA XX16+4             \\\n                        \\ Because we set the following above:\n                        \\\n                        \\   K+2 = |u_y| * |cos(CNT2)|\n                        \\   P   = |u_x| * |cos(CNT2)|\n                        \\\n                        \\ we can add XX16+4 as the high byte to give us the\n                        \\ following:\n                        \\\n                        \\   (XX16+4 K+2) = |u_y| * cos(CNT2)\n                        \\   (XX16+4 P)   = |u_x| * cos(CNT2)\n\n LDA XX16+5             \\ Set S = the sign of XX16+2 * XX16+5\n EOR XX16+2             \\       = the sign of v_x * XX16+5\n STA S                  \\\n                        \\ So because we set this above:\n                        \\\n                        \\   (XX16+5 R) = |v_x| * sin(CNT2)\n                        \\\n                        \\ we now have this:\n                        \\\n                        \\   (S R) = v_x * sin(CNT2)\n\n LDA XX16+4             \\ Set A = the sign of XX16 * XX16+4\n EOR XX16               \\       = the sign of u_x * XX16+4\n                        \\\n                        \\ So because we set this above:\n                        \\\n                        \\   (XX16+4 P)   = |u_x| * cos(CNT2)\n                        \\\n                        \\ we now have this:\n                        \\\n                        \\   (A P) = u_x * cos(CNT2)\n\n JSR ADD                \\ Set (A X) = (A P) + (S R)\n                        \\           = u_x * cos(CNT2) + v_x * sin(CNT2)\n\n STA T                  \\ Store the high byte in T, so the result is now:\n                        \\\n                        \\   (T X) = u_x * cos(CNT2) + v_x * sin(CNT2)\n\n BPL PL42               \\ If the result is positive, jump down to PL42\n\n TXA                    \\ The result is negative, so we need to negate the\n EOR #%11111111         \\ magnitude using two's complement, first doing the low\n CLC                    \\ byte in X\n ADC #1\n TAX\n\n LDA T                  \\ And then the high byte in T, making sure to leave the\n EOR #%01111111         \\ sign bit alone\n ADC #0\n STA T\n\n.PL42\n\n TXA                    \\ Set K6(1 0) = K3(1 0) + (T X)\n ADC K3                 \\\n STA K6                 \\ starting with the low bytes\n\n LDA T                  \\ And then doing the high bytes, so we now get:\n ADC K3+1               \\\n STA K6+1               \\   K6(1 0) = K3(1 0) + (T X)\n                        \\           = K3(1 0) + u_x * cos(CNT2)\n                        \\                     + v_x * sin(CNT2)\n                        \\\n                        \\ K3(1 0) is the x-coordinate of the centre of the\n                        \\ ellipse, so we now have the correct x-coordinate for\n                        \\ our ellipse segment that we can pass to BLINE below\n\n LDA K                  \\ Set R = K = |v_y| * sin(CNT2)\n STA R\n\n LDA XX16+5             \\ Set S = the sign of XX16+3 * XX16+5\n EOR XX16+3             \\       = the sign of v_y * XX16+5\n STA S                  \\\n                        \\ So because we set this above:\n                        \\\n                        \\   (XX16+5 K) = |v_y| * sin(CNT2)\n                        \\\n                        \\ and we just set R = K, we now have this:\n                        \\\n                        \\   (S R) = v_y * sin(CNT2)\n\n LDA K+2                \\ Set P = K+2 = |u_y| * cos(CNT2)\n STA P\n\n LDA XX16+4             \\ Set A = the sign of XX16+1 * XX16+4\n EOR XX16+1             \\       = the sign of u_y * XX16+4\n                        \\\n                        \\ So because we set this above:\n                        \\\n                        \\   (XX16+4 K+2) = |u_y| * cos(CNT2)\n                        \\\n                        \\ and we just set P = K+2, we now have this:\n                        \\\n                        \\   (A P) = u_y * cos(CNT2)\n\n JSR ADD                \\ Set (A X) = (A P) + (S R)\n                        \\           =  u_y * cos(CNT2) + v_y * sin(CNT2)\n\n EOR #%10000000         \\ Store the negated high byte in T, so the result is\n STA T                  \\ now:\n                        \\\n                        \\   (T X) = - u_y * cos(CNT2) - v_y * sin(CNT2)\n                        \\\n                        \\ This negation is necessary because BLINE expects us\n                        \\ to pass pixel coordinates, where y-coordinates get\n                        \\ larger as we go down the screen; u_y and v_y, on the\n                        \\ other hand, are extracted from the orientation\n                        \\ vectors, where y-coordinates get larger as we go up\n                        \\ in space, so to rectify this we need to negate the\n                        \\ result in (T X) before we can add it to the\n                        \\ y-coordinate of the ellipse's centre in BLINE\n\n BPL PL43               \\ If the result is positive, jump down to PL43\n\n TXA                    \\ The result is negative, so we need to negate the\n EOR #%11111111         \\ magnitude using two's complement, first doing the low\n CLC                    \\ byte in X\n ADC #1\n TAX\n\n LDA T                  \\ And then the high byte in T, making sure to leave the\n EOR #%01111111         \\ sign bit alone\n ADC #0\n STA T\n\n.PL43\n\n                        \\ We now call BLINE to draw the ellipse line segment\n                        \\\n                        \\ The first few instructions of BLINE do the following:\n                        \\\n                        \\   K6(3 2) = K4(1 0) + (T X)\n                        \\\n                        \\ which gives:\n                        \\\n                        \\   K6(3 2) = K4(1 0) - u_y * cos(CNT2)\n                        \\                     - v_y * sin(CNT2)\n                        \\\n                        \\ K4(1 0) is the pixel y-coordinate of the centre of the\n                        \\ ellipse, so this gives us the correct y-coordinate for\n                        \\ our ellipse segment (we already calculated the\n                        \\ x-coordinate in K3(1 0) above)\n\n JSR BLINE              \\ Call BLINE to draw this segment, which also returns\n                        \\ the updated value of CNT in A\n\n CMP TGT                \\ If CNT > TGT then jump to PL40 to stop drawing the\n BEQ P%+4               \\ ellipse (which is how we draw half-ellipses)\n BCS PL40\n\n LDA CNT2               \\ Set CNT2 = (CNT2 + STP) mod 64\n CLC\n ADC STP\n AND #63\n STA CNT2\n\n JMP PLL4               \\ Jump back to PLL4 to draw the next segment\n\n.PL40\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: SUN (Part 1 of 4)\n\\       Type: Subroutine\n\\   Category: Drawing suns\n\\    Summary: Draw the sun: Set up all the variables needed to draw the sun\n\\  Deep dive: Drawing the sun\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Draw a new sun with radius K at pixel coordinate (K3, K4), removing the old\n\\ sun if there is one. This routine is used to draw the sun, as well as the\n\\ star systems on the Short-range Chart.\n\\\n\\ The first part sets up all the variables needed to draw the new sun.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   K                   The new sun's radius\n\\\n\\   K3(1 0)             Pixel x-coordinate of the centre of the new sun\n\\\n\\   K4(1 0)             Pixel y-coordinate of the centre of the new sun\n\\\n\\   SUNX(1 0)           The x-coordinate of the vertical centre axis of the old\n\\                       sun (the one currently on-screen)\n\\\n\\ ******************************************************************************\n\n JMP WPLS               \\ Jump to WPLS to remove the old sun from the screen. We\n                        \\ only get here via the BCS just after the SUN entry\n                        \\ point below, when there is no new sun to draw\n\n.PLF3\n\n                        \\ This is called from below to negate X and set A to\n                        \\ &FF, for when the new sun's centre is off the bottom\n                        \\ of the screen (so we don't need to draw its bottom\n                        \\ half)\n                        \\\n                        \\ This happens when the y-coordinate of the centre of\n                        \\ the sun is bigger than the y-coordinate of the bottom\n                        \\ of the space view\n\n TXA                    \\ Negate X using two's complement, so X = ~X + 1\n EOR #%11111111\n CLC\n ADC #1\n TAX\n\n.PLF17\n\n                        \\ This is called from below to set A to &FF, for when\n                        \\ the new sun's centre is right on the bottom of the\n                        \\ screen (so we don't need to draw its bottom half)\n\n LDA #&FF               \\ Set A = &FF\n\n JMP PLF5               \\ Jump to PLF5\n\n.SUN\n\n LDA #1                 \\ Set LSX = 1 to indicate the sun line heap is about to\n STA LSX                \\ be filled up\n\n JSR CHKON              \\ Call CHKON to check whether any part of the new sun's\n                        \\ circle appears on-screen, and if it does, set P(2 1)\n                        \\ to the maximum y-coordinate of the new sun on-screen\n\n BCS PLF3-3             \\ If CHKON set the C flag then the new sun's circle does\n                        \\ not appear on-screen, so jump to WPLS (via the JMP at\n                        \\ the top of this routine) to remove the sun from the\n                        \\ screen, returning from the subroutine using a tail\n                        \\ call\n\n LDA #0                 \\ Set A = 0\n\n LDX K                  \\ Set X = K = radius of the new sun\n\n CPX #96                \\ If X >= 96, set the C flag and rotate it into bit 0\n ROL A                  \\ of A, otherwise rotate a 0 into bit 0\n\n CPX #40                \\ If X >= 40, set the C flag and rotate it into bit 0\n ROL A                  \\ of A, otherwise rotate a 0 into bit 0\n\n CPX #16                \\ If X >= 16, set the C flag and rotate it into bit 0\n ROL A                  \\ of A, otherwise rotate a 0 into bit 0\n\n                        \\ By now, A contains the following:\n                        \\\n                        \\   * If radius is 96-255 then A = %111 = 7\n                        \\\n                        \\   * If radius is 40-95  then A = %11  = 3\n                        \\\n                        \\   * If radius is 16-39  then A = %1   = 1\n                        \\\n                        \\   * If radius is 0-15   then A = %0   = 0\n                        \\\n                        \\ The value of A determines the size of the new sun's\n                        \\ ragged fringes - the bigger the sun, the bigger the\n                        \\ fringes\n\n.PLF18\n\n STA CNT                \\ Store the fringe size in CNT\n\n                        \\ We now calculate the highest pixel y-coordinate of the\n                        \\ new sun, given that P(2 1) contains the 16-bit maximum\n                        \\ y-coordinate of the new sun on-screen\n\n LDA #2*Y-1             \\ #Y is the y-coordinate of the centre of the space\n                        \\ view, so this sets Y to the y-coordinate of the bottom\n                        \\ of the space view\n\n LDX P+2                \\ If P+2 is non-zero, the maximum y-coordinate is off\n BNE PLF2               \\ the bottom of the screen, so skip to PLF2 with A set\n                        \\ to the y-coordinate of the bottom of the space view\n\n CMP P+1                \\ If A < P+1, the maximum y-coordinate is underneath the\n BCC PLF2               \\ dashboard, so skip to PLF2 with A set to the\n                        \\ y-coordinate of the bottom of the space view\n\n LDA P+1                \\ Set A = P+1, the low byte of the maximum y-coordinate\n                        \\ of the sun on-screen\n\n BNE PLF2               \\ If A is non-zero, skip to PLF2 as it contains the\n                        \\ value we are after\n\n LDA #1                 \\ Otherwise set A = 1, the top line of the screen\n\n.PLF2\n\n STA TGT                \\ Set TGT to A, the maximum y-coordinate of the sun on\n                        \\ screen\n\n                        \\ We now calculate the number of lines we need to draw\n                        \\ and the direction in which we need to draw them, both\n                        \\ from the centre of the new sun\n\n LDA #2*Y-1             \\ Set (A X) = y-coordinate of bottom of screen - K4(1 0)\n SEC                    \\\n SBC K4                 \\ Starting with the low bytes\n TAX\n\n LDA #0                 \\ And then doing the high bytes, so (A X) now contains\n SBC K4+1               \\ the number of lines between the centre of the sun and\n                        \\ the bottom of the screen. If it is positive then the\n                        \\ centre of the sun is above the bottom of the screen,\n                        \\ if it is negative then the centre of the sun is below\n                        \\ the bottom of the screen\n\n BMI PLF3               \\ If A < 0, then this means the new sun's centre is off\n                        \\ the bottom of the screen, so jump up to PLF3 to negate\n                        \\ the height in X (so it becomes positive), set A to &FF\n                        \\ and jump down to PLF5\n\n BNE PLF4               \\ If A > 0, then the new sun's centre is at least a full\n                        \\ screen above the bottom of the space view, so jump\n                        \\ down to PLF4 to set X = radius and A = 0\n\n INX                    \\ Set the flags depending on the value of X\n DEX\n\n BEQ PLF17              \\ If X = 0 (we already know A = 0 by this point) then\n                        \\ jump up to PLF17 to set A to &FF before jumping down\n                        \\ to PLF5\n\n CPX K                  \\ If X < the radius in K, jump down to PLF5, so if\n BCC PLF5               \\ X >= the radius in K, we set X = radius and A = 0\n\n.PLF4\n\n LDX K                  \\ Set X to the radius\n\n LDA #0                 \\ Set A = 0\n\n.PLF5\n\n STX V                  \\ Store the height in V\n\n STA V+1                \\ Store the direction in V+1\n\n LDA K                  \\ Set (A P) = K * K\n JSR SQUA2\n\n STA K2+1               \\ Set K2(1 0) = (A P) = K * K\n LDA P\n STA K2\n\n                        \\ By the time we get here, the variables should be set\n                        \\ up as shown in the header for part 3 below\n\n\\ ******************************************************************************\n\\\n\\       Name: SUN (Part 2 of 4)\n\\       Type: Subroutine\n\\   Category: Drawing suns\n\\    Summary: Draw the sun: Start from the bottom of the screen and erase the\n\\             old sun line by line\n\\  Deep dive: Drawing the sun\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This part erases the old sun, starting at the bottom of the screen and working\n\\ upwards until we reach the bottom of the new sun.\n\\\n\\ ******************************************************************************\n\n LDY #2*Y-1             \\ Set Y = y-coordinate of the bottom of the screen,\n                        \\ which we use as a counter in the following routine to\n                        \\ redraw the old sun\n\n LDA SUNX               \\ Set YY(1 0) = SUNX(1 0), the x-coordinate of the\n STA YY                 \\ vertical centre axis of the old sun that's currently\n LDA SUNX+1             \\ on-screen\n STA YY+1\n\n.PLFL2\n\n CPY TGT                \\ If Y = TGT, we have reached the line where we will\n BEQ PLFL               \\ start drawing the new sun, so there is no need to\n                        \\ keep erasing the old one, so jump down to PLFL\n\n LDA LSO,Y              \\ Fetch the Y-th point from the sun line heap, which\n                        \\ gives us the half-width of the old sun's line on this\n                        \\ line of the screen\n\n BEQ PLF13              \\ If A = 0, skip the following call to HLOIN2 as there\n                        \\ is no sun line on this line of the screen\n\n JSR HLOIN2             \\ Call HLOIN2 to draw a horizontal line on pixel line Y,\n                        \\ with centre point YY(1 0) and half-width A, and remove\n                        \\ the line from the sun line heap once done\n\n.PLF13\n\n DEY                    \\ Decrement the loop counter\n\n BNE PLFL2              \\ Loop back for the next line in the line heap until\n                        \\ we have either gone through the entire heap, or\n                        \\ reached the bottom row of the new sun\n\n\\ ******************************************************************************\n\\\n\\       Name: SUN (Part 3 of 4)\n\\       Type: Subroutine\n\\   Category: Drawing suns\n\\    Summary: Draw the sun: Continue to move up the screen, drawing the new sun\n\\             line by line\n\\  Deep dive: Drawing the sun\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This part draws the new sun. By the time we get to this point, the following\n\\ variables should have been set up by parts 1 and 2:\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   V                   As we draw lines for the new sun, V contains the\n\\                       vertical distance between the line we're drawing and the\n\\                       centre of the new sun. As we draw lines and move up the\n\\                       screen, we either decrement (bottom half) or increment\n\\                       (top half) this value\n\\\n\\   V+1                 This determines which half of the new sun we are drawing\n\\                       as we work our way up the screen, line by line:\n\\\n\\                         * 0 means we are drawing the bottom half, so the lines\n\\                           get wider as we work our way up towards the centre,\n\\                           at which point we will move into the top half, and\n\\                           V+1 will switch to &FF\n\\\n\\                         * &FF means we are drawing the top half, so the lines\n\\                           get smaller as we work our way up, away from the\n\\                           centre\n\\\n\\   TGT                 The maximum y-coordinate of the new sun on-screen (i.e.\n\\                       the screen y-coordinate of the bottom row of the new\n\\                       sun)\n\\\n\\   CNT                 The fringe size of the new sun\n\\\n\\   K2(1 0)             The new sun's radius squared, i.e. K^2\n\\\n\\   Y                   The y-coordinate of the bottom row of the new sun\n\\\n\\ ******************************************************************************\n\n.PLFL\n\n LDA V                  \\ Set (T P) = V * V\n JSR SQUA2              \\           = V^2\n STA T\n\n LDA K2                 \\ Set (R Q) = K^2 - V^2\n SEC                    \\\n SBC P                  \\ First calculating the low bytes\n STA Q\n\n LDA K2+1               \\ And then doing the high bytes\n SBC T\n STA R\n\n STY Y1                 \\ Store Y in Y1, so we can restore it after the call to\n                        \\ LL5\n\n JSR LL5                \\ Set Q = SQRT(R Q)\n                        \\       = SQRT(K^2 - V^2)\n                        \\\n                        \\ So Q contains the half-width of the new sun's line at\n                        \\ height V from the sun's centre - in other words, it\n                        \\ contains the half-width of the sun's line on the\n                        \\ current pixel row Y\n\n LDY Y1                 \\ Restore Y from Y1\n\n JSR DORND              \\ Set A and X to random numbers\n\n AND CNT                \\ Reduce A to a random number in the range 0 to CNT,\n                        \\ where CNT is the fringe size of the new sun\n\n CLC                    \\ Set A = A + Q\n ADC Q                  \\\n                        \\ So A now contains the half-width of the sun on row\n                        \\ V, plus a random variation based on the fringe size\n\n BCC PLF44              \\ If the above addition did not overflow, skip the\n                        \\ following instruction\n\n LDA #255               \\ The above overflowed, so set the value of A to 255\n\n                        \\ So A contains the half-width of the new sun on pixel\n                        \\ line Y, changed by a random amount within the size of\n                        \\ the sun's fringe\n\n.PLF44\n\n LDX LSO,Y              \\ Set X to the line heap value for the old sun's line\n                        \\ at row Y\n\n STA LSO,Y              \\ Store the half-width of the new row Y line in the line\n                        \\ heap\n\n BEQ PLF11              \\ If X = 0 then there was no sun line on pixel row Y, so\n                        \\ jump to PLF11\n\n LDA SUNX               \\ Set YY(1 0) = SUNX(1 0), the x-coordinate of the\n STA YY                 \\ vertical centre axis of the old sun that's currently\n LDA SUNX+1             \\ on-screen\n STA YY+1\n\n TXA                    \\ Transfer the line heap value for the old sun's line\n                        \\ from X into A\n\n JSR EDGES              \\ Call EDGES to calculate X1 and X2 for the horizontal\n                        \\ line centred on YY(1 0) and with half-width A, i.e.\n                        \\ the line for the old sun\n\n LDA X1                 \\ Store X1 and X2, the ends of the line for the old sun,\n STA XX                 \\ in XX and XX+1\n LDA X2\n STA XX+1\n\n LDA K3                 \\ Set YY(1 0) = K3(1 0), the x-coordinate of the centre\n STA YY                 \\ of the new sun\n LDA K3+1\n STA YY+1\n\n LDA LSO,Y              \\ Fetch the half-width of the new row Y line from the\n                        \\ line heap (which we stored above)\n\n JSR EDGES              \\ Call EDGES to calculate X1 and X2 for the horizontal\n                        \\ line centred on YY(1 0) and with half-width A, i.e.\n                        \\ the line for the new sun\n\n BCS PLF23              \\ If the C flag is set, the new line doesn't fit on the\n                        \\ screen, so jump to PLF23 to just draw the old line\n                        \\ without drawing the new one\n\n                        \\ At this point the old line is from XX to XX+1 and the\n                        \\ new line is from X1 to X2, and both fit on-screen. We\n                        \\ now want to remove the old line and draw the new one.\n                        \\ We could do this by simply drawing the old one then\n                        \\ drawing the new one, but instead Elite does this by\n                        \\ drawing first from X1 to XX and then from X2 to XX+1,\n                        \\ which you can see in action by looking at all the\n                        \\ permutations below of the four points on the line and\n                        \\ imagining what happens if you draw from X1 to XX and\n                        \\ X2 to XX+1 using EOR logic. The six possible\n                        \\ permutations are as follows, along with the result of\n                        \\ drawing X1 to XX and then X2 to XX+1:\n                        \\\n                        \\   X1    X2    XX____XX+1      ->      +__+  +  +\n                        \\\n                        \\   X1    XX____X2____XX+1      ->      +__+__+  +\n                        \\\n                        \\   X1    XX____XX+1  X2        ->      +__+__+__+\n                        \\\n                        \\   XX____X1____XX+1  X2        ->      +  +__+__+\n                        \\\n                        \\   XX____XX+1  X1    X2        ->      +  +  +__+\n                        \\\n                        \\   XX____X1____X2____XX+1      ->      +  +__+  +\n                        \\\n                        \\ They all end up with a line between X1 and X2, which\n                        \\ is what we want. There's probably a mathematical proof\n                        \\ of why this works somewhere, but the above is probably\n                        \\ easier to follow.\n                        \\\n                        \\ We can draw from X1 to XX and X2 to XX+1 by swapping\n                        \\ XX and X2 and drawing from X1 to X2, and then drawing\n                        \\ from XX to XX+1, so let's do this now\n\n LDA X2                 \\ Swap XX and X2\n LDX XX\n STX X2\n STA XX\n\n JSR HLOIN              \\ Draw a horizontal line from (X1, Y1) to (X2, Y1)\n\n.PLF23\n\n                        \\ If we jump here from the BCS above when there is no\n                        \\ new line this will just draw the old line\n\n LDA XX                 \\ Set X1 = XX\n STA X1\n\n LDA XX+1               \\ Set X2 = XX+1\n STA X2\n\n.PLF16\n\n JSR HLOIN              \\ Draw a horizontal line from (X1, Y1) to (X2, Y1)\n\n.PLF6\n\n DEY                    \\ Decrement the line number in Y to move to the line\n                        \\ above\n\n BEQ PLF8               \\ If we have reached the top of the screen, jump to PLF8\n                        \\ as we are done drawing (the top line of the screen is\n                        \\ the border, so we don't draw there)\n\n LDA V+1                \\ If V+1 is non-zero then we are doing the top half of\n BNE PLF10              \\ the new sun, so jump down to PLF10 to increment V and\n                        \\ decrease the width of the line we draw\n\n DEC V                  \\ Decrement V, the height of the sun that we use to work\n                        \\ out the width, so this makes the line get wider, as we\n                        \\ move up towards the sun's centre\n\n BNE PLFL               \\ If V is non-zero, jump back up to PLFL to do the next\n                        \\ screen line up\n\n DEC V+1                \\ Otherwise V is 0 and we have reached the centre of the\n                        \\ sun, so decrement V+1 to -1 so we start incrementing V\n                        \\ each time, thus doing the top half of the new sun\n\n.PLFLS\n\n JMP PLFL               \\ Jump back up to PLFL to do the next screen line up\n\n.PLF11\n\n                        \\ If we get here then there is no old sun line on this\n                        \\ line, so we can just draw the new sun's line\n\n LDX K3                 \\ Set YY(1 0) = K3(1 0), the x-coordinate of the centre\n STX YY                 \\ of the new sun's line\n LDX K3+1\n STX YY+1\n\n JSR EDGES              \\ Call EDGES to calculate X1 and X2 for the horizontal\n                        \\ line centred on YY(1 0) and with half-width A, i.e.\n                        \\ the line for the new sun\n\n BCC PLF16              \\ If the line is on-screen, jump up to PLF16 to draw the\n                        \\ line and loop round for the next line up\n\n LDA #0                 \\ The line is not on-screen, so set the line heap for\n STA LSO,Y              \\ line Y to 0, which means there is no sun line here\n\n BEQ PLF6               \\ Jump up to PLF6 to loop round for the next line up\n                        \\ (this BEQ is effectively a JMP as A is always zero)\n\n.PLF10\n\n LDX V                  \\ Increment V, the height of the sun that we use to work\n INX                    \\ out the width, so this makes the line get narrower, as\n STX V                  \\ we move up and away from the sun's centre\n\n CPX K                  \\ If V <= the radius of the sun, we still have lines to\n BCC PLFLS              \\ draw, so jump up to PLFL (via PLFLS) to do the next\n BEQ PLFLS              \\ screen line up\n\n\\ ******************************************************************************\n\\\n\\       Name: SUN (Part 4 of 4)\n\\       Type: Subroutine\n\\   Category: Drawing suns\n\\    Summary: Draw the sun: Continue to the top of the screen, erasing the old\n\\             sun line by line\n\\  Deep dive: Drawing the sun\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This part erases any remaining traces of the old sun, now that we have drawn\n\\ all the way to the top of the new sun.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   RTS2                Contains an RTS\n\\\n\\ ******************************************************************************\n\n LDA SUNX               \\ Set YY(1 0) = SUNX(1 0), the x-coordinate of the\n STA YY                 \\ vertical centre axis of the old sun that's currently\n LDA SUNX+1             \\ on-screen\n STA YY+1\n\n.PLFL3\n\n LDA LSO,Y              \\ Fetch the Y-th point from the sun line heap, which\n                        \\ gives us the half-width of the old sun's line on this\n                        \\ line of the screen\n\n BEQ PLF9               \\ If A = 0, skip the following call to HLOIN2 as there\n                        \\ is no sun line on this line of the screen\n\n JSR HLOIN2             \\ Call HLOIN2 to draw a horizontal line on pixel line Y,\n                        \\ with centre point YY(1 0) and half-width A, and remove\n                        \\ the line from the sun line heap once done\n\n.PLF9\n\n DEY                    \\ Decrement the line number in Y to move to the line\n                        \\ above\n\n BNE PLFL3              \\ Jump up to PLFL3 to redraw the next line up, until we\n                        \\ have reached the top of the screen\n\n.PLF8\n\n                        \\ If we get here, we have successfully made it from the\n                        \\ bottom line of the screen to the top, and the old sun\n                        \\ has been replaced by the new one\n\n CLC                    \\ Clear the C flag to indicate success in drawing the\n                        \\ sun\n\n LDA K3                 \\ Set SUNX(1 0) = K3(1 0)\n STA SUNX\n LDA K3+1\n STA SUNX+1\n\n.RTS2\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: CIRCLE\n\\       Type: Subroutine\n\\   Category: Drawing circles\n\\    Summary: Draw a circle for the planet\n\\  Deep dive: Drawing circles\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Draw a circle with the centre at (K3, K4) and radius K. Used to draw the\n\\ planet's main outline.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   K                   The planet's radius\n\\\n\\   K3(1 0)             Pixel x-coordinate of the centre of the planet\n\\\n\\   K4(1 0)             Pixel y-coordinate of the centre of the planet\n\\\n\\ ******************************************************************************\n\n.CIRCLE\n\n JSR CHKON              \\ Call CHKON to check whether the circle fits on-screen\n\n BCS RTS2               \\ If CHKON set the C flag then the circle does not fit\n                        \\ on-screen, so return from the subroutine (as RTS2\n                        \\ contains an RTS)\n\n LDA #0                 \\ Set LSX2 = 0 to indicate that the ball line heap is\n STA LSX2               \\ not empty, as we are about to fill it\n\n LDX K                  \\ Set X = K = radius\n\n LDA #8                 \\ Set A = 8\n\n CPX #8                 \\ If the radius < 8, skip to PL89\n BCC PL89\n\n LSR A                  \\ Halve A so A = 4\n\n CPX #60                \\ If the radius < 60, skip to PL89\n BCC PL89\n\n LSR A                  \\ Halve A so A = 2\n\n.PL89\n\n STA STP                \\ Set STP = A. STP is the step size for the circle, so\n                        \\ the above sets a smaller step size for bigger circles\n\n                        \\ Fall through into CIRCLE2 to draw the circle with the\n                        \\ correct step size\n\n\\ ******************************************************************************\n\\\n\\       Name: CIRCLE2\n\\       Type: Subroutine\n\\   Category: Drawing circles\n\\    Summary: Draw a circle (for the planet or chart)\n\\  Deep dive: Drawing circles\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Draw a circle with the centre at (K3, K4) and radius K. Used to draw the\n\\ planet and the chart circles.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   STP                 The step size for the circle\n\\\n\\   K                   The circle's radius\n\\\n\\   K3(1 0)             Pixel x-coordinate of the centre of the circle\n\\\n\\   K4(1 0)             Pixel y-coordinate of the centre of the circle\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   C flag              The C flag is cleared\n\\\n\\ ******************************************************************************\n\n.CIRCLE2\n\n LDX #&FF               \\ Set FLAG = &FF to reset the ball line heap in the call\n STX FLAG               \\ to the BLINE routine below\n\n INX                    \\ Set CNT = 0, our counter that goes up to 64, counting\n STX CNT                \\ segments in our circle\n\n.PLL3\n\n LDA CNT                \\ Set A = CNT\n\n JSR FMLTU2             \\ Call FMLTU2 to calculate:\n                        \\\n                        \\   A = K * sin(A)\n                        \\     = K * sin(CNT)\n\n LDX #0                 \\ Set T = 0, so we have the following:\n STX T                  \\\n                        \\   (T A) = K * sin(CNT)\n                        \\\n                        \\ which is the x-coordinate of the circle for this count\n\n LDX CNT                \\ If CNT < 33 then jump to PL37, as this is the right\n CPX #33                \\ half of the circle and the sign of the x-coordinate is\n BCC PL37               \\ correct\n\n EOR #%11111111         \\ This is the left half of the circle, so we want to\n ADC #0                 \\ flip the sign of the x-coordinate in (T A) using two's\n TAX                    \\ complement, so we start with the low byte and store it\n                        \\ in X (the ADC adds 1 as we know the C flag is set)\n\n LDA #&FF               \\ And then we flip the high byte in T\n ADC #0\n STA T\n\n TXA                    \\ Finally, we restore the low byte from X, so we have\n                        \\ now negated the x-coordinate in (T A)\n\n CLC                    \\ Clear the C flag so we can do some more addition below\n\n.PL37\n\n ADC K3                 \\ We now calculate the following:\n STA K6                 \\\n                        \\   K6(1 0) = (T A) + K3(1 0)\n                        \\\n                        \\ to add the coordinates of the centre to our circle\n                        \\ point, starting with the low bytes\n\n LDA K3+1               \\ And then doing the high bytes, so we now have:\n ADC T                  \\\n STA K6+1               \\   K6(1 0) = K * sin(CNT) + K3(1 0)\n                        \\\n                        \\ which is the result we want for the x-coordinate\n\n LDA CNT                \\ Set A = CNT + 16\n CLC\n ADC #16\n\n JSR FMLTU2             \\ Call FMLTU2 to calculate:\n                        \\\n                        \\   A = K * sin(A)\n                        \\     = K * sin(CNT + 16)\n                        \\     = K * cos(CNT)\n\n TAX                    \\ Set X = A\n                        \\       = K * cos(CNT)\n\n LDA #0                 \\ Set T = 0, so we have the following:\n STA T                  \\\n                        \\   (T X) = K * cos(CNT)\n                        \\\n                        \\ which is the y-coordinate of the circle for this count\n\n LDA CNT                \\ Set A = (CNT + 15) mod 64\n ADC #15\n AND #63\n\n CMP #33                \\ If A < 33 (i.e. CNT is 0-16 or 48-64) then jump to\n BCC PL38               \\ PL38, as this is the bottom half of the circle and the\n                        \\ sign of the y-coordinate is correct\n\n TXA                    \\ This is the top half of the circle, so we want to\n EOR #%11111111         \\ flip the sign of the y-coordinate in (T X) using two's\n ADC #0                 \\ complement, so we start with the low byte in X (the\n TAX                    \\ ADC adds 1 as we know the C flag is set)\n\n LDA #&FF               \\ And then we flip the high byte in T, so we have\n ADC #0                 \\ now negated the y-coordinate in (T X)\n STA T\n\n CLC                    \\ Clear the C flag so the addition at the start of BLINE\n                        \\ will work\n\n.PL38\n\n JSR BLINE              \\ Call BLINE to draw this segment, which also increases\n                        \\ CNT by STP, the step size\n\n CMP #65                \\ If CNT >= 65 then skip the next instruction\n BCS P%+5\n\n JMP PLL3               \\ Jump back for the next segment\n\n CLC                    \\ Clear the C flag to indicate success\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: WPLS2\n\\       Type: Subroutine\n\\   Category: Drawing planets\n\\    Summary: Remove the planet from the screen\n\\  Deep dive: The ball line heap\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ We do this by redrawing it using the lines stored in the ball line heap when\n\\ the planet was originally drawn by the BLINE routine.\n\\\n\\ ******************************************************************************\n\n.WPLS2\n\n LDY LSX2               \\ If LSX2 is non-zero (which indicates the ball line\n BNE WP1                \\ heap is empty), jump to WP1 to reset the line heap\n                        \\ without redrawing the planet\n\n                        \\ Otherwise Y is now 0, so we can use it as a counter to\n                        \\ loop through the lines in the line heap, redrawing\n                        \\ each one to remove the planet from the screen, before\n                        \\ resetting the line heap once we are done\n\n.WPL1\n\n CPY LSP                \\ If Y >= LSP then we have reached the end of the line\n BCS WP1                \\ heap and have finished redrawing the planet (as LSP\n                        \\ points to the end of the heap), so jump to WP1 to\n                        \\ reset the line heap, returning from the subroutine\n                        \\ using a tail call\n\n LDA LSY2,Y             \\ Set A to the y-coordinate of the current heap entry\n\n CMP #&FF               \\ If the y-coordinate is &FF, this indicates that the\n BEQ WP2                \\ next point in the heap denotes the start of a line\n                        \\ segment, so jump to WP2 to put it into (X1, Y1)\n\n STA Y2                 \\ Set (X2, Y2) to the x- and y-coordinates from the\n LDA LSX2,Y             \\ heap\n STA X2\n\n JSR LOIN               \\ Draw a line from (X1, Y1) to (X2, Y2)\n\n INY                    \\ Increment the loop counter to point to the next point\n\n LDA SWAP               \\ If SWAP is non-zero then we swapped the coordinates\n BNE WPL1               \\ when filling the heap in BLINE, so loop back WPL1\n                        \\ for the next point in the heap\n\n LDA X2                 \\ Swap (X1, Y1) and (X2, Y2), so the next segment will\n STA X1                 \\ be drawn from the current (X2, Y2) to the next point\n LDA Y2                 \\ in the heap\n STA Y1\n\n JMP WPL1               \\ Loop back to WPL1 for the next point in the heap\n\n.WP2\n\n INY                    \\ Increment the loop counter to point to the next point\n\n LDA LSX2,Y             \\ Set (X1, Y1) to the x- and y-coordinates from the\n STA X1                 \\ heap\n LDA LSY2,Y\n STA Y1\n\n INY                    \\ Increment the loop counter to point to the next point\n\n JMP WPL1               \\ Loop back to WPL1 for the next point in the heap\n\n\\ ******************************************************************************\n\\\n\\       Name: WP1\n\\       Type: Subroutine\n\\   Category: Drawing planets\n\\    Summary: Reset the ball line heap\n\\\n\\ ******************************************************************************\n\n.WP1\n\n LDA #1                 \\ Set LSP = 1 to reset the ball line heap pointer\n STA LSP\n\n LDA #&FF               \\ Set LSX2 = &FF to indicate the ball line heap is empty\n STA LSX2\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: WPLS\n\\       Type: Subroutine\n\\   Category: Drawing suns\n\\    Summary: Remove the sun from the screen\n\\  Deep dive: Drawing the sun\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ We do this by redrawing it using the lines stored in the sun line heap when\n\\ the sun was originally drawn by the SUN routine.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   SUNX(1 0)           The x-coordinate of the vertical centre axis of the sun\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   WPLS-1              Contains an RTS\n\\\n\\ ******************************************************************************\n\n.WPLS\n\n LDA LSX                \\ If LSX < 0, the sun line heap is empty, so return from\n BMI WPLS-1             \\ the subroutine (as WPLS-1 contains an RTS)\n\n LDA SUNX               \\ Set YY(1 0) = SUNX(1 0), the x-coordinate of the\n STA YY                 \\ vertical centre axis of the sun that's currently on\n LDA SUNX+1             \\ screen\n STA YY+1\n\n LDY #2*Y-1             \\ #Y is the y-coordinate of the centre of the space\n                        \\ view, so this sets Y as a counter for the number of\n                        \\ lines in the space view (i.e. 191), which is also the\n                        \\ number of lines in the LSO block\n\n.WPL2\n\n LDA LSO,Y              \\ Fetch the Y-th point from the sun line heap, which\n                        \\ gives us the half-width of the sun's line on this line\n                        \\ of the screen\n\n BEQ P%+5               \\ If A = 0, skip the following call to HLOIN2 as there\n                        \\ is no sun line on this line of the screen\n\n JSR HLOIN2             \\ Call HLOIN2 to draw a horizontal line on pixel line Y,\n                        \\ with centre point YY(1 0) and half-width A, and remove\n                        \\ the line from the sun line heap once done\n\n DEY                    \\ Decrement the loop counter\n\n BNE WPL2               \\ Loop back for the next line in the line heap until\n                        \\ we have gone through the entire heap\n\n DEY                    \\ This sets Y to &FF, as we end the loop with Y = 0\n\n STY LSX                \\ Set LSX to &FF to indicate the sun line heap is empty\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: EDGES\n\\       Type: Subroutine\n\\   Category: Drawing lines\n\\    Summary: Draw a horizontal line given a centre and a half-width\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Set X1 and X2 to the x-coordinates of the ends of the horizontal line with\n\\ centre x-coordinate YY(1 0), and length A in either direction from the centre\n\\ (so a total line length of 2 * A). In other words, this line:\n\\\n\\   X1             YY(1 0)             X2\n\\   +-----------------+-----------------+\n\\         <- A ->           <- A ->\n\\\n\\ The resulting line gets clipped to the edges of the screen, if needed. If the\n\\ calculation doesn't overflow, we return with the C flag clear, otherwise the C\n\\ flag gets set to indicate failure and the Y-th LSO entry gets set to 0.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The half-length of the line\n\\\n\\   YY(1 0)             The centre x-coordinate\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   C flag              Clear if the line fits on-screen, set if it doesn't\n\\\n\\   X1, X2              The x-coordinates of the clipped line\n\\\n\\   LSO+Y               If the line doesn't fit, LSO+Y is set to 0\n\\\n\\   Y                   Y is preserved\n\\\n\\ ******************************************************************************\n\n.EDGES\n\n STA T                  \\ Set T to the line's half-length in argument A\n\n CLC                    \\ We now calculate:\n ADC YY                 \\\n STA X2                 \\  (A X2) = YY(1 0) + A\n                        \\\n                        \\ to set X2 to the x-coordinate of the right end of the\n                        \\ line, starting with the low bytes\n\n LDA YY+1               \\ And then adding the high bytes\n ADC #0\n\n BMI ED1                \\ If the addition is negative then the calculation has\n                        \\ overflowed, so jump to ED1 to return a failure\n\n BEQ P%+6               \\ If the high byte A from the result is 0, skip the\n                        \\ next two instructions, as the result already fits on\n                        \\ the screen\n\n LDA #254               \\ The high byte is positive and non-zero, so we went\n STA X2                 \\ past the right edge of the screen, so clip X2 to the\n                        \\ x-coordinate of the right edge of the screen\n\n LDA YY                 \\ We now calculate:\n SEC                    \\\n SBC T                  \\   (A X1) = YY(1 0) - argument A\n STA X1                 \\\n                        \\ to set X1 to the x-coordinate of the left end of the\n                        \\ line, starting with the low bytes\n\n LDA YY+1               \\ And then subtracting the high bytes\n SBC #0\n\n BNE ED3                \\ If the high byte subtraction is non-zero, then skip\n                        \\ to ED3\n\n CLC                    \\ Otherwise the high byte of the subtraction was zero,\n                        \\ so the line fits on-screen and we clear the C flag to\n                        \\ indicate success\n\n RTS                    \\ Return from the subroutine\n\n.ED3\n\n BPL ED1                \\ If the addition is positive then the calculation has\n                        \\ underflowed, so jump to ED1 to return a failure\n\n LDA #2                 \\ The high byte is negative and non-zero, so we went\n STA X1                 \\ past the left edge of the screen, so clip X1 to the\n                        \\ x-coordinate of the left edge of the screen\n\n CLC                    \\ The line does fit on-screen, so clear the C flag to\n                        \\ indicate success\n\n RTS                    \\ Return from the subroutine\n\n.ED1\n\n LDA #0                 \\ Set the Y-th byte of the LSO block to 0\n STA LSO,Y\n\n SEC                    \\ The line does not fit on the screen, so set the C flag\n                        \\ to indicate this result\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: CHKON\n\\       Type: Subroutine\n\\   Category: Drawing circles\n\\    Summary: Check whether any part of a circle appears on the extended screen\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   K                   The circle's radius\n\\\n\\   K3(1 0)             Pixel x-coordinate of the centre of the circle\n\\\n\\   K4(1 0)             Pixel y-coordinate of the centre of the circle\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   C flag              Clear if any part of the circle appears on-screen, set\n\\                       if none of the circle appears on-screen\n\\\n\\   (A X)               Minimum y-coordinate of the circle on-screen (i.e. the\n\\                       y-coordinate of the top edge of the circle)\n\\\n\\   P(2 1)              Maximum y-coordinate of the circle on-screen (i.e. the\n\\                       y-coordinate of the bottom edge of the circle)\n\\\n\\ ******************************************************************************\n\n.CHKON\n\n LDA K3                 \\ Set A = K3 + K\n CLC\n ADC K\n\n LDA K3+1               \\ Set A = K3+1 + 0 + any carry from above, so this\n ADC #0                 \\ effectively sets A to the high byte of K3(1 0) + K:\n                        \\\n                        \\   (A ?) = K3(1 0) + K\n                        \\\n                        \\ so A is the high byte of the x-coordinate of the right\n                        \\ edge of the circle\n\n BMI PL21               \\ If A is negative then the right edge of the circle is\n                        \\ to the left of the screen, so jump to PL21 to set the\n                        \\ C flag and return from the subroutine, as the whole\n                        \\ circle is off-screen to the left\n\n LDA K3                 \\ Set A = K3 - K\n SEC\n SBC K\n\n LDA K3+1               \\ Set A = K3+1 - 0 - any carry from above, so this\n SBC #0                 \\ effectively sets A to the high byte of K3(1 0) - K:\n                        \\\n                        \\   (A ?) = K3(1 0) - K\n                        \\\n                        \\ so A is the high byte of the x-coordinate of the left\n                        \\ edge of the circle\n\n BMI PL31               \\ If A is negative then the left edge of the circle is\n                        \\ to the left of the screen, and we already know the\n                        \\ right edge is either on-screen or off-screen to the\n                        \\ right, so skip to PL31 to move on to the y-coordinate\n                        \\ checks, as at least part of the circle is on-screen in\n                        \\ terms of the x-axis\n\n BNE PL21               \\ If A is non-zero, then the left edge of the circle is\n                        \\ to the right of the screen, so jump to PL21 to set the\n                        \\ C flag and return from the subroutine, as the whole\n                        \\ circle is off-screen to the right\n\n.PL31\n\n LDA K4                 \\ Set P+1 = K4 + K\n CLC\n ADC K\n STA P+1\n\n LDA K4+1               \\ Set A = K4+1 + 0 + any carry from above, so this\n ADC #0                 \\ does the following:\n                        \\\n                        \\   (A P+1) = K4(1 0) + K\n                        \\\n                        \\ so A is the high byte of the y-coordinate of the\n                        \\ bottom edge of the circle\n\n BMI PL21               \\ If A is negative then the bottom edge of the circle is\n                        \\ above the top of the screen, so jump to PL21 to set\n                        \\ the C flag and return from the subroutine, as the\n                        \\ whole circle is off-screen to the top\n\n STA P+2                \\ Store the high byte in P+2, so now we have:\n                        \\\n                        \\   P(2 1) = K4(1 0) + K\n                        \\\n                        \\ i.e. the maximum y-coordinate of the circle on-screen\n                        \\ (which we return)\n\n LDA K4                 \\ Set X = K4 - K\n SEC\n SBC K\n TAX\n\n LDA K4+1               \\ Set A = K4+1 - 0 - any carry from above, so this\n SBC #0                 \\ does the following:\n                        \\\n                        \\   (A X) = K4(1 0) - K\n                        \\\n                        \\ so A is the high byte of the y-coordinate of the top\n                        \\ edge of the circle\n\n BMI PL44               \\ If A is negative then the top edge of the circle is\n                        \\ above the top of the screen, and we already know the\n                        \\ bottom edge is either on-screen or below the bottom\n                        \\ of the screen, so skip to PL44 to clear the C flag and\n                        \\ return from the subroutine using a tail call, as part\n                        \\ of the circle definitely appears on-screen\n\n BNE PL21               \\ If A is non-zero, then the top edge of the circle is\n                        \\ below the bottom of the screen, so jump to PL21 to set\n                        \\ the C flag and return from the subroutine, as the\n                        \\ whole circle is off-screen to the bottom\n\n CPX #2*Y-1             \\ If we get here then A is zero, which means the top\n                        \\ edge of the circle is within the screen boundary, so\n                        \\ now we need to check whether it is in the space view\n                        \\ (in which case it is on-screen) or the dashboard (in\n                        \\ which case the top of the circle is hidden by the\n                        \\ dashboard, so the circle isn't on-screen). We do this\n                        \\ by checking the low byte of the result in X against\n                        \\ 2 * #Y - 1, and returning the C flag from this\n                        \\ comparison. The constant #Y is the y-coordinate of the\n                        \\ mid-point of the space view, so 2 * #Y - 1, the\n                        \\ y-coordinate of the bottom pixel row of the space\n                        \\ view. So this does the following:\n                        \\\n                        \\   * The C flag is set if coordinate (A X) is below the\n                        \\     bottom row of the space view, i.e. the top edge of\n                        \\     the circle is hidden by the dashboard\n                        \\\n                        \\   * The C flag is clear if coordinate (A X) is above\n                        \\     the bottom row of the space view, i.e. the top\n                        \\     edge of the circle is on-screen\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: PL21\n\\       Type: Subroutine\n\\   Category: Drawing planets\n\\    Summary: Return from a planet/sun-drawing routine with a failure flag\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Set the C flag and return from the subroutine. This is used to return from a\n\\ planet- or sun-drawing routine with the C flag indicating an overflow in the\n\\ calculation.\n\\\n\\ ******************************************************************************\n\n.PL21\n\n SEC                    \\ Set the C flag to indicate an overflow\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: PLS3\n\\       Type: Subroutine\n\\   Category: Drawing planets\n\\    Summary: Calculate (Y A P) = 222 * roofv_x / z\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following, with X determining the vector to use:\n\\\n\\   (Y A P) = 222 * roofv_x / z\n\\\n\\ though in reality only (Y A) is used.\n\\\n\\ Although the code below supports a range of values of X, in practice the\n\\ routine is only called with X = 15, and then again after X has been\n\\ incremented to 17. So the values calculated by PLS1 use roofv_x first, then\n\\ roofv_y. The comments below refer to roofv_x, for the first call.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   Determines which of the INWK orientation vectors to\n\\                       divide:\n\\\n\\                         * X = 15: divides roofv_x\n\\\n\\                         * X = 17: divides roofv_y\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   X                   X gets incremented by 2 so it points to the next\n\\                       coordinate in this orientation vector (so consecutive\n\\                       calls to the routine will start with x, then move onto y\n\\                       and then z)\n\\\n\\ ******************************************************************************\n\n.PLS3\n\n JSR PLS1               \\ Call PLS1 to calculate the following:\n STA P                  \\\n                        \\   P = |roofv_x / z|\n                        \\   K+3 = sign of roofv_x / z\n                        \\\n                        \\ and increment X to point to roofv_y for the next call\n\n LDA #222               \\ Set Q = 222, the offset to the crater\n STA Q\n\n STX U                  \\ Store the vector index X in U for retrieval after the\n                        \\ call to MULTU\n\n JSR MULTU              \\ Call MULTU to calculate\n                        \\\n                        \\   (A P) = P * Q\n                        \\         = 222 * |roofv_x / z|\n\n LDX U                  \\ Restore the vector index from U into X\n\n LDY K+3                \\ If the sign of the result in K+3 is positive, skip to\n BPL PL12               \\ PL12 to return with Y = 0\n\n EOR #&FF               \\ Otherwise the result should be negative, so negate the\n CLC                    \\ high byte of the result using two's complement with\n ADC #1                 \\ A = ~A + 1\n\n BEQ PL12               \\ If A = 0, jump to PL12 to return with (Y A) = 0\n\n LDY #&FF               \\ Set Y = &FF to be a negative high byte\n\n RTS                    \\ Return from the subroutine\n\n.PL12\n\n LDY #0                 \\ Set Y = 0 to be a positive high byte\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: PLS4\n\\       Type: Subroutine\n\\   Category: Drawing planets\n\\    Summary: Calculate CNT2 = arctan(P / A) / 4\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following:\n\\\n\\   CNT2 = arctan(P / A) / 4\n\\\n\\ and do the following if nosev_z_hi >= 0:\n\\\n\\   CNT2 = CNT2 + 32\n\\\n\\ which is the equivalent of adding 180 degrees to the result (or PI radians),\n\\ as there are 64 segments in a full circle.\n\\\n\\ This routine is called with the following arguments when calculating the\n\\ equator and meridian for planets:\n\\\n\\   * A = roofv_z_hi, P = -nosev_z_hi\n\\\n\\   * A = sidev_z_hi, P = -nosev_z_hi\n\\\n\\ So it calculates the angle between the planet's orientation vectors, in the\n\\ z-axis.\n\\\n\\ ******************************************************************************\n\n.PLS4\n\n STA Q                  \\ Set Q = A\n\n JSR ARCTAN             \\ Call ARCTAN to calculate:\n                        \\\n                        \\   A = arctan(P / Q)\n                        \\       arctan(P / A)\n                        \\\n                        \\ The result in A will be in the range 0 to 128, which\n                        \\ represents an angle of 0 to 180 degrees (or 0 to PI\n                        \\ radians)\n\n LDX INWK+14            \\ If nosev_z_hi is negative, skip the following\n BMI P%+4               \\ instruction to leave the angle in A as a positive\n                        \\ integer in the range 0 to 128 (so when we calculate\n                        \\ CNT2 below, it will be in the right half of the\n                        \\ anti-clockwise arc that we describe when drawing\n                        \\ circles, i.e. from 6 o'clock, through 3 o'clock and\n                        \\ on to 12 o'clock)\n\n EOR #%10000000         \\ If we get here then nosev_z_hi is positive, so flip\n                        \\ bit 7 of the angle in A, which is the same as adding\n                        \\ 128 to give a result in the range 129 to 256 (i.e. 129\n                        \\ to 0), or 180 to 360 degrees (so when we calculate\n                        \\ CNT2 below, it will be in the left half of the\n                        \\ anti-clockwise arc that we describe when drawing\n                        \\ circles, i.e. from 12 o'clock, through 9 o'clock and\n                        \\ on to 6 o'clock)\n\n LSR A                  \\ Set CNT2 = A / 4\n LSR A\n STA CNT2\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: PLS5\n\\       Type: Subroutine\n\\   Category: Drawing planets\n\\    Summary: Calculate roofv_x / z and roofv_y / z\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following divisions of a specified value from one of the\n\\ orientation vectors (in this example, roofv):\n\\\n\\   (XX16+2 K2+2) = roofv_x / z\n\\\n\\   (XX16+3 K2+3) = roofv_y / z\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   Determines which of the INWK orientation vectors to\n\\                       divide:\n\\\n\\                         * X = 15: divides roofv_x and roofv_y\n\\\n\\                         * X = 21: divides sidev_x and sidev_y\n\\\n\\   INWK                The planet's ship data block\n\\\n\\ ******************************************************************************\n\n.PLS5\n\n JSR PLS1               \\ Call PLS1 to calculate the following:\n STA K2+2               \\\n STY XX16+2             \\   K+2    = |roofv_x / z|\n                        \\   XX16+2 = sign of roofv_x / z\n                        \\\n                        \\ i.e. (XX16+2 K2+2) = roofv_x / z\n                        \\\n                        \\ and increment X to point to roofv_y for the next call\n\n JSR PLS1               \\ Call PLS1 to calculate the following:\n STA K2+3               \\\n STY XX16+3             \\   K+3    = |roofv_y / z|\n                        \\   XX16+3 = sign of roofv_y / z\n                        \\\n                        \\ i.e. (XX16+3 K2+3) = roofv_y / z\n                        \\\n                        \\ and increment X to point to roofv_z for the next call\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: PLS6\n\\       Type: Subroutine\n\\   Category: Drawing planets\n\\    Summary: Calculate (X K) = (A P+1 P) / (z_sign z_hi z_lo)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following:\n\\\n\\   (X K) = (A P+1 P) / (z_sign z_hi z_lo)\n\\\n\\ returning an overflow in the C flag if the result is >= 1024.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   INWK                The planet or sun's ship data block\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   C flag              Set if the result >= 1024, clear otherwise\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   PL44                Clear the C flag and return from the subroutine\n\\\n\\ ******************************************************************************\n\n.PLS6\n\n JSR DVID3B2            \\ Call DVID3B2 to calculate:\n                        \\\n                        \\   K(3 2 1 0) = (A P+1 P) / (z_sign z_hi z_lo)\n\n LDA K+3                \\ Set A = |K+3| OR K+2\n AND #%01111111\n ORA K+2\n\n BNE PL21               \\ If A is non-zero then the two high bytes of K(3 2 1 0)\n                        \\ are non-zero, so jump to PL21 to set the C flag and\n                        \\ return from the subroutine\n\n                        \\ We can now just consider K(1 0), as we know the top\n                        \\ two bytes of K(3 2 1 0) are both 0\n\n LDX K+1                \\ Set X = K+1, so now (X K) contains the result in\n                        \\ K(1 0), which is the format we want to return the\n                        \\ result in\n\n CPX #4                 \\ If the high byte of K(1 0) >= 4 then the result is\n BCS PL6                \\ >= 1024, so return from the subroutine with the C flag\n                        \\ set to indicate an overflow (as PL6 contains an RTS)\n\n LDA K+3                \\ Fetch the sign of the result from K+3 (which we know\n                        \\ has zeroes in bits 0-6, so this just fetches the sign)\n\n\\CLC                    \\ This instruction is commented out in the original\n                        \\ source. It would have no effect as we know the C flag\n                        \\ is already clear, as we skipped past the BCS above\n\n BPL PL6                \\ If the sign bit is clear and the result is positive,\n                        \\ then the result is already correct, so return from\n                        \\ the subroutine with the C flag clear to indicate\n                        \\ success (as PL6 contains an RTS)\n\n LDA K                  \\ Otherwise we need to negate the result, which we do\n EOR #%11111111         \\ using two's complement, starting with the low byte:\n ADC #1                 \\\n STA K                  \\   K = ~K + 1\n\n TXA                    \\ And then the high byte:\n EOR #%11111111         \\\n ADC #0                 \\   X = ~X\n TAX\n\n.PL44\n\n CLC                    \\ Clear the C flag to indicate success\n\n.PL6\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: TT17\n\\       Type: Subroutine\n\\   Category: Keyboard\n\\    Summary: Scan the keyboard for cursor key or joystick movement\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Scan the keyboard and joystick for cursor key or stick movement, and return\n\\ the result as deltas (changes) in x- and y-coordinates as follows:\n\\\n\\   * For joystick, X and Y are integers between -2 and +2 depending on how far\n\\     the stick has moved\n\\\n\\   * For keyboard, X and Y are integers between -1 and +1 depending on which\n\\     keys are pressed\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   A                   The key pressed, if the arrow keys were used\n\\\n\\   X                   Change in the x-coordinate according to the cursor keys\n\\                       being pressed or joystick movement, as an integer (see\n\\                       above)\n\\\n\\   Y                   Change in the y-coordinate according to the cursor keys\n\\                       being pressed or joystick movement, as an integer (see\n\\                       above)\n\\\n\\ ******************************************************************************\n\n.TT17\n\n JSR DOKEY              \\ Scan the keyboard for flight controls and pause keys,\n                        \\ (or the equivalent on joystick) and update the key\n                        \\ logger, setting KL to the key pressed\n\n LDA JSTK               \\ If the joystick is not configured, jump down to TJ1,\n BEQ TJ1                \\ otherwise we move the cursor with the joystick\n\n LDA JSTX               \\ Fetch the joystick roll, ranging from 1 to 255 with\n                        \\ 128 as the centre point\n\n EOR #&FF               \\ Flip the sign so A = -JSTX, because the joystick roll\n                        \\ works in the opposite way to moving a cursor on-screen\n                        \\ in terms of left and right\n\n JSR TJS1               \\ Call TJS1 just below to set A to a value between -2\n                        \\ and +2 depending on the joystick roll value (moving\n                        \\ the stick sideways)\n\n TYA                    \\ Copy Y to A\n\n TAX                    \\ Copy A to X, so X contains the joystick roll value\n\n LDA JSTY               \\ Fetch the joystick pitch, ranging from 1 to 255 with\n                        \\ 128 as the centre point, and fall through into TJS1 to\n                        \\ set Y to the joystick pitch value (moving the stick up\n                        \\ and down)\n\n.TJS1\n\n TAY                    \\ Store A in Y\n\n LDA #0                 \\ Set the result, A = 0\n\n CPY #16                \\ If Y >= 16 set the C flag, so A = A - 1\n SBC #0\n\n\\CPY #&20               \\ These instructions are commented out in the original\n\\SBC #0                 \\ source, but they would make the joystick move the\n                        \\ cursor faster by increasing the range of Y by -1 to +1\n\n CPY #64                \\ If Y >= 64 set the C flag, so A = A - 1\n SBC #0\n\n CPY #192               \\ If Y >= 192 set the C flag, so A = A + 1\n ADC #0\n\n CPY #224               \\ If Y >= 224 set the C flag, so A = A + 1\n ADC #0\n\n\\CPY #&F0               \\ These instructions are commented out in the original\n\\ADC #0                 \\ source, but they would make the joystick move the\n                        \\ cursor faster by increasing the range of Y by -1 to +1\n\n TAY                    \\ Copy the value of A into Y\n\n LDA KL                 \\ Set A to the value of KL (the key pressed)\n\n RTS                    \\ Return from the subroutine\n\n.TJ1\n\n LDA KL                 \\ Set A to the value of KL (the key pressed)\n\n LDX #0                 \\ Set the initial values for the results, X = Y = 0,\n LDY #0                 \\ which we now increase or decrease appropriately\n\n CMP #&19               \\ If left arrow was pressed, set X = X - 1\n BNE P%+3\n DEX\n\n CMP #&79               \\ If right arrow was pressed, set X = X + 1\n BNE P%+3\n INX\n\n CMP #&39               \\ If up arrow was pressed, set Y = Y + 1\n BNE P%+3\n INY\n\n CMP #&29               \\ If down arrow was pressed, set Y = Y - 1\n BNE P%+3\n DEY\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: ping\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Set the selected system to the current system\n\\\n\\ ******************************************************************************\n\n.ping\n\n LDX #1                 \\ We want to copy the X- and Y-coordinates of the\n                        \\ current system in (QQ0, QQ1) to the selected system's\n                        \\ coordinates in (QQ9, QQ10), so set up a counter to\n                        \\ copy two bytes\n\n.pl1\n\n LDA QQ0,X              \\ Load byte X from the current system in QQ0/QQ1\n\n STA QQ9,X              \\ Store byte X in the selected system in QQ9/QQ10\n\n DEX                    \\ Decrement the loop counter\n\n BPL pl1                \\ Loop back for the next byte to copy\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\ Save ELTE.bin\n\\\n\\ ******************************************************************************\n\n PRINT \"ELITE E\"\n PRINT \"Assembled at \", ~CODE_E%\n PRINT \"Ends at \", ~P%\n PRINT \"Code size is \", ~(P% - CODE_E%)\n PRINT \"Execute at \", ~LOAD%\n PRINT \"Reload at \", ~LOAD_E%\n\n PRINT \"S.ELTE \", ~CODE_E%, \" \", ~P%, \" \", ~LOAD%, \" \", ~LOAD_E%\n SAVE \"3-assembled-output/ELTE.bin\", CODE_E%, P%, LOAD%\n\n\\ ******************************************************************************\n\\\n\\ ELITE F FILE\n\\\n\\ Produces the binary file ELTF.bin that gets loaded by elite-bcfs.asm.\n\\\n\\ ******************************************************************************\n\n CODE_F% = P%\n\n LOAD_F% = LOAD% + P% - CODE%\n\n\\ ******************************************************************************\n\\\n\\       Name: KS3\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Set the SLSP ship line heap pointer after shuffling ship slots\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The final part of the KILLSHP routine, called after we have shuffled the ship\n\\ slots and sorted out our missiles. This simply sets SLSP to the new bottom of\n\\ the ship line heap.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   P(1 0)              Points to the ship line heap of the ship in the last\n\\                       occupied slot (i.e. it points to the bottom of the\n\\                       descending heap)\n\\\n\\ ******************************************************************************\n\n.KS3\n\n LDA P                  \\ After shuffling the ship slots, P(1 0) will point to\n STA SLSP               \\ the new bottom of the ship line heap, so store this in\n LDA P+1                \\ SLSP(1 0), which stores the bottom of the heap\n STA SLSP+1\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: KS1\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Remove the current ship from our local bubble of universe\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Part 12 of the main flight loop calls this routine to remove the ship that is\n\\ currently being analysed by the flight loop. Once the ship is removed, it\n\\ jumps back to MAL1 to rejoin the main flight loop, with X pointing to the\n\\ same slot that we just cleared (and which now contains the next ship in the\n\\ local bubble of universe).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   XX0                 The address of the blueprint for this ship\n\\\n\\   INF                 The address of the data block for this ship\n\\\n\\ ******************************************************************************\n\n.KS1\n\n LDX XSAV               \\ Fetch the current ship's slot number from XSAV\n\n JSR KILLSHP            \\ Call KILLSHP to remove the ship in slot X from our\n                        \\ local bubble of universe\n\n LDX XSAV               \\ Restore the current ship's slot number from XSAV,\n                        \\ which now points to the next ship in the bubble\n\n JMP MAL1               \\ Jump to MAL1 to rejoin the main flight loop at the\n                        \\ start of the ship analysis loop\n\n\\ ******************************************************************************\n\\\n\\       Name: KS4\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Remove the space station and replace it with the sun\n\\\n\\ ******************************************************************************\n\n.KS4\n\n JSR ZINF               \\ Call ZINF to reset the INWK ship workspace\n\n JSR FLFLLS             \\ Reset the LSO block, returns with A = 0\n\n STA FRIN+1             \\ Set the second slot in the FRIN table to 0, which\n                        \\ sets this slot to empty, so when we call NWSHP below\n                        \\ the new sun that gets created will go into FRIN+1\n\n STA SSPR               \\ Set the \"space station present\" flag to 0, as we are\n                        \\ no longer in the space station's safe zone\n\n JSR SPBLB              \\ Call SPBLB to redraw the space station bulb, which\n                        \\ will erase it from the dashboard\n\n LDA #6                 \\ Set the sun's y_sign to 6\n STA INWK+5\n\n LDA #129               \\ Set A = 129, the ship type for the sun\n\n JMP NWSHP              \\ Call NWSHP to set up the sun's data block and add it\n                        \\ to FRIN, where it will get put in the second slot as\n                        \\ we just cleared out the second slot, and the first\n                        \\ slot is already taken by the planet\n\n\\ ******************************************************************************\n\\\n\\       Name: KS2\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Check the local bubble for missiles with target lock\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Check the local bubble of universe to see if there are any missiles with\n\\ target lock in the vicinity. If there are, then check their targets; if we\n\\ just removed their target in the KILLSHP routine, then switch off their AI so\n\\ they just drift in space, otherwise update their targets to reflect the newly\n\\ shuffled slot numbers.\n\\\n\\ This is called from KILLSHP once the slots have been shuffled down, following\n\\ the removal of a ship.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   XX4                 The slot number of the ship we removed just before\n\\                       calling this routine\n\\\n\\ ******************************************************************************\n\n.KS2\n\n LDX #&FF               \\ We want to go through the ships in our local bubble\n                        \\ and pick out all the missiles, so set X to &FF to\n                        \\ use as a counter\n\n.KSL4\n\n INX                    \\ Increment the counter (so it starts at 0 on the first\n                        \\ iteration)\n\n LDA FRIN,X             \\ If slot X is empty then we have worked our way through\n BEQ KS3                \\ all the slots, so jump to KS3 to stop looking\n\n CMP #MSL               \\ If the slot does not contain a missile, loop back to\n BNE KSL4               \\ KSL4 to check the next slot\n\n                        \\ We have found a slot containing a missile, so now we\n                        \\ want to check whether it has target lock\n\n TXA                    \\ Set Y = X * 2 and fetch the Y-th address from UNIV\n ASL A                  \\ and store it in SC and SC+1 - in other words, set\n TAY                    \\ SC(1 0) to point to the missile's ship data block\n LDA UNIV,Y\n STA SC\n LDA UNIV+1,Y\n STA SC+1\n\n LDY #32                \\ Fetch byte #32 from the missile's ship data (AI)\n LDA (SC),Y\n\n BPL KSL4               \\ If bit 7 of byte #32 is clear, then the missile is\n                        \\ dumb and has no AI, so loop back to KSL4 to move on\n                        \\ to the next slot\n\n AND #%01111111         \\ Otherwise this missile has AI, so clear bit 7 and\n LSR A                  \\ shift right to set the C flag to the missile's \"is\n                        \\ locked\" flag, and A to the target's slot number\n\n CMP XX4                \\ If this missile's target is less than XX4, then the\n BCC KSL4               \\ target's slot isn't being shuffled down, so jump to\n                        \\ KSL4 to move on to the next slot\n\n BEQ KS6                \\ If this missile was locked onto the ship that we just\n                        \\ removed in KILLSHP, jump to KS6 to stop the missile\n                        \\ from continuing to hunt it down\n\n SBC #1                 \\ Otherwise this missile is locked and has AI enabled,\n                        \\ and its target will have moved down a slot, so\n                        \\ subtract 1 from the target number (we know C is set\n                        \\ from the BCC above)\n\n ASL A                  \\ Shift the target number left by 1, so it's in bits\n                        \\ 1-6 once again, and also set bit 0 to 1, as the C\n                        \\ flag is still set, so this makes sure the missile is\n                        \\ still set to being locked\n\n ORA #%10000000         \\ Set bit 7, so the missile's AI is enabled\n\n STA (SC),Y             \\ Update the missile's AI flag to the value in A\n\n BNE KSL4               \\ Loop back to KSL4 to move on to the next slot (this\n                        \\ BNE is effectively a JMP as A will never be zero)\n\n.KS6\n\n LDA #0                 \\ The missile's target lock just got removed, so set the\n STA (SC),Y             \\ AI flag to 0 to make it dumb and not locked\n\n BEQ KSL4               \\ Loop back to KSL4 to move on to the next slot (this\n                        \\ BEQ is effectively a JMP as A is always zero)\n\n\\ ******************************************************************************\n\\\n\\       Name: KILLSHP\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Remove a ship from our local bubble of universe\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Remove the ship in slot X from our local bubble of universe. This happens\n\\ when we kill a ship, collide with a ship and destroy it, or when a ship moves\n\\ outside our local bubble.\n\\\n\\ We also use this routine when we move out of range of the space station, in\n\\ which case we replace it with the sun.\n\\\n\\ When removing a ship, this creates a gap in the ship slots at FRIN, so we\n\\ shuffle all the later slots down to close the gap. We also shuffle the ship\n\\ data blocks at K% and ship line heap at WP, to reclaim all the memory that\n\\ the removed ship used to occupy.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   The slot number of the ship to remove\n\\\n\\   XX0                 The address of the blueprint for the ship to remove\n\\\n\\   INF                 The address of the data block for the ship to remove\n\\\n\\ ******************************************************************************\n\n.KILLSHP\n\n STX XX4                \\ Store the slot number of the ship to remove in XX4\n\nIF _SOURCE_DISC\n\n LDA MSTG               \\ Check whether this slot matches the slot number in\n CMP XX4                \\ MSTG, which is the target of our missile lock\n\nELIF _TEXT_SOURCES OR _STH_CASSETTE\n\n CPX MSTG               \\ Check whether this slot matches the slot number in\n                        \\ MSTG, which is the target of our missile lock\n                        \\\n                        \\ This instructions saves two bytes of memory over the\n                        \\ LDA and CMP-based code in the source disc version, as\n                        \\ CPX MSTG is a two-byte opcode, while LDA MSTG and\n                        \\ CMP XX4 take up four bytes between them (the code does\n                        \\ the same thing)\n\nENDIF\n\n BNE KS5                \\ If our missile is not locked on this ship, jump to KS5\n\n LDY #&EE               \\ Otherwise we need to remove our missile lock, so call\n JSR ABORT              \\ ABORT to disarm the missile and update the missile\n                        \\ indicators on the dashboard to green/cyan (Y = &EE)\n\n LDA #200               \\ Print recursive token 40 (\"TARGET LOST\") as an\n JSR MESS               \\ in-flight message\n\n.KS5\n\n LDY XX4                \\ Restore the slot number of the ship to remove into Y\n\n LDX FRIN,Y             \\ Fetch the contents of the slot, which contains the\n                        \\ ship type\n\n CPX #SST               \\ If this is the space station, then jump to KS4 to\n BEQ KS4                \\ replace the space station with the sun\n\n DEC MANY,X             \\ Decrease the number of this type of ship in our little\n                        \\ bubble, which is stored in MANY+X (where X is the ship\n                        \\ type)\n\n LDX XX4                \\ Restore the slot number of the ship to remove into X\n\n                        \\ We now want to remove this ship and reclaim all the\n                        \\ memory that it uses. Removing the ship will leave a\n                        \\ gap in three places, which we need to close up:\n                        \\\n                        \\   * The ship slots in FRIN\n                        \\\n                        \\   * The ship data blocks in K%\n                        \\\n                        \\   * The descending ship line heap at WP down\n                        \\\n                        \\ The rest of this routine closes up these gaps by\n                        \\ looping through all the occupied ship slots after the\n                        \\ slot we are removing, one by one, and shuffling each\n                        \\ ship's slot, data block and line heap down to close\n                        \\ up the gaps left by the removed ship. As part of this,\n                        \\ we have to make sure we update any address pointers\n                        \\ so they point to the newly shuffled data blocks and\n                        \\ line heaps\n                        \\\n                        \\ In the following, when shuffling a ship's data down\n                        \\ into the preceding empty slot, we call the ship that\n                        \\ we are shuffling down the \"source\", and we call the\n                        \\ empty slot we are shuffling it into the \"destination\"\n                        \\\n                        \\ Before we start looping through the ships we need to\n                        \\ shuffle down, we need to set up some variables to\n                        \\ point to the source and destination line heaps\n\n LDY #5                 \\ Fetch byte #5 of the removed ship's blueprint into A,\n LDA (XX0),Y            \\ which gives the ship's maximum heap size for the ship\n                        \\ we are removing (i.e. the size of the gap in the heap\n                        \\ created by the ship removal)\n\n                        \\ INF currently contains the ship data for the ship we\n                        \\ are removing, and INF(34 33) contains the address of\n                        \\ the bottom of the ship's heap, so we can calculate\n                        \\ the address of the top of the heap by adding the heap\n                        \\ size to this address\n\n LDY #33                \\ First we add A and the address in INF+33, to get the\n CLC                    \\ low byte of the top of the heap, which we store in P\n ADC (INF),Y\n STA P\n\n INY                    \\ And next we add A and the address in INF+34, with any\n LDA (INF),Y            \\ carry from the previous addition, to get the high byte\n ADC #0                 \\ of the top of the heap, which we store in P+1, so\n STA P+1                \\ P(1 0) points to the top of this ship's heap\n\n                        \\ Now, we're ready to start looping through the ships\n                        \\ we want to move, moving the slots, data blocks and\n                        \\ line heap from the source to the destination. In the\n                        \\ following, we set up SC to point to the source data,\n                        \\ and INF (which currently points to the removed ship's\n                        \\ data that we can now overwrite) points to the\n                        \\ destination\n                        \\\n                        \\ So P(1 0) now points to the top of the line heap for\n                        \\ the destination\n\n.KSL1\n\n INX                    \\ On entry, X points to the empty slot we want to\n                        \\ shuffle the next ship into (the destination), so\n                        \\ this increment points X to the next slot - i.e. the\n                        \\ source slot we want to shuffle down\n\n LDA FRIN,X             \\ Copy the contents of the source slot into the\n STA FRIN-1,X           \\ destination slot\n\n BEQ KS2                \\ If the slot we just shuffled down contains 0, then\n                        \\ the source slot is empty and we are done shuffling,\n                        \\ so jump to KS2 to move on to processing missiles\n\n ASL A                  \\ Otherwise we have a source ship to shuffle down into\n TAY                    \\ the destination, so set Y = A * 2 so it can act as an\n                        \\ index into the two-byte ship blueprint lookup table\n                        \\ at XX21 for the source ship\n\n LDA XX21-2,Y           \\ Set SC(0 1) to point to the blueprint data for the\n STA SC                 \\ source ship\n LDA XX21-1,Y\n STA SC+1\n\n LDY #5                 \\ Fetch blueprint byte #5 for the source ship, which\n LDA (SC),Y             \\ gives us its maximum heap size, and store it in T\n STA T\n\n                        \\ We now subtract T from P(1 0), so P(1 0) will point to\n                        \\ the bottom of the line heap for the destination\n                        \\ (which we will use later when closing up the gap in\n                        \\ the heap space)\n\n LDA P                  \\ First, we subtract the low bytes\n SEC\n SBC T\n STA P\n\n LDA P+1                \\ And then we do the high bytes, for which we subtract\n SBC #0                 \\ 0 to include any carry, so this is effectively doing\n STA P+1                \\ P(1 0) = P(1 0) - (0 T)\n\n                        \\ Next, we want to set SC(1 0) to point to the source\n                        \\ ship's data block\n\n TXA                    \\ Set Y = X * 2 so it can act as an index into the\n ASL A                  \\ two-byte lookup table at UNIV, which contains the\n TAY                    \\ addresses of the ship data blocks. In this case we are\n                        \\ multiplying X by 2, and X contains the source ship's\n                        \\ slot number so Y is now an index for the source ship's\n                        \\ entry in UNIV\n\n LDA UNIV,Y             \\ Set SC(1 0) to the address of the data block for the\n STA SC                 \\ source ship\n LDA UNIV+1,Y\n STA SC+1\n\n                        \\ We have now set up our variables as follows:\n                        \\\n                        \\   SC(1 0) points to the source's ship data block\n                        \\\n                        \\   INF(1 0) points to the destination's ship data block\n                        \\\n                        \\   P(1 0) points to the destination's line heap\n                        \\\n                        \\ so let's start copying data from the source to the\n                        \\ destination\n\n LDY #35                \\ We are going to be using Y as a counter for the 36\n                        \\ bytes of ship data we want to copy from the source\n                        \\ to the destination, so we set it to 35 to start things\n                        \\ off, and will decrement Y for each byte we copy\n\n LDA (SC),Y             \\ Fetch byte #35 of the source's ship data block at SC,\n STA (INF),Y            \\ and store it in byte #35 of the destination's block\n                        \\ at INF, so that's the ship's energy copied from the\n                        \\ source to the destination. One down, quite a few to\n                        \\ go...\n\n DEY                    \\ Fetch byte #34 of the source ship, which is the\n LDA (SC),Y             \\ high byte of the source ship's line heap, and store\n STA K+1                \\ in K+1\n\n LDA P+1                \\ Set the low byte of the destination's heap pointer\n STA (INF),Y            \\ to P+1\n\n DEY                    \\ Fetch byte #33 of the source ship, which is the\n LDA (SC),Y             \\ low byte of the source ship's heap, and store in K\n STA K                  \\ so now we have the following:\n                        \\\n                        \\   K(1 0) points to the source's line heap\n\n LDA P                  \\ Set the low byte of the destination's heap pointer\n STA (INF),Y            \\ to P, so now the destination's heap pointer is to\n                        \\ P(1 0), so that's the heap pointer in bytes #33 and\n                        \\ #34 done\n\n DEY                    \\ Luckily, we can just copy the rest of the source's\n                        \\ ship data block into the destination, as there are no\n                        \\ more address pointers, so first we decrement our\n                        \\ counter in Y to point to the next byte (the AI flag)\n                        \\ in byte #32) and then start looping\n\n.KSL2\n\n LDA (SC),Y             \\ Copy the Y-th byte of the source to the Y-th byte of\n STA (INF),Y            \\ the destination\n\n DEY                    \\ Decrement the counter\n\n BPL KSL2               \\ Loop back to KSL2 to copy the next byte until we have\n                        \\ copied the whole block\n\n                        \\ We have now shuffled the ship's slot and the ship's\n                        \\ data block, so we only have the heap data itself to do\n\n LDA SC                 \\ First, we copy SC into INF, so when we loop round\n STA INF                \\ again, INF will correctly point to the destination for\n LDA SC+1               \\ the next iteration\n STA INF+1\n\n LDY T                  \\ Now we want to move the contents of the heap, as all\n                        \\ we did above was to update the pointers, so first\n                        \\ we set a counter in Y that is initially set to T\n                        \\ (which we set above to the maximum heap size for the\n                        \\ source ship)\n                        \\\n                        \\ As a reminder, we have already set the following:\n                        \\\n                        \\   K(1 0) points to the source's line heap\n                        \\\n                        \\   P(1 0) points to the destination's line heap\n                        \\\n                        \\ so we can move the heap data by simply copying the\n                        \\ correct number of bytes from K(1 0) to P(1 0)\n.KSL3\n\n DEY                    \\ Decrement the counter\n\n LDA (K),Y              \\ Copy the Y-th byte of the source heap at K(1 0) to\n STA (P),Y              \\ the destination heap at P(1 0)\n\n TYA                    \\ Loop back to KSL3 to copy the next byte, until we\n BNE KSL3               \\ have done them all\n\n BEQ KSL1               \\ We have now shuffled everything down one slot, so\n                        \\ jump back up to KSL1 to see if there is another slot\n                        \\ that needs shuffling down (this BEQ is effectively a\n                        \\ JMP as A will always be zero)\n\n\\ ******************************************************************************\n\\\n\\       Name: SFX\n\\       Type: Variable\n\\   Category: Sound\n\\    Summary: Sound data\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Sound data. To make a sound, the NOS1 routine copies the four relevant sound\n\\ bytes to XX16, and NO3 then makes the sound. The sound numbers are shown in\n\\ the table, and are always multiples of 8. Generally, sounds are made by\n\\ calling the NOISE routine with the sound number in A.\n\\\n\\ These bytes are passed to OSWORD 7, and are the equivalents to the parameters\n\\ passed to the SOUND keyword in BASIC. The parameters therefore have these\n\\ meanings:\n\\\n\\   channel/flush, amplitude (or envelope number if 1-4), pitch, duration\n\\\n\\ For the channel/flush parameter, the high nibble of the low byte is the flush\n\\ control (where a flush control of 0 queues the sound, and a flush control of\n\\ 1 makes the sound instantly), while the low nibble of the low byte is the\n\\ channel number. When written in hexadecimal, the first figure gives the flush\n\\ control, while the second is the channel (so &13 indicates flush control = 1\n\\ and channel = 3).\n\\\n\\ So when we call NOISE with A = 40 to make a long, low beep, then this is\n\\ effectively what the NOISE routine does:\n\\\n\\   SOUND &13, &F4, &0C, &08\n\\\n\\ which makes a sound with flush control 1 on channel 3, and with amplitude &F4\n\\ (-12), pitch &0C (2) and duration &08 (8). Meanwhile, to make the hyperspace\n\\ sound, the NOISE routine does this:\n\\\n\\   SOUND &10, &02, &60, &10\n\\\n\\ which makes a sound with flush control 1 on channel 0, using envelope 2,\n\\ and with pitch &60 (96) and duration &10 (16). The four sound envelopes (1-4)\n\\ are set up by the loading process.\n\\\n\\ ******************************************************************************\n\n.SFX\n\n EQUB &12, &01, &00, &10    \\ 0  - Lasers fired by us\n EQUB &12, &02, &2C, &08    \\ 8  - We're being hit by lasers\n EQUB &11, &03, &F0, &18    \\ 16 - We died 1 / We made a hit or kill 2\n EQUB &10, &F1, &07, &1A    \\ 24 - We died 2 / We made a hit or kill 1\n EQUB &03, &F1, &BC, &01    \\ 32 - Short, high beep\n EQUB &13, &F4, &0C, &08    \\ 40 - Long, low beep\n EQUB &10, &F1, &06, &0C    \\ 48 - Missile launched / Ship launched from station\n EQUB &10, &02, &60, &10    \\ 56 - Hyperspace drive engaged\n EQUB &13, &04, &C2, &FF    \\ 64 - E.C.M. on\n EQUB &13, &00, &00, &00    \\ 72 - E.C.M. off\n\n\\ ******************************************************************************\n\\\n\\       Name: RESET\n\\       Type: Subroutine\n\\   Category: Start and end\n\\    Summary: Reset most variables\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Reset our ship and various controls, recharge shields and energy, and then\n\\ fall through into RES2 to reset the stardust and the ship workspace at INWK.\n\\\n\\ In this subroutine, this means zero-filling the following locations:\n\\\n\\   * Pages &9, &A, &B, &C and &D\n\\\n\\   * BETA to BETA+6, which covers the following:\n\\\n\\     * BETA, BET1 - Set pitch to 0\n\\\n\\     * XC, YC - Set text cursor to (0, 0)\n\\\n\\     * QQ22 - Set hyperspace counters to 0\n\\\n\\     * ECMA - Turn E.C.M. off\n\\\n\\ It also sets QQ12 to &FF, to indicate we are docked, recharges the shields and\n\\ energy banks, and then falls through into RES2.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   RES4                Reset the shields and energy banks, then fall through\n\\                       into RES2 to reset the stardust and the ship workspace\n\\                       at INWK\n\\\n\\ ******************************************************************************\n\n.RESET\n\n JSR ZERO               \\ Zero-fill pages &9, &A, &B, &C and &D, which clears\n                        \\ the ship data blocks, the ship line heap, the ship\n                        \\ slots for the local bubble of universe, and various\n                        \\ flight and ship status variables\n\n LDX #6                 \\ Set up a counter for zeroing BETA through BETA+6\n\n.SAL3\n\n STA BETA,X             \\ Zero the X-th byte after BETA\n\n DEX                    \\ Decrement the loop counter\n\n BPL SAL3               \\ Loop back for the next byte to zero\n\n STX QQ12               \\ X is now negative - i.e. &FF - so this sets QQ12 to\n                        \\ &FF to indicate we are docked\n\n                        \\ We now fall through into RES4 to restore shields and\n                        \\ energy, and reset the stardust and ship workspace at\n                        \\ INWK\n\n.RES4\n\n LDA #&FF               \\ Set A to &FF so we can fill up the shields and energy\n                        \\ bars with a full charge\n\n LDX #2                 \\ We're now going to recharge both shields and the\n                        \\ energy bank, which live in the three bytes at FSH,\n                        \\ ASH (FSH+1) and ENERGY (FSH+2), so set a loop counter\n                        \\ in X for 3 bytes\n\n.REL5\n\n STA FSH,X              \\ Set the X-th byte of FSH to &FF to charge up that\n                        \\ shield/bank\n\n DEX                    \\ Decrement the loop counter\n\n BPL REL5               \\ Loop back to REL5 until we have recharged both shields\n                        \\ and the energy bank\n\n                        \\ Fall through into RES2 to reset the stardust and ship\n                        \\ workspace at INWK\n\n\\ ******************************************************************************\n\\\n\\       Name: RES2\n\\       Type: Subroutine\n\\   Category: Start and end\n\\    Summary: Reset a number of flight variables and workspaces\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This is called after we launch from a space station, arrive in a new system\n\\ after hyperspace, launch an escape pod, or die a cold, lonely death in the\n\\ depths of space.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   Y                   Y is set to &FF\n\\\n\\ ******************************************************************************\n\n.RES2\n\n LDA #NOST              \\ Reset NOSTM, the number of stardust particles, to the\n STA NOSTM              \\ maximum allowed (18)\n\n LDX #&FF               \\ Reset LSX2 and LSY2, the ball line heaps used by the\n STX LSX2               \\ BLINE routine for drawing circles, to &FF, to set the\n STX LSY2               \\ heap to empty\n\n STX MSTG               \\ Reset MSTG, the missile target, to &FF (no target)\n\n LDA #128               \\ Set the current pitch rate to the mid-point, 128\n STA JSTY\n\n STA ALP2               \\ Reset ALP2 (roll sign) and BET2 (pitch sign)\n STA BET2               \\ to negative, i.e. pitch and roll negative\n\n ASL A                  \\ This sets A to 0\n\n STA ALP2+1             \\ Reset ALP2+1 (flipped roll sign) and BET2+1 (flipped\n STA BET2+1             \\ pitch sign) to positive, i.e. pitch and roll negative\n\n STA MCNT               \\ Reset MCNT (the main loop counter) to 0\n\n LDA #3                 \\ Reset DELTA (speed) to 3\n STA DELTA\n\n STA ALPHA              \\ Reset ALPHA (roll angle alpha) to 3\n\n STA ALP1               \\ Reset ALP1 (magnitude of roll angle alpha) to 3\n\n LDA SSPR               \\ Fetch the \"space station present\" flag, and if we are\n BEQ P%+5               \\ not inside the safe zone, skip the next instruction\n\n JSR SPBLB              \\ Light up the space station bulb on the dashboard\n\n LDA ECMA               \\ Fetch the E.C.M. status flag, and if E.C.M. is off,\n BEQ yu                 \\ skip the next instruction\n\n JSR ECMOF              \\ Turn off the E.C.M. sound\n\n.yu\n\n JSR WPSHPS             \\ Wipe all ships from the scanner\n\n JSR ZERO               \\ Zero-fill pages &9, &A, &B, &C and &D, which clears\n                        \\ the ship data blocks, the ship line heap, the ship\n                        \\ slots for the local bubble of universe, and various\n                        \\ flight and ship status variables\n\n LDA #LO(WP-1)          \\ We have reset the ship line heap, so we now point\n STA SLSP               \\ SLSP to the byte before the WP workspace to indicate\n LDA #HI(WP-1)          \\ that the heap is empty\n STA SLSP+1\n\n JSR DIALS              \\ Update the dashboard\n\n                        \\ Finally, fall through into ZINF to reset the INWK\n                        \\ ship workspace\n\n\\ ******************************************************************************\n\\\n\\       Name: ZINF\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Reset the INWK workspace and orientation vectors\n\\  Deep dive: Orientation vectors\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Zero-fill the INWK ship workspace and reset the orientation vectors, with\n\\ nosev pointing out of the screen, towards us.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   Y                   Y is set to &FF\n\\\n\\ ******************************************************************************\n\n.ZINF\n\n LDY #NI%-1             \\ There are NI% bytes in the INWK workspace, so set a\n                        \\ counter in Y so we can loop through them\n\n LDA #0                 \\ Set A to 0 so we can zero-fill the workspace\n\n.ZI1\n\n STA INWK,Y             \\ Zero the Y-th byte of the INWK workspace\n\n DEY                    \\ Decrement the loop counter\n\n BPL ZI1                \\ Loop back for the next byte, ending when we have\n                        \\ zero-filled the last byte at INWK, which leaves Y\n                        \\ with a value of &FF\n\n                        \\ Finally, we reset the orientation vectors as follows:\n                        \\\n                        \\   sidev = (1,  0,  0)\n                        \\   roofv = (0,  1,  0)\n                        \\   nosev = (0,  0, -1)\n                        \\\n                        \\ 96 * 256 (&6000) represents 1 in the orientation\n                        \\ vectors, while -96 * 256 (&E000) represents -1. We\n                        \\ already set the vectors to zero above, so we just\n                        \\ need to set up the high bytes of the diagonal values\n                        \\ and we're done. The negative nosev makes the ship\n                        \\ point towards us, as the z-axis points into the screen\n\n LDA #96                \\ Set A to represent a 1 (in vector terms)\n\n STA INWK+18            \\ Set byte #18 = roofv_y_hi = 96 = 1\n\n STA INWK+22            \\ Set byte #22 = sidev_x_hi = 96 = 1\n\n ORA #%10000000         \\ Flip the sign of A to represent a -1\n\n STA INWK+14            \\ Set byte #14 = nosev_z_hi = -96 = -1\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: msblob\n\\       Type: Subroutine\n\\   Category: Dashboard\n\\    Summary: Display the dashboard's missile indicators in green\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Display the dashboard's missile indicators, with all the missiles reset to\n\\ green/cyan (i.e. not armed or locked).\n\\\n\\ ******************************************************************************\n\n.msblob\n\n LDX #4                 \\ Set up a loop counter in X to count through all four\n                        \\ missile indicators\n\n.ss\n\n CPX NOMSL              \\ If the counter is equal to the number of missiles,\n BEQ SAL8               \\ jump down to SAL8 to draw the remaining missiles, as\n                        \\ the rest of them are present and should be drawn in\n                        \\ green/cyan\n\n LDY #0                 \\ Draw the missile indicator at position X in black\n JSR MSBAR\n\n DEX                    \\ Decrement the counter to point to the next missile\n\n BNE ss                 \\ Loop back to ss if we still have missiles to draw\n\n RTS                    \\ Return from the subroutine\n\n.SAL8\n\n LDY #&EE               \\ Draw the missile indicator at position X in green/cyan\n JSR MSBAR\n\n DEX                    \\ Decrement the counter to point to the next missile\n\n BNE SAL8               \\ Loop back to SAL8 if we still have missiles to draw\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: me2\n\\       Type: Subroutine\n\\   Category: Flight\n\\    Summary: Remove an in-flight message from the space view\n\\\n\\ ******************************************************************************\n\n.me2\n\n LDA MCH                \\ Fetch the token number of the current message into A\n\n JSR MESS               \\ Call MESS to print the token, which will remove it\n                        \\ from the screen as printing uses EOR logic\n\n LDA #0                 \\ Set the delay in DLY to 0, so any new in-flight\n STA DLY                \\ messages will be shown instantly\n\n JMP me3                \\ Jump back into the main spawning loop at me3\n\n\\ ******************************************************************************\n\\\n\\       Name: Ze\n\\       Type: Subroutine\n\\   Category: Universe\n\\    Summary: Initialise the INWK workspace to a fairly aggressive ship\n\\  Deep dive: Fixing ship positions\n\\             Aggression and hostility in ship tactics\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Specifically, this routine does the following:\n\\\n\\   * Reset the INWK ship workspace\n\\\n\\   * Set the ship to a fair distance away in all axes, in front of us but\n\\     randomly up or down, left or right\n\\\n\\   * Give the ship a 4% chance of having E.C.M.\n\\\n\\   * Set the ship's aggression level to at least 32 out of 63, with AI enabled\n\\\n\\ This routine also sets A, X, T1 and the C flag to random values.\n\\\n\\ Note that because this routine uses the value of X returned by DORND, and X\n\\ contains the value of A returned by the previous call to DORND, this routine\n\\ does not necessarily set the new ship to a totally random location.\n\\\n\\ ******************************************************************************\n\n.Ze\n\n JSR ZINF               \\ Call ZINF to reset the INWK ship workspace\n\n JSR DORND              \\ Set A and X to random numbers\n\n STA T1                 \\ Store A in T1\n\n AND #%10000000         \\ Extract the sign of A and store in x_sign\n STA INWK+2\n\n TXA                    \\ Extract the sign of X and store in y_sign\n AND #%10000000\n STA INWK+5\n\n LDA #32                \\ Set x_hi = y_hi = z_hi = 32, a fair distance away\n STA INWK+1\n STA INWK+4\n STA INWK+7\n\n TXA                    \\ Set the C flag if X >= 245 (4% chance)\n CMP #245\n\n ROL A                  \\ Set bit 0 of A to the C flag (i.e. there's a 4%\n                        \\ chance of this ship having E.C.M.)\n\n ORA #%11000000         \\ Set bits 6 and 7 of A, so the ship has AI (bit 7) and\n                        \\ an aggression level of at least 32 out of 63\n\n STA INWK+32            \\ Store A in the AI flag of this ship\n\n                        \\ Fall through into DORND2 to set A, X and the C flag\n                        \\ randomly\n\n\\ ******************************************************************************\n\\\n\\       Name: DORND\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Generate random numbers\n\\  Deep dive: Generating random numbers\n\\             Fixing ship positions\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Set A and X to random numbers (though note that X is set to the random number\n\\ that was returned in A the last time DORND was called).\n\\\n\\ The C and V flags are also set randomly.\n\\\n\\ If we want to generate a repeatable sequence of random numbers, when\n\\ generating explosion clouds, for example, then we call DORND2 to ensure that\n\\ the value of the C flag on entry doesn't affect the outcome, as otherwise we\n\\ might not get the same sequence of numbers if the C flag changes.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   DORND2              Make sure the C flag doesn't affect the outcome\n\\\n\\ ******************************************************************************\n\n.DORND2\n\n CLC                    \\ Clear the C flag so the value of the C flag on entry\n                        \\ doesn't affect the outcome\n\n.DORND\n\n LDA RAND               \\ Calculate the next two values f2 and f3 in the feeder\n ROL A                  \\ sequence:\n TAX                    \\\n ADC RAND+2             \\   * f2 = (f1 << 1) mod 256 + C flag on entry\n STA RAND               \\   * f3 = f0 + f2 + (1 if bit 7 of f1 is set)\n STX RAND+2             \\   * C flag is set according to the f3 calculation\n\n LDA RAND+1             \\ Calculate the next value m2 in the main sequence:\n TAX                    \\\n ADC RAND+3             \\   * A = m2 = m0 + m1 + C flag from feeder calculation\n STA RAND+1             \\   * X = m1\n STX RAND+3             \\   * C and V flags set according to the m2 calculation\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: Main game loop (Part 1 of 6)\n\\       Type: Subroutine\n\\   Category: Main loop\n\\    Summary: Spawn a trader (a peaceful Cobra Mk III)\n\\  Deep dive: Program flow of the main game loop\n\\             Ship data blocks\n\\             Aggression and hostility in ship tactics\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This is part of the main game loop. This is where the core loop of the game\n\\ lives, and it's in two parts. The shorter loop (just parts 5 and 6) is\n\\ iterated when we are docked, while the entire loop from part 1 to 6 iterates\n\\ if we are in space.\n\\\n\\ This section covers the following:\n\\\n\\   * Spawn a trader, i.e. a Cobra Mk III with AI disabled, a 50% chance of it\n\\     having an E.C.M., a speed between 16 and 31, a random aggression level\n\\     and a gentle clockwise roll\n\\\n\\ We call this from within the main loop, with A set to a random number.\n\\\n\\ ******************************************************************************\n\n.MTT4\n\n LSR A                  \\ Clear bit 7 of our random number in A and set the C\n                        \\ flag to bit 0 of A, which is random\n\n STA INWK+32            \\ Store this in the ship's AI flag, so this ship does\n                        \\ not have AI\n\n STA INWK+29            \\ Store A in the ship's roll counter, giving it a\n                        \\ clockwise roll (as bit 7 is clear), and a 1 in 127\n                        \\ chance of it having no damping\n\n ROL INWK+31            \\ This instruction would appear to set bit 0 of the\n                        \\ ship's missile count randomly (as the C flag was set),\n                        \\ giving the ship either no missiles or one missile\n                        \\\n                        \\ However, INWK+31 is overwritten in the call to the\n                        \\ NWSHP routine below, where it is set to the number of\n                        \\ missiles from the ship blueprint, and the value of the\n                        \\ C flag is not used, so this instruction actually has\n                        \\ no effect\n                        \\\n                        \\ Interestingly, the original source code for the NWSPS\n                        \\ routine also has an instruction that sets INWK+31 and\n                        \\ which gets overwritten when it falls through into\n                        \\ NWSHP, but in this case the instruction is commented\n                        \\ out in the source. Perhaps the original version of\n                        \\ NWSHP didn't set the missile count and instead relied\n                        \\ on the calling code to set it, and when the authors\n                        \\ changed it, they commented out the INWK+31 instruction\n                        \\ in NWSPS and forgot about this one. Who knows?\n\n AND #31                \\ Set the ship speed to our random number, set to a\n ORA #16                \\ minimum of 16 and a maximum of 31\n STA INWK+27\n\n LDA #CYL               \\ Add a new Cobra Mk III to the local bubble and fall\n JSR NWSHP              \\ through into the main game loop again\n\n\\ ******************************************************************************\n\\\n\\       Name: Main game loop (Part 2 of 6)\n\\       Type: Subroutine\n\\   Category: Main loop\n\\    Summary: Call the main flight loop, and potentially spawn a trader, an\n\\             asteroid, or a cargo canister\n\\  Deep dive: Program flow of the main game loop\n\\             Ship data blocks\n\\             Fixing ship positions\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This section covers the following:\n\\\n\\   * Call M% to do the main flight loop\n\\\n\\   * Potentially spawn a trader, asteroid or cargo canister\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   TT100               The entry point for the start of the main game loop,\n\\                       which calls the main flight loop and the moves into the\n\\                       spawning routine\n\\\n\\   me3                 Used by me2 to jump back into the main game loop after\n\\                       printing an in-flight message\n\\\n\\ ******************************************************************************\n\n.TT100\n\n JSR M%                 \\ Call M% to iterate through the main flight loop\n\n DEC DLY                \\ Decrement the delay counter in DLY, so any in-flight\n                        \\ messages get removed once the counter reaches zero\n\n BEQ me2                \\ If DLY is now 0, jump to me2 to remove any in-flight\n                        \\ message from the space view, and once done, return to\n                        \\ me3 below, skipping the following two instructions\n\n BPL me3                \\ If DLY is positive, jump to me3 to skip the next\n                        \\ instruction\n\n INC DLY                \\ If we get here, DLY is negative, so we have gone too\n                        \\ and need to increment DLY back to 0\n\n.me3\n\n DEC MCNT               \\ Decrement the main loop counter in MCNT\n\n BEQ P%+5               \\ If the counter has reached zero, which it will do\n                        \\ every 256 main loops, skip the next JMP instruction\n                        \\ (or to put it another way, if the counter hasn't\n                        \\ reached zero, jump down to MLOOP, skipping all the\n                        \\ following checks)\n\n.ytq\n\n JMP MLOOP              \\ Jump down to MLOOP to do some end-of-loop tidying and\n                        \\ restart the main loop\n\n                        \\ We only get here once every 256 iterations of the\n                        \\ main loop. If we aren't in witchspace and don't\n                        \\ already have 3 or more asteroids in our local bubble,\n                        \\ then this section has a 13% chance of spawning\n                        \\ something benign (the other 87% of the time we jump\n                        \\ down to consider spawning cops, pirates and bounty\n                        \\ hunters)\n                        \\\n                        \\ If we are in that 13%, then 50% of the time this will\n                        \\ be a trader, and the other 50% of the time it will\n                        \\ either be an asteroid (98.5% chance) or, very rarely,\n                        \\ a cargo canister (1.5% chance)\n\n LDA MJ                 \\ If we are in witchspace following a mis-jump, skip the\n BNE ytq                \\ following by jumping down to MLOOP (via ytq above)\n\n JSR DORND              \\ Set A and X to random numbers\n\n CMP #35                \\ If A >= 35 (87% chance), jump down to MTT1 to skip\n BCS MTT1               \\ the spawning of an asteroid or cargo canister and\n                        \\ potentially spawn something else\n\n LDA MANY+AST           \\ If we already have 3 or more asteroids in the local\n CMP #3                 \\ bubble, jump down to MTT1 to skip the following and\n BCS MTT1               \\ potentially spawn something else\n\n JSR ZINF               \\ Call ZINF to reset the INWK ship workspace\n\n LDA #38                \\ Set z_hi = 38 (far away)\n STA INWK+7\n\n JSR DORND              \\ Set A, X and C flag to random numbers\n\n STA INWK               \\ Set x_lo = random\n\n STX INWK+3             \\ Set y_lo = random\n                        \\\n                        \\ Note that because we use the value of X returned by\n                        \\ DORND, and X contains the value of A returned by the\n                        \\ previous call to DORND, this does not set the new ship\n                        \\ to a totally random location\n\n AND #%10000000         \\ Set x_sign = bit 7 of x_lo\n STA INWK+2\n\n TXA                    \\ Set y_sign = bit 7 of y_lo\n AND #%10000000\n STA INWK+5\n\n ROL INWK+1             \\ Set bit 1 of x_hi to the C flag, which is random, so\n ROL INWK+1             \\ this randomly moves us off-centre by 512 (as if x_hi\n                        \\ is %00000010, then (x_hi x_lo) is 512 + x_lo)\n\n JSR DORND              \\ Set A, X and V flag to random numbers\n\n BVS MTT4               \\ If V flag is set (50% chance), jump up to MTT4 to\n                        \\ spawn a trader\n\n ORA #%01101111         \\ Take the random number in A and set bits 0-3 and 5-6,\n STA INWK+29            \\ so the result has a 50% chance of being positive or\n                        \\ negative, and a 50% chance of bits 0-6 being 127.\n                        \\ Storing this number in the roll counter therefore\n                        \\ gives our new ship a fast roll speed with a 50%\n                        \\ chance of having no damping, plus a 50% chance of\n                        \\ rolling clockwise or anti-clockwise\n\n LDA SSPR               \\ If we are inside the space station safe zone, jump\n BNE MTT1               \\ down to MTT1 to skip the following and potentially\n                        \\ spawn something else\n\n TXA                    \\ Set A to the random X we set above, which we haven't\n BCS MTT2               \\ used yet, and if the C flag is set (50% chance) jump\n                        \\ down to MTT2 to skip the following\n\n AND #31                \\ Set the ship speed to our random number, set to a\n ORA #16                \\ minimum of 16 and a maximum of 31\n STA INWK+27\n\n BCC MTT3               \\ Jump down to MTT3, skipping the following (this BCC\n                        \\ is effectively a JMP as we know the C flag is clear,\n                        \\ having passed through the BCS above)\n\n.MTT2\n\n ORA #%01111111         \\ Set bits 0-6 of A to 127, leaving bit 7 as random, so\n STA INWK+30            \\ storing this number in the pitch counter means we have\n                        \\ full pitch with no damping, with a 50% chance of\n                        \\ pitching up or down\n\n.MTT3\n\n JSR DORND              \\ Set A and X to random numbers\n\n CMP #5                 \\ Set A to the ship number of an asteroid, and keep\n LDA #AST               \\ this value for 98.5% of the time (i.e. if random\n BCS P%+4               \\ A >= 5 then skip the following instruction)\n\n LDA #OIL               \\ Set A to the ship number of a cargo canister\n\n JSR NWSHP              \\ Add our new asteroid or canister to the universe\n\n\\ ******************************************************************************\n\\\n\\       Name: Main game loop (Part 3 of 6)\n\\       Type: Subroutine\n\\   Category: Main loop\n\\    Summary: Potentially spawn a cop, particularly if we've been bad\n\\  Deep dive: Program flow of the main game loop\n\\             Ship data blocks\n\\             Fixing ship positions\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This section covers the following:\n\\\n\\   * Potentially spawn a cop (in a Viper), very rarely if we have been good,\n\\     more often if have been naughty, and very often if we have been properly\n\\     bad\n\\\n\\ ******************************************************************************\n\n.MTT1\n\n LDA SSPR               \\ If we are inside the space station's safe zone, jump\n BNE MLOOP              \\ to MLOOP to skip the following\n\n JSR BAD                \\ Call BAD to work out how much illegal contraband we\n                        \\ are carrying in our hold (A is up to 40 for a\n                        \\ standard hold crammed with contraband, up to 70 for\n                        \\ an extended cargo hold full of narcotics and slaves)\n\n ASL A                  \\ Double A to a maximum of 80 or 140\n\n LDX MANY+COPS          \\ If there are no cops in the local bubble, skip the\n BEQ P%+5               \\ next instruction\n\n ORA FIST               \\ There are cops in the vicinity and we've got a hold\n                        \\ full of jail time, so OR the value in A with FIST to\n                        \\ get a new value that is at least as high as both\n                        \\ values, to reflect the fact that they have almost\n                        \\ certainly scanned our ship\n\n STA T                  \\ Store our badness level in T\n\n JSR Ze                 \\ Call Ze to initialise INWK to a fairly aggressive\n                        \\ ship, and set A and X to random values\n                        \\\n                        \\ Note that because Ze uses the value of X returned by\n                        \\ DORND, and X contains the value of A returned by the\n                        \\ previous call to DORND, this does not set the new ship\n                        \\ to a totally random location\n\n CMP T                  \\ If the random value in A >= our badness level, which\n BCS P%+7               \\ will be the case unless we have been really, really\n                        \\ bad, then skip the following two instructions (so\n                        \\ if we are really bad, there's a higher chance of\n                        \\ spawning a cop, otherwise we got away with it, for\n                        \\ now)\n\n LDA #COPS              \\ Add a new police ship to the local bubble\n JSR NWSHP\n\n LDA MANY+COPS          \\ If we now have at least one cop in the local bubble,\n BNE MLOOP              \\ jump down to MLOOP, otherwise fall through into the\n                        \\ next part to look at spawning something else\n\n\\ ******************************************************************************\n\\\n\\       Name: Main game loop (Part 4 of 6)\n\\       Type: Subroutine\n\\   Category: Main loop\n\\    Summary: Potentially spawn a lone bounty hunter, a Thargoid, or up to four\n\\             pirates\n\\  Deep dive: Program flow of the main game loop\n\\             Ship data blocks\n\\             Fixing ship positions\n\\             Aggression and hostility in ship tactics\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This section covers the following:\n\\\n\\   * Potentially spawn (35% chance) either a lone bounty hunter (a Mamba,\n\\     Python or Cobra Mk III), a Thargoid, or a group of up to 4 pirates\n\\     (Sidewinders and/or Mambas)\n\\\n\\ ******************************************************************************\n\n DEC EV                 \\ Decrement EV, the extra vessels spawning delay, and\n BPL MLOOP              \\ jump to MLOOP if it is still positive, so we only\n                        \\ do the following when the EV counter runs down\n\n INC EV                 \\ EV is negative, so bump it up again, setting it back\n                        \\ to 0\n\n JSR DORND              \\ Set A and X to random numbers\n\n LDY gov                \\ If the government of this system is 0 (anarchy), jump\n BEQ LABEL_2            \\ straight to LABEL_2 to start spawning pirates or a\n                        \\ lone bounty hunter\n\n CMP #90                \\ If the random number in A >= 90 (65% chance), jump to\n BCS MLOOP              \\ MLOOP to stop spawning (so there's a 35% chance of\n                        \\ spawning pirates or a lone bounty hunter)\n\n AND #7                 \\ Reduce the random number in A to the range 0-7, and\n CMP gov                \\ if A is less than government of this system, jump\n BCC MLOOP              \\ to MLOOP to stop spawning (so safer governments with\n                        \\ larger gov numbers have a greater chance of jumping\n                        \\ out, which is another way of saying that more\n                        \\ dangerous systems spawn pirates and bounty hunters\n                        \\ more often)\n\n.LABEL_2\n\n                        \\ Now to spawn a lone bounty hunter, a Thargoid or a\n                        \\ group of pirates\n\n JSR Ze                 \\ Call Ze to initialise INWK to a fairly aggressive\n                        \\ ship, and set A and X to random values\n                        \\\n                        \\ Note that because Ze uses the value of X returned by\n                        \\ DORND, and X contains the value of A returned by the\n                        \\ previous call to DORND, this does not set the new ship\n                        \\ to a totally random location\n\n CMP #200               \\ If the random number in A >= 200 (13% chance), jump\n BCS mt1                \\ to mt1 to spawn pirates, otherwise keep going to\n                        \\ spawn a lone bounty hunter or a Thargoid\n\n INC EV                 \\ Increase the extra vessels spawning counter, to\n                        \\ prevent the next attempt to spawn extra vessels\n\n AND #3                 \\ Set A = Y = random number in the range 3-6, which\n ADC #3                 \\ we will use to determine the type of ship\n TAY\n\n                        \\ We now build the AI flag for this ship in A\n\n TXA                    \\ First, copy the random number in X to A\n\n CMP #200               \\ First, set the C flag if X >= 200 (22% chance)\n\n ROL A                  \\ Set bit 0 of A to the C flag (i.e. there's a 22%\n                        \\ chance of this ship having E.C.M.)\n\n ORA #%11000000         \\ Set bits 6 and 7 of A, so the ship has AI (bit 7) and\n                        \\ an aggression level of at least 32 out of 63\n\n CPY #6                 \\ If Y = 6 (i.e. a Thargoid), jump down to the tha\n BEQ tha                \\ routine in part 6 to decide whether or not to spawn it\n                        \\ (where there's a 22% chance of this happening)\n\n STA INWK+32            \\ Store A in the AI flag of this ship\n\n TYA                    \\ Add a new ship of type Y to the local bubble, so\n JSR NWSHP              \\ that's a Mamba, Cobra Mk III or Python\n\n.mj1\n\n JMP MLOOP              \\ Jump down to MLOOP, as we are done spawning ships\n\n.mt1\n\n AND #3                 \\ It's time to spawn a group of pirates, so set A to a\n                        \\ random number in the range 0-3, which will be the\n                        \\ loop counter for spawning pirates below (so we will\n                        \\ spawn 1-4 pirates)\n\n STA EV                 \\ Delay further spawnings by this number\n\n STA XX13               \\ Store the number in XX13, the pirate counter\n\n.mt3\n\n JSR DORND              \\ Set A and X to random numbers\n\n AND #3                 \\ Set A to a random number in the range 0-3\n\n ORA #1                 \\ Set A to %01 or %11 (Sidewinder or Mamba)\n\n JSR NWSHP              \\ Try adding a new ship of type A to the local bubble\n\n DEC XX13               \\ Decrement the pirate counter\n\n BPL mt3                \\ If we need more pirates, loop back up to mt3,\n                        \\ otherwise we are done spawning, so fall through into\n                        \\ the end of the main loop at MLOOP\n\n\\ ******************************************************************************\n\\\n\\       Name: Main game loop (Part 5 of 6)\n\\       Type: Subroutine\n\\   Category: Main loop\n\\    Summary: Cool down lasers, make calls to update the dashboard\n\\  Deep dive: Program flow of the main game loop\n\\             The dashboard indicators\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This is the first half of the minimal game loop, which we iterate when we are\n\\ docked. This section covers the following:\n\\\n\\   * Cool down lasers\n\\\n\\   * Make calls to update the dashboard\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   MLOOP               The entry point for the main game loop. This entry point\n\\                       comes after the call to the main flight loop and\n\\                       spawning routines, so it marks the start of the main\n\\                       game loop for when we are docked (as we don't need to\n\\                       call the main flight loop or spawning routines if we\n\\                       aren't in space)\n\\\n\\ ******************************************************************************\n\n.MLOOP\n\n LDA #%00000001         \\ Set 6522 System VIA interrupt enable register IER\n STA VIA+&4E            \\ (SHEILA &4E) bit 1 (i.e. disable the CA2 interrupt,\n                        \\ which comes from the keyboard)\n\n LDX #&FF               \\ Set the stack pointer to &01FF, which is the standard\n TXS                    \\ location for the 6502 stack, so this instruction\n                        \\ effectively resets the stack\n\n LDX GNTMP              \\ If the laser temperature in GNTMP is non-zero,\n BEQ EE20               \\ decrement it (i.e. cool it down a bit)\n DEC GNTMP\n\n.EE20\n\n JSR DIALS              \\ Call DIALS to update the dashboard\n\n LDA QQ11               \\ If this is a space view, skip the following four\n BEQ P%+11              \\ instructions (i.e. jump to JSR TT17 below)\n\n AND PATG               \\ If PATG = &FF (author names are shown on start-up)\n LSR A                  \\ and bit 0 of QQ11 is 1 (the current view is type 1),\n BCS P%+5               \\ then skip the following instruction\n\n JSR DELAY-5            \\ Wait for 8/50 of a second (0.16 seconds), to slow the\n                        \\ main loop down a bit\n\n JSR TT17               \\ Scan the keyboard for the cursor keys or joystick,\n                        \\ returning the cursor's delta values in X and Y and\n                        \\ the key pressed in A\n\n\\ ******************************************************************************\n\\\n\\       Name: Main game loop (Part 6 of 6)\n\\       Type: Subroutine\n\\   Category: Main loop\n\\    Summary: Process non-flight key presses (red function keys, docked keys)\n\\  Deep dive: Program flow of the main game loop\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This is the second half of the minimal game loop, which we iterate when we are\n\\ docked. This section covers the following:\n\\\n\\   * Process more key presses (red function keys, docked keys etc.)\n\\\n\\ It also supports joining the main loop with a key already \"pressed\", so we can\n\\ jump into the main game loop to perform a specific action. In practice, this\n\\ is used when we enter the docking bay in BAY to display Status Mode (red key\n\\ f8), and when we finish buying or selling cargo in BAY2 to jump to the\n\\ Inventory (red key f9).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   FRCE                The entry point for the main game loop if we want to\n\\                       jump straight to a specific screen, by pretending to\n\\                       \"press\" a key, in which case A contains the internal key\n\\                       number of the key we want to \"press\"\n\\\n\\   tha                 Consider spawning a Thargoid (22% chance)\n\\\n\\ ******************************************************************************\n\n.FRCE\n\n JSR TT102              \\ Call TT102 to process the key pressed in A\n\n LDA QQ12               \\ Fetch the docked flag from QQ12 into A\n\n BNE MLOOP              \\ If we are docked, loop back up to MLOOP just above\n                        \\ to restart the main loop, but skipping all the flight\n                        \\ and spawning code in the top part of the main loop\n\n JMP TT100              \\ Otherwise jump to TT100 to restart the main loop from\n                        \\ the start\n\n.tha\n\n JSR DORND              \\ Set A and X to random numbers\n\n CMP #200               \\ If A < 200 (78% chance), skip the next instruction\n BCC P%+5\n\n JSR GTHG               \\ Call GTHG to spawn a Thargoid ship and a Thargon\n                        \\ companion\n\n JMP MLOOP              \\ Jump back into the main loop at MLOOP, which is just\n                        \\ after the ship-spawning section\n\n\\ ******************************************************************************\n\\\n\\       Name: TT102\n\\       Type: Subroutine\n\\   Category: Keyboard\n\\    Summary: Process function key, save key, hyperspace and chart key presses\n\\             and update the hyperspace counter\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Process function key presses, plus \"@\" (save commander), \"H\" (hyperspace),\n\\ \"D\" (show distance to system) and \"O\" (move chart cursor back to current\n\\ system). We can also pass cursor position deltas in X and Y to indicate that\n\\ the cursor keys or joystick have been used (i.e. the values that are returned\n\\ by routine TT17).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The internal key number of the key pressed (see page 142\n\\                       of the \"Advanced User Guide for the BBC Micro\" by Bray,\n\\                       Dickens and Holmes for a list of internal key numbers)\n\\\n\\   X                   The amount to move the crosshairs in the x-axis\n\\\n\\   Y                   The amount to move the crosshairs in the y-axis\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   T95                 Print the distance to the selected system\n\\\n\\ ******************************************************************************\n\n.TT102\n\n CMP #f8                \\ If red key f8 was pressed, jump to STATUS to show the\n BNE P%+5               \\ Status Mode screen, returning from the subroutine\n JMP STATUS             \\ using a tail call\n\n CMP #f4                \\ If red key f4 was pressed, jump to TT22 to show the\n BNE P%+5               \\ Long-range Chart, returning from the subroutine using\n JMP TT22               \\ a tail call\n\n CMP #f5                \\ If red key f5 was pressed, jump to TT23 to show the\n BNE P%+5               \\ Short-range Chart, returning from the subroutine using\n JMP TT23               \\ a tail call\n\n CMP #f6                \\ If red key f6 was pressed, call TT111 to select the\n BNE TT92               \\ system nearest to galactic coordinates (QQ9, QQ10)\n JSR TT111              \\ (the location of the chart crosshairs) and jump to\n JMP TT25               \\ TT25 to show the Data on System screen, returning\n                        \\ from the subroutine using a tail call\n\n.TT92\n\n CMP #f9                \\ If red key f9 was pressed, jump to TT213 to show the\n BNE P%+5               \\ Inventory screen, returning from the subroutine\n JMP TT213              \\ using a tail call\n\n CMP #f7                \\ If red key f7 was pressed, jump to TT167 to show the\n BNE P%+5               \\ Market Price screen, returning from the subroutine\n JMP TT167              \\ using a tail call\n\n CMP #f0                \\ If red key f0 was pressed, jump to TT110 to launch our\n BNE fvw                \\ ship (if docked), returning from the subroutine using\n JMP TT110              \\ a tail call\n\n.fvw\n\n BIT QQ12               \\ If bit 7 of QQ12 is clear (i.e. we are not docked, but\n BPL INSP               \\ in space), jump to INSP to skip the following checks\n                        \\ for f1-f3 and \"@\" (save commander file) key presses\n\n CMP #f3                \\ If red key f3 was pressed, jump to EQSHP to show the\n BNE P%+5               \\ Equip Ship screen, returning from the subroutine using\n JMP EQSHP              \\ a tail call\n\n CMP #f1                \\ If red key f1 was pressed, jump to TT219 to show the\n BNE P%+5               \\ Buy Cargo screen, returning from the subroutine using\n JMP TT219              \\ a tail call\n\n CMP #&47               \\ If \"@\" was pressed, jump to SVE to save the commander\n BNE P%+5               \\ file, returning from the subroutine using a tail call\n JMP SVE\n\n CMP #f2                \\ If red key f2 was pressed, jump to TT208 to show the\n BNE LABEL_3            \\ Sell Cargo screen, returning from the subroutine using\n JMP TT208              \\ a tail call\n\n.INSP\n\n CMP #f1                \\ If the key pressed is < red key f1 or > red key f3,\n BCC LABEL_3            \\ jump to LABEL_3 (so only do the following if the key\n CMP #f3+1              \\ pressed is f1, f2 or f3)\n BCS LABEL_3\n\n AND #3                 \\ If we get here then we are either in space, or we are\n TAX                    \\ docked and none of f1-f3 were pressed, so we can now\n JMP LOOK1              \\ process f1-f3 with their in-flight functions, i.e.\n                        \\ switching space views\n                        \\\n                        \\ A will contain &71, &72 or &73 (for f1, f2 or f3), so\n                        \\ set X to the last digit (1, 2 or 3) and jump to LOOK1\n                        \\ to switch to view X (rear, left or right), returning\n                        \\ from the subroutine using a tail call\n\n.LABEL_3\n\n CMP #&54               \\ If \"H\" was pressed, jump to hyp to do a hyperspace\n BNE P%+5               \\ jump (if we are in space), returning from the\n JMP hyp                \\ subroutine using a tail call\n\n CMP #&32               \\ If \"D\" was pressed, jump to T95 to print the distance\n BEQ T95                \\ to a system (if we are in one of the chart screens)\n\n STA T1                 \\ Store A (the key that's been pressed) in T1\n\n LDA QQ11               \\ If the current view is a chart (QQ11 = 64 or 128),\n AND #%11000000         \\ keep going, otherwise jump down to TT107 to skip the\n BEQ TT107              \\ following\n\n LDA QQ22+1             \\ If the on-screen hyperspace counter is non-zero,\n BNE TT107              \\ then we are already counting down, so jump to TT107\n                        \\ to skip the following\n\n LDA T1                 \\ Restore the original value of A (the key that's been\n                        \\ pressed) from T1\n\n CMP #&36               \\ If \"O\" was pressed, do the following three jumps,\n BNE ee2                \\ otherwise skip to ee2 to continue\n\n JSR TT103              \\ Draw small crosshairs at coordinates (QQ9, QQ10),\n                        \\ which will erase the crosshairs currently there\n\n JSR ping               \\ Set the target system to the current system (which\n                        \\ will move the location in (QQ9, QQ10) to the current\n                        \\ home system\n\n JSR TT103              \\ Draw small crosshairs at coordinates (QQ9, QQ10),\n                        \\ which will draw the crosshairs at our current home\n                        \\ system\n\n.ee2\n\n JSR TT16               \\ Call TT16 to move the crosshairs by the amount in X\n                        \\ and Y, which were passed to this subroutine as\n                        \\ arguments\n\n.TT107\n\n LDA QQ22+1             \\ If the on-screen hyperspace counter is zero, return\n BEQ t95                \\ from the subroutine (as t95 contains an RTS), as we\n                        \\ are not currently counting down to a hyperspace jump\n\n DEC QQ22               \\ Decrement the internal hyperspace counter\n\n BNE t95                \\ If the internal hyperspace counter is still non-zero,\n                        \\ then we are still counting down, so return from the\n                        \\ subroutine (as t95 contains an RTS)\n\n                        \\ If we get here then the internal hyperspace counter\n                        \\ has just reached zero and it wasn't zero before, so\n                        \\ we need to reduce the on-screen counter and update\n                        \\ the screen. We do this by first printing the next\n                        \\ number in the countdown sequence, and then printing\n                        \\ the old number, which will erase the old number\n                        \\ and display the new one because printing uses EOR\n                        \\ logic\n\n LDX QQ22+1             \\ Set X = the on-screen hyperspace counter - 1\n DEX                    \\ (i.e. the next number in the sequence)\n\n JSR ee3                \\ Print the 8-bit number in X at text location (0, 1)\n\n LDA #5                 \\ Reset the internal hyperspace counter to 5\n STA QQ22\n\n LDX QQ22+1             \\ Set X = the on-screen hyperspace counter (i.e. the\n                        \\ current number in the sequence, which is already\n                        \\ shown on-screen)\n\n JSR ee3                \\ Print the 8-bit number in X at text location (0, 1),\n                        \\ i.e. print the hyperspace countdown in the top-left\n                        \\ corner\n\n DEC QQ22+1             \\ Decrement the on-screen hyperspace countdown\n\n BNE t95                \\ If the countdown is not yet at zero, return from the\n                        \\ subroutine (as t95 contains an RTS)\n\n JMP TT18               \\ Otherwise the countdown has finished, so jump to TT18\n                        \\ to do a hyperspace jump, returning from the subroutine\n                        \\ using a tail call\n\n.t95\n\n RTS                    \\ Return from the subroutine\n\n.T95\n\n                        \\ If we get here, \"D\" was pressed, so we need to show\n                        \\ the distance to the selected system (if we are in a\n                        \\ chart view)\n\n LDA QQ11               \\ If the current view is a chart (QQ11 = 64 or 128),\n AND #%11000000         \\ keep going, otherwise return from the subroutine (as\n BEQ t95                \\ t95 contains an RTS)\n\n JSR hm                 \\ Call hm to move the crosshairs to the target system\n                        \\ in (QQ9, QQ10), returning with A = 0\n\n STA QQ17               \\ Set QQ17 = 0 to switch to ALL CAPS\n\n JSR cpl                \\ Print control code 3 (the selected system name)\n\n LDA #%10000000         \\ Set bit 7 of QQ17 to switch to Sentence Case, with the\n STA QQ17               \\ next letter in capitals\n\n LDA #1                 \\ Move the text cursor to column 1 and down one line\n STA XC                 \\ (in other words, to the start of the next line)\n INC YC\n\n JMP TT146              \\ Print the distance to the selected system and return\n                        \\ from the subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: BAD\n\\       Type: Subroutine\n\\   Category: Status\n\\    Summary: Calculate how bad we have been\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Work out how bad we are from the amount of contraband in our hold. The\n\\ formula is:\n\\\n\\   (slaves + narcotics) * 2 + firearms\n\\\n\\ so slaves and narcotics are twice as illegal as firearms. The value in FIST\n\\ (our legal status) is set to at least this value whenever we launch from a\n\\ space station, and a FIST of 50 or more gives us fugitive status, so leaving a\n\\ station carrying 25 tonnes of slaves/narcotics, or 50 tonnes of firearms\n\\ across multiple trips, is enough to make us a fugitive.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   A                   A value that determines how bad we are from the amount\n\\                       of contraband in our hold\n\\\n\\ ******************************************************************************\n\n.BAD\n\n LDA QQ20+3             \\ Set A to the number of tonnes of slaves in the hold\n\n CLC                    \\ Clear the C flag so we can do addition without the\n                        \\ C flag affecting the result\n\n ADC QQ20+6             \\ Add the number of tonnes of narcotics in the hold\n\n ASL A                  \\ Double the result and add the number of tonnes of\n ADC QQ20+10            \\ firearms in the hold\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: FAROF\n\\       Type: Subroutine\n\\   Category: Maths (Geometry)\n\\    Summary: Compare x_hi, y_hi and z_hi with 224\n\\  Deep dive: A sense of scale\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Compare x_hi, y_hi and z_hi with 224, and set the C flag if all three <= 224,\n\\ otherwise clear the C flag.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   C flag              Set if x_hi <= 224 and y_hi <= 224 and z_hi <= 224\n\\\n\\                       Clear otherwise (i.e. if any one of them are bigger than\n\\                       224)\n\\\n\\ ******************************************************************************\n\n.FAROF\n\n LDA #224               \\ Set A = 224 and fall through into FAROF2 to do the\n                        \\ comparison\n\n\\ ******************************************************************************\n\\\n\\       Name: FAROF2\n\\       Type: Subroutine\n\\   Category: Maths (Geometry)\n\\    Summary: Compare x_hi, y_hi and z_hi with A\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Compare x_hi, y_hi and z_hi with A, and set the C flag if all three <= A,\n\\ otherwise clear the C flag.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   C flag              Set if x_hi <= A and y_hi <= A and z_hi <= A\n\\\n\\                       Clear otherwise (i.e. if any one of them are bigger than\n\\                       A)\n\\\n\\ ******************************************************************************\n\n.FAROF2\n\n CMP INWK+1             \\ If A < x_hi, C will be clear so jump to MA34 to\n BCC MA34               \\ return from the subroutine with C clear, otherwise\n                        \\ C will be set so move on to the next one\n\n CMP INWK+4             \\ If A < y_hi, C will be clear so jump to MA34 to\n BCC MA34               \\ return from the subroutine with C clear, otherwise\n                        \\ C will be set so move on to the next one\n\n CMP INWK+7             \\ If A < z_hi, C will be clear, otherwise C will be set\n\n.MA34\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: MAS4\n\\       Type: Subroutine\n\\   Category: Maths (Geometry)\n\\    Summary: Calculate a cap on the maximum distance to a ship\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Logical OR the value in A with the high bytes of the ship's position (x_hi,\n\\ y_hi and z_hi).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   A                   A OR x_hi OR y_hi OR z_hi\n\\\n\\ ******************************************************************************\n\n.MAS4\n\n ORA INWK+1             \\ OR A with x_hi, y_hi and z_hi\n ORA INWK+4\n ORA INWK+7\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: DEATH\n\\       Type: Subroutine\n\\   Category: Start and end\n\\    Summary: Display the death screen\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ We have been killed, so display the chaos of our destruction above a \"GAME\n\\ OVER\" sign, and clean up the mess ready for the next attempt.\n\\\n\\ ******************************************************************************\n\n.DEATH\n\n JSR EXNO3              \\ Make the sound of us dying\n\n JSR RES2               \\ Reset a number of flight variables and workspaces\n\n ASL DELTA              \\ Divide our speed in DELTA by 4\n ASL DELTA\n\n LDX #24                \\ Set the screen to only show 24 text rows, which hides\n JSR DET1               \\ the dashboard, setting A to 6 in the process\n\n JSR TT66               \\ Clear the top part of the screen, draw a border box,\n                        \\ and set the current view type in QQ11 to 6 (death\n                        \\ screen)\n\n JSR BOX                \\ Call BOX to redraw the same border box (BOX is part\n                        \\ of TT66), which removes the border as it is drawn\n                        \\ using EOR logic\n\n JSR nWq                \\ Create a cloud of stardust containing the correct\n                        \\ number of dust particles (i.e. NOSTM of them)\n\n LDA #12                \\ Move the text cursor to column 12 on row 12\n STA YC\n STA XC\n\n LDA #146               \\ Print recursive token 146 (\"{all caps}GAME OVER\")\n JSR ex\n\n.D1\n\n JSR Ze                 \\ Call Ze to initialise INWK to a fairly aggressive\n                        \\ ship, and set A and X to random values\n\n LSR A                  \\ Set A = A / 4, so A is now between 0 and 63, and\n LSR A                  \\ store in byte #0 (x_lo)\n STA INWK\n\n LDY #0                 \\ Set the following to 0: the current view in QQ11\n STY QQ11               \\ (space view), x_hi, y_hi, z_hi and the AI flag (no AI\n STY INWK+1             \\ or E.C.M. and zero aggression)\n STY INWK+4\n STY INWK+7\n STY INWK+32\n\n DEY                    \\ Set Y = 255\n\n STY MCNT               \\ Reset the main loop counter to 255, so all timer-based\n                        \\ calls will be stopped\n\n STY LASCT              \\ Set the laser count to 255 to act as a counter in the\n                        \\ D2 loop below, so this setting determines how long the\n                        \\ death animation lasts (it's 5.1 seconds, as LASCT is\n                        \\ decremented every vertical sync, or 50 times a second,\n                        \\ and 255 / 50 = 5.1)\n\n EOR #%00101010         \\ Flip bits 1, 3 and 5 in A (x_lo) to get another number\n STA INWK+3             \\ between 48 and 63, and store in byte #3 (y_lo)\n\n ORA #%01010000         \\ Set bits 4 and 6 of A to bump it up to between 112 and\n STA INWK+6             \\ 127, and store in byte #6 (z_lo)\n\n TXA                    \\ Set A to the random number in X and keep bits 0-3 and\n AND #%10001111         \\ the sign in bit 7 to get a number between -15 and +15,\n STA INWK+29            \\ and store in byte #29 (roll counter) to give our ship\n                        \\ a gentle roll with damping\n\n ROR A                  \\ The C flag is randomly set from the above call to Ze,\n AND #%10000111         \\ so this sets A to a number between -7 and +7, which\n STA INWK+30            \\ we store in byte #30 (the pitch counter) to give our\n                        \\ ship a very gentle pitch with damping\n\n PHP                    \\ Store the processor flags\n\n LDX #OIL               \\ Call fq1 with X set to #OIL, which adds a new cargo\n JSR fq1                \\ canister to our local bubble of universe and points it\n                        \\ away from us with double DELTA speed (i.e. 6, as DELTA\n                        \\ was set to 3 by the call to RES2 above). INF is set to\n                        \\ point to the canister's ship data block in K%\n\n PLP                    \\ Restore the processor flags, including our random C\n                        \\ flag from before\n\n LDA #0                 \\ Set bit 7 of A to our random C flag and store in byte\n ROR A                  \\ #31 of the ship's data block, so this has a 50% chance\n LDY #31                \\ of marking our new canister as being killed (so it\n STA (INF),Y            \\ will explode)\n\n LDA FRIN+3             \\ The call we made to RES2 before we entered the loop at\n BEQ D1                 \\ D1 will have reset all the ship slots at FRIN, so this\n                        \\ checks to see if the fourth slot is empty, and if it\n                        \\ is we loop back to D1 to add another canister, until\n                        \\ we have added four of them\n\n JSR U%                 \\ Clear the key logger, which also sets A = 0\n\n STA DELTA              \\ Set our speed in DELTA to 0, as we aren't going\n                        \\ anywhere any more\n\n.D2\n\n JSR M%                 \\ Call the M% routine to do the main flight loop once,\n                        \\ which will display our exploding canister scene and\n                        \\ move everything about\n\n LDA LASCT              \\ Loop back to D2 to run the main flight loop until\n BNE D2                 \\ LASCT reaches zero (which will take 5.1 seconds, as\n                        \\ explained above)\n\n LDX #31                \\ Set the screen to show all 31 text rows, which shows\n JSR DET1               \\ the dashboard\n\n                        \\ Fall through into DEATH2 to reset and restart the game\n\n\\ ******************************************************************************\n\\\n\\       Name: DEATH2\n\\       Type: Subroutine\n\\   Category: Start and end\n\\    Summary: Reset most of the game and restart from the title screen\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine is called following death, and when the game is quit by pressing\n\\ ESCAPE when paused.\n\\\n\\ ******************************************************************************\n\n.DEATH2\n\n JSR RES2               \\ Reset a number of flight variables and workspaces\n                        \\ and fall through into the entry code for the game\n                        \\ to restart from the title screen\n\n\\ ******************************************************************************\n\\\n\\       Name: TT170\n\\       Type: Subroutine\n\\   Category: Start and end\n\\    Summary: Main entry point for the Elite game code\n\\  Deep dive: Program flow of the main game loop\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This is the main entry point for the main game code.\n\\\n\\ ******************************************************************************\n\n.TT170\n\n LDX #&FF               \\ Set the stack pointer to &01FF, which is the standard\n TXS                    \\ location for the 6502 stack, so this instruction\n                        \\ effectively resets the stack. We need to do this\n                        \\ because the loader code in elite-loader.asm pushes\n                        \\ code onto the stack, and this effectively removes that\n                        \\ code so we start afresh\n\n                        \\ Fall through into BR1 to start the game\n\n\\ ******************************************************************************\n\\\n\\       Name: BR1 (Part 1 of 2)\n\\       Type: Subroutine\n\\   Category: Start and end\n\\    Summary: Show the \"Load New Commander (Y/N)?\" screen and start the game\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ BRKV is set to point to BR1 by the loading process.\n\\\n\\ ******************************************************************************\n\n.BR1\n\n LDX #3                 \\ Set XC = 3 (set text cursor to column 3)\n STX XC\n\n JSR FX200              \\ Disable the ESCAPE key and clear memory if the BREAK\n                        \\ key is pressed (*FX 200,3)\n\n LDX #CYL               \\ Call TITLE to show a rotating Cobra Mk III (#CYL) and\n LDA #128               \\ token 128 (\"  LOAD NEW COMMANDER (Y/N)?{crlf}{crlf}\"),\n JSR TITLE              \\ returning with the internal number of the key pressed\n                        \\ in A\n\n CMP #&44               \\ Did we press \"Y\"? If not, jump to QU5, otherwise\n BNE QU5                \\ continue on to load a new commander\n\n\\.BR1                   \\ These instructions are commented out in the original\n\\\n\\LDX #3                 \\ source. This block starts with the same *FX call as\n\\STX XC                 \\ above, then clears the screen, calls a routine to\n\\                       \\ flush the keyboard buffer (FLKB) that isn't present\n\\JSR FX200              \\ in the cassette version but is in other versions,\n\\                       \\ and then it displays \"LOAD NEW COMMANDER (Y/N)?\" and\n\\LDA #1                 \\ lists the current cargo, before falling straight into\n\\JSR TT66               \\ the load routine below, whether or not we have\n\\                       \\ pressed \"Y\". This may be a bit of testing code, as the\n\\JSR FLKB               \\ first line is a commented label, BR1, which is where\n\\                       \\ BRKV points, so when this is uncommented, any BRK\n\\LDA #14                \\ instructions will jump straight to the load screen\n\\JSR TT214\n\\\n\\BCC QU5\n\n JSR GTNME              \\ We want to load a new commander, so we need to get\n                        \\ the commander name to load\n\n JSR LOD                \\ We then call the LOD subroutine to load the commander\n                        \\ file to address NA%+8, which is where we store the\n                        \\ commander save file\n\n JSR TRNME              \\ Once loaded, we copy the commander name to NA%\n\n JSR TTX66              \\ And we clear the top part of the screen and draw a\n                        \\ border box\n\n\\ ******************************************************************************\n\\\n\\       Name: QU5\n\\       Type: Subroutine\n\\   Category: Start and end\n\\    Summary: Reset the current commander data block to the last saved commander\n\\\n\\ ******************************************************************************\n\n.QU5\n\n                        \\ By the time we get here, the correct commander name\n                        \\ is at NA% and the correct commander data is at NA%+8.\n                        \\ Specifically:\n                        \\\n                        \\   * If we loaded a commander file, then the name and\n                        \\     data from that file will be at NA% and NA%+8\n                        \\\n                        \\   * If this is a brand new game, then NA% will contain\n                        \\     the default starting commander name (\"JAMESON\")\n                        \\     and NA%+8 will contain the default commander data\n                        \\\n                        \\   * If this is not a new game (because they died or\n                        \\     quit) and we didn't want to load a commander file,\n                        \\     then NA% will contain the last saved commander\n                        \\     name, and NA%+8 the last saved commander data. If\n                        \\     the game has never been saved, this will still be\n                        \\     the default commander\n\n\\JSR TTX66              \\ This instruction is commented out in the original\n                        \\ source; it clears the screen and draws a border\n\n LDX #NT%               \\ The size of the commander data block is NT% bytes,\n                        \\ and it starts at NA%+8, so we need to copy the data\n                        \\ from the \"last saved\" buffer at NA%+8 to the current\n                        \\ commander workspace at TP. So we set up a counter in X\n                        \\ for the NT% bytes that we want to copy\n\n.QUL1\n\n LDA NA%+7,X            \\ Copy the X-th byte of NA%+7 to the X-th byte of TP-1,\n STA TP-1,X             \\ (the -1 is because X is counting down from NT% to 1)\n\n DEX                    \\ Decrement the loop counter\n\n BNE QUL1               \\ Loop back for the next byte of the commander data\n                        \\ block\n\n STX QQ11               \\ X is 0 by the end of the above loop, so this sets QQ11\n                        \\ to 0, which means we will be showing a view without a\n                        \\ boxed title at the top (i.e. we're going to use the\n                        \\ screen layout of a space view in the following)\n\n                        \\ If the commander check below fails, we keep jumping\n                        \\ back to here to crash the game with an infinite loop\n\n JSR CHECK              \\ Call the CHECK subroutine to calculate the checksum\n                        \\ for the current commander block at NA%+8 and put it\n                        \\ in A\n\n CMP CHK                \\ Test the calculated checksum against CHK\n\nIF _REMOVE_CHECKSUMS\n\n NOP                    \\ If we have disabled checksums, then ignore the result\n NOP                    \\ of the comparison and fall through into the next part\n\nELSE\n\n BNE P%-6               \\ If the calculated checksum does not match CHK, then\n                        \\ loop back to repeat the check - in other words, we\n                        \\ enter an infinite loop here, as the checksum routine\n                        \\ will keep returning the same incorrect value\n\nENDIF\n\n                        \\ The checksum CHK is correct, so now we check whether\n                        \\ CHK2 = CHK EOR A9, and if this check fails, bit 7 of\n                        \\ the competition flags at COK gets set, to indicate\n                        \\ to Acornsoft via the competition code that there has\n                        \\ been some hacking going on with this competition entry\n\n EOR #&A9               \\ X = checksum EOR &A9\n TAX\n\n LDA COK                \\ Set A to the competition flags in COK\n\n CPX CHK2               \\ If X = CHK2, then skip the next instruction\n BEQ tZ\n\n ORA #%10000000         \\ Set bit 7 of A to indicate this commander file has\n                        \\ been tampered with\n\n.tZ\n\n ORA #%00000010         \\ Set bit 1 of A to denote that this is the cassette\n                        \\ version\n\n STA COK                \\ Store the updated competition flags in COK\n\n\\ ******************************************************************************\n\\\n\\       Name: BR1 (Part 2 of 2)\n\\       Type: Subroutine\n\\   Category: Start and end\n\\    Summary: Show the \"Press Fire or Space, Commander\" screen and start the\n\\             game\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ BRKV is set to point to BR1 by the loading process.\n\\\n\\ ******************************************************************************\n\n JSR msblob             \\ Reset the dashboard's missile indicators so none of\n                        \\ them are targeted\n\n LDA #147               \\ Call TITLE to show a rotating Mamba (#3) and token\n LDX #3                 \\ 147 (\"PRESS FIRE OR SPACE,COMMANDER.{crlf}{crlf}\"),\n JSR TITLE              \\ returning with the internal number of the key pressed\n                        \\ in A\n\n JSR ping               \\ Set the target system coordinates (QQ9, QQ10) to the\n                        \\ current system coordinates (QQ0, QQ1) we just loaded\n\n JSR hyp1               \\ Arrive in the system closest to (QQ9, QQ10)\n\n                        \\ Fall through into the docking bay routine below\n\n\\ ******************************************************************************\n\\\n\\       Name: BAY\n\\       Type: Subroutine\n\\   Category: Status\n\\    Summary: Go to the docking bay (i.e. show the Status Mode screen)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ We end up here after the start-up process (load commander etc.), as well as\n\\ after a successful save, an escape pod launch, a successful docking, the end\n\\ of a cargo sell, and various errors (such as not having enough cash, entering\n\\ too many items when buying, trying to fit an item to your ship when you\n\\ already have it, running out of cargo space, and so on).\n\\\n\\ ******************************************************************************\n\n.BAY\n\n LDA #&FF               \\ Set QQ12 = &FF (the docked flag) to indicate that we\n STA QQ12               \\ are docked\n\n LDA #f8                \\ Jump into the main loop at FRCE, setting the key\n JMP FRCE               \\ that's \"pressed\" to red key f8 (so we show the Status\n                        \\ Mode screen)\n\n\\ ******************************************************************************\n\\\n\\       Name: TITLE\n\\       Type: Subroutine\n\\   Category: Start and end\n\\    Summary: Display a title screen with a rotating ship and prompt\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Display the title screen, with a rotating ship and a text token at the bottom\n\\ of the screen.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The number of the recursive token to show below the\n\\                       rotating ship (see variable QQ18 for details of\n\\                       recursive tokens)\n\\\n\\   X                   The type of the ship to show (see variable XX21 for a\n\\                       list of ship types)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   X                   If a key is being pressed, X contains the internal key\n\\                       number, otherwise it contains 0\n\\\n\\ ******************************************************************************\n\n.TITLE\n\n PHA                    \\ Store the token number on the stack for later\n\n STX TYPE               \\ Store the ship type in location TYPE\n\n JSR RESET              \\ Reset our ship so we can use it for the rotating\n                        \\ title ship\n\n LDA #1                 \\ Clear the top part of the screen, draw a border box,\n JSR TT66               \\ and set the current view type in QQ11 to 1\n\n DEC QQ11               \\ Decrement QQ11 to 0, so from here on we are using a\n                        \\ space view\n\n LDA #96                \\ Set nosev_z hi = 96 (96 is the value of unity in the\n STA INWK+14            \\ rotation vector)\n\n\\LSR A                  \\ This instruction is commented out in the original\n                        \\ source. It would halve the value of z_hi to 48, so the\n                        \\ ship would start off closer to the viewer\n\n STA INWK+7             \\ Set z_hi, the high byte of the ship's z-coordinate,\n                        \\ to 96, which is the distance at which the rotating\n                        \\ ship starts out before coming towards us\n\n LDX #127               \\ Set roll counter = 127, so don't dampen the roll and\n STX INWK+29            \\ make the roll direction clockwise\n\n STX INWK+30            \\ Set pitch counter = 127, so don't dampen the pitch and\n                        \\ set the pitch direction to dive\n\n INX                    \\ Set QQ17 to 128 (so bit 7 is set) to switch to\n STX QQ17               \\ Sentence Case, with the next letter printing in upper\n                        \\ case\n\n LDA TYPE               \\ Set up a new ship, using the ship type in TYPE\n JSR NWSHP\n\n LDY #6                 \\ Move the text cursor to column 6\n STY XC\n\n JSR DELAY              \\ Wait for 6/50 of a second (0.12 seconds)\n\n LDA #30                \\ Print recursive token 144 (\"---- E L I T E ----\")\n JSR plf                \\ followed by a newline\n\n LDY #6                 \\ Move the text cursor to column 6 again\n STY XC\n\n INC YC                 \\ Move the text cursor down a row\n\n LDA PATG               \\ If PATG = 0, skip the following two lines, which\n BEQ awe                \\ print the author credits (PATG can be toggled by\n                        \\ pausing the game and pressing \"X\")\n\n LDA #254               \\ Print recursive token 94 (\"BY D.BRABEN & I.BELL\")\n JSR TT27\n\n.awe\n\n JSR CLYNS              \\ Clear the bottom three text rows of the upper screen,\n                        \\ and move the text cursor to the first cleared row.\n                        \\ It also returns with Y = 0\n\n STY DELTA              \\ Set DELTA = 0 (i.e. ship speed = 0)\n\n STY JSTK               \\ Set JSTK = 0 (i.e. keyboard, not joystick)\n\n PLA                    \\ Restore the recursive token number we stored on the\n JSR ex                 \\ stack at the start of this subroutine, and print that\n                        \\ token\n\n LDA #148               \\ Set A to recursive token 148\n\n LDX #7                 \\ Move the text cursor to column 7\n STX XC\n\n JSR ex                 \\ Print recursive token 148 (\"(C) ACORNSOFT 1984\")\n\n.TLL2\n\n LDA INWK+7             \\ If z_hi (the ship's distance) is 1, jump to TL1 to\n CMP #1                 \\ skip the following decrement\n BEQ TL1\n\n DEC INWK+7             \\ Decrement the ship's distance, to bring the ship\n                        \\ a bit closer to us\n\n.TL1\n\n JSR MVEIT              \\ Move the ship in space according to the orientation\n                        \\ vectors and the new value in z_hi\n\n LDA #128               \\ Set z_lo = 128, so the closest the ship gets to us is\n STA INWK+6             \\ z_hi = 1, z_lo = 128, or 256 + 128 = 384\n\n ASL A                  \\ Set A = 0\n\n STA INWK               \\ Set x_lo = 0, so the ship remains in the screen centre\n\n STA INWK+3             \\ Set y_lo = 0, so the ship remains in the screen centre\n\n JSR LL9                \\ Call LL9 to display the ship\n\n DEC MCNT               \\ Decrement the main loop counter\n\n LDA VIA+&40            \\ Read 6522 System VIA input register IRB (SHEILA &40)\n\n AND #%00010000         \\ Bit 4 of IRB (PB4) is clear if joystick 1's fire\n                        \\ button is pressed, otherwise it is set, so AND'ing\n                        \\ the value of IRB with %10000 extracts this bit\n\n\\TAX                    \\ This instruction is commented out in the original\n                        \\ source; it would have no effect, as the comparison\n                        \\ flags are already set by the AND, and the value of X\n                        \\ is not used anywhere\n\n BEQ TL2                \\ If the joystick fire button is pressed, jump to TL2\n\n JSR RDKEY              \\ Scan the keyboard for a key press and return the\n                        \\ internal key number in A and X (or 0 for no key press)\n\n BEQ TLL2               \\ If no key was pressed, loop back up to move/rotate\n                        \\ the ship and check again for a key press\n\n RTS                    \\ Return from the subroutine\n\n.TL2\n\n DEC JSTK               \\ Joystick fire button was pressed, so set JSTK to &FF\n                        \\ (it was set to 0 above), to disable keyboard and\n                        \\ enable joysticks\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: CHECK\n\\       Type: Subroutine\n\\   Category: Save and load\n\\    Summary: Calculate the checksum for the last saved commander data block\n\\  Deep dive: Commander save files\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The checksum for the last saved commander data block is saved as part of the\n\\ commander file, in two places (CHK AND CHK2), to protect against file\n\\ tampering. This routine calculates the checksum and returns it in A.\n\\\n\\ This algorithm is also implemented in elite-checksum.py.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   A                   The checksum for the last saved commander data block\n\\\n\\ ******************************************************************************\n\n.CHECK\n\n LDX #NT%-2             \\ Set X to the size of the commander data block, less\n                        \\ 2 (to omit the checksum bytes and the save count)\n\n CLC                    \\ Clear the C flag so we can do addition without the\n                        \\ C flag affecting the result\n\n TXA                    \\ Seed the checksum calculation by setting A to the\n                        \\ size of the commander data block, less 2\n\n                        \\ We now loop through the commander data block,\n                        \\ starting at the end and looping down to the start\n                        \\ (so at the start of this loop, the X-th byte is the\n                        \\ last byte of the commander data block, i.e. the save\n                        \\ count)\n\n.QUL2\n\n ADC NA%+7,X            \\ Add the X-1-th byte of the data block to A, plus the\n                        \\ C flag\n\n EOR NA%+8,X            \\ EOR A with the X-th byte of the data block\n\n DEX                    \\ Decrement the loop counter\n\n BNE QUL2               \\ Loop back for the next byte in the calculation, until\n                        \\ we have added byte #0 and EOR'd with byte #1 of the\n                        \\ data block\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: TRNME\n\\       Type: Subroutine\n\\   Category: Save and load\n\\    Summary: Copy the last saved commander's name from INWK to NA%\n\\\n\\ ******************************************************************************\n\n.TRNME\n\n LDX #7                 \\ The commander's name can contain a maximum of 7\n                        \\ characters, and is terminated by a carriage return,\n                        \\ so set up a counter in X to copy 8 characters\n\n.GTL1\n\n LDA INWK,X             \\ Copy the X-th byte of INWK to the X-th byte of NA%\n STA NA%,X\n\n DEX                    \\ Decrement the loop counter\n\n BPL GTL1               \\ Loop back until we have copied all 8 bytes\n\n                        \\ Fall through into TR1 to copy the name back from NA%\n                        \\ to INWK. This isn't necessary as the name is already\n                        \\ there, but it does save one byte, as we don't need an\n                        \\ RTS here\n\n\\ ******************************************************************************\n\\\n\\       Name: TR1\n\\       Type: Subroutine\n\\   Category: Save and load\n\\    Summary: Copy the last saved commander's name from NA% to INWK\n\\\n\\ ******************************************************************************\n\n.TR1\n\n LDX #7                 \\ The commander's name can contain a maximum of 7\n                        \\ characters, and is terminated by a carriage return,\n                        \\ so set up a counter in X to copy 8 characters\n\n.GTL2\n\n LDA NA%,X              \\ Copy the X-th byte of NA% to the X-th byte of INWK\n STA INWK,X\n\n DEX                    \\ Decrement the loop counter\n\n BPL GTL2               \\ Loop back until we have copied all 8 bytes\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: GTNME\n\\       Type: Subroutine\n\\   Category: Save and load\n\\    Summary: Fetch the name of a commander file to save or load\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Get the commander's name for loading or saving a commander file. The name is\n\\ stored in the INWK workspace and is terminated by a return character (13).\n\\\n\\ If ESCAPE is pressed or a blank name is entered, then the name stored is set\n\\ to the name from the last saved commander block.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   INWK                The commander name entered, terminated by a return\n\\                       character (13)\n\\\n\\ ******************************************************************************\n\n.GTNME\n\n LDA #1                 \\ Clear the top part of the screen, draw a border box,\n JSR TT66               \\ and set the current view type in QQ11 to 1\n\n LDA #123               \\ Print recursive token 123 (\"{crlf}COMMANDER'S NAME? \")\n JSR TT27\n\n JSR DEL8               \\ Wait for 8/50 of a second (0.16 seconds)\n\n LDA #%10000001         \\ Clear 6522 System VIA interrupt enable register IER\n STA VIA+&4E            \\ (SHEILA &4E) bit 1 (i.e. enable the CA2 interrupt,\n                        \\ which comes from the keyboard)\n\n LDA #15                \\ Call OSBYTE with A = 15 (flush all buffers)\n TAX\n JSR OSBYTE\n\n LDX #LO(RLINE)         \\ Set (Y X) to point to the RLINE parameter block\n LDY #HI(RLINE)         \\ configuration block below\n\n LDA #0                 \\ Call OSWORD with A = 0 to read a line from the current\n JSR OSWORD             \\ input stream (i.e. the keyboard)\n\n\\LDA #%00000001         \\ These instructions are commented out in the original\n\\STA VIA+&4E            \\ source, but they would set 6522 System VIA interrupt\n                        \\ enable register IER (SHEILA &4E) bit 1 (i.e. disable\n                        \\ the CA2 interrupt, which comes from the keyboard)\n\n BCS TR1                \\ The C flag will be set if we pressed ESCAPE when\n                        \\ entering the name, in which case jump to TR1 to copy\n                        \\ the last saved commander's name from NA% to INWK\n                        \\ and return from the subroutine there\n\n TYA                    \\ The OSWORD call returns the length of the commander's\n                        \\ name in Y, so transfer this to A\n\n BEQ TR1                \\ If A = 0, no name was entered, so jump to TR1 to copy\n                        \\ the last saved commander's name from NA% to INWK\n                        \\ and return from the subroutine there\n\n JMP TT67               \\ We have a name, so jump to TT67 to print a newline\n                        \\ and return from the subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: RLINE\n\\       Type: Variable\n\\   Category: Text\n\\    Summary: The OSWORD configuration block used to fetch a line of text from\n\\             the keyboard\n\\\n\\ ******************************************************************************\n\n.RLINE\n\n EQUW INWK              \\ The address to store the input, so the commander's\n                        \\ name will be stored in INWK as it is typed\n\n EQUB 7                 \\ Maximum line length = 7, as that's the maximum size\n                        \\ for a commander's name\n\n EQUB '!'               \\ Allow ASCII characters from \"!\" through to \"z\" in\n EQUB 'z'               \\ the name\n\n\\ ******************************************************************************\n\\\n\\       Name: ZERO\n\\       Type: Subroutine\n\\   Category: Utility routines\n\\    Summary: Zero-fill pages &9, &A, &B, &C and &D\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This resets the following workspaces to zero:\n\\\n\\   * The ship data blocks ascending from K% at &0900\n\\\n\\   * The ship line heap descending from WP at &0D40\n\\\n\\   * WP workspace variables from FRIN to de, which include the ship slots for\n\\     the local bubble of universe, and various flight and ship status variables\n\\     (only a portion of the LSX/LSO sun line heap is cleared)\n\\\n\\ ******************************************************************************\n\n.ZERO\n\n LDX #&D                \\ Point X to page &D\n\n.ZEL\n\n JSR ZES1               \\ Call ZES1 to zero-fill the page in X\n\n DEX                    \\ Decrement X to point to the next page\n\n CPX #9                 \\ If X is > 9 (i.e. is &A, &B or &C), then loop back\n BNE ZEL                \\ up to clear the next page\n\n                        \\ Then fall through into ZES1 with X set to 9, so we\n                        \\ clear page &9 too\n\n\\ ******************************************************************************\n\\\n\\       Name: ZES1\n\\       Type: Subroutine\n\\   Category: Utility routines\n\\    Summary: Zero-fill the page whose number is in X\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   The page we want to zero-fill\n\\\n\\ ******************************************************************************\n\n.ZES1\n\n LDY #0                 \\ If we set Y = SC = 0 and fall through into ZES2\n STY SC                 \\ below, then we will zero-fill 255 bytes starting from\n                        \\ SC - in other words, we will zero-fill the whole of\n                        \\ page X\n\n\\ ******************************************************************************\n\\\n\\       Name: ZES2\n\\       Type: Subroutine\n\\   Category: Utility routines\n\\    Summary: Zero-fill a specific page\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Zero-fill from address (X SC) + Y to (X SC) + &FF.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   The high byte (i.e. the page) of the starting point of\n\\                       the zero-fill\n\\\n\\   Y                   The offset from (X SC) where we start zeroing, counting\n\\                       up to &FF\n\\\n\\   SC                  The low byte (i.e. the offset into the page) of the\n\\                       starting point of the zero-fill\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   Z flag              Z flag is set\n\\\n\\ ******************************************************************************\n\n.ZES2\n\n LDA #0                 \\ Load A with the byte we want to fill the memory block\n                        \\ with - i.e. zero\n\n STX SC+1               \\ We want to zero-fill page X, so store this in the\n                        \\ high byte of SC, so the 16-bit address in SC and\n                        \\ SC+1 is now pointing to the SC-th byte of page X\n\n.ZEL1\n\n STA (SC),Y             \\ Zero the Y-th byte of the block pointed to by SC,\n                        \\ so that's effectively the Y-th byte before SC\n\n INY                    \\ Increment the loop counter\n\n BNE ZEL1               \\ Loop back to zero the next byte\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: SVE\n\\       Type: Subroutine\n\\   Category: Save and load\n\\    Summary: Save the commander file\n\\  Deep dive: Commander save files\n\\             The competition code\n\\\n\\ ******************************************************************************\n\n.SVE\n\n JSR GTNME              \\ Clear the screen and ask for the commander filename\n                        \\ to save, storing the name at INWK\n\n JSR TRNME              \\ Transfer the commander filename from INWK to NA%\n\n JSR ZERO               \\ Zero-fill pages &9, &A, &B, &C and &D, which clears\n                        \\ the ship data blocks, the ship line heap, the ship\n                        \\ slots for the local bubble of universe, and various\n                        \\ flight and ship status variables\n\n LSR SVC                \\ Halve the save count value in SVC\n\n LDX #NT%               \\ We now want to copy the current commander data block\n                        \\ from location TP to the last saved commander block at\n                        \\ NA%+8, so set a counter in X to copy the NT% bytes in\n                        \\ the commander data block\n                        \\\n                        \\ We also want to copy the data block to another\n                        \\ location &0B00, which is normally used for the ship\n                        \\ lines heap\n\n.SVL1\n\n LDA TP,X               \\ Copy the X-th byte of TP to the X-th byte of &0B00\n STA &0B00,X            \\ and NA%+8\n STA NA%+8,X\n\n DEX                    \\ Decrement the loop counter\n\n BPL SVL1               \\ Loop back until we have copied all the bytes in the\n                        \\ commander data block\n\n JSR CHECK              \\ Call CHECK to calculate the checksum for the last\n                        \\ saved commander and return it in A\n\n STA CHK                \\ Store the checksum in CHK, which is at the end of the\n                        \\ last saved commander block\n\n PHA                    \\ Store the checksum on the stack\n\n ORA #%10000000         \\ Set K = checksum with bit 7 set\n STA K\n\n EOR COK                \\ Set K+2 = K EOR COK (the competition flags)\n STA K+2\n\n EOR CASH+2             \\ Set K+1 = K+2 EOR CASH+2 (the third cash byte)\n STA K+1\n\n EOR #&5A               \\ Set K+3 = K+1 EOR &5A EOR TALLY+1 (the high byte of\n EOR TALLY+1            \\ the kill tally)\n STA K+3\n\n JSR BPRNT              \\ Print the competition number stored in K to K+3. The\n                        \\ value of U might affect how this is printed, and as\n                        \\ it's a temporary variable in zero page that isn't\n                        \\ reset by ZERO, it might have any value, but as the\n                        \\ competition code is a 10-digit number, this just means\n                        \\ it may or may not have an extra space of padding\n\n JSR TT67               \\ Call TT67 twice to print two newlines\n JSR TT67\n\n PLA                    \\ Restore the checksum from the stack\n\n STA &0B00+NT%          \\ Store the checksum in the last byte of the save file\n                        \\ at &0B00 (the equivalent of CHK in the last saved\n                        \\ block)\n\n EOR #&A9               \\ Store the checksum EOR &A9 in CHK2, the penultimate\n STA CHK2               \\ byte of the last saved commander block\n\n STA &0AFF+NT%          \\ Store the checksum EOR &A9 in the penultimate byte of\n                        \\ the save file at &0B00 (the equivalent of CHK2 in the\n                        \\ last saved block)\n\n LDY #&B                \\ Set up an OSFILE block at &0C00, containing:\n STY &0C0B              \\\n INY                    \\ Start address for save = &00000B00 in &0C0A to &0C0D\n STY &0C0F              \\\n                        \\ End address for save = &00000C00 in &0C0E to &0C11\n                        \\\n                        \\ Y is left containing &C which we use below\n\n LDA #%10000001         \\ Clear 6522 System VIA interrupt enable register IER\n STA VIA+&4E            \\ (SHEILA &4E) bit 1 (i.e. enable the CA2 interrupt,\n                        \\ which comes from the keyboard)\n\n INC SVN                \\ Increment SVN to indicate we are about to start saving\n\n LDA #0                 \\ Call QUS1 with A = 0, Y = &C to save the commander\n JSR QUS1               \\ file with the filename we copied to INWK at the start\n                        \\ of this routine\n\n LDX #0                 \\ Set X = 0 for storing in SVN below\n\n\\STX VIA+&4E            \\ This instruction is commented out in the original\n                        \\ source. It would affect the 6522 System VIA interrupt\n                        \\ enable register IER (SHEILA &4E) if any of bits 0-6\n                        \\ of X were set, but they aren't, so this instruction\n                        \\ would have no effect anyway\n\n\\DEX                    \\ This instruction is commented out in the original\n                        \\ source. It would end up setting SVN to &FF, which\n                        \\ affects the logic in the IRQ1 handler\n\n STX SVN                \\ Set SVN to 0 to indicate we are done saving\n\n JMP BAY                \\ Go to the docking bay (i.e. show Status Mode)\n\n\\ ******************************************************************************\n\\\n\\       Name: QUS1\n\\       Type: Subroutine\n\\   Category: Save and load\n\\    Summary: Save or load the commander file\n\\  Deep dive: Commander save files\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The filename should be stored at INWK, terminated with a carriage return (13).\n\\ The routine should be called with Y set to &C.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   File operation to be performed. Can be one of the\n\\                       following:\n\\\n\\                         * 0 (save file)\n\\\n\\                         * &FF (load file)\n\\\n\\   Y                   Points to the page number containing the OSFILE block,\n\\                       which must be &C because that's where the pointer to the\n\\                       filename in INWK is stored below (by the STX &0C00\n\\                       instruction)\n\\\n\\ ******************************************************************************\n\n.QUS1\n\n LDX #INWK              \\ Store a pointer to INWK at the start of the block at\n STX &0C00              \\ &0C00, storing #INWK in the low byte because INWK is\n                        \\ in zero page\n\n LDX #0                 \\ Set X to 0 so (Y X) = &0C00\n\n JMP OSFILE             \\ Jump to OSFILE to do the file operation specified in\n                        \\ &0C00 (i.e. save or load a file depending on the value\n                        \\ of A), returning from the subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: LOD\n\\       Type: Subroutine\n\\   Category: Save and load\n\\    Summary: Load a commander file\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The filename should be stored at INWK, terminated with a carriage return (13).\n\\\n\\ ******************************************************************************\n\n.LOD\n\n LDX #2                 \\ Enable the ESCAPE key and clear memory if the BREAK\n JSR FX200              \\ key is pressed (*FX 200,2)\n\n JSR ZERO               \\ Zero-fill pages &9, &A, &B, &C and &D, which clears\n                        \\ the ship data blocks, the ship line heap, the ship\n                        \\ slots for the local bubble of universe, and various\n                        \\ flight and ship status variables\n\n LDY #&B                \\ Set up an OSFILE block at &0C00, containing:\n STY &0C03              \\\n INC &0C0B              \\ Load address = &00000B00 in &0C02 to &0C05\n                        \\\n                        \\ Length of file = &00000100 in &0C0A to &0C0D\n\n INY                    \\ Increment Y to &C, which we use next\n\n LDA #&FF               \\ Call QUS1 with A = &FF, Y = &C to load the commander\n JSR QUS1               \\ file to address &0B00\n\n LDA &0B00              \\ If the first byte of the loaded file has bit 7 set,\n BMI SPS1+1             \\ jump to SPS+1, which is the second byte of an LDA #0\n                        \\ instruction, i.e. a BRK instruction, which will force\n                        \\ an interrupt to call the address in BRKV, which is set\n                        \\ to BR1... so this instruction restarts the game from\n                        \\ the title screen. Valid commander files for the\n                        \\ cassette version of Elite only have 0 for the first\n                        \\ byte, as there are no missions in this version, so\n                        \\ having bit 7 set is invalid anyway\n\n LDX #NT%               \\ We have successfully loaded the commander file at\n                        \\ &0B00, so now we want to copy it to the last saved\n                        \\ commander data block at NA%+8, so we set up a counter\n                        \\ in X to copy NT% bytes\n\n.LOL1\n\n LDA &0B00,X            \\ Copy the X-th byte of &0B00 to the X-th byte of NA%+8\n STA NA%+8,X\n\n DEX                    \\ Decrement the loop counter\n\n BPL LOL1               \\ Loop back until we have copied all NT% bytes\n\n LDX #3                 \\ Fall through into FX200 to disable the ESCAPE key and\n                        \\ clear memory if the BREAK key is pressed (*FX 200,3)\n                        \\ and return from the subroutine there\n\n\\ ******************************************************************************\n\\\n\\       Name: FX200\n\\       Type: Subroutine\n\\   Category: Utility routines\n\\    Summary: Set the behaviour of the ESCAPE and BREAK keys\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This is the equivalent of a *FX 200 command, which controls the behaviour of\n\\ the ESCAPE and BREAK keys.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   Controls the behaviour as follows:\n\\\n\\                         * 0 = Enable ESCAPE key\n\\                               Normal BREAK key action\n\\\n\\                         * 1 = Disable ESCAPE key\n\\                               Normal BREAK key action\n\\\n\\                         * 2 = Enable ESCAPE key\n\\                               Clear memory if the BREAK key is pressed\n\\\n\\                         * 3 = Disable ESCAPE key\n\\                               Clear memory if the BREAK key is pressed\n\\\n\\ ******************************************************************************\n\n.FX200\n\n LDY #0                 \\ Call OSBYTE 200 with Y = 0, so the new value is set to\n LDA #200               \\ X, and return from the subroutine using a tail call\n JMP OSBYTE\n\n RTS                    \\ This instruction has no effect, as we already returned\n                        \\ from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: SPS1\n\\       Type: Subroutine\n\\   Category: Maths (Geometry)\n\\    Summary: Calculate the vector to the planet and store it in XX15\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   SPS1+1              A BRK instruction\n\\\n\\ ******************************************************************************\n\n.SPS1\n\n LDX #0                 \\ Copy the two high bytes of the planet's x-coordinate\n JSR SPS3               \\ into K3(2 1 0), separating out the sign bit into K3+2\n\n LDX #3                 \\ Copy the two high bytes of the planet's y-coordinate\n JSR SPS3               \\ into K3(5 4 3), separating out the sign bit into K3+5\n\n LDX #6                 \\ Copy the two high bytes of the planet's z-coordinate\n JSR SPS3               \\ into K3(8 7 6), separating out the sign bit into K3+8\n\n                        \\ Fall through into TAS2 to build XX15 from K3\n\n\\ ******************************************************************************\n\\\n\\       Name: TAS2\n\\       Type: Subroutine\n\\   Category: Maths (Geometry)\n\\    Summary: Normalise the three-coordinate vector in K3\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Normalise the vector in K3, which has 16-bit values and separate sign bits,\n\\ and store the normalised version in XX15 as a signed 8-bit vector.\n\\\n\\ A normalised vector (also known as a unit vector) has length 1, so this\n\\ routine takes an existing vector in K3 and scales it so the length of the\n\\ new vector is 1. This is used in a number of places: when drawing the compass,\n\\ when applying AI tactics to ships (so traders fly towards planets and missiles\n\\ fly towards their targets, for example), and when implementing the docking\n\\ computer in the enhanced versions of Elite.\n\\\n\\ We do this in two stages. This stage shifts the 16-bit vector coordinates in\n\\ K3 to the left as far as they will go without losing any bits off the end, so\n\\ we can then take the high bytes and use them as the most accurate 8-bit vector\n\\ to normalise. Then the next stage (in routine NORM) does the normalisation.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   K3(2 1 0)           The 16-bit x-coordinate as (x_sign x_hi x_lo), where\n\\                       x_sign is just bit 7\n\\\n\\   K3(5 4 3)           The 16-bit y-coordinate as (y_sign y_hi y_lo), where\n\\                       y_sign is just bit 7\n\\\n\\   K3(8 7 6)           The 16-bit z-coordinate as (z_sign z_hi z_lo), where\n\\                       z_sign is just bit 7\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   XX15                The normalised vector, with:\n\\\n\\                         * The x-coordinate in XX15\n\\\n\\                         * The y-coordinate in XX15+1\n\\\n\\                         * The z-coordinate in XX15+2\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   TA2                 Calculate the length of the vector in XX15 (ignoring the\n\\                       low coordinates), returning it in Q\n\\\n\\ ******************************************************************************\n\n.TAS2\n\n LDA K3                 \\ OR the three low bytes and 1 to get a byte that has\n ORA K3+3               \\ a 1 wherever any of the three low bytes has a 1\n ORA K3+6               \\ (as well as always having bit 0 set), and store in\n ORA #1                 \\ K3+9\n STA K3+9\n\n LDA K3+1               \\ OR the three high bytes to get a byte in A that has a\n ORA K3+4               \\ 1 wherever any of the three high bytes has a 1\n ORA K3+7\n\n                        \\ (A K3+9) now has a 1 wherever any of the 16-bit\n                        \\ values in K3 has a 1\n.TAL2\n\n ASL K3+9               \\ Shift (A K3+9) to the left, so bit 7 of the high byte\n ROL A                  \\ goes into the C flag\n\n BCS TA2                \\ If the left shift pushed a 1 out of the end, then we\n                        \\ know that at least one of the coordinates has a 1 in\n                        \\ this position, so jump to TA2 as we can't shift the\n                        \\ values in K3 any further to the left\n\n ASL K3                 \\ Shift K3(1 0), the x-coordinate, to the left\n ROL K3+1\n\n ASL K3+3               \\ Shift K3(4 3), the y-coordinate, to the left\n ROL K3+4\n\n ASL K3+6               \\ Shift K3(6 7), the z-coordinate, to the left\n ROL K3+7\n\n BCC TAL2               \\ Jump back to TAL2 to do another shift left (this BCC\n                        \\ is effectively a JMP as we know bit 7 of K3+7 is not a\n                        \\ 1, as otherwise bit 7 of A would have been a 1 and we\n                        \\ would have taken the BCS above)\n\n.TA2\n\n LDA K3+1               \\ Fetch the high byte of the x-coordinate from our left-\n LSR A                  \\ shifted K3, shift it right to clear bit 7, stick the\n ORA K3+2               \\ sign bit in there from the x_sign part of K3, and\n STA XX15               \\ store the resulting signed 8-bit x-coordinate in XX15\n\n LDA K3+4               \\ Fetch the high byte of the y-coordinate from our left-\n LSR A                  \\ shifted K3, shift it right to clear bit 7, stick the\n ORA K3+5               \\ sign bit in there from the y_sign part of K3, and\n STA XX15+1             \\ store the resulting signed 8-bit y-coordinate in\n                        \\ XX15+1\n\n LDA K3+7               \\ Fetch the high byte of the z-coordinate from our left-\n LSR A                  \\ shifted K3, shift it right to clear bit 7, stick the\n ORA K3+8               \\ sign bit in there from the z_sign part of K3, and\n STA XX15+2             \\ store the resulting signed 8-bit  z-coordinate in\n                        \\ XX15+2\n\n                        \\ Now we have a signed 8-bit version of the vector K3 in\n                        \\ XX15, so fall through into NORM to normalise it\n\n\\ ******************************************************************************\n\\\n\\       Name: NORM\n\\       Type: Subroutine\n\\   Category: Maths (Geometry)\n\\    Summary: Normalise the three-coordinate vector in XX15\n\\  Deep dive: Tidying orthonormal vectors\n\\             Orientation vectors\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ We do this by dividing each of the three coordinates by the length of the\n\\ vector, which we can calculate using Pythagoras. Once normalised, 96 (&60) is\n\\ used to represent a value of 1, and 96 with bit 7 set (&E0) is used to\n\\ represent -1. This enables us to represent fractional values of less than 1\n\\ using integers.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   XX15                The vector to normalise, with:\n\\\n\\                         * The x-coordinate in XX15\n\\\n\\                         * The y-coordinate in XX15+1\n\\\n\\                         * The z-coordinate in XX15+2\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   XX15                The normalised vector\n\\\n\\   Q                   The length of the original XX15 vector\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   NO1                 Contains an RTS\n\\\n\\ ******************************************************************************\n\n.NORM\n\n LDA XX15               \\ Fetch the x-coordinate into A\n\n JSR SQUA               \\ Set (A P) = A * A = x^2\n\n STA R                  \\ Set (R Q) = (A P) = x^2\n LDA P\n STA Q\n\n LDA XX15+1             \\ Fetch the y-coordinate into A\n\n JSR SQUA               \\ Set (A P) = A * A = y^2\n\n STA T                  \\ Set (T P) = (A P) = y^2\n\n LDA P                  \\ Set (R Q) = (R Q) + (T P) = x^2 + y^2\n ADC Q                  \\\n STA Q                  \\ First, doing the low bytes, Q = Q + P\n\n LDA T                  \\ And then the high bytes, R = R + T\n ADC R\n STA R\n\n LDA XX15+2             \\ Fetch the z-coordinate into A\n\n JSR SQUA               \\ Set (A P) = A * A = z^2\n\n STA T                  \\ Set (T P) = (A P) = z^2\n\n LDA P                  \\ Set (R Q) = (R Q) + (T P) = x^2 + y^2 + z^2\n ADC Q                  \\\n STA Q                  \\ First, doing the low bytes, Q = Q + P\n\n LDA T                  \\ And then the high bytes, R = R + T\n ADC R\n STA R\n\n JSR LL5                \\ We now have the following:\n                        \\\n                        \\ (R Q) = x^2 + y^2 + z^2\n                        \\\n                        \\ so we can call LL5 to use Pythagoras to get:\n                        \\\n                        \\ Q = SQRT(R Q)\n                        \\   = SQRT(x^2 + y^2 + z^2)\n                        \\\n                        \\ So Q now contains the length of the vector (x, y, z),\n                        \\ and we can normalise the vector by dividing each of\n                        \\ the coordinates by this value, which we do by calling\n                        \\ routine TIS2. TIS2 returns the divided figure, using\n                        \\ 96 to represent 1 and 96 with bit 7 set for -1\n\n LDA XX15               \\ Call TIS2 to divide the x-coordinate in XX15 by Q,\n JSR TIS2               \\ with 1 being represented by 96\n STA XX15\n\n LDA XX15+1             \\ Call TIS2 to divide the y-coordinate in XX15+1 by Q,\n JSR TIS2               \\ with 1 being represented by 96\n STA XX15+1\n\n LDA XX15+2             \\ Call TIS2 to divide the z-coordinate in XX15+2 by Q,\n JSR TIS2               \\ with 1 being represented by 96\n STA XX15+2\n\n.NO1\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: RDKEY\n\\       Type: Subroutine\n\\   Category: Keyboard\n\\    Summary: Scan the keyboard for key presses\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Scan the keyboard, starting with internal key number 16 (\"Q\") and working\n\\ through the set of internal key numbers (see page 142 of the \"Advanced User\n\\ Guide for the BBC Micro\" by Bray, Dickens and Holmes for a list of internal\n\\ key numbers).\n\\\n\\ This routine is effectively the same as OSBYTE 122, though the OSBYTE call\n\\ preserves A, unlike this routine.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   X                   If a key is being pressed, X contains the internal key\n\\                       number, otherwise it contains 0\n\\\n\\   A                   Contains the same as X\n\\\n\\ ******************************************************************************\n\n.RDKEY\n\n LDX #16                \\ Start the scan with internal key number 16 (\"Q\")\n\n.Rd1\n\n JSR DKS4               \\ Scan the keyboard to see if the key in X is currently\n                        \\ being pressed, returning the result in A and X\n\n BMI Rd2                \\ Jump to Rd2 if this key is being pressed (in which\n                        \\ case DKS4 will have returned the key number with bit\n                        \\ 7 set, which is negative)\n\n INX                    \\ Increment the key number, which was unchanged by the\n                        \\ above call to DKS4\n\n BPL Rd1                \\ Loop back to test the next key, ending the loop when\n                        \\ X is negative (i.e. 128)\n\n TXA                    \\ If we get here, nothing is being pressed, so copy X\n                        \\ into A so that X = A = 128 = %10000000\n\n.Rd2\n\n EOR #%10000000         \\ EOR A with #%10000000 to flip bit 7, so A now contains\n                        \\ 0 if no key has been pressed, or the internal key\n                        \\ number if a key has been pressed\n\n TAX                    \\ Copy A into X\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: ECMOF\n\\       Type: Subroutine\n\\   Category: Dashboard\n\\    Summary: Switch off the E.C.M. and turn off the dashboard bulb\n\\\n\\ ******************************************************************************\n\n.ECMOF\n\n LDA #0                 \\ Set ECMA and ECMP to 0 to indicate that no E.C.M. is\n STA ECMA               \\ currently running\n STA ECMP\n\n JSR ECBLB              \\ Update the E.C.M. indicator bulb on the dashboard\n\n LDA #72                \\ Call the NOISE routine with A = 72 to make the sound\n BNE NOISE              \\ of the E.C.M. being turned off and return from the\n                        \\ subroutine using a tail call (this BNE is effectively\n                        \\ a JMP as A will never be zero)\n\n\\ ******************************************************************************\n\\\n\\       Name: EXNO3\n\\       Type: Subroutine\n\\   Category: Sound\n\\    Summary: Make an explosion sound\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Make the sound of death in the cold, hard vacuum of space. Apparently, in\n\\ Elite space, everyone can hear you scream.\n\\\n\\ This routine also makes the sound of a destroyed cargo canister if we don't\n\\ get scooping right, the sound of us colliding with another ship, and the sound\n\\ of us being hit with depleted shields. It is not a good sound to hear.\n\\\n\\ ******************************************************************************\n\n.EXNO3\n\n LDA #16                \\ Call the NOISE routine with A = 16 to make the first\n JSR NOISE              \\ death sound\n\n LDA #24                \\ Call the NOISE routine with A = 24 to make the second\n BNE NOISE              \\ death sound and return from the subroutine using a\n                        \\ tail call (this BNE is effectively a JMP as A will\n                        \\ never be zero)\n\n\\ ******************************************************************************\n\\\n\\       Name: SFRMIS\n\\       Type: Subroutine\n\\   Category: Tactics\n\\    Summary: Add an enemy missile to our local bubble of universe\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ An enemy has fired a missile, so add the missile to our universe if there is\n\\ room, and if there is, make the appropriate warnings and noises.\n\\\n\\ ******************************************************************************\n\n.SFRMIS\n\n LDX #MSL               \\ Set X to the ship type of a missile, and call SFS1-2\n JSR SFS1-2             \\ to add a missile to our universe that has AI (bit 7\n                        \\ set), is hostile (bit 6 set) and has been launched\n                        \\ (bit 0 clear); the target slot number is set to 31,\n                        \\ but this is ignored as the hostile flags means we\n                        \\ are the target\n\n BCC NO1                \\ The C flag will be set if the call to SFS1-2 was a\n                        \\ success, so if it's clear, jump to NO1 to return from\n                        \\ the subroutine (as NO1 contains an RTS)\n\n LDA #120               \\ Print recursive token 120 (\"INCOMING MISSILE\") as an\n JSR MESS               \\ in-flight message\n\n LDA #48                \\ Call the NOISE routine with A = 48 to make the sound\n BNE NOISE              \\ of the missile being launched and return from the\n                        \\ subroutine using a tail call (this BNE is effectively\n                        \\ a JMP as A will never be zero)\n\n\\ ******************************************************************************\n\\\n\\       Name: EXNO2\n\\       Type: Subroutine\n\\   Category: Status\n\\    Summary: Process us making a kill\n\\  Deep dive: Combat rank\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ We have killed a ship, so increase the kill tally, displaying an iconic\n\\ message of encouragement if the kill total is a multiple of 256, and then\n\\ make a nearby explosion sound.\n\\\n\\ ******************************************************************************\n\n.EXNO2\n\n INC TALLY              \\ Increment the low byte of the kill count in TALLY\n\n BNE EXNO-2             \\ If there is no carry, jump to the LDX #7 below (at\n                        \\ EXNO-2)\n\n INC TALLY+1            \\ Increment the high byte of the kill count in TALLY\n\n LDA #101               \\ The kill total is a multiple of 256, so it's time\n JSR MESS               \\ for a pat on the back, so print recursive token 101\n                        \\ (\"RIGHT ON COMMANDER!\") as an in-flight message\n\n LDX #7                 \\ Set X = 7 and fall through into EXNO to make the\n                        \\ sound of a ship exploding\n\n\\ ******************************************************************************\n\\\n\\       Name: EXNO\n\\       Type: Subroutine\n\\   Category: Sound\n\\    Summary: Make the sound of a laser strike on another ship or a ship\n\\             explosion\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Make the two-part explosion sound of us making a laser strike, or of another\n\\ ship exploding.\n\\\n\\ The volume of the first explosion is affected by the distance of the ship\n\\ being hit, with more distant ships being quieter. The value in X also affects\n\\ the volume of the first explosion, with a higher X giving a quieter sound\n\\ (so X can be used to differentiate a laser strike from an explosion).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   The larger the value of X, the fainter the explosion.\n\\                       Allowed values are:\n\\\n\\                         * 7  = explosion is louder (i.e. the ship has just\n\\                                exploded)\n\\\n\\                         * 15 = explosion is quieter (i.e. this is just a laser\n\\                                strike)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   EXNO-2              Set X = 7 and fall through into EXNO to make the sound\n\\                       of a ship exploding\n\\\n\\ ******************************************************************************\n\n.EXNO\n\n STX T                  \\ Store the distance in T\n\n LDA #24                \\ Set A = 24 to denote the sound of us making a hit or\n JSR NOS1               \\ kill (part 1 of the explosion), and call NOS1 to set\n                        \\ up the sound block in XX16\n\n LDA INWK+7             \\ Fetch z_hi, the distance of the ship being hit in\n LSR A                  \\ terms of the z-axis (in and out of the screen), and\n LSR A                  \\ divide by 4. If z_hi has either bit 6 or 7 set then\n                        \\ that ship is too far away to be shown on the scanner\n                        \\ (as per the SCAN routine), so we know the maximum\n                        \\ z_hi at this point is %00111111, and shifting z_hi\n                        \\ to the right twice gives us a maximum value of\n                        \\ %00001111\n\n AND T                  \\ This reduces A to a maximum of X; X can be either\n                        \\ 7 = %0111 or 15 = %1111, so AND'ing with 15 will\n                        \\ not affect A, while AND'ing with 7 will clear bit\n                        \\ 3, reducing the maximum value in A to 7\n\n ORA #%11110001         \\ The SOUND statement's amplitude ranges from 0 (for no\n                        \\ sound) to -15 (full volume), so we can set bits 0 and\n                        \\ 4-7 in A, and keep bits 1-3 from the above to get\n                        \\ a value between -15 (%11110001) and -1 (%11111111),\n                        \\ with lower values of z_hi and argument X leading\n                        \\ to a more negative, or quieter number (so the closer\n                        \\ the ship, i.e. the smaller the value of X, the louder\n                        \\ the sound)\n\n STA XX16+2             \\ The amplitude byte of the sound block in XX16 is in\n                        \\ byte #3 (where it's the low byte of the amplitude), so\n                        \\ this sets the amplitude to the value in A\n\n JSR NO3                \\ Make the sound from our updated sound block in XX16\n\n LDA #16                \\ Set A = 16 to denote we have made a hit or kill\n                        \\ (part 2 of the explosion), and fall through into NOISE\n                        \\ to make the sound\n\n EQUB &2C               \\ Skip the next instruction by turning it into\n                        \\ &2C &A9 &20, or BIT &20A9, which does nothing apart\n                        \\ from affect the flags\n\n\\ ******************************************************************************\n\\\n\\       Name: BEEP\n\\       Type: Subroutine\n\\   Category: Sound\n\\    Summary: Make a short, high beep\n\\\n\\ ******************************************************************************\n\n.BEEP\n\n LDA #32                \\ Set A = 32 to denote a short, high beep, and fall\n                        \\ through into the NOISE routine to make the sound\n\n\\ ******************************************************************************\n\\\n\\       Name: NOISE\n\\       Type: Subroutine\n\\   Category: Sound\n\\    Summary: Make the sound whose number is in A\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The number of the sound to be made. See the\n\\                       documentation for variable SFX for a list of sound\n\\                       numbers\n\\\n\\ ******************************************************************************\n\n.NOISE\n\n JSR NOS1               \\ Set up the sound block in XX16 for the sound in A and\n                        \\ fall through into NO3 to make the sound\n\n\\ ******************************************************************************\n\\\n\\       Name: NO3\n\\       Type: Subroutine\n\\   Category: Sound\n\\    Summary: Make a sound from a prepared sound block\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Make a sound from a prepared sound block in XX16 (if sound is enabled). See\n\\ routine NOS1 for details of preparing the XX16 sound block.\n\\\n\\ ******************************************************************************\n\n.NO3\n\n LDX DNOIZ              \\ Set X to the DNOIZ configuration setting\n\n BNE NO1                \\ If DNOIZ is non-zero, then sound is disabled, so\n                        \\ return from the subroutine (as NO1 contains an RTS)\n\n LDX #LO(XX16)          \\ Otherwise set (Y X) to point to the sound block in\n LDY #HI(XX16)          \\ XX16\n\n LDA #7                 \\ Call OSWORD 7 to makes the sound, as described in the\n JMP OSWORD             \\ documentation for variable SFX, and return from the\n                        \\ subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: NOS1\n\\       Type: Subroutine\n\\   Category: Sound\n\\    Summary: Prepare a sound block\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Copy four sound bytes from SFX into XX16, interspersing them with null bytes,\n\\ with Y indicating the sound number to copy (from the values in the sound\n\\ table at SFX). So, for example, if we call this routine with A = 40 (long,\n\\ low beep), the following bytes will be set in XX16 to XX16+7:\n\\\n\\   &13 &00 &F4 &00 &0C &00 &08 &00\n\\\n\\ This block will be passed to OSWORD 7 to make the sound, which expects the\n\\ four sound attributes as 16-bit big-endian values - in other words, with the\n\\ low byte first. So the above block would pass the values &0013, &00F4, &000C\n\\ and &0008 to the SOUND statement when used with OSWORD 7, or:\n\\\n\\   SOUND &13, &F4, &0C, &08\n\\\n\\ as the high bytes are always zero.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The sound number to copy from SFX to XX16, which is\n\\                       always a multiple of 8\n\\\n\\ ******************************************************************************\n\n.NOS1\n\n LSR A                  \\ Divide A by 2, and also clear the C flag, as bit 0 of\n                        \\ A is always zero (as A is a multiple of 8)\n\n ADC #3                 \\ Set Y = A + 3, so Y now points to the last byte of\n TAY                    \\ four within the block of four-byte values\n\n LDX #7                 \\ We want to copy four bytes, spread out into an\n                        \\ eight-byte block, so set a counter in Y to cover eight\n                        \\ bytes\n\n.NOL1\n\n LDA #0                 \\ Set the X-th byte of XX16 to 0\n STA XX16,X\n\n DEX                    \\ Decrement the destination byte pointer\n\n LDA SFX,Y              \\ Set the X-th byte of XX16 to the value from SFX+Y\n STA XX16,X\n\n DEY                    \\ Decrement the source byte pointer again\n\n DEX                    \\ Decrement the destination byte pointer again\n\n BPL NOL1               \\ Loop back for the next source byte\n\n                        \\ Fall through into KYTB to return from the subroutine,\n                        \\ as the first byte of KYTB is an RTS\n\n\\ ******************************************************************************\n\\\n\\       Name: KYTB\n\\       Type: Variable\n\\   Category: Keyboard\n\\    Summary: Lookup table for in-flight keyboard controls\n\\  Deep dive: The key logger\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Keyboard table for in-flight controls. This table contains the internal key\n\\ codes for the flight keys (see page 142 of the \"Advanced User Guide for the\n\\ BBC Micro\" by Bray, Dickens and Holmes for a list of internal key numbers).\n\\\n\\ The pitch, roll, speed and laser keys (i.e. the seven primary flight\n\\ control keys) have bit 7 set, so they have 128 added to their internal\n\\ values. This doesn't appear to be used anywhere.\n\\\n\\ Note that KYTB actually points to the byte before the start of the table, so\n\\ the offset of the first key value is 1 (i.e. KYTB+1), not 0.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   KYTB                Contains an RTS\n\\\n\\ ******************************************************************************\n\n.KYTB\n\n RTS                    \\ Return from the subroutine (used as an entry point and\n                        \\ a fall-through from above)\n\n                        \\ These are the primary flight controls (pitch, roll,\n                        \\ speed and lasers):\n\n EQUB &68 + 128         \\ ?         KYTB+1      Slow down\n EQUB &62 + 128         \\ Space     KYTB+2      Speed up\n EQUB &66 + 128         \\ <         KYTB+3      Roll left\n EQUB &67 + 128         \\ >         KYTB+4      Roll right\n EQUB &42 + 128         \\ X         KYTB+5      Pull up\n EQUB &51 + 128         \\ S         KYTB+6      Pitch down\n EQUB &41 + 128         \\ A         KYTB+7      Fire lasers\n\n                        \\ These are the secondary flight controls:\n\n EQUB &60               \\ TAB       KYTB+8      Energy bomb\n EQUB &70               \\ ESCAPE    KYTB+9      Launch escape pod\n EQUB &23               \\ T         KYTB+10     Arm missile\n EQUB &35               \\ U         KYTB+11     Unarm missile\n EQUB &65               \\ M         KYTB+12     Fire missile\n EQUB &22               \\ E         KYTB+13     E.C.M.\n EQUB &45               \\ J         KYTB+14     In-system jump\n EQUB &52               \\ C         KYTB+15     Docking computer\n\n\\ ******************************************************************************\n\\\n\\       Name: DKS1\n\\       Type: Subroutine\n\\   Category: Keyboard\n\\    Summary: Scan the keyboard for a flight key\n\\  Deep dive: The key logger\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Scan the keyboard for the flight key given in register Y, where Y is the\n\\ offset into the KYTB table above (so we can scan for Space by setting Y to\n\\ 2, for example). If the key is pressed, set the corresponding byte in the\n\\ key logger at KL to &FF.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   Y                   The offset into the KYTB table above of the key that we\n\\                       want to scan on the keyboard\n\\\n\\ ******************************************************************************\n\n.DKS1\n\n LDX KYTB,Y             \\ Get the internal key number from the Y-th byte of the\n                        \\ KYTB table above\n\n JSR DKS4               \\ Call DKS4, which will set A and X to a negative value\n                        \\ if the key is being pressed\n\n BPL DKS2-1             \\ The key is not being pressed, so return from the\n                        \\ subroutine (as DKS2-1 contains an RTS)\n\n LDX #&FF               \\ Store &FF in the Y-th byte of the key logger at KL\n STX KL,Y\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: CTRL\n\\       Type: Subroutine\n\\   Category: Keyboard\n\\    Summary: Scan the keyboard to see if CTRL is currently pressed\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   X                   X = %10000001 (i.e. 129 or -127) if CTRL is being\n\\                       pressed\n\\\n\\                       X = 1 if CTRL is not being pressed\n\\\n\\   A                   Contains the same as X\n\\\n\\ ******************************************************************************\n\n.CTRL\n\n LDX #1                 \\ Set X to the internal key number for CTRL and fall\n                        \\ through into DKS4 to scan the keyboard\n\n\\ ******************************************************************************\n\\\n\\       Name: DKS4\n\\       Type: Subroutine\n\\   Category: Keyboard\n\\    Summary: Scan the keyboard to see if a specific key is being pressed\n\\  Deep dive: The key logger\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   The internal number of the key to check (see page 142 of\n\\                       the \"Advanced User Guide for the BBC Micro\" by Bray,\n\\                       Dickens and Holmes for a list of internal key numbers)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   A                   If the key in A is being pressed, A contains the\n\\                       original argument A, but with bit 7 set (i.e. A + 128).\n\\                       If the key in A is not being pressed, the value in A is\n\\                       unchanged\n\\\n\\   X                   Contains the same as A\n\\\n\\ ******************************************************************************\n\n.DKS4\n\n LDA #%00000011         \\ Set A to %00000011, so it's ready to send to SHEILA\n                        \\ once interrupts have been disabled\n\n SEI                    \\ Disable interrupts so we can scan the keyboard\n                        \\ without being hijacked\n\n STA VIA+&40            \\ Set 6522 System VIA output register ORB (SHEILA &40)\n                        \\ to %00000011 to stop auto scan of keyboard\n\n LDA #%01111111         \\ Set 6522 System VIA data direction register DDRA\n STA VIA+&43            \\ (SHEILA &43) to %01111111. This sets the A registers\n                        \\ (IRA and ORA) so that:\n                        \\\n                        \\   * Bits 0-6 of ORA will be sent to the keyboard\n                        \\\n                        \\   * Bit 7 of IRA will be read from the keyboard\n\n STX VIA+&4F            \\ Set 6522 System VIA output register ORA (SHEILA &4F)\n                        \\ to X, the key we want to scan for; bits 0-6 will be\n                        \\ sent to the keyboard, of which bits 0-3 determine the\n                        \\ keyboard column, and bits 4-6 the keyboard row\n\n LDX VIA+&4F            \\ Read 6522 System VIA output register IRA (SHEILA &4F)\n                        \\ into X; bit 7 is the only bit that will have changed.\n                        \\ If the key is pressed, then bit 7 will be set,\n                        \\ otherwise it will be clear\n\n LDA #%00001011         \\ Set 6522 System VIA output register ORB (SHEILA &40)\n STA VIA+&40            \\ to %00001011 to restart auto scan of keyboard\n\n CLI                    \\ Allow interrupts again\n\n TXA                    \\ Transfer X into A\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: DKS2\n\\       Type: Subroutine\n\\   Category: Keyboard\n\\    Summary: Read the joystick position\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Return the value of ADC channel in X (used to read the joystick). The value\n\\ will be inverted if the game has been configured to reverse both joystick\n\\ channels (which can be done by pausing the game and pressing J).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   The ADC channel to read:\n\\\n\\                         * 1 = joystick X\n\\\n\\                         * 2 = joystick Y\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   (A X)               The 16-bit value read from channel X, with the value\n\\                       inverted if the game has been configured to reverse the\n\\                       joystick\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   DKS2-1              Contains an RTS\n\\\n\\ ******************************************************************************\n\n.DKS2\n\n LDA #128               \\ Call OSBYTE with A = 128 to fetch the 16-bit value\n JSR OSBYTE             \\ from ADC channel X, returning (Y X), i.e. the high\n                        \\ byte in Y and the low byte in X\n                        \\\n                        \\   * Channel 1 is the x-axis: 0 = right, 65520 = left\n                        \\\n                        \\   * Channel 2 is the y-axis: 0 = down,  65520 = up\n\n TYA                    \\ Copy Y to A, so the result is now in (A X)\n\n EOR JSTE               \\ The high byte A is now EOR'd with the value in\n                        \\ location JSTE, which contains &FF if both joystick\n                        \\ channels are reversed and 0 otherwise (so A now\n                        \\ contains the high byte but inverted, if that's what\n                        \\ the current settings say)\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: DKS3\n\\       Type: Subroutine\n\\   Category: Keyboard\n\\    Summary: Toggle a configuration setting and emit a beep\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This is called when the game is paused and a key is pressed that changes the\n\\ game's configuration.\n\\\n\\ Specifically, this routine toggles the configuration settings for the\n\\ following keys:\n\\\n\\   * CAPS LOCK toggles keyboard flight damping (&40)\n\\   * A toggles keyboard auto-recentre (&41)\n\\   * X toggles author names on start-up screen (&42)\n\\   * F toggles flashing console bars (&43)\n\\   * Y toggles reverse joystick Y channel (&44)\n\\   * J toggles reverse both joystick channels (&45)\n\\   * K toggles keyboard and joystick (&46)\n\\\n\\ The numbers in brackets are the internal key numbers (see page 142 of the\n\\ \"Advanced User Guide for the BBC Micro\" by Bray, Dickens and Holmes for a list\n\\ of internal key numbers). We pass the key that has been pressed in X, and the\n\\ configuration option to check it against in Y, so this routine is typically\n\\ called in a loop that loops through the various configuration options.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   The internal number of the key that's been pressed\n\\\n\\   Y                   The internal number of the configuration key to check\n\\                       against, from the list above (i.e. Y must be from &40 to\n\\                       &46)\n\\\n\\ ******************************************************************************\n\n.DKS3\n\n STY T                  \\ Store the configuration key argument in T\n\n CPX T                  \\ If X <> Y, jump to Dk3 to return from the subroutine\n BNE Dk3\n\n                        \\ We have a match between X and Y, so now to toggle\n                        \\ the relevant configuration byte. CAPS LOCK has a key\n                        \\ value of &40 and has its configuration byte at\n                        \\ location DAMP, A has a value of &41 and has its byte\n                        \\ at location DJD, which is DAMP+1, and so on. So we\n                        \\ can toggle the configuration byte by changing the\n                        \\ byte at DAMP + (X - &40), or to put it in indexing\n                        \\ terms, DAMP-&40,X. It's no coincidence that the\n                        \\ game's configuration bytes are set up in this order\n                        \\ and with these keys (and this is also why the sound\n                        \\ on/off keys are dealt with elsewhere, as the internal\n                        \\ key for S and Q are &51 and &10, which don't fit\n                        \\ nicely into this approach)\n\n LDA DAMP-&40,X         \\ Fetch the byte from DAMP + (X - &40), invert it and\n EOR #&FF               \\ put it back (0 means no and &FF means yes in the\n STA DAMP-&40,X         \\ configuration bytes, so this toggles the setting)\n\n JSR BELL               \\ Make a beep sound so we know something has happened\n\n JSR DELAY              \\ Wait for Y/50 seconds (Y is between 64 and 70, so this\n                        \\ is always a bit longer than a second)\n\n LDY T                  \\ Restore the configuration key argument into Y\n\n.Dk3\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: DKJ1\n\\       Type: Subroutine\n\\   Category: Keyboard\n\\    Summary: Read joystick and flight controls\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Specifically, scan the keyboard for the speed up and slow down keys, and read\n\\ the joystick's fire button and X and Y axes, storing the results in the key\n\\ logger and the joystick position variables.\n\\\n\\ This routine is only called if joysticks are enabled (JSTK = non-zero).\n\\\n\\ ******************************************************************************\n\n.DKJ1\n\n LDY #1                 \\ Update the key logger for key 1 in the KYTB table, so\n JSR DKS1               \\ KY1 will be &FF if \"?\" (slow down) is being pressed\n\n INY                    \\ Update the key logger for key 2 in the KYTB table, so\n JSR DKS1               \\ KY2 will be &FF if Space (speed up) is being pressed\n\n LDA VIA+&40            \\ Read 6522 System VIA input register IRB (SHEILA &40)\n\n TAX                    \\ This instruction doesn't seem to have any effect, as\n                        \\ X is overwritten in a few instructions. When the\n                        \\ joystick is checked in a similar way in the TITLE\n                        \\ subroutine for the \"Press Fire Or Space,Commander.\"\n                        \\ stage of the start-up screen, there's another\n                        \\ unnecessary TAX instruction present, but there it's\n                        \\ commented out\n\n AND #%00010000         \\ Bit 4 of IRB (PB4) is clear if joystick 1's fire\n                        \\ button is pressed, otherwise it is set, so AND'ing\n                        \\ the value of IRB with %10000 extracts this bit\n\n EOR #%00010000         \\ Flip bit 4 so that it's set if the fire button has\n STA KY7                \\ been pressed, and store the result in the keyboard\n                        \\ logger at location KY7, which is also where the A key\n                        \\ (fire lasers) key is logged\n\n LDX #1                 \\ Call DKS2 to fetch the value of ADC channel 1 (the\n JSR DKS2               \\ joystick X value) into (A X), and OR A with 1. This\n ORA #1                 \\ ensures that the high byte is at least 1, and then we\n STA JSTX               \\ store the result in JSTX\n\n LDX #2                 \\ Call DKS2 to fetch the value of ADC channel 2 (the\n JSR DKS2               \\ joystick Y value) into (A X), and EOR A with JSTGY.\n EOR JSTGY              \\ JSTGY will be &FF if the game is configured to\n STA JSTY               \\ reverse the joystick Y channel, so this EOR does\n                        \\ exactly that, and then we store the result in JSTY\n\n JMP DK4                \\ We are done scanning the joystick flight controls,\n                        \\ so jump to DK4 to scan for other keys, using a tail\n                        \\ call so we can return from the subroutine there\n\n\\ ******************************************************************************\n\\\n\\       Name: U%\n\\       Type: Subroutine\n\\   Category: Keyboard\n\\    Summary: Clear the key logger\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   A                   A is set to 0\n\\\n\\   Y                   Y is set to 0\n\\\n\\ ******************************************************************************\n\n.U%\n\n LDA #0                 \\ Set A to 0, as this means \"key not pressed\" in the\n                        \\ key logger at KL\n\n LDY #15                \\ We want to clear the 15 key logger locations from\n                        \\ KY1 to KY19, so set a counter in Y\n\n.DKL3\n\n STA KL,Y               \\ Store 0 in the Y-th byte of the key logger\n\n DEY                    \\ Decrement the counter\n\n BNE DKL3               \\ And loop back for the next key, until we have just\n                        \\ cleared KL+1. We don't want to clear the first key\n                        \\ logger location at KL, as the keyboard table at KYTB\n                        \\ starts with offset 1, not 0, so KL is not technically\n                        \\ part of the key logger (it's actually used for logging\n                        \\ keys that don't appear in the keyboard table, and\n                        \\ which therefore don't use the key logger)\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: DOKEY\n\\       Type: Subroutine\n\\   Category: Keyboard\n\\    Summary: Scan for the seven primary flight controls\n\\  Deep dive: The key logger\n\\             The docking computer\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Scan for the seven primary flight controls (or the equivalent on joystick),\n\\ pause and configuration keys, and secondary flight controls, and update the\n\\ key logger accordingly. Specifically:\n\\\n\\   * If we are on keyboard configuration, clear the key logger and update it\n\\     for the seven primary flight controls, and update the pitch and roll\n\\     rates accordingly.\n\\\n\\   * If we are on joystick configuration, clear the key logger and jump to\n\\     DKJ1, which reads the joystick equivalents of the primary flight\n\\     controls.\n\\\n\\ Both options end up at DK4 to scan for other keys, beyond the seven primary\n\\ flight controls.\n\\\n\\ ******************************************************************************\n\n.DOKEY\n\n JSR U%                 \\ Call U% to clear the key logger\n\n LDA JSTK               \\ If JSTK is non-zero, then we are configured to use\n BNE DKJ1               \\ the joystick rather than keyboard, so jump to DKJ1\n                        \\ to read the joystick flight controls, before jumping\n                        \\ to DK4 to scan for pause, configuration and secondary\n                        \\ flight keys\n\n LDY #7                 \\ We're going to work our way through the primary flight\n                        \\ control keys (pitch, roll, speed and laser), so set a\n                        \\ counter in Y so we can loop through all 7\n\n.DKL2\n\n JSR DKS1               \\ Call DKS1 to see if the KYTB key at offset Y is being\n                        \\ pressed, and set the key logger accordingly\n\n DEY                    \\ Decrement the loop counter\n\n BNE DKL2               \\ Loop back for the next key, working our way from A at\n                        \\ KYTB+7 down to ? at KYTB+1\n\n LDX JSTX               \\ Set X = JSTX, the current roll rate (as shown in the\n                        \\ RL indicator on the dashboard)\n\n LDA #7                 \\ Set A to 7, which is the amount we want to alter the\n                        \\ roll rate by if the roll keys are being pressed\n\n LDY KL+3               \\ If the \"<\" key is being pressed, then call the BUMP2\n BEQ P%+5               \\ routine to increase the roll rate in X by A\n JSR BUMP2\n\n LDY KL+4               \\ If the \">\" key is being pressed, then call the REDU2\n BEQ P%+5               \\ routine to decrease the roll rate in X by A, taking\n JSR REDU2              \\ the keyboard auto re-centre setting into account\n\n STX JSTX               \\ Store the updated roll rate in JSTX\n\n ASL A                  \\ Double the value of A, to 14\n\n LDX JSTY               \\ Set X = JSTY, the current pitch rate (as shown in the\n                        \\ DC indicator on the dashboard)\n\n LDY KL+5               \\ If the \"X\" key is being pressed, then call the REDU2\n BEQ P%+5               \\ routine to decrease the pitch rate in X by A, taking\n JSR REDU2              \\ the keyboard auto re-centre setting into account\n\n LDY KL+6               \\ If the \"S\" key is being pressed, then call the BUMP2\n BEQ P%+5               \\ routine to increase the pitch rate in X by A\n JSR BUMP2\n\n STX JSTY               \\ Store the updated roll rate in JSTY\n\n                        \\ Fall through into DK4 to scan for other keys\n\n\\ ******************************************************************************\n\\\n\\       Name: DK4\n\\       Type: Subroutine\n\\   Category: Keyboard\n\\    Summary: Scan for pause, configuration and secondary flight keys\n\\  Deep dive: The key logger\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Scan for pause and configuration keys, and if this is a space view, also scan\n\\ for secondary flight controls.\n\\\n\\ Specifically:\n\\\n\\   * Scan for the pause button (COPY) and if it's pressed, pause the game and\n\\     process any configuration key presses until the game is unpaused (DELETE)\n\\\n\\   * If this is a space view, scan for secondary flight keys and update the\n\\     relevant bytes in the key logger\n\\\n\\ ******************************************************************************\n\n.DK4\n\n JSR RDKEY              \\ Scan the keyboard for a key press and return the\n                        \\ internal key number in A and X (or 0 for no key press)\n\n STX KL                 \\ Store X in KL, byte #0 of the key logger\n\n CPX #&69               \\ If COPY is not being pressed, jump to DK2 below,\n BNE DK2                \\ otherwise let's process the configuration keys\n\n.FREEZE\n\n                        \\ COPY is being pressed, so we enter a loop that\n                        \\ listens for configuration keys, and we keep looping\n                        \\ until we detect a DELETE key press. This effectively\n                        \\ pauses the game when COPY is pressed, and unpauses\n                        \\ it when DELETE is pressed\n\n JSR WSCAN              \\ Call WSCAN to wait for the vertical sync, so the whole\n                        \\ screen gets drawn\n\n JSR RDKEY              \\ Scan the keyboard for a key press and return the\n                        \\ internal key number in A and X (or 0 for no key press)\n\n CPX #&51               \\ If \"S\" is not being pressed, skip to DK6\n BNE DK6\n\n LDA #0                 \\ \"S\" is being pressed, so set DNOIZ to 0 to turn the\n STA DNOIZ              \\ sound on\n\n.DK6\n\n LDY #&40               \\ We now want to loop through the keys that toggle\n                        \\ various settings. These have internal key numbers\n                        \\ between &40 (CAPS LOCK) and &46 (\"K\"), so we set up\n                        \\ the first key number in Y to act as a loop counter.\n                        \\ See subroutine DKS3 for more details on this\n\n.DKL4\n\n JSR DKS3               \\ Call DKS3 to scan for the key given in Y, and toggle\n                        \\ the relevant setting if it is pressed\n\n INY                    \\ Increment Y to point to the next toggle key\n\n CPY #&47               \\ The last toggle key is &46 (K), so check whether we\n                        \\ have just done that one\n\n BNE DKL4               \\ If not, loop back to check for the next toggle key\n\n.DK55\n\n CPX #&10               \\ If \"Q\" is not being pressed, skip to DK7\n BNE DK7\n\n STX DNOIZ              \\ \"Q\" is being pressed, so set DNOIZ to X, which is\n                        \\ non-zero (&10), so this will turn the sound off\n\n.DK7\n\n CPX #&70               \\ If ESCAPE is not being pressed, skip over the next\n BNE P%+5               \\ instruction\n\n JMP DEATH2             \\ ESCAPE is being pressed, so jump to DEATH2 to end\n                        \\ the game\n\n CPX #&59               \\ If DELETE is not being pressed, we are still paused,\n BNE FREEZE             \\ so loop back up to keep listening for configuration\n                        \\ keys, otherwise fall through into the rest of the\n                        \\ key detection code, which unpauses the game\n\n.DK2\n\n LDA QQ11               \\ If the current view is non-zero (i.e. not a space\n BNE DK5                \\ view), return from the subroutine (as DK5 contains\n                        \\ an RTS)\n\n LDY #15                \\ This is a space view, so now we want to check for all\n                        \\ the secondary flight keys. The internal key numbers\n                        \\ are in the keyboard table KYTB from KYTB+8 to\n                        \\ KYTB+15, and their key logger locations are from KL+8\n                        \\ to KL+15. So set a decreasing counter in Y for the\n                        \\ index, starting at 15, so we can loop through them\n\n LDA #&FF               \\ Set A to &FF so we can store this in the keyboard\n                        \\ logger for keys that are being pressed\n\n.DKL1\n\n LDX KYTB,Y             \\ Get the internal key number of the Y-th flight key\n                        \\ the KYTB keyboard table\n\n CPX KL                 \\ We stored the key that's being pressed in KL above,\n                        \\ so check to see if the Y-th flight key is being\n                        \\ pressed\n\n BNE DK1                \\ If it is not being pressed, skip to DK1 below\n\n STA KL,Y               \\ The Y-th flight key is being pressed, so set that\n                        \\ key's location in the key logger to &FF\n\n.DK1\n\n DEY                    \\ Decrement the loop counter\n\n CPY #7                 \\ Have we just done the last key?\n\n BNE DKL1               \\ If not, loop back to process the next key\n\n.DK5\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: TT217\n\\       Type: Subroutine\n\\   Category: Keyboard\n\\    Summary: Scan the keyboard until a key is pressed\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Scan the keyboard until a key is pressed, and return the key's ASCII code.\n\\ If, on entry, a key is already being held down, then wait until that key is\n\\ released first (so this routine detects the first key down event following\n\\ the subroutine call).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   X                   The ASCII code of the key that was pressed\n\\\n\\   A                   Contains the same as X\n\\\n\\   Y                   Y is preserved\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   out                 Contains an RTS\n\\\n\\ ******************************************************************************\n\n.TT217\n\n STY YSAV               \\ Store Y in temporary storage, so we can restore it\n                        \\ later\n\n.t\n\n JSR DELAY-5            \\ Wait for 8/50 of a second (0.16 seconds) to implement\n                        \\ a simple keyboard debounce and prevent multiple key\n                        \\ presses being recorded\n\n JSR RDKEY              \\ Scan the keyboard for a key press and return the\n                        \\ internal key number in A and X (or 0 for no key press)\n\n BNE t                  \\ If a key was already being held down when we entered\n                        \\ this routine, keep looping back up to t, until the\n                        \\ key is released\n\n.t2\n\n JSR RDKEY              \\ Any pre-existing key press is now gone, so we can\n                        \\ start scanning the keyboard again, returning the\n                        \\ internal key number in A and X (or 0 for no key press)\n\n BEQ t2                 \\ Keep looping up to t2 until a key is pressed\n\n TAY                    \\ Copy A to Y, so Y contains the internal key number\n                        \\ of the key pressed\n\n LDA (TRTB%),Y          \\ The address in TRTB% points to the MOS key\n                        \\ translation table, which is used to translate\n                        \\ internal key numbers to ASCII, so this fetches the\n                        \\ key's ASCII code into A\n\n LDY YSAV               \\ Restore the original value of Y we stored above\n\n TAX                    \\ Copy A into X\n\n.out\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: me1\n\\       Type: Subroutine\n\\   Category: Flight\n\\    Summary: Erase an old in-flight message and display a new one\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The text token to be printed\n\\\n\\   X                   Must be set to 0\n\\\n\\ ******************************************************************************\n\n.me1\n\n STX DLY                \\ Set the message delay in DLY to 0, so any new\n                        \\ in-flight messages will be shown instantly\n\n PHA                    \\ Store the new message token we want to print\n\n LDA MCH                \\ Set A to the token number of the message that is\n JSR mes9               \\ currently on-screen, and call mes9 to print it (which\n                        \\ will remove it from the screen, as printing is done\n                        \\ using EOR logic)\n\n PLA                    \\ Restore the new message token\n\n EQUB &2C               \\ Fall through into ou2 to print the new message, but\n                        \\ skip the first instruction by turning it into\n                        \\ &2C &A9 &6C, or BIT &6CA9, which does nothing apart\n                        \\ from affect the flags\n\n\\ ******************************************************************************\n\\\n\\       Name: ou2\n\\       Type: Subroutine\n\\   Category: Flight\n\\    Summary: Display \"E.C.M.SYSTEM DESTROYED\" as an in-flight message\n\\\n\\ ******************************************************************************\n\n.ou2\n\n LDA #108               \\ Set A to recursive token 108 (\"E.C.M.SYSTEM\")\n\n EQUB &2C               \\ Fall through into ou3 to print the new message, but\n                        \\ skip the first instruction by turning it into\n                        \\ &2C &A9 &6F, or BIT &6FA9, which does nothing apart\n                        \\ from affect the flags\n\n\\ ******************************************************************************\n\\\n\\       Name: ou3\n\\       Type: Subroutine\n\\   Category: Flight\n\\    Summary: Display \"FUEL SCOOPS DESTROYED\" as an in-flight message\n\\\n\\ ******************************************************************************\n\n.ou3\n\n LDA #111               \\ Set A to recursive token 111 (\"FUEL SCOOPS\")\n\n\\ ******************************************************************************\n\\\n\\       Name: MESS\n\\       Type: Subroutine\n\\   Category: Flight\n\\    Summary: Display an in-flight message\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Display an in-flight message in capitals at the bottom of the space view,\n\\ erasing any existing in-flight message first.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   A                   The text token to be printed\n\\\n\\ ******************************************************************************\n\n.MESS\n\n LDX #0                 \\ Set QQ17 = 0 to switch to ALL CAPS\n STX QQ17\n\n LDY #9                 \\ Move the text cursor to column 9, row 22, at the\n STY XC                 \\ bottom middle of the screen, and set Y = 22\n LDY #22\n STY YC\n\n CPX DLY                \\ If the message delay in DLY is not zero, jump up to\n BNE me1                \\ me1 to erase the current message first (whose token\n                        \\ number will be in MCH)\n\n STY DLY                \\ Set the message delay in DLY to 22\n\n STA MCH                \\ Set MCH to the token we are about to display\n\n                        \\ Fall through into mes9 to print the token in A\n\n\\ ******************************************************************************\n\\\n\\       Name: mes9\n\\       Type: Subroutine\n\\   Category: Flight\n\\    Summary: Print a text token, possibly followed by \" DESTROYED\"\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Print a text token, followed by \" DESTROYED\" if the destruction flag is set\n\\ (for when a piece of equipment is destroyed).\n\\\n\\ ******************************************************************************\n\n.mes9\n\n JSR TT27               \\ Call TT27 to print the text token in A\n\n LSR de                 \\ If bit 0 of variable de is clear, return from the\n BCC out                \\ subroutine (as out contains an RTS)\n\n LDA #253               \\ Print recursive token 93 (\" DESTROYED\") and return\n JMP TT27               \\ from the subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: OUCH\n\\       Type: Subroutine\n\\   Category: Flight\n\\    Summary: Potentially lose cargo or equipment following damage\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Our shields are dead and we are taking damage, so there is a small chance of\n\\ losing cargo or equipment.\n\\\n\\ ******************************************************************************\n\n.OUCH\n\n JSR DORND              \\ Set A and X to random numbers\n\n BMI out                \\ If A < 0 (50% chance), return from the subroutine\n                        \\ (as out contains an RTS)\n\n CPX #22                \\ If X >= 22 (91% chance), return from the subroutine\n BCS out                \\ (as out contains an RTS)\n\n LDA QQ20,X             \\ If we do not have any of item QQ20+X, return from the\n BEQ out                \\ subroutine (as out contains an RTS). X is in the range\n                        \\ 0-21, so this not only checks for cargo, but also for\n                        \\ E.C.M., fuel scoops, energy bomb, energy unit and\n                        \\ docking computer, all of which can be destroyed\n\n LDA DLY                \\ If there is already an in-flight message on-screen,\n BNE out                \\ return from the subroutine (as out contains an RTS)\n\n LDY #3                 \\ Set bit 1 of de, the equipment destruction flag, so\n STY de                 \\ that when we call MESS below, \" DESTROYED\" is appended\n                        \\ to the in-flight message\n\n STA QQ20,X             \\ A is 0 (as we didn't branch with the BNE above), so\n                        \\ this sets QQ20+X to 0, which destroys any cargo or\n                        \\ equipment we have of that type\n\n CPX #17                \\ If X >= 17 then we just lost a piece of equipment, so\n BCS ou1                \\ jump to ou1 to print the relevant message\n\n TXA                    \\ Print recursive token 48 + A as an in-flight token,\n ADC #208               \\ which will be in the range 48 (\"FOOD\") to 64 (\"ALIEN\n BNE MESS               \\ ITEMS\") as the C flag is clear, so this prints the\n                        \\ destroyed item's name, followed by \" DESTROYED\" (as we\n                        \\ set bit 1 of the de flag above), and returns from the\n                        \\ subroutine using a tail call\n\n.ou1\n\n BEQ ou2                \\ If X = 17, jump to ou2 to print \"E.C.M.SYSTEM\n                        \\ DESTROYED\" and return from the subroutine using a tail\n                        \\ call\n\n CPX #18                \\ If X = 18, jump to ou3 to print \"FUEL SCOOPS\n BEQ ou3                \\ DESTROYED\" and return from the subroutine using a tail\n                        \\ call\n\n TXA                    \\ Otherwise X is in the range 19 to 21 and the C flag is\n ADC #113-20            \\ set (as we got here via a BCS to ou1), so we set A as\n                        \\ follows:\n                        \\\n                        \\   A = 113 - 20 + X + C\n                        \\     = 113 - 19 + X\n                        \\     = 113 to 115\n\n BNE MESS               \\ Print recursive token A (\"ENERGY BOMB\", \"ENERGY UNIT\"\n                        \\ or \"DOCKING COMPUTERS\") as an in-flight message,\n                        \\ followed by \" DESTROYED\", and return from the\n                        \\ subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: QQ16\n\\       Type: Variable\n\\   Category: Text\n\\    Summary: The two-letter token lookup table\n\\  Deep dive: Printing text tokens\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Two-letter token lookup table for tokens 128-159.\n\\\n\\ ******************************************************************************\n\n.QQ16\n\n EQUS \"AL\"              \\ Token 128\n EQUS \"LE\"              \\ Token 129\n EQUS \"XE\"              \\ Token 130\n EQUS \"GE\"              \\ Token 131\n EQUS \"ZA\"              \\ Token 132\n EQUS \"CE\"              \\ Token 133\n EQUS \"BI\"              \\ Token 134\n EQUS \"SO\"              \\ Token 135\n EQUS \"US\"              \\ Token 136\n EQUS \"ES\"              \\ Token 137\n EQUS \"AR\"              \\ Token 138\n EQUS \"MA\"              \\ Token 139\n EQUS \"IN\"              \\ Token 140\n EQUS \"DI\"              \\ Token 141\n EQUS \"RE\"              \\ Token 142\n EQUS \"A?\"              \\ Token 143\n EQUS \"ER\"              \\ Token 144\n EQUS \"AT\"              \\ Token 145\n EQUS \"EN\"              \\ Token 146\n EQUS \"BE\"              \\ Token 147\n EQUS \"RA\"              \\ Token 148\n EQUS \"LA\"              \\ Token 149\n EQUS \"VE\"              \\ Token 150\n EQUS \"TI\"              \\ Token 151\n EQUS \"ED\"              \\ Token 152\n EQUS \"OR\"              \\ Token 153\n EQUS \"QU\"              \\ Token 154\n EQUS \"AN\"              \\ Token 155\n EQUS \"TE\"              \\ Token 156\n EQUS \"IS\"              \\ Token 157\n EQUS \"RI\"              \\ Token 158\n EQUS \"ON\"              \\ Token 159\n\n\\ ******************************************************************************\n\\\n\\       Name: ITEM\n\\       Type: Macro\n\\   Category: Market\n\\    Summary: Macro definition for the market prices table\n\\  Deep dive: Market item prices and availability\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The following macro is used to build the market prices table:\n\\\n\\   ITEM price, factor, units, quantity, mask\n\\\n\\ It inserts an item into the market prices table at QQ23.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   price               Base price\n\\\n\\   factor              Economic factor\n\\\n\\   units               Units: \"t\", \"g\" or \"k\"\n\\\n\\   quantity            Base quantity\n\\\n\\   mask                Fluctuations mask\n\\\n\\ ******************************************************************************\n\nMACRO ITEM price, factor, units, quantity, mask\n\n IF factor < 0\n  s = 1 << 7\n ELSE\n  s = 0\n ENDIF\n\n IF units = 't'\n  u = 0\n ELIF units = 'k'\n  u = 1 << 5\n ELSE\n  u = 1 << 6\n ENDIF\n\n e = ABS(factor)\n\n EQUB price\n EQUB s + u + e\n EQUB quantity\n EQUB mask\n\nENDMACRO\n\n\\ ******************************************************************************\n\\\n\\       Name: QQ23\n\\       Type: Variable\n\\   Category: Market\n\\    Summary: Market prices table\n\\  Deep dive: Market item prices and availability\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Each item has four bytes of data, like this:\n\\\n\\   Byte #0 = Base price\n\\   Byte #1 = Economic factor in bits 0-4, with the sign in bit 7\n\\             Unit in bits 5-6\n\\   Byte #2 = Base quantity\n\\   Byte #3 = Mask to control price fluctuations\n\\\n\\ To make it easier for humans to follow, I've defined a macro called ITEM\n\\ that takes the following arguments and builds the four bytes for us:\n\\\n\\   ITEM base price, economic factor, units, base quantity, mask\n\\\n\\ So for food, we have the following, for example:\n\\\n\\   * Base price = 19\n\\   * Economic factor = -2\n\\   * Unit = tonnes\n\\   * Base quantity = 6\n\\   * Mask = %00000001\n\\\n\\ ******************************************************************************\n\n.QQ23\n\n ITEM 19,  -2, 't',   6, %00000001  \\  0 = Food\n ITEM 20,  -1, 't',  10, %00000011  \\  1 = Textiles\n ITEM 65,  -3, 't',   2, %00000111  \\  2 = Radioactives\n ITEM 40,  -5, 't', 226, %00011111  \\  3 = Slaves\n ITEM 83,  -5, 't', 251, %00001111  \\  4 = Liquor/Wines\n ITEM 196,  8, 't',  54, %00000011  \\  5 = Luxuries\n ITEM 235, 29, 't',   8, %01111000  \\  6 = Narcotics\n ITEM 154, 14, 't',  56, %00000011  \\  7 = Computers\n ITEM 117,  6, 't',  40, %00000111  \\  8 = Machinery\n ITEM 78,   1, 't',  17, %00011111  \\  9 = Alloys\n ITEM 124, 13, 't',  29, %00000111  \\ 10 = Firearms\n ITEM 176, -9, 't', 220, %00111111  \\ 11 = Furs\n ITEM 32,  -1, 't',  53, %00000011  \\ 12 = Minerals\n ITEM 97,  -1, 'k',  66, %00000111  \\ 13 = Gold\n ITEM 171, -2, 'k',  55, %00011111  \\ 14 = Platinum\n ITEM 45,  -1, 'g', 250, %00001111  \\ 15 = Gem-Stones\n ITEM 53,  15, 't', 192, %00000111  \\ 16 = Alien items\n\n\\ ******************************************************************************\n\\\n\\       Name: TIDY\n\\       Type: Subroutine\n\\   Category: Maths (Geometry)\n\\    Summary: Orthonormalise the orientation vectors for a ship\n\\  Deep dive: Tidying orthonormal vectors\n\\             Orientation vectors\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine orthonormalises the orientation vectors for a ship. This means\n\\ making the three orientation vectors orthogonal (perpendicular to each other),\n\\ and normal (so each of the vectors has length 1).\n\\\n\\ We do this because we use the small angle approximation to rotate these\n\\ vectors in space. It is not completely accurate, so the three vectors tend\n\\ to get stretched over time, so periodically we tidy the vectors with this\n\\ routine to ensure they remain as orthonormal as possible.\n\\\n\\ ******************************************************************************\n\n.TI2\n\n                        \\ Called from below with A = 0, X = 0, Y = 4 when\n                        \\ nosev_x and nosev_y are small, so we assume that\n                        \\ nosev_z is big\n\n TYA                    \\ A = Y = 4\n LDY #2\n JSR TIS3               \\ Call TIS3 with X = 0, Y = 2, A = 4, to set roofv_z =\n STA INWK+20            \\ -(nosev_x * roofv_x + nosev_y * roofv_y) / nosev_z\n\n JMP TI3                \\ Jump to TI3 to keep tidying\n\n.TI1\n\n                        \\ Called from below with A = 0, Y = 4 when nosev_x is\n                        \\ small\n\n TAX                    \\ Set X = A = 0\n\n LDA XX15+1             \\ Set A = nosev_y, and if the top two magnitude bits\n AND #%01100000         \\ are both clear, jump to TI2 with A = 0, X = 0, Y = 4\n BEQ TI2\n\n LDA #2                 \\ Otherwise nosev_y is big, so set up the index values\n                        \\ to pass to TIS3\n\n JSR TIS3               \\ Call TIS3 with X = 0, Y = 4, A = 2, to set roofv_y =\n STA INWK+18            \\ -(nosev_x * roofv_x + nosev_z * roofv_z) / nosev_y\n\n JMP TI3                \\ Jump to TI3 to keep tidying\n\n.TIDY\n\n LDA INWK+10            \\ Set (XX15, XX15+1, XX15+2) = nosev\n STA XX15\n LDA INWK+12\n STA XX15+1\n LDA INWK+14\n STA XX15+2\n\n JSR NORM               \\ Call NORM to normalise the vector in XX15, i.e. nosev\n\n LDA XX15               \\ Set nosev = (XX15, XX15+1, XX15+2)\n STA INWK+10\n LDA XX15+1\n STA INWK+12\n LDA XX15+2\n STA INWK+14\n\n LDY #4                 \\ Set Y = 4\n\n LDA XX15               \\ Set A = nosev_x, and if the top two magnitude bits\n AND #%01100000         \\ are both clear, jump to TI1 with A = 0, Y = 4\n BEQ TI1\n\n LDX #2                 \\ Otherwise nosev_x is big, so set up the index values\n LDA #0                 \\ to pass to TIS3\n\n JSR TIS3               \\ Call TIS3 with X = 2, Y = 4, A = 0, to set roofv_x =\n STA INWK+16            \\ -(nosev_y * roofv_y + nosev_z * roofv_z) / nosev_x\n\n.TI3\n\n LDA INWK+16            \\ Set (XX15, XX15+1, XX15+2) = roofv\n STA XX15\n LDA INWK+18\n STA XX15+1\n LDA INWK+20\n STA XX15+2\n\n JSR NORM               \\ Call NORM to normalise the vector in XX15, i.e. roofv\n\n LDA XX15               \\ Set roofv = (XX15, XX15+1, XX15+2)\n STA INWK+16\n LDA XX15+1\n STA INWK+18\n LDA XX15+2\n STA INWK+20\n\n LDA INWK+12            \\ Set Q = nosev_y\n STA Q\n\n LDA INWK+20            \\ Set A = roofv_z\n\n JSR MULT12             \\ Set (S R) = Q * A = nosev_y * roofv_z\n\n LDX INWK+14            \\ Set X = nosev_z\n\n LDA INWK+18            \\ Set A = roofv_y\n\n JSR TIS1               \\ Set (A ?) = (-X * A + (S R)) / 96\n                        \\        = (-nosev_z * roofv_y + nosev_y * roofv_z) / 96\n                        \\\n                        \\ This also sets Q = nosev_z\n\n EOR #%10000000         \\ Set sidev_x = -A\n STA INWK+22            \\        = (nosev_z * roofv_y - nosev_y * roofv_z) / 96\n\n LDA INWK+16            \\ Set A = roofv_x\n\n JSR MULT12             \\ Set (S R) = Q * A = nosev_z * roofv_x\n\n LDX INWK+10            \\ Set X = nosev_x\n\n LDA INWK+20            \\ Set A = roofv_z\n\n JSR TIS1               \\ Set (A ?) = (-X * A + (S R)) / 96\n                        \\        = (-nosev_x * roofv_z + nosev_z * roofv_x) / 96\n                        \\\n                        \\ This also sets Q = nosev_x\n\n EOR #%10000000         \\ Set sidev_y = -A\n STA INWK+24            \\        = (nosev_x * roofv_z - nosev_z * roofv_x) / 96\n\n LDA INWK+18            \\ Set A = roofv_y\n\n JSR MULT12             \\ Set (S R) = Q * A = nosev_x * roofv_y\n\n LDX INWK+12            \\ Set X = nosev_y\n\n LDA INWK+16            \\ Set A = roofv_x\n\n JSR TIS1               \\ Set (A ?) = (-X * A + (S R)) / 96\n                        \\        = (-nosev_y * roofv_x + nosev_x * roofv_y) / 96\n\n EOR #%10000000         \\ Set sidev_z = -A\n STA INWK+26            \\        = (nosev_y * roofv_x - nosev_x * roofv_y) / 96\n\n LDA #0                 \\ Set A = 0 so we can clear the low bytes of the\n                        \\ orientation vectors\n\n LDX #14                \\ We want to clear the low bytes, so start from sidev_y\n                        \\ at byte #9+14 (we clear all except sidev_z_lo, though\n                        \\ I suspect this is in error and that X should be 16)\n\n.TIL1\n\n STA INWK+9,X           \\ Set the low byte in byte #9+X to zero\n\n DEX                    \\ Set X = X - 2 to jump down to the next low byte\n DEX\n\n BPL TIL1               \\ Loop back until we have zeroed all the low bytes\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: TIS2\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate A = A / Q\n\\  Deep dive: Shift-and-subtract division\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following division, where A is a sign-magnitude number and Q is\n\\ a positive integer:\n\\\n\\   A = A / Q\n\\\n\\ The value of A is returned as a sign-magnitude number with 96 representing 1,\n\\ and the maximum value returned is 1 (i.e. 96). This routine is used when\n\\ normalising vectors, where we represent fractions using integers, so this\n\\ gives us an approximation to two decimal places.\n\\\n\\ ******************************************************************************\n\n.TIS2\n\n TAY                    \\ Store the argument A in Y\n\n AND #%01111111         \\ Strip the sign bit from the argument, so A = |A|\n\n CMP Q                  \\ If A >= Q then jump to TI4 to return a 1 with the\n BCS TI4                \\ correct sign\n\n LDX #%11111110         \\ Set T to have bits 1-7 set, so we can rotate through 7\n STX T                  \\ loop iterations, getting a 1 each time, and then\n                        \\ getting a 0 on the 8th iteration... and we can also\n                        \\ use T to catch our result bits into bit 0 each time\n\n.TIL2\n\n ASL A                  \\ Shift A to the left\n\n CMP Q                  \\ If A < Q skip the following subtraction\n BCC P%+4\n\n SBC Q                  \\ A >= Q, so set A = A - Q\n                        \\\n                        \\ Going into this subtraction we know the C flag is\n                        \\ set as we passed through the BCC above, and we also\n                        \\ know that A >= Q, so the C flag will still be set once\n                        \\ we are done\n\n ROL T                  \\ Rotate the counter in T to the left, and catch the\n                        \\ result bit into bit 0 (which will be a 0 if we didn't\n                        \\ do the subtraction, or 1 if we did)\n\n BCS TIL2               \\ If we still have set bits in T, loop back to TIL2 to\n                        \\ do the next iteration of 7\n\n                        \\ We've done the division and now have a result in the\n                        \\ range 0-255 here, which we need to reduce to the range\n                        \\ 0-96. We can do that by multiplying the result by 3/8,\n                        \\ as 256 * 3/8 = 96\n\n LDA T                  \\ Set T = T / 4\n LSR A\n LSR A\n STA T\n\n LSR A                  \\ Set T = T / 8 + T / 4\n ADC T                  \\       = 3T / 8\n STA T\n\n TYA                    \\ Fetch the sign bit of the original argument A\n AND #%10000000\n\n ORA T                  \\ Apply the sign bit to T\n\n RTS                    \\ Return from the subroutine\n\n.TI4\n\n TYA                    \\ Fetch the sign bit of the original argument A\n AND #%10000000\n\n ORA #96                \\ Apply the sign bit to 96 (which represents 1)\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: TIS3\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate -(nosev_1 * roofv_1 + nosev_2 * roofv_2) / nosev_3\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following expression:\n\\\n\\   A = -(nosev_1 * roofv_1 + nosev_2 * roofv_2) / nosev_3\n\\\n\\ where 1, 2 and 3 are x, y, or z, depending on the values of X, Y and A. This\n\\ routine is called with the following values:\n\\\n\\   X = 0, Y = 2, A = 4 ->\n\\         A = -(nosev_x * roofv_x + nosev_y * roofv_y) / nosev_z\n\\\n\\   X = 0, Y = 4, A = 2 ->\n\\         A = -(nosev_x * roofv_x + nosev_z * roofv_z) / nosev_y\n\\\n\\   X = 2, Y = 4, A = 0 ->\n\\         A = -(nosev_y * roofv_y + nosev_z * roofv_z) / nosev_x\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   X                   Index 1 (0 = x, 2 = y, 4 = z)\n\\\n\\   Y                   Index 2 (0 = x, 2 = y, 4 = z)\n\\\n\\   A                   Index 3 (0 = x, 2 = y, 4 = z)\n\\\n\\ ******************************************************************************\n\n.TIS3\n\n STA P+2                \\ Store P+2 in A for later\n\n LDA INWK+10,X          \\ Set Q = nosev_x_hi (plus X)\n STA Q\n\n LDA INWK+16,X          \\ Set A = roofv_x_hi (plus X)\n\n JSR MULT12             \\ Set (S R) = Q * A\n                        \\           = nosev_x_hi * roofv_x_hi\n\n LDX INWK+10,Y          \\ Set Q = nosev_x_hi (plus Y)\n STX Q\n\n LDA INWK+16,Y          \\ Set A = roofv_x_hi (plus Y)\n\n JSR MAD                \\ Set (A X) = Q * A + (S R)\n                        \\           = (nosev_x,X * roofv_x,X) +\n                        \\             (nosev_x,Y * roofv_x,Y)\n\n STX P                  \\ Store low byte of result in P, so result is now in\n                        \\ (A P)\n\n LDY P+2                \\ Set Q = roofv_x_hi (plus argument A)\n LDX INWK+10,Y\n STX Q\n\n EOR #%10000000         \\ Flip the sign of A\n\n                        \\ Fall through into DIVDT to do:\n                        \\\n                        \\   (P+1 A) = (A P) / Q\n                        \\\n                        \\     = -((nosev_x,X * roofv_x,X) +\n                        \\         (nosev_x,Y * roofv_x,Y))\n                        \\       / nosev_x,A\n\n\\ ******************************************************************************\n\\\n\\       Name: DVIDT\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate (P+1 A) = (A P) / Q\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following integer division between sign-magnitude numbers:\n\\\n\\   (P+1 A) = (A P) / Q\n\\\n\\ This uses the same shift-and-subtract algorithm as TIS2.\n\\\n\\ ******************************************************************************\n\n.DVIDT\n\n STA P+1                \\ Set P+1 = A, so P(1 0) = (A P)\n\n EOR Q                  \\ Set T = the sign bit of A EOR Q, so it's 1 if A and Q\n AND #%10000000         \\ have different signs, i.e. it's the sign of the result\n STA T                  \\ of A / Q\n\n LDA #0                 \\ Set A = 0 for us to build a result\n\n LDX #16                \\ Set a counter in X to count the 16 bits in P(1 0)\n\n ASL P                  \\ Shift P(1 0) left\n ROL P+1\n\n ASL Q                  \\ Clear the sign bit of Q the C flag at the same time\n LSR Q\n\n.DVL2\n\n ROL A                  \\ Shift A to the left\n\n CMP Q                  \\ If A < Q skip the following subtraction\n BCC P%+4\n\n SBC Q                  \\ Set A = A - Q\n                        \\\n                        \\ Going into this subtraction we know the C flag is\n                        \\ set as we passed through the BCC above, and we also\n                        \\ know that A >= Q, so the C flag will still be set once\n                        \\ we are done\n\n ROL P                  \\ Rotate P(1 0) to the left, and catch the result bit\n ROL P+1                \\ into the C flag (which will be a 0 if we didn't\n                        \\ do the subtraction, or 1 if we did)\n\n DEX                    \\ Decrement the loop counter\n\n BNE DVL2               \\ Loop back for the next bit until we have done all 16\n                        \\ bits of P(1 0)\n\n LDA P                  \\ Set A = P so the low byte is in the result in A\n\n ORA T                  \\ Set A to the correct sign bit that we set in T above\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\ Save ELTF.bin\n\\\n\\ ******************************************************************************\n\n PRINT \"ELITE F\"\n PRINT \"Assembled at \", ~CODE_F%\n PRINT \"Ends at \", ~P%\n PRINT \"Code size is \", ~(P% - CODE_F%)\n PRINT \"Execute at \", ~LOAD%\n PRINT \"Reload at \", ~LOAD_F%\n\n PRINT \"S.ELTF \", ~CODE_F%, \" \", ~P%, \" \", ~LOAD%, \" \", ~LOAD_F%\n SAVE \"3-assembled-output/ELTF.bin\", CODE_F%, P%, LOAD%\n\n\\ ******************************************************************************\n\\\n\\ ELITE G FILE\n\\\n\\ Produces the binary file ELTG.bin that gets loaded by elite-bcfs.asm.\n\\\n\\ ******************************************************************************\n\n CODE_G% = P%\n\n LOAD_G% = LOAD% + P% - CODE%\n\n\\ ******************************************************************************\n\\\n\\       Name: SHPPT\n\\       Type: Subroutine\n\\   Category: Drawing ships\n\\    Summary: Draw a distant ship as a point rather than a full wireframe\n\\\n\\ ******************************************************************************\n\n.SHPPT\n\n JSR EE51               \\ Call EE51 to remove the ship's wireframe from the\n                        \\ screen, if there is one\n\n JSR PROJ               \\ Project the ship onto the screen, returning:\n                        \\\n                        \\   * K3(1 0) = the screen x-coordinate\n                        \\   * K4(1 0) = the screen y-coordinate\n                        \\   * A = K4+1\n\n ORA K3+1               \\ If either of the high bytes of the screen coordinates\n BNE nono               \\ are non-zero, jump to nono as the ship is off-screen\n\n LDA K4                 \\ Set A = the y-coordinate of the dot\n\n CMP #Y*2-2             \\ If the y-coordinate is bigger than the y-coordinate of\n BCS nono               \\ the bottom of the screen, jump to nono as the ship's\n                        \\ dot is off the bottom of the space view\n\n LDY #2                 \\ Call Shpt with Y = 2 to set up bytes 1-4 in the ship\n JSR Shpt               \\ lines space, aborting the call to LL9 if the dot is\n                        \\ off the side of the screen. This call sets up the\n                        \\ first row of the dot (i.e. a four-pixel dash)\n\n LDY #6                 \\ Set Y to 6 for the next call to Shpt\n\n LDA K4                 \\ Set A = y-coordinate of dot + 1 (so this is the second\n ADC #1                 \\ row of the two-pixel high dot)\n                        \\\n                        \\ The addition works as the Shpt routine clears the C\n                        \\ flag\n\n JSR Shpt               \\ Call Shpt with Y = 6 to set up bytes 5-8 in the ship\n                        \\ lines space, aborting the call to LL9 if the dot is\n                        \\ off the side of the screen. This call sets up the\n                        \\ second row of the dot (i.e. another four-pixel dash,\n                        \\ on the row below the first one)\n\n LDA #%00001000         \\ Set bit 3 of the ship's byte #31 to record that we\n ORA XX1+31             \\ have now drawn something on-screen for this ship\n STA XX1+31\n\n LDA #8                 \\ Set A = 8 so when we call LL18+2 next, byte #0 of the\n                        \\ heap gets set to 8, for the 8 bytes we just stuck on\n                        \\ the heap\n\n JMP LL81+2             \\ Call LL81+2 to draw the ship's dot, returning from the\n                        \\ subroutine using a tail call\n\n PLA                    \\ Pull the return address from the stack, so the RTS\n PLA                    \\ below actually returns from the subroutine that called\n                        \\ LL9 (as we called SHPPT from LL9 with a JMP)\n\n.nono\n\n LDA #%11110111         \\ Clear bit 3 of the ship's byte #31 to record that\n AND XX1+31             \\ nothing is being drawn on-screen for this ship\n STA XX1+31\n\n RTS                    \\ Return from the subroutine\n\n.Shpt\n\n                        \\ This routine sets up four bytes in the ship line heap,\n                        \\ from byte Y-1 to byte Y+2. If the ship's screen point\n                        \\ turns out to be off-screen, then this routine aborts\n                        \\ the entire call to LL9, exiting via nono. The four\n                        \\ bytes define a horizontal four-pixel dash, for either\n                        \\ the top or the bottom of the ship's dot\n\n STA (XX19),Y           \\ Store A in byte Y of the ship line heap (i.e. Y1)\n\n INY                    \\ Store A in byte Y+2 of the ship line heap (i.e. Y2)\n INY\n STA (XX19),Y\n\n LDA K3                 \\ Set A = screen x-coordinate of the ship dot\n\n DEY                    \\ Store A in byte Y+1 of the ship line heap (i.e. X2)\n STA (XX19),Y\n\n ADC #3                 \\ Set A = screen x-coordinate of the ship dot + 3\n\n BCS nono-2             \\ If the addition pushed the dot off the right side of\n                        \\ the screen, jump to nono-2 to return from the parent\n                        \\ subroutine early (i.e. LL9). This works because we\n                        \\ called Shpt from above with a JSR, so nono-2 removes\n                        \\ that return address from the stack, leaving the next\n                        \\ return address exposed. LL9 called SHPPT with a JMP,\n                        \\ so the next return address is the one that was put on\n                        \\ the stack by the original call to LL9. So the RTS in\n                        \\ nono will actually return us from the original call\n                        \\ to LL9, thus aborting the entire drawing process\n\n DEY                    \\ Store A in byte Y-1 of the ship line heap (i.e. X1)\n DEY\n STA (XX19),Y\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: LL5\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate Q = SQRT(R Q)\n\\  Deep dive: Calculating square roots\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following square root:\n\\\n\\   Q = SQRT(R Q)\n\\\n\\ ******************************************************************************\n\n.LL5\n\n LDY R                  \\ Set (Y S) = (R Q)\n LDA Q\n STA S\n\n                        \\ So now to calculate Q = SQRT(Y S)\n\n LDX #0                 \\ Set X = 0, to hold the remainder\n\n STX Q                  \\ Set Q = 0, to hold the result\n\n LDA #8                 \\ Set T = 8, to use as a loop counter\n STA T\n\n.LL6\n\n CPX Q                  \\ If X < Q, jump to LL7\n BCC LL7\n\n BNE LL8                \\ If X > Q, jump to LL8\n\n CPY #64                \\ If Y < 64, jump to LL7 with the C flag clear,\n BCC LL7                \\ otherwise fall through into LL8 with the C flag set\n\n.LL8\n\n TYA                    \\ Set Y = Y - 64\n SBC #64                \\\n TAY                    \\ This subtraction will work as we know C is set from\n                        \\ the BCC above, and the result will not underflow as we\n                        \\ already checked that Y >= 64, so the C flag is also\n                        \\ set for the next subtraction\n\n TXA                    \\ Set X = X - Q\n SBC Q\n TAX\n\n.LL7\n\n ROL Q                  \\ Shift the result in Q to the left, shifting the C flag\n                        \\ into bit 0 and bit 7 into the C flag\n\n ASL S                  \\ Shift the dividend in (Y S) to the left, inserting\n TYA                    \\ bit 7 from above into bit 0\n ROL A\n TAY\n\n TXA                    \\ Shift the remainder in X to the left\n ROL A\n TAX\n\n ASL S                  \\ Shift the dividend in (Y S) to the left\n TYA\n ROL A\n TAY\n\n TXA                    \\ Shift the remainder in X to the left\n ROL A\n TAX\n\n DEC T                  \\ Decrement the loop counter\n\n BNE LL6                \\ Loop back to LL6 until we have done 8 loops\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: LL28\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate R = 256 * A / Q\n\\  Deep dive: Shift-and-subtract division\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following, where A < Q:\n\\\n\\   R = 256 * A / Q\n\\\n\\ This is a sister routine to LL61, which does the division when A >= Q.\n\\\n\\ If A >= Q then 255 is returned and the C flag is set to indicate an overflow\n\\ (the C flag is clear if the division was a success).\n\\\n\\ The result is returned in one byte as the result of the division multiplied\n\\ by 256, so we can return fractional results using integers.\n\\\n\\ This routine uses the same shift-and-subtract algorithm that's documented in\n\\ TIS2, but it leaves the fractional result in the integer range 0-255.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   C flag              Set if the answer is too big for one byte, clear if the\n\\                       division was a success\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   LL28+4              Skips the A >= Q check and always returns with C flag\n\\                       cleared, so this can be called if we know the division\n\\                       will work\n\\\n\\   LL31                Skips the A >= Q check and does not set the R counter,\n\\                       so this can be used for jumping straight into the\n\\                       division loop if R is already set to 254 and we know the\n\\                       division will work\n\\\n\\ ******************************************************************************\n\n.LL28\n\n CMP Q                  \\ If A >= Q, then the answer will not fit in one byte,\n BCS LL2                \\ so jump to LL2 to return 255\n\n LDX #%11111110         \\ Set R to have bits 1-7 set, so we can rotate through 7\n STX R                  \\ loop iterations, getting a 1 each time, and then\n                        \\ getting a 0 on the 8th iteration... and we can also\n                        \\ use R to catch our result bits into bit 0 each time\n\n.LL31\n\n ASL A                  \\ Shift A to the left\n\n BCS LL29               \\ If bit 7 of A was set, then jump straight to the\n                        \\ subtraction\n\n CMP Q                  \\ If A < Q, skip the following subtraction\n BCC P%+4\n\n SBC Q                  \\ A >= Q, so set A = A - Q\n\n ROL R                  \\ Rotate the counter in R to the left, and catch the\n                        \\ result bit into bit 0 (which will be a 0 if we didn't\n                        \\ do the subtraction, or 1 if we did)\n\n BCS LL31               \\ If we still have set bits in R, loop back to LL31 to\n                        \\ do the next iteration of 7\n\n RTS                    \\ R left with remainder of division\n\n.LL29\n\n SBC Q                  \\ A >= Q, so set A = A - Q\n\n SEC                    \\ Set the C flag to rotate into the result in R\n\n ROL R                  \\ Rotate the counter in R to the left, and catch the\n                        \\ result bit into bit 0 (which will be a 0 if we didn't\n                        \\ do the subtraction, or 1 if we did)\n\n BCS LL31               \\ If we still have set bits in R, loop back to LL31 to\n                        \\ do the next iteration of 7\n\n RTS                    \\ Return from the subroutine with R containing the\n                        \\ remainder of the division\n\n.LL2\n\n LDA #255               \\ The division is very close to 1, so return the closest\n STA R                  \\ possible answer to 256, i.e. R = 255\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: LL38\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate (S A) = (S R) + (A Q)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following between sign-magnitude numbers:\n\\\n\\   (S A) = (S R) + (A Q)\n\\\n\\ where the sign bytes only contain the sign bits, not magnitudes.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   C flag              Set if the addition overflowed, clear otherwise\n\\\n\\ ******************************************************************************\n\n.LL38\n\n EOR S                  \\ If the sign of A * S is negative, skip to LL35, as\n BMI LL39               \\ A and S have different signs so we need to subtract\n\n LDA Q                  \\ Otherwise set A = R + Q, which is the result we need,\n CLC                    \\ as S already contains the correct sign\n ADC R\n\n RTS                    \\ Return from the subroutine\n\n.LL39\n\n LDA R                  \\ Set A = R - Q\n SEC\n SBC Q\n\n BCC P%+4               \\ If the subtraction underflowed, skip the next two\n                        \\ instructions so we can negate the result\n\n CLC                    \\ Otherwise the result is correct, and S contains the\n                        \\ correct sign of the result as R is the dominant side\n                        \\ of the subtraction, so clear the C flag\n\n RTS                    \\ And return from the subroutine\n\n                        \\ If we get here we need to negate both the result and\n                        \\ the sign in S, as both are the wrong sign\n\n PHA                    \\ Store the result of the subtraction on the stack\n\n LDA S                  \\ Flip the sign of S\n EOR #%10000000\n STA S\n\n PLA                    \\ Restore the subtraction result into A\n\n EOR #%11111111         \\ Negate the result in A using two's complement, i.e.\n ADC #1                 \\ set A = ~A + 1\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: LL51\n\\       Type: Subroutine\n\\   Category: Maths (Geometry)\n\\    Summary: Calculate the dot product of XX15 and XX16\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following dot products:\n\\\n\\   XX12(1 0) = XX15(5 0) . XX16(5 0)\n\\   XX12(3 2) = XX15(5 0) . XX16(11 6)\n\\   XX12(5 4) = XX15(5 0) . XX16(12 17)\n\\\n\\ storing the results as sign-magnitude numbers in XX12 through XX12+5.\n\\\n\\ When called from part 5 of LL9, XX12 contains the vector [x y z] to the ship\n\\ we're drawing, and XX16 contains the orientation vectors, so it returns:\n\\\n\\   [ x ]   [ sidev_x ]         [ x ]   [ roofv_x ]         [ x ]   [ nosev_x ]\n\\   [ y ] . [ sidev_y ]         [ y ] . [ roofv_y ]         [ y ] . [ nosev_y ]\n\\   [ z ]   [ sidev_z ]         [ z ]   [ roofv_z ]         [ z ]   [ nosev_z ]\n\\\n\\ When called from part 6 of LL9, XX12 contains the vector [x y z] of the vertex\n\\ we're analysing, and XX16 contains the transposed orientation vectors with\n\\ each of them containing the x, y and z elements of the original vectors, so it\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   [ x ]   [ sidev_x ]         [ x ]   [ sidev_y ]         [ x ]   [ sidev_z ]\n\\   [ y ] . [ roofv_x ]         [ y ] . [ roofv_y ]         [ y ] . [ roofv_z ]\n\\   [ z ]   [ nosev_x ]         [ z ]   [ nosev_y ]         [ z ]   [ nosev_z ]\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   XX15(1 0)           The ship (or vertex)'s x-coordinate as (x_sign x_lo)\n\\\n\\   XX15(3 2)           The ship (or vertex)'s y-coordinate as (y_sign y_lo)\n\\\n\\   XX15(5 4)           The ship (or vertex)'s z-coordinate as (z_sign z_lo)\n\\\n\\   XX16 to XX16+5      The scaled sidev (or _x) vector, with:\n\\\n\\                         * x, y, z magnitudes in XX16, XX16+2, XX16+4\n\\\n\\                         * x, y, z signs in XX16+1, XX16+3, XX16+5\n\\\n\\   XX16+6 to XX16+11   The scaled roofv (or _y) vector, with:\n\\\n\\                         * x, y, z magnitudes in XX16+6, XX16+8, XX16+10\n\\\n\\                         * x, y, z signs in XX16+7, XX16+9, XX16+11\n\\\n\\   XX16+12 to XX16+17  The scaled nosev (or _z) vector, with:\n\\\n\\                         * x, y, z magnitudes in XX16+12, XX16+14, XX16+16\n\\\n\\                         * x, y, z signs in XX16+13, XX16+15, XX16+17\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   XX12(1 0)           The dot product of [x y z] vector with the sidev (or _x)\n\\                       vector, with the sign in XX12+1 and magnitude in XX12\n\\\n\\   XX12(3 2)           The dot product of [x y z] vector with the roofv (or _y)\n\\                       vector, with the sign in XX12+3 and magnitude in XX12+2\n\\\n\\   XX12(5 4)           The dot product of [x y z] vector with the nosev (or _z)\n\\                       vector, with the sign in XX12+5 and magnitude in XX12+4\n\\\n\\ ******************************************************************************\n\n.LL51\n\n LDX #0                 \\ Set X = 0, which will contain the offset of the vector\n                        \\ to use in the calculation, increasing by 6 for each\n                        \\ new vector\n\n LDY #0                 \\ Set Y = 0, which will contain the offset of the\n                        \\ result bytes in XX12, increasing by 2 for each new\n                        \\ result\n\n.ll51\n\n LDA XX15               \\ Set Q = x_lo\n STA Q\n\n LDA XX16,X             \\ Set A = |sidev_x|\n\n JSR FMLTU              \\ Set T = A * Q / 256\n STA T                  \\       = |sidev_x| * x_lo / 256\n\n LDA XX15+1             \\ Set S to the sign of x_sign * sidev_x\n EOR XX16+1,X\n STA S\n\n LDA XX15+2             \\ Set Q = y_lo\n STA Q\n\n LDA XX16+2,X           \\ Set A = |sidev_y|\n\n JSR FMLTU              \\ Set Q = A * Q / 256\n STA Q                  \\       = |sidev_y| * y_lo / 256\n\n LDA T                  \\ Set R = T\n STA R                  \\       = |sidev_x| * x_lo / 256\n\n LDA XX15+3             \\ Set A to the sign of y_sign * sidev_y\n EOR XX16+3,X\n\n JSR LL38               \\ Set (S T) = (S R) + (A Q)\n STA T                  \\           = |sidev_x| * x_lo + |sidev_y| * y_lo\n\n LDA XX15+4             \\ Set Q = z_lo\n STA Q\n\n LDA XX16+4,X           \\ Set A = |sidev_z|\n\n JSR FMLTU              \\ Set Q = A * Q / 256\n STA Q                  \\       = |sidev_z| * z_lo / 256\n\n LDA T                  \\ Set R = T\n STA R                  \\       = |sidev_x| * x_lo + |sidev_y| * y_lo\n\n LDA XX15+5             \\ Set A to the sign of z_sign * sidev_z\n EOR XX16+5,X\n\n JSR LL38               \\ Set (S A) = (S R) + (A Q)\n                        \\           = |sidev_x| * x_lo + |sidev_y| * y_lo\n                        \\             + |sidev_z| * z_lo\n\n STA XX12,Y             \\ Store the result in XX12+Y(1 0)\n LDA S\n STA XX12+1,Y\n\n INY                    \\ Set Y = Y + 2\n INY\n\n TXA                    \\ Set X = X + 6\n CLC\n ADC #6\n TAX\n\n CMP #17                \\ If X < 17, loop back to ll51 for the next vector\n BCC ll51\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: LL9 (Part 1 of 12)\n\\       Type: Subroutine\n\\   Category: Drawing ships\n\\    Summary: Draw ship: Check if ship is exploding, check if ship is in front\n\\  Deep dive: Drawing ships\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine draws the current ship on the screen. This part checks to see if\n\\ the ship is exploding, or if it should start exploding, and if it does it sets\n\\ things up accordingly.\n\\\n\\ It also does some basic checks to see if we can see the ship, and if not it\n\\ removes it from the screen.\n\\\n\\ In this code, XX1 is used to point to the current ship's data block at INWK\n\\ (the two labels are interchangeable).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   XX1                 XX1 shares its location with INWK, which contains the\n\\                       zero-page copy of the data block for this ship from the\n\\                       K% workspace\n\\\n\\   INF                 The address of the data block for this ship in workspace\n\\                       K%\n\\\n\\   XX19(1 0)           XX19(1 0) shares its location with INWK(34 33), which\n\\                       contains the ship line heap address pointer\n\\\n\\   XX0                 The address of the blueprint for this ship\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   EE51                Remove the current ship from the screen, called from\n\\                       SHPPT before drawing the ship as a point\n\\\n\\ ******************************************************************************\n\n.LL25\n\n JMP PLANET             \\ Jump to the PLANET routine, returning from the\n                        \\ subroutine using a tail call\n\n.LL9\n\n LDA TYPE               \\ If the ship type is negative then this indicates a\n BMI LL25               \\ planet or sun, so jump to PLANET via LL25 above\n\n LDA #31                \\ Set XX4 = 31 to store the ship's distance for later\n STA XX4                \\ comparison with the visibility distance. We will\n                        \\ update this value below with the actual ship's\n                        \\ distance if it turns out to be visible on-screen\n\n LDA #%00100000         \\ If bit 5 of the ship's byte #31 is set, then the ship\n BIT XX1+31             \\ is currently exploding, so jump down to EE28\n BNE EE28\n\n BPL EE28               \\ If bit 7 of the ship's byte #31 is clear then the ship\n                        \\ has not just been killed, so jump down to EE28\n\n                        \\ Otherwise bit 5 is clear and bit 7 is set, so the ship\n                        \\ is not yet exploding but it has been killed, so we\n                        \\ need to start an explosion\n\n ORA XX1+31             \\ Clear bits 6 and 7 of the ship's byte #31, to stop the\n AND #%00111111         \\ ship from firing its laser and to mark it as no longer\n STA XX1+31             \\ having just been killed\n\n LDA #0                 \\ Set the ship's acceleration in byte #31 to 0, updating\n LDY #28                \\ the byte in the workspace K% data block so we don't\n STA (INF),Y            \\ have to copy it back from INWK later\n\n LDY #30                \\ Set the ship's pitch counter in byte #30 to 0, to stop\n STA (INF),Y            \\ the ship from pitching\n\n JSR EE51               \\ Call EE51 to remove the ship from the screen\n\n                        \\ We now need to set up a new explosion cloud. We\n                        \\ initialise it with a size of 18 (which gets increased\n                        \\ by 4 every time the cloud gets redrawn), and the\n                        \\ explosion count (i.e. the number of particles in the\n                        \\ explosion), which go into bytes 1 and 2 of the ship\n                        \\ line heap. See DOEXP for more details of explosion\n                        \\ clouds\n\n LDY #1                 \\ Set byte #1 of the ship line heap to 18, the initial\n LDA #18                \\ size of the explosion cloud\n STA (XX19),Y\n\n LDY #7                 \\ Fetch byte #7 from the ship's blueprint, which\n LDA (XX0),Y            \\ determines the explosion count (i.e. the number of\n LDY #2                 \\ vertices used as origins for explosion clouds), and\n STA (XX19),Y           \\ store it in byte #2 of the ship line heap\n\n\\LDA XX1+32             \\ These instructions are commented out in the original\n\\AND #&7F               \\ source\n\n                        \\ The following loop sets bytes 3-6 of the of the ship\n                        \\ line heap to random numbers\n\n.EE55\n\n INY                    \\ Increment Y (so the loop starts at 3)\n\n JSR DORND              \\ Set A and X to random numbers\n\n STA (XX19),Y           \\ Store A in the Y-th byte of the ship line heap\n\n CPY #6                 \\ Loop back until we have randomised the 6th byte\n BNE EE55\n\n.EE28\n\n LDA XX1+8              \\ Set A = z_sign\n\n.EE49\n\n BPL LL10               \\ If A is positive, i.e. the ship is in front of us,\n                        \\ jump down to LL10\n\n.LL14\n\n                        \\ The following removes the ship from the screen by\n                        \\ redrawing it (or, if it is exploding, by redrawing the\n                        \\ explosion cloud). We call it when the ship is no\n                        \\ longer on-screen, is too far away to be fully drawn,\n                        \\ and so on\n\n LDA XX1+31             \\ If bit 5 of the ship's byte #31 is clear, then the\n AND #%00100000         \\ ship is not currently exploding, so jump down to EE51\n BEQ EE51               \\ to redraw its wireframe\n\n LDA XX1+31             \\ The ship is exploding, so clear bit 3 of the ship's\n AND #%11110111         \\ byte #31 to denote that the ship is no longer being\n STA XX1+31             \\ drawn on-screen\n\n JMP DOEXP              \\ Jump to DOEXP to display the explosion cloud, which\n                        \\ will remove it from the screen, returning from the\n                        \\ subroutine using a tail call\n\n.EE51\n\n LDA #%00001000         \\ If bit 3 of the ship's byte #31 is clear, then there\n BIT XX1+31             \\ is already nothing being shown for this ship, so\n BEQ LL10-1             \\ return from the subroutine (as LL10-1 contains an RTS)\n\n EOR XX1+31             \\ Otherwise flip bit 3 of byte #31 and store it (which\n STA XX1+31             \\ clears bit 3 as we know it was set before the EOR), so\n                        \\ this sets this ship as no longer being drawn on-screen\n\n JMP LL155              \\ Jump to LL155 to draw the ship, which removes it from\n                        \\ the screen, returning from the subroutine using a\n                        \\ tail call\n\n\\.LL24                  \\ This label is commented out in the original source,\n                        \\ and was presumably used to label the RTS which is\n                        \\ actually called by LL10-1 above, not LL24\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: LL9 (Part 2 of 12)\n\\       Type: Subroutine\n\\   Category: Drawing ships\n\\    Summary: Draw ship: Check if ship is in field of view, close enough to draw\n\\  Deep dive: Drawing ships\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This part checks whether the ship is in our field of view, and whether it is\n\\ close enough to be fully drawn (if not, we jump to SHPPT to draw it as a dot).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   LL10-1              Contains an RTS\n\\\n\\ ******************************************************************************\n\n.LL10\n\n LDA XX1+7              \\ Set A = z_hi\n\n CMP #192               \\ If A >= 192 then the ship is a long way away, so jump\n BCS LL14               \\ to LL14 to remove the ship from the screen\n\n LDA XX1                \\ If x_lo >= z_lo, set the C flag, otherwise clear it\n CMP XX1+6\n\n LDA XX1+1              \\ Set A = x_hi - z_hi using the carry from the low\n SBC XX1+7              \\ bytes, which sets the C flag as if we had done a full\n                        \\ two-byte subtraction (x_hi x_lo) - (z_hi z_lo)\n\n BCS LL14               \\ If the C flag is set then x >= z, so the ship is\n                        \\ further to the side than it is in front of us, so it's\n                        \\ outside our viewing angle of 45 degrees, and we jump\n                        \\ to LL14 to remove it from the screen\n\n LDA XX1+3              \\ If y_lo >= z_lo, set the C flag, otherwise clear it\n CMP XX1+6\n\n LDA XX1+4              \\ Set A = y_hi - z_hi using the carry from the low\n SBC XX1+7              \\ bytes, which sets the C flag as if we had done a full\n                        \\ two-byte subtraction (y_hi y_lo) - (z_hi z_lo)\n\n BCS LL14               \\ If the C flag is set then y >= z, so the ship is\n                        \\ further above us than it is in front of us, so it's\n                        \\ outside our viewing angle of 45 degrees, and we jump\n                        \\ to LL14 to remove it from the screen\n\n LDY #6                 \\ Fetch byte #6 from the ship's blueprint into X, which\n LDA (XX0),Y            \\ is the number * 4 of the vertex used for the ship's\n TAX                    \\ laser\n\n LDA #255               \\ Set bytes X and X+1 of the XX3 heap to 255. We're\n STA XX3,X              \\ going to use XX3 to store the screen coordinates of\n STA XX3+1,X            \\ all the visible vertices of this ship, so setting the\n                        \\ laser vertex to 255 means that if we don't update this\n                        \\ vertex with its screen coordinates in parts 6 and 7,\n                        \\ this vertex's entry in the XX3 heap will still be 255,\n                        \\ which we can check in part 9 to see if the laser\n                        \\ vertex is visible (and therefore whether we should\n                        \\ draw laser lines if the ship is firing at us)\n\n LDA XX1+6              \\ Set (A T) = (z_hi z_lo)\n STA T\n LDA XX1+7\n\n LSR A                  \\ Set (A T) = (A T) / 8\n ROR T\n LSR A\n ROR T\n LSR A\n ROR T\n\n LSR A                  \\ If A >> 4 is non-zero, i.e. z_hi >= 16, jump to LL13\n BNE LL13               \\ as the ship is possibly far away enough to be shown as\n                        \\ a dot\n\n LDA T                  \\ Otherwise the C flag contains the previous bit 0 of A,\n ROR A                  \\ which could have been set, so rotate A right four\n LSR A                  \\ times so it's in the form %000xxxxx, i.e. z_hi reduced\n LSR A                  \\ to a maximum value of 31\n LSR A\n\n STA XX4                \\ Store A in XX4, which is now the distance of the ship\n                        \\ we can use for visibility testing\n\n BPL LL17               \\ Jump down to LL17 (this BPL is effectively a JMP as we\n                        \\ know bit 7 of A is definitely clear)\n\n.LL13\n\n                        \\ If we get here then the ship is possibly far enough\n                        \\ away to be shown as a dot\n\n LDY #13                \\ Fetch byte #13 from the ship's blueprint, which gives\n LDA (XX0),Y            \\ the ship's visibility distance, beyond which we show\n                        \\ the ship as a dot\n\n CMP XX1+7              \\ If z_hi <= the visibility distance, skip to LL17 to\n BCS LL17               \\ draw the ship fully, rather than as a dot, as it is\n                        \\ closer than the visibility distance\n\n LDA #%00100000         \\ If bit 5 of the ship's byte #31 is set, then the\n AND XX1+31             \\ ship is currently exploding, so skip to LL17 to draw\n BNE LL17               \\ the ship's explosion cloud\n\n JMP SHPPT              \\ Otherwise jump to SHPPT to draw the ship as a dot,\n                        \\ returning from the subroutine using a tail call\n\n\\ ******************************************************************************\n\\\n\\       Name: LL9 (Part 3 of 12)\n\\       Type: Subroutine\n\\   Category: Drawing ships\n\\    Summary: Draw ship: Set up orientation vector, ship coordinate variables\n\\  Deep dive: Drawing ships\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This part sets up the following variable blocks:\n\\\n\\   * XX16 contains the orientation vectors, divided to normalise them\n\\\n\\   * XX18 contains the ship's x, y and z coordinates in space\n\\\n\\ ******************************************************************************\n\n.LL17\n\n LDX #5                 \\ First we copy the three orientation vectors into XX16,\n                        \\ so set up a counter in X for the 6 bytes in each\n                        \\ vector\n\n.LL15\n\n LDA XX1+21,X           \\ Copy the X-th byte of sidev to the X-th byte of XX16\n STA XX16,X\n\n LDA XX1+15,X           \\ Copy the X-th byte of roofv to XX16+6 to the X-th byte\n STA XX16+6,X           \\ of XX16+6\n\n LDA XX1+9,X            \\ Copy the X-th byte of nosev to XX16+12 to the X-th\n STA XX16+12,X          \\ byte of XX16+12\n\n DEX                    \\ Decrement the counter\n\n BPL LL15               \\ Loop back to copy the next byte of each vector, until\n                        \\ we have the following:\n                        \\\n                        \\   * XX16(1 0) = sidev_x\n                        \\   * XX16(3 2) = sidev_y\n                        \\   * XX16(5 4) = sidev_z\n                        \\\n                        \\   * XX16(7 6) = roofv_x\n                        \\   * XX16(9 8) = roofv_y\n                        \\   * XX16(11 10) = roofv_z\n                        \\\n                        \\   * XX16(13 12) = nosev_x\n                        \\   * XX16(15 14) = nosev_y\n                        \\   * XX16(17 16) = nosev_z\n\n LDA #197               \\ Set Q = 197\n STA Q\n\n LDY #16                \\ Set Y to be a counter that counts down by 2 each time,\n                        \\ starting with 16, then 14, 12 and so on. We use this\n                        \\ to work through each of the coordinates in each of the\n                        \\ orientation vectors\n\n.LL21\n\n LDA XX16,Y             \\ Set A = the low byte of the vector coordinate, e.g.\n                        \\ nosev_z_lo when Y = 16\n\n ASL A                  \\ Shift bit 7 into the C flag\n\n LDA XX16+1,Y           \\ Set A = the high byte of the vector coordinate, e.g.\n                        \\ nosev_z_hi when Y = 16\n\n ROL A                  \\ Rotate A left, incorporating the C flag, so A now\n                        \\ contains the original high byte, doubled, and without\n                        \\ a sign bit, e.g. A = |nosev_z_hi| * 2\n\n JSR LL28               \\ Call LL28 to calculate:\n                        \\\n                        \\   R = 256 * A / Q\n                        \\\n                        \\ so, for nosev, this would be:\n                        \\\n                        \\   R = 256 * |nosev_z_hi| * 2 / 197\n                        \\     = 2.6 * |nosev_z_hi|\n\n LDX R                  \\ Store R in the low byte's location, so we can keep the\n STX XX16,Y             \\ old, unscaled high byte intact for the sign\n\n DEY                    \\ Decrement the loop counter twice\n DEY\n\n BPL LL21               \\ Loop back for the next vector coordinate until we have\n                        \\ divided them all\n\n                        \\ By this point, the vectors have been turned into\n                        \\ scaled magnitudes, so we have the following:\n                        \\\n                        \\   * XX16   = scaled |sidev_x|\n                        \\   * XX16+2 = scaled |sidev_y|\n                        \\   * XX16+4 = scaled |sidev_z|\n                        \\\n                        \\   * XX16+6  = scaled |roofv_x|\n                        \\   * XX16+8  = scaled |roofv_y|\n                        \\   * XX16+10 = scaled |roofv_z|\n                        \\\n                        \\   * XX16+12 = scaled |nosev_x|\n                        \\   * XX16+14 = scaled |nosev_y|\n                        \\   * XX16+16 = scaled |nosev_z|\n\n LDX #8                 \\ Next we copy the ship's coordinates into XX18, so set\n                        \\ up a counter in X for 9 bytes\n\n.ll91\n\n LDA XX1,X              \\ Copy the X-th byte from XX1 to XX18\n STA XX18,X\n\n DEX                    \\ Decrement the loop counter\n\n BPL ll91               \\ Loop back for the next byte until we have copied all\n                        \\ three coordinates\n\n                        \\ So we now have the following:\n                        \\\n                        \\   * XX18(2 1 0) = (x_sign x_hi x_lo)\n                        \\\n                        \\   * XX18(5 4 3) = (y_sign y_hi y_lo)\n                        \\\n                        \\   * XX18(8 7 6) = (z_sign z_hi z_lo)\n\n LDA #255               \\ Set the 15th byte of XX2 to 255, so that face 15 is\n STA XX2+15             \\ always visible. No ship definitions actually have this\n                        \\ number of faces, but this allows us to force a vertex\n                        \\ to always be visible by associating it with face 15\n                        \\ (see the ship blueprints for the Cobra Mk III at\n                        \\ SHIP_COBRA_MK_3 and the asteroid at SHIP_ASTEROID for\n                        \\ examples of vertices that are associated with face 15)\n\n LDY #12                \\ Set Y = 12 to point to the ship blueprint byte #12,\n\n LDA XX1+31             \\ If bit 5 of the ship's byte #31 is clear, then the\n AND #%00100000         \\ ship is not currently exploding, so jump down to EE29\n BEQ EE29               \\ to skip the following\n\n                        \\ Otherwise we fall through to set up the visibility\n                        \\ block for an exploding ship\n\n\\ ******************************************************************************\n\\\n\\       Name: LL9 (Part 4 of 12)\n\\       Type: Subroutine\n\\   Category: Drawing ships\n\\    Summary: Draw ship: Set visibility for exploding ship (all faces visible)\n\\  Deep dive: Drawing ships\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This part sets up the visibility block in XX2 for a ship that is exploding.\n\\\n\\ The XX2 block consists of one byte for each face in the ship's blueprint,\n\\ which holds the visibility of that face. Because the ship is exploding, we\n\\ want to set all the faces to be visible. A value of 255 in the visibility\n\\ table means the face is visible, so the following code sets each face to 255\n\\ and then skips over the face visibility calculations that we would apply to a\n\\ non-exploding ship.\n\\\n\\ ******************************************************************************\n\n LDA (XX0),Y            \\ Fetch byte #12 of the ship's blueprint, which contains\n                        \\ the number of faces * 4\n\n LSR A                  \\ Set X = A / 4\n LSR A                  \\       = the number of faces\n TAX\n\n LDA #255               \\ Set A = 255\n\n.EE30\n\n STA XX2,X              \\ Set the X-th byte of XX2 to 255\n\n DEX                    \\ Decrement the loop counter\n\n BPL EE30               \\ Loop back for the next byte until there is one byte\n                        \\ set to 255 for each face\n\n INX                    \\ Set XX4 = 0 for the distance value we use to test\n STX XX4                \\ for visibility, so we always shows everything\n\n.LL41\n\n JMP LL42               \\ Jump to LL42 to skip the face visibility calculations\n                        \\ as we don't need to do them now we've set up the XX2\n                        \\ block for the explosion\n\n\\ ******************************************************************************\n\\\n\\       Name: LL9 (Part 5 of 12)\n\\       Type: Subroutine\n\\   Category: Drawing ships\n\\    Summary: Draw ship: Calculate the visibility of each of the ship's faces\n\\  Deep dive: Drawing ships\n\\             Back-face culling\n\\\n\\ ******************************************************************************\n\n.EE29\n\n LDA (XX0),Y            \\ We set Y to 12 above before jumping down to EE29, so\n                        \\ this fetches byte #12 of the ship's blueprint, which\n                        \\ contains the number of faces * 4\n\n BEQ LL41               \\ If there are no faces in this ship, jump to LL42 (via\n                        \\ LL41) to skip the face visibility calculations\n\n STA XX20               \\ Set A = the number of faces * 4\n\n LDY #18                \\ Fetch byte #18 of the ship's blueprint, which contains\n LDA (XX0),Y            \\ the factor by which we scale the face normals, into X\n TAX\n\n LDA XX18+7             \\ Set A = z_hi\n\n.LL90\n\n TAY                    \\ Set Y = z_hi\n\n BEQ LL91               \\ If z_hi = 0 then jump to LL91\n\n                        \\ The following is a loop that jumps back to LL90+3,\n                        \\ i.e. here. LL90 is only used for this loop, so it's a\n                        \\ bit of a strange use of the label here\n\n INX                    \\ Increment the scale factor in X\n\n LSR XX18+4             \\ Divide (y_hi y_lo) by 2\n ROR XX18+3\n\n LSR XX18+1             \\ Divide (x_hi x_lo) by 2\n ROR XX18\n\n LSR A                  \\ Divide (z_hi z_lo) by 2 (as A contains z_hi)\n ROR XX18+6\n\n TAY                    \\ Set Y = z_hi\n\n BNE LL90+3             \\ If Y is non-zero, loop back to LL90+3 to divide the\n                        \\ three coordinates until z_hi is 0\n\n.LL91\n\n                        \\ By this point z_hi is 0 and X contains the number of\n                        \\ right shifts we had to do, plus the scale factor from\n                        \\ the blueprint\n\n STX XX17               \\ Store the updated scale factor in XX17\n\n LDA XX18+8             \\ Set XX15+5 = z_sign\n STA XX15+5\n\n LDA XX18               \\ Set XX15(1 0) = (x_sign x_lo)\n STA XX15\n LDA XX18+2\n STA XX15+1\n\n LDA XX18+3             \\ Set XX15(3 2) = (y_sign y_lo)\n STA XX15+2\n LDA XX18+5\n STA XX15+3\n\n LDA XX18+6             \\ Set XX15+4 = z_lo, so now XX15(5 4) = (z_sign z_lo)\n STA XX15+4\n\n JSR LL51               \\ Call LL51 to set XX12 to the dot products of XX15 and\n                        \\ XX16, which we'll call dot_sidev, dot_roofv and\n                        \\ dot_nosev:\n                        \\\n                        \\   XX12(1 0) = [x y z] . sidev\n                        \\             = (dot_sidev_sign dot_sidev_lo)\n                        \\             = dot_sidev\n                        \\\n                        \\   XX12(3 2) = [x y z] . roofv\n                        \\             = (dot_roofv_sign dot_roofv_lo)\n                        \\             = dot_roofv\n                        \\\n                        \\   XX12(5 4) = [x y z] . nosev\n                        \\             = (dot_nosev_sign dot_nosev_lo)\n                        \\             = dot_nosev\n\n LDA XX12               \\ Set XX18(2 0) = dot_sidev\n STA XX18\n LDA XX12+1\n STA XX18+2\n\n LDA XX12+2             \\ Set XX18(5 3) = dot_roofv\n STA XX18+3\n LDA XX12+3\n STA XX18+5\n\n LDA XX12+4             \\ Set XX18(8 6) = dot_nosev\n STA XX18+6\n LDA XX12+5\n STA XX18+8\n\n LDY #4                 \\ Fetch byte #4 of the ship's blueprint, which contains\n LDA (XX0),Y            \\ the low byte of the offset to the faces data\n\n CLC                    \\ Set V = low byte faces offset + XX0\n ADC XX0\n STA V\n\n LDY #17                \\ Fetch byte #17 of the ship's blueprint, which contains\n LDA (XX0),Y            \\ the high byte of the offset to the faces data\n\n ADC XX0+1              \\ Set V+1 = high byte faces offset + XX0+1\n STA V+1                \\\n                        \\ So V(1 0) now points to the start of the faces data\n                        \\ for this ship\n\n LDY #0                 \\ We're now going to loop through all the faces for this\n                        \\ ship, so set a counter in Y, starting from 0, which we\n                        \\ will increment by 4 each loop to step through the\n                        \\ four bytes of data for each face\n\n.LL86\n\n LDA (V),Y              \\ Fetch byte #0 for this face into A, so:\n                        \\\n                        \\   A = %xyz vvvvv, where:\n                        \\\n                        \\     * Bits 0-4 = visibility distance, beyond which the\n                        \\       face is always shown\n                        \\\n                        \\     * Bits 7-5 = the sign bits of normal_x, normal_y\n                        \\       and normal_z\n\n STA XX12+1             \\ Store byte #0 in XX12+1, so XX12+1 now has the sign of\n                        \\ normal_x\n\n AND #%00011111         \\ Extract bits 0-4 to give the visibility distance\n\n CMP XX4                \\ If XX4 <= the visibility distance, where XX4 contains\n BCS LL87               \\ the ship's z-distance reduced to 0-31 (which we set in\n                        \\ part 2), skip to LL87 as this face is close enough\n                        \\ that we have to test its visibility using the face\n                        \\ normals\n\n                        \\ Otherwise this face is within range and is therefore\n                        \\ always shown\n\n TYA                    \\ Set X = Y / 4\n LSR A                  \\       = the number of this face * 4 /4\n LSR A                  \\       = the number of this face\n TAX\n\n LDA #255               \\ Set the X-th byte of XX2 to 255 to denote that this\n STA XX2,X              \\ face is visible\n\n TYA                    \\ Set Y = Y + 4 to point to the next face\n ADC #4\n TAY\n\n JMP LL88               \\ Jump down to LL88 to skip the following, as we don't\n                        \\ need to test the face normals\n\n.LL87\n\n LDA XX12+1             \\ Fetch byte #0 for this face into A\n\n ASL A                  \\ Shift A left and store it, so XX12+3 now has the sign\n STA XX12+3             \\ of normal_y\n\n ASL A                  \\ Shift A left and store it, so XX12+5 now has the sign\n STA XX12+5             \\ of normal_z\n\n INY                    \\ Increment Y to point to byte #1\n\n LDA (V),Y              \\ Fetch byte #1 for this face and store in XX12, so\n STA XX12               \\ XX12 = normal_x\n\n INY                    \\ Increment Y to point to byte #2\n\n LDA (V),Y              \\ Fetch byte #2 for this face and store in XX12+2, so\n STA XX12+2             \\ XX12+2 = normal_y\n\n INY                    \\ Increment Y to point to byte #3\n\n LDA (V),Y              \\ Fetch byte #3 for this face and store in XX12+4, so\n STA XX12+4             \\ XX12+4 = normal_z\n\n                        \\ So we now have:\n                        \\\n                        \\   XX12(1 0) = (normal_x_sign normal_x)\n                        \\\n                        \\   XX12(3 2) = (normal_y_sign normal_y)\n                        \\\n                        \\   XX12(5 4) = (normal_z_sign normal_z)\n\n LDX XX17               \\ If XX17 < 4 then jump to LL92, otherwise we stored a\n CPX #4                 \\ larger scale factor above\n BCC LL92\n\n.LL143\n\n LDA XX18               \\ Set XX15(1 0) = XX18(2 0)\n STA XX15               \\               = dot_sidev\n LDA XX18+2\n STA XX15+1\n\n LDA XX18+3             \\ Set XX15(3 2) = XX18(5 3)\n STA XX15+2             \\               = dot_roofv\n LDA XX18+5\n STA XX15+3\n\n LDA XX18+6             \\ Set XX15(5 4) = XX18(8 6)\n STA XX15+4             \\               = dot_nosev\n LDA XX18+8\n STA XX15+5\n\n JMP LL89               \\ Jump down to LL89\n\n.ovflw\n\n                        \\ If we get here then the addition below overflowed, so\n                        \\ we halve the dot products and normal vector\n\n LSR XX18               \\ Divide dot_sidev_lo by 2, so dot_sidev = dot_sidev / 2\n\n LSR XX18+6             \\ Divide dot_nosev_lo by 2, so dot_nosev = dot_nosev / 2\n\n LSR XX18+3             \\ Divide dot_roofv_lo by 2, so dot_roofv = dot_roofv / 2\n\n LDX #1                 \\ Set X = 1 so when we fall through into LL92, we divide\n                        \\ the normal vector by 2 as well\n\n.LL92\n\n                        \\ We jump here from above with the scale factor in X,\n                        \\ and now we apply it by scaling the normal vector down\n                        \\ by a factor of 2^X (i.e. divide by 2^X)\n\n LDA XX12               \\ Set XX15 = normal_x\n STA XX15\n\n LDA XX12+2             \\ Set XX15+2 = normal_y\n STA XX15+2\n\n LDA XX12+4             \\ Set A = normal_z\n\n.LL93\n\n DEX                    \\ Decrement the scale factor in X\n\n BMI LL94               \\ If X was 0 before the decrement, there is no scaling\n                        \\ to do, so jump to LL94 to exit the loop\n\n LSR XX15               \\ Set XX15 = XX15 / 2\n                        \\          = normal_x / 2\n\n LSR XX15+2             \\ Set XX15+2 = XX15+2 / 2\n                        \\            = normal_y / 2\n\n LSR A                  \\ Set A = A / 2\n                        \\       = normal_z / 2\n\n DEX                    \\ Decrement the scale factor in X\n\n BPL LL93+3             \\ If we have more scaling to do, loop back up to the\n                        \\ first LSR above until the normal vector is scaled down\n\n.LL94\n\n STA R                  \\ Set R = normal_z\n\n LDA XX12+5             \\ Set S = normal_z_sign\n STA S\n\n LDA XX18+6             \\ Set Q = dot_nosev_lo\n STA Q\n\n LDA XX18+8             \\ Set A = dot_nosev_sign\n\n JSR LL38               \\ Set (S A) = (S R) + (A Q)\n                        \\           = normal_z + dot_nosev\n                        \\\n                        \\ setting the sign of the result in S\n\n BCS ovflw              \\ If the addition overflowed, jump up to ovflw to divide\n                        \\ both the normal vector and dot products by 2 and try\n                        \\ again\n\n STA XX15+4             \\ Set XX15(5 4) = (S A)\n LDA S                  \\               = normal_z + dot_nosev\n STA XX15+5\n\n LDA XX15               \\ Set R = normal_x\n STA R\n\n LDA XX12+1             \\ Set S = normal_x_sign\n STA S\n\n LDA XX18               \\ Set Q = dot_sidev_lo\n STA Q\n\n LDA XX18+2             \\ Set A = dot_sidev_sign\n\n JSR LL38               \\ Set (S A) = (S R) + (A Q)\n                        \\           = normal_x + dot_sidev\n                        \\\n                        \\ setting the sign of the result in S\n\n BCS ovflw              \\ If the addition overflowed, jump up to ovflw to divide\n                        \\ both the normal vector and dot products by 2 and try\n                        \\ again\n\n STA XX15               \\ Set XX15(1 0) = (S A)\n LDA S                  \\               = normal_x + dot_sidev\n STA XX15+1\n\n LDA XX15+2             \\ Set R = normal_y\n STA R\n\n LDA XX12+3             \\ Set S = normal_y_sign\n STA S\n\n LDA XX18+3             \\ Set Q = dot_roofv_lo\n STA Q\n\n LDA XX18+5             \\ Set A = dot_roofv_sign\n\n JSR LL38               \\ Set (S A) = (S R) + (A Q)\n                        \\           = normal_y + dot_roofv\n\n BCS ovflw              \\ If the addition overflowed, jump up to ovflw to divide\n                        \\ both the normal vector and dot products by 2 and try\n                        \\ again\n\n STA XX15+2             \\ Set XX15(3 2) = (S A)\n LDA S                  \\               = normal_y + dot_roofv\n STA XX15+3\n\n.LL89\n\n                        \\ When we get here, we have set up the following:\n                        \\\n                        \\   XX15(1 0) = normal_x + dot_sidev\n                        \\             = normal_x + [x y z] . sidev\n                        \\\n                        \\   XX15(3 2) = normal_y + dot_roofv\n                        \\             = normal_y + [x y z] . roofv\n                        \\\n                        \\   XX15(5 4) = normal_z + dot_nosev\n                        \\             = normal_z + [x y z] . nosev\n                        \\\n                        \\ and:\n                        \\\n                        \\   XX12(1 0) = (normal_x_sign normal_x)\n                        \\\n                        \\   XX12(3 2) = (normal_y_sign normal_y)\n                        \\\n                        \\   XX12(5 4) = (normal_z_sign normal_z)\n                        \\\n                        \\ We now calculate the dot product XX12 . XX15 to tell\n                        \\ us whether or not this face is visible\n\n LDA XX12               \\ Set Q = XX12\n STA Q\n\n LDA XX15               \\ Set A = XX15\n\n JSR FMLTU              \\ Set T = A * Q / 256\n STA T                  \\       = XX15 * XX12 / 256\n\n LDA XX12+1             \\ Set S = sign of XX15(1 0) * XX12(1 0), so:\n EOR XX15+1             \\\n STA S                  \\   (S T) = XX15(1 0) * XX12(1 0) / 256\n\n LDA XX12+2             \\ Set Q = XX12+2\n STA Q\n\n LDA XX15+2             \\ Set A = XX15+2\n\n JSR FMLTU              \\ Set Q = A * Q\n STA Q                  \\       = XX15+2 * XX12+2 / 256\n\n LDA T                  \\ Set T = R, so now:\n STA R                  \\\n                        \\   (S R) = XX15(1 0) * XX12(1 0) / 256\n\n LDA XX12+3             \\ Set A = sign of XX15+3 * XX12+3, so:\n EOR XX15+3             \\\n                        \\   (A Q) = XX15(3 2) * XX12(3 2) / 256\n\n JSR LL38               \\ Set (S T) = (S R) + (A Q)\n STA T                  \\           =   XX15(1 0) * XX12(1 0) / 256\n                        \\             + XX15(3 2) * XX12(3 2) / 256\n\n LDA XX12+4             \\ Set Q = XX12+4\n STA Q\n\n LDA XX15+4             \\ Set A = XX15+4\n\n JSR FMLTU              \\ Set Q = A * Q\n STA Q                  \\       = XX15+4 * XX12+4 / 256\n\n LDA T                  \\ Set T = R, so now:\n STA R                  \\\n                        \\   (S R) =   XX15(1 0) * XX12(1 0) / 256\n                        \\           + XX15(3 2) * XX12(3 2) / 256\n\n LDA XX15+5             \\ Set A = sign of XX15+5 * XX12+5, so:\n EOR XX12+5             \\\n                        \\   (A Q) = XX15(5 4) * XX12(5 4) / 256\n\n JSR LL38               \\ Set (S A) = (S R) + (A Q)\n                        \\           =   XX15(1 0) * XX12(1 0) / 256\n                        \\             + XX15(3 2) * XX12(3 2) / 256\n                        \\             + XX15(5 4) * XX12(5 4) / 256\n\n PHA                    \\ Push the result A onto the stack, so the stack now\n                        \\ contains the dot product XX12 . XX15\n\n TYA                    \\ Set X = Y / 4\n LSR A                  \\       = the number of this face * 4 /4\n LSR A                  \\       = the number of this face\n TAX\n\n PLA                    \\ Pull the dot product off the stack into A\n\n BIT S                  \\ If bit 7 of S is set, i.e. the dot product is\n BMI P%+4               \\ negative, then this face is visible as its normal is\n                        \\ pointing towards us, so skip the following instruction\n\n LDA #0                 \\ Otherwise the face is not visible, so set A = 0 so we\n                        \\ can store this to mean \"not visible\"\n\n STA XX2,X              \\ Store the face's visibility in the X-th byte of XX2\n\n INY                    \\ Above we incremented Y to point to byte #3, so this\n                        \\ increments Y to point to byte #4, i.e. byte #0 of the\n                        \\ next face\n\n.LL88\n\n CPY XX20               \\ If Y >= XX20, the number of faces * 4, jump down to\n BCS LL42               \\ LL42 to move on to the\n\n JMP LL86               \\ Otherwise loop back to LL86 to work out the visibility\n                        \\ of the next face\n\n\\ ******************************************************************************\n\\\n\\       Name: LL9 (Part 6 of 12)\n\\       Type: Subroutine\n\\   Category: Drawing ships\n\\    Summary: Draw ship: Calculate the visibility of each of the ship's vertices\n\\  Deep dive: Drawing ships\n\\             Calculating vertex coordinates\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This section calculates the visibility of each of the ship's vertices, and for\n\\ those that are visible, it starts the process of calculating the screen\n\\ coordinates of each vertex\n\\\n\\ ******************************************************************************\n\n.LL42\n\n                        \\ The first task is to set up the inverse matrix, ready\n                        \\ for us to send to the dot product routine at LL51.\n                        \\ Back up in part 3, we set up the following variables:\n                        \\\n                        \\   * XX16(1 0) = sidev_x\n                        \\   * XX16(3 2) = sidev_y\n                        \\   * XX16(5 4) = sidev_z\n                        \\\n                        \\   * XX16(7 6) = roofv_x\n                        \\   * XX16(9 8) = roofv_y\n                        \\   * XX16(11 10) = roofv_z\n                        \\\n                        \\   * XX16(13 12) = nosev_x\n                        \\   * XX16(15 14) = nosev_y\n                        \\   * XX16(17 16) = nosev_z\n                        \\\n                        \\ and we then scaled the vectors to give the following:\n                        \\\n                        \\   * XX16   = scaled |sidev_x|\n                        \\   * XX16+2 = scaled |sidev_y|\n                        \\   * XX16+4 = scaled |sidev_z|\n                        \\\n                        \\   * XX16+6  = scaled |roofv_x|\n                        \\   * XX16+8  = scaled |roofv_y|\n                        \\   * XX16+10 = scaled |roofv_z|\n                        \\\n                        \\   * XX16+12 = scaled |nosev_x|\n                        \\   * XX16+14 = scaled |nosev_y|\n                        \\   * XX16+16 = scaled |nosev_z|\n                        \\\n                        \\ We now need to rearrange these locations so they\n                        \\ effectively transpose the matrix into its inverse\n\n LDY XX16+2             \\ Set XX16+2 = XX16+6 = scaled |roofv_x|\n LDX XX16+3             \\ Set XX16+3 = XX16+7 = roofv_x_hi\n LDA XX16+6             \\ Set XX16+6 = XX16+2 = scaled |sidev_y|\n STA XX16+2             \\ Set XX16+7 = XX16+3 = sidev_y_hi\n LDA XX16+7\n STA XX16+3\n STY XX16+6\n STX XX16+7\n\n LDY XX16+4             \\ Set XX16+4 = XX16+12 = scaled |nosev_x|\n LDX XX16+5             \\ Set XX16+5 = XX16+13 = nosev_x_hi\n LDA XX16+12            \\ Set XX16+12 = XX16+4 = scaled |sidev_z|\n STA XX16+4             \\ Set XX16+13 = XX16+5 = sidev_z_hi\n LDA XX16+13\n STA XX16+5\n STY XX16+12\n STX XX16+13\n\n LDY XX16+10            \\ Set XX16+10 = XX16+14 = scaled |nosev_y|\n LDX XX16+11            \\ Set XX16+11 = XX16+15 = nosev_y_hi\n LDA XX16+14            \\ Set XX16+14 = XX16+10 = scaled |roofv_z|\n STA XX16+10            \\ Set XX16+15 = XX16+11 = roofv_z\n LDA XX16+15\n STA XX16+11\n STY XX16+14\n STX XX16+15\n\n                        \\ So now we have the following sign-magnitude variables\n                        \\ containing parts of the scaled orientation vectors:\n                        \\\n                        \\   XX16(1 0)   = scaled sidev_x\n                        \\   XX16(3 2)   = scaled roofv_x\n                        \\   XX16(5 4)   = scaled nosev_x\n                        \\\n                        \\   XX16(7 6)   = scaled sidev_y\n                        \\   XX16(9 8)   = scaled roofv_y\n                        \\   XX16(11 10) = scaled nosev_y\n                        \\\n                        \\   XX16(13 12) = scaled sidev_z\n                        \\   XX16(15 14) = scaled roofv_z\n                        \\   XX16(17 16) = scaled nosev_z\n                        \\\n                        \\ which is what we want, as the various vectors are now\n                        \\ arranged so we can use LL51 to multiply by the\n                        \\ transpose (i.e. the inverse of the matrix)\n\n LDY #8                 \\ Fetch byte #8 of the ship's blueprint, which is the\n LDA (XX0),Y            \\ number of vertices * 8, and store it in XX20\n STA XX20\n\n                        \\ We now set V(1 0) = XX0(1 0) + 20, so V(1 0) points\n                        \\ to byte #20 of the ship's blueprint, which is always\n                        \\ where the vertex data starts (i.e. just after the 20\n                        \\ byte block that define the ship's characteristics)\n\n LDA XX0                \\ We start with the low bytes\n CLC\n ADC #20\n STA V\n\n LDA XX0+1              \\ And then do the high bytes\n ADC #0\n STA V+1\n\n LDY #0                 \\ We are about to step through all the vertices, using\n                        \\ Y as a counter. There are six data bytes for each\n                        \\ vertex, so we will increment Y by 6 for each iteration\n                        \\ so it can act as an offset from V(1 0) to the current\n                        \\ vertex's data\n\n STY CNT                \\ Set CNT = 0, which we will use as a pointer to the\n                        \\ heap at XX3, starting it at zero so the heap starts\n                        \\ out empty\n\n.LL48\n\n STY XX17               \\ Set XX17 = Y, so XX17 now contains the offset of the\n                        \\ current vertex's data\n\n LDA (V),Y              \\ Fetch byte #0 for this vertex into XX15, so:\n STA XX15               \\\n                        \\   XX15 = magnitude of the vertex's x-coordinate\n\n INY                    \\ Increment Y to point to byte #1\n\n LDA (V),Y              \\ Fetch byte #1 for this vertex into XX15+2, so:\n STA XX15+2             \\\n                        \\   XX15+2 = magnitude of the vertex's y-coordinate\n\n INY                    \\ Increment Y to point to byte #2\n\n LDA (V),Y              \\ Fetch byte #2 for this vertex into XX15+4, so:\n STA XX15+4             \\\n                        \\   XX15+4 = magnitude of the vertex's z-coordinate\n\n INY                    \\ Increment Y to point to byte #3\n\n LDA (V),Y              \\ Fetch byte #3 for this vertex into T, so:\n STA T                  \\\n                        \\   T = %xyz vvvvv, where:\n                        \\\n                        \\     * Bits 0-4 = visibility distance, beyond which the\n                        \\                  vertex is not shown\n                        \\\n                        \\     * Bits 7-5 = the sign bits of x, y and z\n\n AND #%00011111         \\ Extract bits 0-4 to get the visibility distance\n\n CMP XX4                \\ If XX4 > the visibility distance, where XX4 contains\n BCC LL49-3             \\ the ship's z-distance reduced to 0-31 (which we set in\n                        \\ part 2), then this vertex is too far away to be\n                        \\ visible, so jump down to LL50 (via the JMP instruction\n                        \\ in LL49-3) to move on to the next vertex\n\n INY                    \\ Increment Y to point to byte #4\n\n LDA (V),Y              \\ Fetch byte #4 for this vertex into P, so:\n STA P                  \\\n                        \\  P = %ffff ffff, where:\n                        \\\n                        \\    * Bits 0-3 = the number of face 1\n                        \\\n                        \\    * Bits 4-7 = the number of face 2\n\n AND #%00001111         \\ Extract the number of face 1 into X\n TAX\n\n LDA XX2,X              \\ If XX2+X is non-zero then we decided in part 5 that\n BNE LL49               \\ face 1 is visible, so jump to LL49\n\n LDA P                  \\ Fetch byte #4 for this vertex into A\n\n LSR A                  \\ Shift right four times to extract the number of face 2\n LSR A                  \\ from bits 4-7 into X\n LSR A\n LSR A\n TAX\n\n LDA XX2,X              \\ If XX2+X is non-zero then we decided in part 5 that\n BNE LL49               \\ face 2 is visible, so jump to LL49\n\n INY                    \\ Increment Y to point to byte #5\n\n LDA (V),Y              \\ Fetch byte #5 for this vertex into P, so:\n STA P                  \\\n                        \\  P = %ffff ffff, where:\n                        \\\n                        \\    * Bits 0-3 = the number of face 3\n                        \\\n                        \\    * Bits 4-7 = the number of face 4\n\n AND #%00001111         \\ Extract the number of face 1 into X\n TAX\n\n LDA XX2,X              \\ If XX2+X is non-zero then we decided in part 5 that\n BNE LL49               \\ face 3 is visible, so jump to LL49\n\n LDA P                  \\ Fetch byte #5 for this vertex into A\n\n LSR A                  \\ Shift right four times to extract the number of face 4\n LSR A                  \\ from bits 4-7 into X\n LSR A\n LSR A\n TAX\n\n LDA XX2,X              \\ If XX2+X is non-zero then we decided in part 5 that\n BNE LL49               \\ face 4 is visible, so jump to LL49\n\n JMP LL50               \\ If we get here then none of the four faces associated\n                        \\ with this vertex are visible, so this vertex is also\n                        \\ not visible, so jump to LL50 to move on to the next\n                        \\ vertex\n\n.LL49\n\n LDA T                  \\ Fetch byte #5 for this vertex into A and store it, so\n STA XX15+1             \\ XX15+1 now has the sign of the vertex's x-coordinate\n\n ASL A                  \\ Shift A left and store it, so XX15+3 now has the sign\n STA XX15+3             \\ of the vertex's y-coordinate\n\n ASL A                  \\ Shift A left and store it, so XX15+5 now has the sign\n STA XX15+5             \\ of the vertex's z-coordinate\n\n                        \\ By this point we have the following:\n                        \\\n                        \\   XX15(1 0) = vertex x-coordinate\n                        \\   XX15(3 2) = vertex y-coordinate\n                        \\   XX15(5 4) = vertex z-coordinate\n                        \\\n                        \\   XX16(1 0)   = scaled sidev_x\n                        \\   XX16(3 2)   = scaled roofv_x\n                        \\   XX16(5 4)   = scaled nosev_x\n                        \\\n                        \\   XX16(7 6)   = scaled sidev_y\n                        \\   XX16(9 8)   = scaled roofv_y\n                        \\   XX16(11 10) = scaled nosev_y\n                        \\\n                        \\   XX16(13 12) = scaled sidev_z\n                        \\   XX16(15 14) = scaled roofv_z\n                        \\   XX16(17 16) = scaled nosev_z\n\n JSR LL51               \\ Call LL51 to set XX12 to the dot products of XX15 and\n                        \\ XX16, as follows:\n                        \\\n                        \\   XX12(1 0) = [ x y z ] . [ sidev_x roofv_x nosev_x ]\n                        \\\n                        \\   XX12(3 2) = [ x y z ] . [ sidev_y roofv_y nosev_y ]\n                        \\\n                        \\   XX12(5 4) = [ x y z ] . [ sidev_z roofv_z nosev_z ]\n                        \\\n                        \\ XX12 contains the vector from the ship's centre to\n                        \\ the vertex, transformed from the orientation vector\n                        \\ space to the universe orientated around our ship. So\n                        \\ we can refer to this vector below, let's call it\n                        \\ vertv, so:\n                        \\\n                        \\   vertv_x = [ x y z ] . [ sidev_x roofv_x nosev_x ]\n                        \\\n                        \\   vertv_y = [ x y z ] . [ sidev_y roofv_y nosev_y ]\n                        \\\n                        \\   vertv_z = [ x y z ] . [ sidev_z roofv_z nosev_z ]\n                        \\\n                        \\ To finish the calculation, we now want to calculate:\n                        \\\n                        \\   vertv + [ x y z ]\n                        \\\n                        \\ So let's start with the vertv_x + x\n\n LDA XX1+2              \\ Set A = x_sign of the ship's location\n\n STA XX15+2             \\ Set XX15+2 = x_sign\n\n EOR XX12+1             \\ If the sign of x_sign * the sign of vertv_x is\n BMI LL52               \\ negative (i.e. they have different signs), skip to\n                        \\ LL52\n\n CLC                    \\ Set XX15(2 1 0) = XX1(2 1 0) + XX12(1 0)\n LDA XX12               \\                 = (x_sign x_hi x_lo) + vertv_x\n ADC XX1                \\\n STA XX15               \\ Starting with the low bytes\n\n LDA XX1+1              \\ And then doing the high bytes (we can add 0 here as\n ADC #0                 \\ we know the sign byte of vertv_x is 0)\n STA XX15+1\n\n JMP LL53               \\ We've added the x-coordinates, so jump to LL53 to do\n                        \\ the y-coordinates\n\n.LL52\n\n                        \\ If we get here then x_sign and vertv_x have different\n                        \\ signs, so we need to subtract them to get the result\n\n LDA XX1                \\ Set XX15(2 1 0) = XX1(2 1 0) - XX12(1 0)\n SEC                    \\                 = (x_sign x_hi x_lo) - vertv_x\n SBC XX12               \\\n STA XX15               \\ Starting with the low bytes\n\n LDA XX1+1              \\ And then doing the high bytes (we can subtract 0 here\n SBC #0                 \\ as we know the sign byte of vertv_x is 0)\n STA XX15+1\n\n BCS LL53               \\ If the subtraction didn't underflow, then the sign of\n                        \\ the result is the same sign as x_sign, and that's what\n                        \\ we want, so we can jump down to LL53 to do the\n                        \\ y-coordinates\n\n EOR #%11111111         \\ Otherwise we need to negate the result using two's\n STA XX15+1             \\ complement, so first we flip the bits of the high byte\n\n LDA #1                 \\ And then subtract the low byte from 1\n SBC XX15\n STA XX15\n\n BCC P%+4               \\ If the above subtraction underflowed then we need to\n INC XX15+1             \\ bump the high byte of the result up by 1\n\n LDA XX15+2             \\ And now we flip the sign of the result to get the\n EOR #%10000000         \\ correct result\n STA XX15+2\n\n.LL53\n\n                        \\ Now for the y-coordinates, vertv_y + y\n\n LDA XX1+5              \\ Set A = y_sign of the ship's location\n\n STA XX15+5             \\ Set XX15+5 = y_sign\n\n EOR XX12+3             \\ If the sign of y_sign * the sign of vertv_y is\n BMI LL54               \\ negative (i.e. they have different signs), skip to\n                        \\ LL54\n\n CLC                    \\ Set XX15(5 4 3) = XX1(5 4 3) + XX12(3 2)\n LDA XX12+2             \\                 = (y_sign y_hi y_lo) + vertv_y\n ADC XX1+3              \\\n STA XX15+3             \\ Starting with the low bytes\n\n LDA XX1+4              \\ And then doing the high bytes (we can add 0 here as\n ADC #0                 \\ we know the sign byte of vertv_y is 0)\n STA XX15+4\n\n JMP LL55               \\ We've added the y-coordinates, so jump to LL55 to do\n                        \\ the z-coordinates\n\n.LL54\n\n                        \\ If we get here then y_sign and vertv_y have different\n                        \\ signs, so we need to subtract them to get the result\n\n LDA XX1+3              \\ Set XX15(5 4 3) = XX1(5 4 3) - XX12(3 2)\n SEC                    \\                 = (y_sign y_hi y_lo) - vertv_y\n SBC XX12+2             \\\n STA XX15+3             \\ Starting with the low bytes\n\n LDA XX1+4              \\ And then doing the high bytes (we can subtract 0 here\n SBC #0                 \\ as we know the sign byte of vertv_z is 0)\n STA XX15+4\n\n BCS LL55               \\ If the subtraction didn't underflow, then the sign of\n                        \\ the result is the same sign as y_sign, and that's what\n                        \\ we want, so we can jump down to LL55 to do the\n                        \\ z-coordinates\n\n EOR #%11111111         \\ Otherwise we need to negate the result using two's\n STA XX15+4             \\ complement, so first we flip the bits of the high byte\n\n LDA XX15+3             \\ And then flip the bits of the low byte and add 1\n EOR #%11111111\n ADC #1\n STA XX15+3\n\n LDA XX15+5             \\ And now we flip the sign of the result to get the\n EOR #%10000000         \\ correct result\n STA XX15+5\n\n BCC LL55               \\ If the above subtraction underflowed then we need to\n INC XX15+4             \\ bump the high byte of the result up by 1\n\n.LL55\n\n                        \\ Now for the z-coordinates, vertv_z + z\n\n LDA XX12+5             \\ If vertv_z_hi is negative, jump down to LL56\n BMI LL56\n\n LDA XX12+4             \\ Set (U T) = XX1(7 6) + XX12(5 4)\n CLC                    \\           = (z_hi z_lo) + vertv_z\n ADC XX1+6              \\\n STA T                  \\ Starting with the low bytes\n\n LDA XX1+7              \\ And then doing the high bytes (we can add 0 here as\n ADC #0                 \\ we know the sign byte of vertv_y is 0)\n STA U\n\n JMP LL57               \\ We've added the z-coordinates, so jump to LL57\n\n                        \\ The adding process is continued in part 7, after a\n                        \\ couple of subroutines that we don't need quite yet\n\n\\ ******************************************************************************\n\\\n\\       Name: LL61\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate (U R) = 256 * A / Q\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following, where A >= Q:\n\\\n\\   (U R) = 256 * A / Q\n\\\n\\ This is a sister routine to LL28, which does the division when A < Q.\n\\\n\\ ******************************************************************************\n\n.LL61\n\n LDX Q                  \\ If Q = 0, jump down to LL84 to return a division\n BEQ LL84               \\ error\n\n                        \\ The LL28 routine returns A / Q, but only if A < Q. In\n                        \\ our case A >= Q, but we still want to use the LL28\n                        \\ routine, so we halve A until it's less than Q, call\n                        \\ the division routine, and then double A by the same\n                        \\ number of times\n\n LDX #0                 \\ Set X = 0 to count the number of times we halve A\n\n.LL63\n\n LSR A                  \\ Halve A by shifting right\n\n INX                    \\ Increment X\n\n CMP Q                  \\ If A >= Q, loop back to LL63 to halve it again\n BCS LL63\n\n STX S                  \\ Otherwise store the number of times we halved A in S\n\n JSR LL28               \\ Call LL28 to calculate:\n                        \\\n                        \\   R = 256 * A / Q\n                        \\\n                        \\ which we can do now as A < Q\n\n LDX S                  \\ Otherwise restore the number of times we halved A\n                        \\ above into X\n\n LDA R                  \\ Set A = our division result\n\n.LL64\n\n ASL A                  \\ Double (U A) by shifting left\n ROL U\n\n BMI LL84               \\ If bit 7 of U is set, the doubling has overflowed, so\n                        \\ jump to LL84 to return a division error\n\n DEX                    \\ Decrement X\n\n BNE LL64               \\ If X is not yet zero then we haven't done as many\n                        \\ doublings as we did halvings earlier, so loop back for\n                        \\ another doubling\n\n STA R                  \\ Store the low byte of the division result in R\n\n RTS                    \\ Return from the subroutine\n\n.LL84\n\n LDA #50                \\ If we get here then either we tried to divide by 0, or\n STA R                  \\ the result overflowed, so we set U and R to 50\n STA U\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: LL62\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate 128 - (U R)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following for a positive sign-magnitude number (U R):\n\\\n\\   128 - (U R)\n\\\n\\ and then store the result, low byte then high byte, on the end of the heap at\n\\ XX3, where X points to the first free byte on the heap. Return by jumping down\n\\ to LL66.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   X                   X is incremented by 1\n\\\n\\ ******************************************************************************\n\n.LL62\n\n LDA #128               \\ Calculate 128 - (U R), starting with the low bytes\n SEC\n SBC R\n\n STA XX3,X              \\ Store the low byte of the result in the X-th byte of\n                        \\ the heap at XX3\n\n INX                    \\ Increment the heap pointer in X to point to the next\n                        \\ byte\n\n LDA #0                 \\ And then subtract the high bytes\n SBC U\n\n STA XX3,X              \\ Store the low byte of the result in the X-th byte of\n                        \\ the heap at XX3\n\n JMP LL66               \\ Jump down to LL66\n\n\\ ******************************************************************************\n\\\n\\       Name: LL9 (Part 7 of 12)\n\\       Type: Subroutine\n\\   Category: Drawing ships\n\\    Summary: Draw ship: Calculate the visibility of each of the ship's vertices\n\\  Deep dive: Drawing ships\n\\             Calculating vertex coordinates\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This section continues the coordinate adding from part 6 by finishing off the\n\\ calculation that we started above:\n\\\n\\                      [ sidev_x roofv_x nosev_x ]   [ x ]   [ x ]\n\\   vector to vertex = [ sidev_y roofv_y nosev_y ] . [ y ] + [ y ]\n\\                      [ sidev_z roofv_z nosev_z ]   [ z ]   [ z ]\n\\\n\\ The gets stored as follows, in sign-magnitude values with the magnitudes\n\\ fitting into the low bytes:\n\\\n\\   XX15(2 0)           [ x y z ] . [ sidev_x roofv_x nosev_x ] + [ x y z ]\n\\\n\\   XX15(5 3)           [ x y z ] . [ sidev_y roofv_y nosev_y ] + [ x y z ]\n\\\n\\   (U T)               [ x y z ] . [ sidev_z roofv_z nosev_z ] + [ x y z ]\n\\\n\\ Finally, because this vector is from our ship to the vertex, and we are at the\n\\ origin, this vector is the same as the coordinates of the vertex. In other\n\\ words, we have just worked out:\n\\\n\\   XX15(2 0)           x-coordinate of the current vertex\n\\\n\\   XX15(5 3)           y-coordinate of the current vertex\n\\\n\\   (U T)               z-coordinate of the current vertex\n\\\n\\ ******************************************************************************\n\n.LL56\n\n LDA XX1+6              \\ Set (U T) = XX1(7 6) - XX12(5 4)\n SEC                    \\           = (z_hi z_lo) - vertv_z\n SBC XX12+4             \\\n STA T                  \\ Starting with the low bytes\n\n LDA XX1+7              \\ And then doing the high bytes (we can subtract 0 here\n SBC #0                 \\ as we know the sign byte of vertv_z is 0)\n STA U\n\n BCC LL140              \\ If the subtraction just underflowed, skip to LL140 to\n                        \\ set (U T) to the minimum value of 4\n\n BNE LL57               \\ If U is non-zero, jump down to LL57\n\n LDA T                  \\ If T >= 4, jump down to LL57\n CMP #4\n BCS LL57\n\n.LL140\n\n LDA #0                 \\ If we get here then either (U T) < 4 or the\n STA U                  \\ subtraction underflowed, so set (U T) = 4\n LDA #4\n STA T\n\n.LL57\n\n                        \\ By this point we have our results, so now to scale\n                        \\ the 16-bit results down into 8-bit values\n\n LDA U                  \\ If the high bytes of the result are all zero, we are\n ORA XX15+1             \\ done, so jump down to LL60 for the next stage\n ORA XX15+4\n BEQ LL60\n\n LSR XX15+1             \\ Shift XX15(1 0) to the right\n ROR XX15\n\n LSR XX15+4             \\ Shift XX15(4 3) to the right\n ROR XX15+3\n\n LSR U                  \\ Shift (U T) to the right\n ROR T\n\n JMP LL57               \\ Jump back to LL57 to see if we can shift the result\n                        \\ any more\n\n\\ ******************************************************************************\n\\\n\\       Name: LL9 (Part 8 of 12)\n\\       Type: Subroutine\n\\   Category: Drawing ships\n\\    Summary: Draw ship: Calculate the screen coordinates of visible vertices\n\\  Deep dive: Drawing ships\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This section projects the coordinate of the vertex into screen coordinates and\n\\ stores them on the XX3 heap. By the end of this part, the XX3 heap contains\n\\ four bytes containing the 16-bit screen coordinates of the current vertex, in\n\\ the order: x_lo, x_hi, y_lo, y_hi.\n\\\n\\ When we reach here, we are looping through the vertices, and we've just worked\n\\ out the coordinates of the vertex in our normal coordinate system, as follows\n\\\n\\   XX15(2 0)           (x_sign x_lo) = x-coordinate of the current vertex\n\\\n\\   XX15(5 3)           (y_sign y_lo) = y-coordinate of the current vertex\n\\\n\\   (U T)               (z_sign z_lo) = z-coordinate of the current vertex\n\\\n\\ Note that U is always zero when we get to this point, as the vertex is always\n\\ in front of us (so it has a positive z-coordinate, into the screen).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   LL70+1              Contains an RTS (as the first byte of an LDA\n\\                       instruction)\n\\\n\\   LL66                A re-entry point into the ship-drawing routine, used by\n\\                       the LL62 routine to store 128 - (U R) on the XX3 heap\n\\\n\\ ******************************************************************************\n\n.LL60\n\n LDA T                  \\ Set Q = z_lo\n STA Q\n\n LDA XX15               \\ Set A = x_lo\n\n CMP Q                  \\ If x_lo < z_lo jump to LL69\n BCC LL69\n\n JSR LL61               \\ Call LL61 to calculate:\n                        \\\n                        \\   (U R) = 256 * A / Q\n                        \\         = 256 * x / z\n                        \\\n                        \\ which we can do as x >= z\n\n JMP LL65               \\ Jump to LL65 to skip the division for x_lo < z_lo\n\n.LL69\n\n JSR LL28               \\ Call LL28 to calculate:\n                        \\\n                        \\   R = 256 * A / Q\n                        \\     = 256 * x / z\n                        \\\n                        \\ Because x < z, the result fits into one byte, and we\n                        \\ also know that U = 0, so (U R) also contains the\n                        \\ result\n\n.LL65\n\n                        \\ At this point we have:\n                        \\\n                        \\   (U R) = x / z\n                        \\\n                        \\ so (U R) contains the vertex's x-coordinate projected\n                        \\ on screen\n                        \\\n                        \\ The next task is to convert (U R) to a pixel screen\n                        \\ coordinate and stick it on the XX3 heap.\n                        \\\n                        \\ We start with the x-coordinate. To convert the\n                        \\ x-coordinate to a screen pixel we add 128, the\n                        \\ x-coordinate of the centre of the screen, because the\n                        \\ projected value is relative to an origin at the centre\n                        \\ of the screen, but the origin of the screen pixels is\n                        \\ at the top-left of the screen\n\n LDX CNT                \\ Fetch the pointer to the end of the XX3 heap from CNT\n                        \\ into X\n\n LDA XX15+2             \\ If x_sign is negative, jump up to LL62, which will\n BMI LL62               \\ store 128 - (U R) on the XX3 heap and return by\n                        \\ jumping down to LL66 below\n\n LDA R                  \\ Calculate 128 + (U R), starting with the low bytes\n CLC\n ADC #128\n\n STA XX3,X              \\ Store the low byte of the result in the X-th byte of\n                        \\ the heap at XX3\n\n INX                    \\ Increment the heap pointer in X to point to the next\n                        \\ byte\n\n LDA U                  \\ And then add the high bytes\n ADC #0\n\n STA XX3,X              \\ Store the high byte of the result in the X-th byte of\n                        \\ the heap at XX3\n\n.LL66\n\n                        \\ We've just stored the screen x-coordinate of the\n                        \\ vertex on the XX3 heap, so now for the y-coordinate\n\n TXA                    \\ Store the heap pointer in X on the stack (at this\n PHA                    \\ it points to the last entry on the heap, not the first\n                        \\ free byte)\n\n LDA #0                 \\ Set U = 0\n STA U\n\n LDA T                  \\ Set Q = z_lo\n STA Q\n\n LDA XX15+3             \\ Set A = y_lo\n\n CMP Q                  \\ If y_lo < z_lo jump to LL67\n BCC LL67\n\n JSR LL61               \\ Call LL61 to calculate:\n                        \\\n                        \\   (U R) = 256 * A / Q\n                        \\         = 256 * y / z\n                        \\\n                        \\ which we can do as y >= z\n\n JMP LL68               \\ Jump to LL68 to skip the division for y_lo < z_lo\n\n.LL70\n\n                        \\ This gets called from below when y_sign is negative\n\n LDA #Y                 \\ Calculate #Y + (U R), starting with the low bytes\n CLC\n ADC R\n\n STA XX3,X              \\ Store the low byte of the result in the X-th byte of\n                        \\ the heap at XX3\n\n INX                    \\ Increment the heap pointer in X to point to the next\n                        \\ byte\n\n LDA #0                 \\ And then add the high bytes\n ADC U\n\n STA XX3,X              \\ Store the high byte of the result in the X-th byte of\n                        \\ the heap at XX3\n\n JMP LL50               \\ Jump to LL50 to move on to the next vertex\n\n.LL67\n\n JSR LL28               \\ Call LL28 to calculate:\n                        \\\n                        \\   R = 256 * A / Q\n                        \\     = 256 * y / z\n                        \\\n                        \\ Because y < z, the result fits into one byte, and we\n                        \\ also know that U = 0, so (U R) also contains the\n                        \\ result\n\n.LL68\n\n                        \\ At this point we have:\n                        \\\n                        \\   (U R) = y / z\n                        \\\n                        \\ so (U R) contains the vertex's y-coordinate projected\n                        \\ on screen\n                        \\\n                        \\ We now want to convert this to a screen y-coordinate\n                        \\ and stick it on the XX3 heap, much like we did with\n                        \\ the x-coordinate above. Again, we convert the\n                        \\ coordinate by adding or subtracting the y-coordinate\n                        \\ of the centre of the screen, which is in the constant\n                        \\ #Y, but this time we do the opposite, as a positive\n                        \\ projected y-coordinate, i.e. up the space y-axis and\n                        \\ up the screen, converts to a low y-coordinate, which\n                        \\ is the opposite way round to the x-coordinates\n\n PLA                    \\ Restore the heap pointer from the stack into X\n TAX\n\n INX                    \\ When we stored the heap pointer, it pointed to the\n                        \\ last entry on the heap, not the first free byte, so we\n                        \\ increment it so it does point to the next free byte\n\n LDA XX15+5             \\ If y_sign is negative, jump up to LL70, which will\n BMI LL70               \\ store #Y + (U R) on the XX3 heap and return by jumping\n                        \\ down to LL50 below\n\n LDA #Y                 \\ Calculate #Y - (U R), starting with the low bytes\n SEC\n SBC R\n\n STA XX3,X              \\ Store the low byte of the result in the X-th byte of\n                        \\ the heap at XX3\n\n INX                    \\ Increment the heap pointer in X to point to the next\n                        \\ byte\n\n LDA #0                 \\ And then subtract the high bytes\n SBC U\n\n STA XX3,X              \\ Store the high byte of the result in the X-th byte of\n                        \\ the heap at XX3\n\n.LL50\n\n                        \\ By the time we get here, the XX3 heap contains four\n                        \\ bytes containing the screen coordinates of the current\n                        \\ vertex, in the order: x_lo, x_hi, y_lo, y_hi\n\n CLC                    \\ Set CNT = CNT + 4, so the heap pointer points to the\n LDA CNT                \\ next free byte on the heap\n ADC #4\n STA CNT\n\n LDA XX17               \\ Set A to the offset of the current vertex's data,\n                        \\ which we set in part 6\n\n ADC #6                 \\ Set Y = A + 6, so Y now points to the data for the\n TAY                    \\ next vertex\n\n BCS LL72               \\ If the addition just overflowed, meaning we just tried\n                        \\ to access vertex #43, jump to LL72, as the maximum\n                        \\ number of vertices allowed is 42\n\n CMP XX20               \\ If Y >= number of vertices * 6 (which we stored in\n BCS LL72               \\ XX20 in part 6), jump to LL72, as we have processed\n                        \\ all the vertices for this ship\n\n JMP LL48               \\ Loop back to LL48 in part 6 to calculate visibility\n                        \\ and screen coordinates for the next vertex\n\n\\ ******************************************************************************\n\\\n\\       Name: LL9 (Part 9 of 12)\n\\       Type: Subroutine\n\\   Category: Drawing ships\n\\    Summary: Draw ship: Draw laser beams if the ship is firing its laser at us\n\\  Deep dive: Drawing ships\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This part sets things up so we can loop through the edges in the next part. It\n\\ also adds a line to the ship line heap, if the ship is firing at us.\n\\\n\\ When we get here, the heap at XX3 contains all the visible vertex screen\n\\ coordinates.\n\\\n\\ ******************************************************************************\n\n.LL72\n\n LDA XX1+31             \\ If bit 5 of the ship's byte #31 is clear, then the\n AND #%00100000         \\ ship is not currently exploding, so jump down to EE31\n BEQ EE31\n\n LDA XX1+31             \\ The ship is exploding, so set bit 3 of the ship's byte\n ORA #%00001000         \\ #31 to denote that we are drawing something on-screen\n STA XX1+31             \\ for this ship\n\n JMP DOEXP              \\ Jump to DOEXP to display the explosion cloud,\n                        \\ returning from the subroutine using a tail call\n\n.EE31\n\n LDA #%00001000         \\ If bit 3 of the ship's byte #31 is clear, then there\n BIT XX1+31             \\ is nothing already being shown for this ship, so skip\n BEQ LL74               \\ to LL74 as we don't need to erase anything from the\n                        \\ screen\n\n JSR LL155              \\ Otherwise call LL155 to draw the existing ship, which\n                        \\ removes it from the screen\n\n LDA #%00001000         \\ Set bit 3 of A so the next instruction sets bit 3 of\n                        \\ the ship's byte #31 to denote that we are drawing\n                        \\ something on-screen for this ship\n\n.LL74\n\n ORA XX1+31             \\ Apply bit 3 of A to the ship's byte #31, so if there\n STA XX1+31             \\ was no ship already on screen, the bit is clear,\n                        \\ otherwise it is set\n\n LDY #9                 \\ Fetch byte #9 of the ship's blueprint, which is the\n LDA (XX0),Y            \\ number of edges, and store it in XX20\n STA XX20\n\n LDY #0                 \\ We are about to step through all the edges, using Y\n                        \\ as a counter\n\n STY U                  \\ Set U = 0 (though we increment it to 1 below)\n\n STY XX17               \\ Set XX17 = 0, which we are going to use as a counter\n                        \\ for stepping through the ship's edges\n\n INC U                  \\ We are going to start calculating the lines we need to\n                        \\ draw for this ship, and will store them in the ship\n                        \\ line heap, using U to point to the end of the heap, so\n                        \\ we start by setting U = 1\n\n BIT XX1+31             \\ If bit 6 of the ship's byte #31 is clear, then the\n BVC LL170              \\ ship is not firing its lasers, so jump to LL170 to\n                        \\ skip the drawing of laser lines\n\n                        \\ The ship is firing its laser at us, so we need to draw\n                        \\ the laser lines\n\n LDA XX1+31             \\ Clear bit 6 of the ship's byte #31 so the ship doesn't\n AND #%10111111         \\ keep firing endlessly\n STA XX1+31\n\n LDY #6                 \\ Fetch byte #6 of the ship's blueprint, which is the\n LDA (XX0),Y            \\ number * 4 of the vertex where the ship has its lasers\n\n TAY                    \\ Put the vertex number into Y, where it can act as an\n                        \\ index into list of vertex screen coordinates we added\n                        \\ to the XX3 heap\n\n LDX XX3,Y              \\ Fetch the x_lo coordinate of the laser vertex from the\n STX XX15               \\ XX3 heap into XX15\n\n INX                    \\ If X = 255 then the laser vertex is not visible, as\n BEQ LL170              \\ the value we stored in part 2 wasn't overwritten by\n                        \\ the vertex calculation in part 6 and 7, so jump to\n                        \\ LL170 to skip drawing the laser lines\n\n                        \\ We now build a laser beam from the ship's laser vertex\n                        \\ towards our ship, as follows:\n                        \\\n                        \\   XX15(1 0) = laser vertex x-coordinate\n                        \\\n                        \\   XX15(3 2) = laser vertex y-coordinate\n                        \\\n                        \\   XX15(5 4) = x-coordinate of the end of the beam\n                        \\\n                        \\   XX12(1 0) = y-coordinate of the end of the beam\n                        \\\n                        \\ The end of the laser beam will be positioned to look\n                        \\ good, rather than being directly aimed at us, as\n                        \\ otherwise we would only see a flashing point of light\n                        \\ as they unleashed their attack\n\n LDX XX3+1,Y            \\ Fetch the x_hi coordinate of the laser vertex from the\n STX XX15+1             \\ XX3 heap into XX15+1\n\n INX                    \\ If X = 255 then the laser vertex is not visible, as\n BEQ LL170              \\ the value we stored in part 2 wasn't overwritten by\n                        \\ a vertex calculation in part 6 and 7, so jump to LL170\n                        \\ to skip drawing the laser beam\n\n LDX XX3+2,Y            \\ Fetch the y_lo coordinate of the laser vertex from the\n STX XX15+2             \\ XX3 heap into XX15+2\n\n LDX XX3+3,Y            \\ Fetch the y_hi coordinate of the laser vertex from the\n STX XX15+3             \\ XX3 heap into XX15+3\n\n LDA #0                 \\ Set XX15(5 4) = 0, so their laser beam fires to the\n STA XX15+4             \\ left edge of the screen\n STA XX15+5\n\n STA XX12+1             \\ Set XX12(1 0) = the ship's z_lo coordinate, which will\n LDA XX1+6              \\ effectively make the vertical position of the end of\n STA XX12               \\ the laser beam move around as the ship moves in space\n\n LDA XX1+2              \\ If the ship's x_sign is positive, skip the next\n BPL P%+4               \\ instruction\n\n DEC XX15+4             \\ The ship's x_sign is negative (i.e. it's on the left\n                        \\ side of the screen), so switch the laser beam so it\n                        \\ goes to the right edge of the screen by decrementing\n                        \\ XX15(5 4) to 255\n\n JSR LL145              \\ Call LL145 to see if the laser beam needs to be\n                        \\ clipped to fit on-screen, returning the clipped line's\n                        \\ end-points in (X1, Y1) and (X2, Y2)\n\n BCS LL170              \\ If the C flag is set then the line is not visible on\n                        \\ screen, so jump to LL170 so we don't store this line\n                        \\ in the ship line heap\n\n LDY U                  \\ Fetch the ship line heap pointer, which points to the\n                        \\ next free byte on the heap, into Y\n\n LDA XX15               \\ Add X1 to the end of the heap\n STA (XX19),Y\n\n INY                    \\ Increment the heap pointer\n\n LDA XX15+1             \\ Add Y1 to the end of the heap\n STA (XX19),Y\n\n INY                    \\ Increment the heap pointer\n\n LDA XX15+2             \\ Add X2 to the end of the heap\n STA (XX19),Y\n\n INY                    \\ Increment the heap pointer\n\n LDA XX15+3             \\ Add Y2 to the end of the heap\n STA (XX19),Y\n\n INY                    \\ Increment the heap pointer\n\n STY U                  \\ Store the updated ship line heap pointer in U\n\n\\ ******************************************************************************\n\\\n\\       Name: LL9 (Part 10 of 12)\n\\       Type: Subroutine\n\\   Category: Drawing ships\n\\    Summary: Draw ship: Calculate the visibility of each of the ship's edges\n\\  Deep dive: Drawing ships\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This part calculates which edges are visible - in other words, which lines we\n\\ should draw - and clips them to fit on the screen.\n\\\n\\ When we get here, the heap at XX3 contains all the visible vertex screen\n\\ coordinates.\n\\\n\\ ******************************************************************************\n\n.LL170\n\n LDY #3                 \\ Fetch byte #3 of the ship's blueprint, which contains\n CLC                    \\ the low byte of the offset to the edges data\n LDA (XX0),Y\n\n ADC XX0                \\ Set V = low byte edges offset + XX0\n STA V\n\n LDY #16                \\ Fetch byte #16 of the ship's blueprint, which contains\n LDA (XX0),Y            \\ the high byte of the offset to the edges data\n\n ADC XX0+1              \\ Set V+1 = high byte edges offset + XX0+1\n STA V+1                \\\n                        \\ So V(1 0) now points to the start of the edges data\n                        \\ for this ship\n\n LDY #5                 \\ Fetch byte #5 of the ship's blueprint, which contains\n LDA (XX0),Y            \\ the maximum heap size for plotting the ship (which is\n STA T1                 \\ 1 + 4 * the maximum number of visible edges) and store\n                        \\ it in T1\n\n LDY XX17               \\ Set Y to the edge counter in XX17\n\n.LL75\n\n LDA (V),Y              \\ Fetch byte #0 for this edge, which contains the\n                        \\ visibility distance for this edge, beyond which the\n                        \\ edge is not shown\n\n CMP XX4                \\ If XX4 > the visibility distance, where XX4 contains\n BCC LL78               \\ the ship's z-distance reduced to 0-31 (which we set in\n                        \\ part 2), then this edge is too far away to be visible,\n                        \\ so jump down to LL78 to move on to the next edge\n\n INY                    \\ Increment Y to point to byte #1\n\n LDA (V),Y              \\ Fetch byte #1 for this edge into A, so:\n                        \\\n                        \\   A = %ffff ffff, where:\n                        \\\n                        \\     * Bits 0-3 = the number of face 1\n                        \\\n                        \\     * Bits 4-7 = the number of face 2\n\n INY                    \\ Increment Y to point to byte #2\n\n STA P                  \\ Store byte #1 into P\n\n AND #%00001111         \\ Extract the number of face 1 into X\n TAX\n\n LDA XX2,X              \\ If XX2+X is non-zero then we decided in part 5 that\n BNE LL79               \\ face 1 is visible, so jump to LL79\n\n LDA P                  \\ Fetch byte #1 for this edge into A\n\n LSR A                  \\ Shift right four times to extract the number of face 2\n LSR A                  \\ from bits 4-7 into X\n LSR A\n LSR A\n TAX\n\n LDA XX2,X              \\ If XX2+X is zero then we decided in part 5 that\n BEQ LL78               \\ face 2 is hidden, so jump to LL78\n\n.LL79\n\n                        \\ We now build the screen line for this edge, as\n                        \\ follows:\n                        \\\n                        \\   XX15(1 0) = start x-coordinate\n                        \\\n                        \\   XX15(3 2) = start y-coordinate\n                        \\\n                        \\   XX15(5 4) = end x-coordinate\n                        \\\n                        \\   XX12(1 0) = end y-coordinate\n                        \\\n                        \\ We can then pass this to the line clipping routine\n                        \\ before storing the resulting line in the ship line\n                        \\ heap\n\n LDA (V),Y              \\ Fetch byte #2 for this edge into X, which contains\n TAX                    \\ the number of the vertex at the start of the edge\n                        \\\n                        \\ Byte #2 contains the vertex number multiplied by 4,\n                        \\ so we can use it as an index into the heap at XX3 to\n                        \\ fetch the vertex's screen coordinates, which are\n                        \\ stored as four bytes containing two 16-bit numbers\n\n INY                    \\ Increment Y to point to byte #3\n\n LDA (V),Y              \\ Fetch byte #3 for this edge into Q, which contains\n STA Q                  \\ the number of the vertex at the end of the edge\n                        \\\n                        \\ Byte #3 contains the vertex number multiplied by 4,\n                        \\ so we can use it as an index into the heap at XX3 to\n                        \\ fetch the vertex's screen coordinates, which are\n                        \\ stored as four bytes containing two 16-bit numbers\n\n LDA XX3+1,X            \\ Fetch the x_hi coordinate of the edge's start vertex\n STA XX15+1             \\ from the XX3 heap into XX15+1\n\n LDA XX3,X              \\ Fetch the x_lo coordinate of the edge's start vertex\n STA XX15               \\ from the XX3 heap into XX15\n\n LDA XX3+2,X            \\ Fetch the y_lo coordinate of the edge's start vertex\n STA XX15+2             \\ from the XX3 heap into XX15+2\n\n LDA XX3+3,X            \\ Fetch the y_hi coordinate of the edge's start vertex\n STA XX15+3             \\ from the XX3 heap into XX15+3\n\n LDX Q                  \\ Set X to the number of the vertex at the end of the\n                        \\ edge, which we stored in Q\n\n LDA XX3,X              \\ Fetch the x_lo coordinate of the edge's end vertex\n STA XX15+4             \\ from the XX3 heap into XX15+4\n\n LDA XX3+3,X            \\ Fetch the y_hi coordinate of the edge's end vertex\n STA XX12+1             \\ from the XX3 heap into XX12+1\n\n LDA XX3+2,X            \\ Fetch the y_lo coordinate of the edge's end vertex\n STA XX12               \\ from the XX3 heap into XX12\n\n LDA XX3+1,X            \\ Fetch the x_hi coordinate of the edge's end vertex\n STA XX15+5             \\ from the XX3 heap into XX15+5\n\n JSR LL147              \\ Call LL147 to see if the new line segment needs to be\n                        \\ clipped to fit on-screen, returning the clipped line's\n                        \\ end-points in (X1, Y1) and (X2, Y2)\n\n BCS LL78               \\ If the C flag is set then the line is not visible on\n                        \\ screen, so jump to LL78 so we don't store this line\n                        \\ in the ship line heap\n\n\\ ******************************************************************************\n\\\n\\       Name: LL9 (Part 11 of 12)\n\\       Type: Subroutine\n\\   Category: Drawing ships\n\\    Summary: Draw ship: Add all visible edges to the ship line heap\n\\  Deep dive: Drawing ships\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This part adds all the visible edges to the ship line heap, so we can draw\n\\ them in part 12.\n\\\n\\ Other entry points:\n\\\n\\   LL81+2              Draw the contents of the ship line heap, used to draw\n\\                       the ship as a dot from SHPPT\n\\\n\\ ******************************************************************************\n\n.LL80\n\n LDY U                  \\ Fetch the ship line heap pointer, which points to the\n                        \\ next free byte on the heap, into Y\n\n LDA XX15               \\ Add X1 to the end of the heap\n STA (XX19),Y\n\n INY                    \\ Increment the heap pointer\n\n LDA XX15+1             \\ Add Y1 to the end of the heap\n STA (XX19),Y\n\n INY                    \\ Increment the heap pointer\n\n LDA XX15+2             \\ Add X2 to the end of the heap\n STA (XX19),Y\n\n INY                    \\ Increment the heap pointer\n\n LDA XX15+3             \\ Add Y2 to the end of the heap\n STA (XX19),Y\n\n INY                    \\ Increment the heap pointer\n\n STY U                  \\ Store the updated ship line heap pointer in U\n\n CPY T1                 \\ If Y >= T1 then we have reached the maximum number of\n BCS LL81               \\ edge lines that we can store in the ship line heap, so\n                        \\ skip to LL81 so we don't loop back for the next edge\n\n.LL78\n\n INC XX17               \\ Increment the edge counter to point to the next edge\n\n LDY XX17               \\ If Y >= XX20, which contains the number of edges in\n CPY XX20               \\ the blueprint, jump to LL81 as we have processed all\n BCS LL81               \\ the edges and don't need to loop back for the next one\n\n LDY #0                 \\ Set Y to point to byte #0 again, ready for the next\n                        \\ edge\n\n LDA V                  \\ Increment V by 4 so V(1 0) points to the data for the\n ADC #4                 \\ next edge\n STA V\n\n BCC ll81               \\ If the above addition didn't overflow, jump to ll81 to\n                        \\ skip the following instruction\n\n INC V+1                \\ Otherwise increment the high byte of V(1 0), as we\n                        \\ just moved the V(1 0) pointer past a page boundary\n\n.ll81\n\n JMP LL75               \\ Loop back to LL75 to process the next edge\n\n.LL81\n\n                        \\ We have finished adding lines to the ship line heap,\n                        \\ so now we need to set the first byte of the heap to\n                        \\ the number of bytes stored there\n\n LDA U                  \\ Fetch the ship line heap pointer from U into A, which\n                        \\ points to the end of the heap, and therefore contains\n                        \\ the heap size\n\n LDY #0                 \\ Store A as the first byte of the ship line heap, so\n STA (XX19),Y           \\ the heap is now correctly set up\n\n\\ ******************************************************************************\n\\\n\\       Name: LL9 (Part 12 of 12)\n\\       Type: Subroutine\n\\   Category: Drawing ships\n\\    Summary: Draw ship: Draw all the visible edges from the ship line heap\n\\  Deep dive: Drawing ships\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This part draws the lines in the ship line heap, which is used both to draw\n\\ the ship, and to remove it from the screen.\n\\\n\\ ******************************************************************************\n\n.LL155\n\n LDY #0                 \\ Fetch the first byte from the ship line heap into A,\n LDA (XX19),Y           \\ which contains the number of bytes in the heap\n\n STA XX20               \\ Store the heap size in XX20\n\n CMP #4                 \\ If the heap size is less than 4, there is nothing to\n BCC LL118-1            \\ draw, so return from the subroutine (as LL118-1\n                        \\ contains an RTS)\n\n INY                    \\ Set Y = 1, which we will use as an index into the ship\n                        \\ line heap, starting at byte #1 (as byte #0 contains\n                        \\ the heap size)\n\n.LL27\n\n LDA (XX19),Y           \\ Fetch the X1 line coordinate from the heap and store\n STA XX15               \\ it in XX15\n\n INY                    \\ Increment the heap pointer\n\n LDA (XX19),Y           \\ Fetch the Y1 line coordinate from the heap and store\n STA XX15+1             \\ it in XX15+1\n\n INY                    \\ Increment the heap pointer\n\n LDA (XX19),Y           \\ Fetch the X2 line coordinate from the heap and store\n STA XX15+2             \\ it in XX15+2\n\n INY                    \\ Increment the heap pointer\n\n LDA (XX19),Y           \\ Fetch the Y2 line coordinate from the heap and store\n STA XX15+3             \\ it in XX15+3\n\n JSR LL30               \\ Draw a line from (X1, Y1) to (X2, Y2)\n\n INY                    \\ Increment the heap pointer\n\n CPY XX20               \\ If the heap counter is less than the size of the heap,\n BCC LL27               \\ loop back to LL27 to draw the next line from the heap\n\n\\.LL82                  \\ This label is commented out in the original source\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: LL118\n\\       Type: Subroutine\n\\   Category: Drawing lines\n\\    Summary: Move a point along a line until it is on-screen\n\\  Deep dive: Line-clipping\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Given a point (x1, y1), a gradient and a direction of slope, move the point\n\\ along the line until it is on-screen, so this effectively clips the (x1, y1)\n\\ end of a line to be on the screen.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   XX15(1 0)           x1 as a 16-bit coordinate (x1_hi x1_lo)\n\\\n\\   XX15(3 2)           y1 as a 16-bit coordinate (y1_hi y1_lo)\n\\\n\\   XX12+2              The line's gradient * 256 (so 1.0 = 256)\n\\\n\\   XX12+3              The direction of slope:\n\\\n\\                         * Positive (bit 7 clear) = top left to bottom right\n\\\n\\                         * Negative (bit 7 set) = top right to bottom left\n\\\n\\   T                   The gradient of slope:\n\\\n\\                         * 0 if it's a shallow slope\n\\\n\\                         * &FF if it's a steep slope\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   XX15                x1 as an 8-bit coordinate\n\\\n\\   XX15+2              y1 as an 8-bit coordinate\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   LL118-1             Contains an RTS\n\\\n\\ ******************************************************************************\n\n.LL118\n\n LDA XX15+1             \\ If x1_hi is positive, jump down to LL119 to skip the\n BPL LL119              \\ following\n\n STA S                  \\ Otherwise x1_hi is negative, i.e. off the left of the\n                        \\ screen, so set S = x1_hi\n\n JSR LL120              \\ Call LL120 to calculate:\n                        \\\n                        \\   (Y X) = (S x1_lo) * XX12+2      if T = 0\n                        \\         = x1 * gradient\n                        \\\n                        \\   (Y X) = (S x1_lo) / XX12+2      if T <> 0\n                        \\         = x1 / gradient\n                        \\\n                        \\ with the sign of (Y X) set to the opposite of the\n                        \\ line's direction of slope\n\n TXA                    \\ Set y1 = y1 + (Y X)\n CLC                    \\\n ADC XX15+2             \\ starting with the low bytes\n STA XX15+2\n\n TYA                    \\ And then adding the high bytes\n ADC XX15+3\n STA XX15+3\n\n LDA #0                 \\ Set x1 = 0\n STA XX15\n STA XX15+1\n\n TAX                    \\ Set X = 0 so the next instruction becomes a JMP\n\n.LL119\n\n BEQ LL134              \\ If x1_hi = 0 then jump down to LL134 to skip the\n                        \\ following, as the x-coordinate is already on-screen\n                        \\ (as 0 <= (x_hi x_lo) <= 255)\n\n STA S                  \\ Otherwise x1_hi is positive, i.e. x1 >= 256 and off\n DEC S                  \\ the right side of the screen, so set S = x1_hi - 1\n\n JSR LL120              \\ Call LL120 to calculate:\n                        \\\n                        \\   (Y X) = (S x1_lo) * XX12+2      if T = 0\n                        \\         = (x1 - 256) * gradient\n                        \\\n                        \\   (Y X) = (S x1_lo) / XX12+2      if T <> 0\n                        \\         = (x1 - 256) / gradient\n                        \\\n                        \\ with the sign of (Y X) set to the opposite of the\n                        \\ line's direction of slope\n\n TXA                    \\ Set y1 = y1 + (Y X)\n CLC                    \\\n ADC XX15+2             \\ starting with the low bytes\n STA XX15+2\n\n TYA                    \\ And then adding the high bytes\n ADC XX15+3\n STA XX15+3\n\n LDX #255               \\ Set x1 = 255\n STX XX15\n INX\n STX XX15+1\n\n.LL134\n\n                        \\ We have moved the point so the x-coordinate is on\n                        \\ screen (i.e. in the range 0-255), so now for the\n                        \\ y-coordinate\n\n LDA XX15+3             \\ If y1_hi is positive, jump down to LL119 to skip\n BPL LL135              \\ the following\n\n STA S                  \\ Otherwise y1_hi is negative, i.e. off the top of the\n                        \\ screen, so set S = y1_hi\n\n LDA XX15+2             \\ Set R = y1_lo\n STA R\n\n JSR LL123              \\ Call LL123 to calculate:\n                        \\\n                        \\   (Y X) = (S R) / XX12+2      if T = 0\n                        \\         = y1 / gradient\n                        \\\n                        \\   (Y X) = (S R) * XX12+2      if T <> 0\n                        \\         = y1 * gradient\n                        \\\n                        \\ with the sign of (Y X) set to the opposite of the\n                        \\ line's direction of slope\n\n TXA                    \\ Set x1 = x1 + (Y X)\n CLC                    \\\n ADC XX15               \\ starting with the low bytes\n STA XX15\n\n TYA                    \\ And then adding the high bytes\n ADC XX15+1\n STA XX15+1\n\n LDA #0                 \\ Set y1 = 0\n STA XX15+2\n STA XX15+3\n\n.LL135\n\n\\BNE LL139              \\ This instruction is commented out in the original\n                        \\ source\n\n LDA XX15+2             \\ Set (S R) = (y1_hi y1_lo) - screen height\n SEC                    \\\n SBC #Y*2               \\ starting with the low bytes\n STA R\n\n LDA XX15+3             \\ And then subtracting the high bytes\n SBC #0\n STA S\n\n BCC LL136              \\ If the subtraction underflowed, i.e. if y1 < screen\n                        \\ height, then y1 is already on-screen, so jump to LL136\n                        \\ to return from the subroutine, as we are done\n\n.LL139\n\n                        \\ If we get here then y1 >= screen height, i.e. off the\n                        \\ bottom of the screen\n\n JSR LL123              \\ Call LL123 to calculate:\n                        \\\n                        \\   (Y X) = (S R) / XX12+2      if T = 0\n                        \\         = (y1 - screen height) / gradient\n                        \\\n                        \\   (Y X) = (S R) * XX12+2      if T <> 0\n                        \\         = (y1 - screen height) * gradient\n                        \\\n                        \\ with the sign of (Y X) set to the opposite of the\n                        \\ line's direction of slope\n\n TXA                    \\ Set x1 = x1 + (Y X)\n CLC                    \\\n ADC XX15               \\ starting with the low bytes\n STA XX15\n\n TYA                    \\ And then adding the high bytes\n ADC XX15+1\n STA XX15+1\n\n LDA #Y*2-1             \\ Set y1 = 2 * #Y - 1. The constant #Y is 96, the\n STA XX15+2             \\ y-coordinate of the mid-point of the space view, so\n LDA #0                 \\ this sets Y2 to 191, the y-coordinate of the bottom\n STA XX15+3             \\ pixel row of the space view\n\n.LL136\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: LL120\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate (Y X) = (S x1_lo) * XX12+2 or (S x1_lo) / XX12+2\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following:\n\\\n\\   * If T = 0, this is a shallow slope, so calculate (Y X) = (S x1_lo) * XX12+2\n\\\n\\   * If T <> 0, this is a steep slope, so calculate (Y X) = (S x1_lo) / XX12+2\n\\\n\\ giving (Y X) the opposite sign to the slope direction in XX12+3.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   T                   The gradient of slope:\n\\\n\\                         * 0 if it's a shallow slope\n\\\n\\                         * &FF if it's a steep slope\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   LL122               Calculate (Y X) = (S R) * Q and set the sign to the\n\\                       opposite of the top byte on the stack\n\\\n\\ ******************************************************************************\n\n.LL120\n\n LDA XX15               \\ Set R = x1_lo\n STA R\n\n\\.LL120                 \\ This label is commented out in the original source\n\n JSR LL129              \\ Call LL129 to do the following:\n                        \\\n                        \\   Q = XX12+2\n                        \\     = line gradient\n                        \\\n                        \\   A = S EOR XX12+3\n                        \\     = S EOR slope direction\n                        \\\n                        \\   (S R) = |S R|\n                        \\\n                        \\ So A contains the sign of S * slope direction\n\n PHA                    \\ Store A on the stack so we can use it later\n\n LDX T                  \\ If T is non-zero, then it's a steep slope, so jump\n BNE LL121              \\ down to LL121 to calculate this instead:\n                        \\\n                        \\   (Y X) = (S R) / Q\n\n.LL122\n\n                        \\ The following calculates:\n                        \\\n                        \\   (Y X) = (S R) * Q\n                        \\\n                        \\ using the same shift-and-add algorithm that's\n                        \\ documented in MULT1\n\n LDA #0                 \\ Set A = 0\n\n TAX                    \\ Set (Y X) = 0 so we can start building the answer here\n TAY\n\n LSR S                  \\ Shift (S R) to the right, so we extract bit 0 of (S R)\n ROR R                  \\ into the C flag\n\n ASL Q                  \\ Shift Q to the left, catching bit 7 in the C flag\n\n BCC LL126              \\ If C (i.e. the next bit from Q) is clear, do not do\n                        \\ the addition for this bit of Q, and instead skip to\n                        \\ LL126 to just do the shifts\n\n.LL125\n\n TXA                    \\ Set (Y X) = (Y X) + (S R)\n CLC                    \\\n ADC R                  \\ starting with the low bytes\n TAX\n\n TYA                    \\ And then doing the high bytes\n ADC S\n TAY\n\n.LL126\n\n LSR S                  \\ Shift (S R) to the right\n ROR R\n\n ASL Q                  \\ Shift Q to the left, catching bit 7 in the C flag\n\n BCS LL125              \\ If C (i.e. the next bit from Q) is set, loop back to\n                        \\ LL125 to do the addition for this bit of Q\n\n BNE LL126              \\ If Q has not yet run out of set bits, loop back to\n                        \\ LL126 to do the \"shift\" part of shift-and-add until\n                        \\ we have done additions for all the set bits in Q, to\n                        \\ give us our multiplication result\n\n PLA                    \\ Restore A, which we calculated above, from the stack\n\n BPL LL133              \\ If A is positive jump to LL133 to negate (Y X) and\n                        \\ return from the subroutine using a tail call\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: LL123\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate (Y X) = (S R) / XX12+2 or (S R) * XX12+2\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Calculate the following:\n\\\n\\   * If T = 0, this is a shallow slope, so calculate (Y X) = (S R) / XX12+2\n\\\n\\   * If T <> 0, this is a steep slope, so calculate (Y X) = (S R) * XX12+2\n\\\n\\ giving (Y X) the opposite sign to the slope direction in XX12+3.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   XX12+2              The line's gradient * 256 (so 1.0 = 256)\n\\\n\\   XX12+3              The direction of slope:\n\\\n\\                         * Bit 7 clear means top left to bottom right\n\\\n\\                         * Bit 7 set means top right to bottom left\n\\\n\\   T                   The gradient of slope:\n\\\n\\                         * 0 if it's a shallow slope\n\\\n\\                         * &FF if it's a steep slope\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   LL121               Calculate (Y X) = (S R) / Q and set the sign to the\n\\                       opposite of the top byte on the stack\n\\\n\\   LL133               Negate (Y X) and return from the subroutine\n\\\n\\   LL128               Contains an RTS\n\\\n\\ ******************************************************************************\n\n.LL123\n\n JSR LL129              \\ Call LL129 to do the following:\n                        \\\n                        \\   Q = XX12+2\n                        \\     = line gradient\n                        \\\n                        \\   A = S EOR XX12+3\n                        \\     = S EOR slope direction\n                        \\\n                        \\   (S R) = |S R|\n                        \\\n                        \\ So A contains the sign of S * slope direction\n\n PHA                    \\ Store A on the stack so we can use it later\n\n LDX T                  \\ If T is non-zero, then it's a steep slope, so jump up\n BNE LL122              \\ to LL122 to calculate this instead:\n                        \\\n                        \\   (Y X) = (S R) * Q\n\n.LL121\n\n                        \\ The following calculates:\n                        \\\n                        \\   (Y X) = (S R) / Q\n                        \\\n                        \\ using the same shift-and-subtract algorithm that's\n                        \\ documented in TIS2\n\n LDA #%11111111         \\ Set Y = %11111111\n TAY\n\n ASL A                  \\ Set X = %11111110\n TAX\n\n                        \\ This sets (Y X) = %1111111111111110, so we can rotate\n                        \\ through 15 loop iterations, getting a 1 each time, and\n                        \\ then getting a 0 on the 16th iteration... and we can\n                        \\ also use it to catch our result bits into bit 0 each\n                        \\ time\n\n.LL130\n\n ASL R                  \\ Shift (S R) to the left\n ROL S\n\n LDA S                  \\ Set A = S\n\n BCS LL131              \\ If bit 7 of S was set, then jump straight to the\n                        \\ subtraction\n\n CMP Q                  \\ If A < Q (i.e. S < Q), skip the following subtractions\n BCC LL132\n\n.LL131\n\n SBC Q                  \\ A >= Q (i.e. S >= Q) so set:\n STA S                  \\\n                        \\   S = (A R) - Q\n                        \\     = (S R) - Q\n                        \\\n                        \\ starting with the low bytes (we know the C flag is\n                        \\ set so the subtraction will be correct)\n\n LDA R                  \\ And then doing the high bytes\n SBC #0\n STA R\n\n SEC                    \\ Set the C flag to rotate into the result in (Y X)\n\n.LL132\n\n TXA                    \\ Rotate the counter in (Y X) to the left, and catch the\n ROL A                  \\ result bit into bit 0 (which will be a 0 if we didn't\n TAX                    \\ do the subtraction, or 1 if we did)\n TYA\n ROL A\n TAY\n\n BCS LL130              \\ If we still have set bits in (Y X), loop back to LL130\n                        \\ to do the next iteration of 15, until we have done the\n                        \\ whole division\n\n PLA                    \\ Restore A, which we calculated above, from the stack\n\n BMI LL128              \\ If A is negative jump to LL128 to return from the\n                        \\ subroutine with (Y X) as is\n\n.LL133\n\n TXA                    \\ Otherwise negate (Y X) using two's complement by first\n EOR #%11111111         \\ setting the low byte to ~X + 1\n\\CLC                    \\\n ADC #1                 \\ The CLC instruction is commented out in the original\n TAX                    \\ source. It would have no effect as we know the C flag\n                        \\ is clear from when we passed through the BCS above\n\n TYA                    \\ Then set the high byte to ~Y + C\n EOR #%11111111\n ADC #0\n TAY\n\n.LL128\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: LL129\n\\       Type: Subroutine\n\\   Category: Maths (Arithmetic)\n\\    Summary: Calculate Q = XX12+2, A = S EOR XX12+3 and (S R) = |S R|\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Do the following, in this order:\n\\\n\\   Q = XX12+2\n\\\n\\   A = S EOR XX12+3\n\\\n\\   (S R) = |S R|\n\\\n\\ This sets up the variables required above to calculate (S R) / XX12+2 and give\n\\ the result the opposite sign to XX12+3.\n\\\n\\ ******************************************************************************\n\n.LL129\n\n LDX XX12+2             \\ Set Q = XX12+2\n STX Q\n\n LDA S                  \\ If S is positive, jump to LL127\n BPL LL127\n\n LDA #0                 \\ Otherwise set R = -R\n SEC\n SBC R\n STA R\n\n LDA S                  \\ Push S onto the stack\n PHA\n\n EOR #%11111111         \\ Set S = ~S + 1 + C\n ADC #0\n STA S\n\n PLA                    \\ Pull the original, negative S from the stack into A\n\n.LL127\n\n EOR XX12+3             \\ Set A = original argument S EOR'd with XX12+3\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\       Name: LL145 (Part 1 of 4)\n\\       Type: Subroutine\n\\   Category: Drawing lines\n\\    Summary: Clip line: Work out which end-points are on-screen, if any\n\\  Deep dive: Line-clipping\n\\             Extended screen coordinates\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This routine clips the line from (x1, y1) to (x2, y2) so it fits on-screen, or\n\\ returns an error if it can't be clipped to fit. The arguments are 16-bit\n\\ coordinates, and the clipped line is returned using 8-bit screen coordinates.\n\\\n\\ This part sets XX13 to reflect which of the two points are on-screen and\n\\ off-screen.\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   XX15(1 0)           x1 as a 16-bit coordinate (x1_hi x1_lo)\n\\\n\\   XX15(3 2)           y1 as a 16-bit coordinate (y1_hi y1_lo)\n\\\n\\   XX15(5 4)           x2 as a 16-bit coordinate (x2_hi x2_lo)\n\\\n\\   XX12(1 0)           y2 as a 16-bit coordinate (y2_hi y2_lo)\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Returns:\n\\\n\\   (X1, Y1)            Screen coordinate of the start of the clipped line\n\\\n\\   (X2, Y2)            Screen coordinate of the end of the clipped line\n\\\n\\   C flag              Clear if the clipped line fits on-screen, set if it\n\\                       doesn't\n\\\n\\   XX13                The state of the original coordinates on-screen:\n\\\n\\                         * 0   = (x2, y2) on-screen\n\\\n\\                         * 95  = (x1, y1) on-screen,  (x2, y2) off-screen\n\\\n\\                         * 191 = (x1, y1) off-screen, (x2, y2) off-screen\n\\\n\\                       So XX13 is non-zero if the end of the line was clipped,\n\\                       meaning the next line sent to BLINE can't join onto the\n\\                       end but has to start a new segment\n\\\n\\   SWAP                The swap status of the returned coordinates:\n\\\n\\                         * &FF if we swapped the values of (x1, y1) and\n\\                           (x2, y2) as part of the clipping process\n\\\n\\                         * 0 if the coordinates are still in the same order\n\\\n\\   Y                   Y is preserved\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Other entry points:\n\\\n\\   LL147               Don't initialise the values in SWAP or A\n\\\n\\ ******************************************************************************\n\n.LL145\n\n LDA #0                 \\ Set SWAP = 0\n STA SWAP\n\n LDA XX15+5             \\ Set A = x2_hi\n\n.LL147\n\n LDX #Y*2-1             \\ Set X = #Y * 2 - 1. The constant #Y is 96, the\n                        \\ y-coordinate of the mid-point of the space view, so\n                        \\ this sets Y2 to 191, the y-coordinate of the bottom\n                        \\ pixel row of the space view\n\n ORA XX12+1             \\ If one or both of x2_hi and y2_hi are non-zero, jump\n BNE LL107              \\ to LL107 to skip the following, leaving X at 191\n\n CPX XX12               \\ If y2_lo > the y-coordinate of the bottom of screen\n BCC LL107              \\ then (x2, y2) is off the bottom of the screen, so skip\n                        \\ the following instruction, leaving X at 191\n\n LDX #0                 \\ Set X = 0\n\n.LL107\n\n STX XX13               \\ Set XX13 = X, so we have:\n                        \\\n                        \\   * XX13 = 0 if x2_hi = y2_hi = 0, y2_lo is on-screen\n                        \\\n                        \\   * XX13 = 191 if x2_hi or y2_hi are non-zero or y2_lo\n                        \\            is off the bottom of the screen\n                        \\\n                        \\ In other words, XX13 is 191 if (x2, y2) is off-screen,\n                        \\ otherwise it is 0\n\n LDA XX15+1             \\ If one or both of x1_hi and y1_hi are non-zero, jump\n ORA XX15+3             \\ to LL83\n BNE LL83\n\n LDA #Y*2-1             \\ If y1_lo > the y-coordinate of the bottom of screen\n CMP XX15+2             \\ then (x1, y1) is off the bottom of the screen, so jump\n BCC LL83               \\ to LL83\n\n                        \\ If we get here, (x1, y1) is on-screen\n\n LDA XX13               \\ If XX13 is non-zero, i.e. (x2, y2) is off-screen, jump\n BNE LL108              \\ to LL108 to halve it before continuing at LL83\n\n                        \\ If we get here, the high bytes are all zero, which\n                        \\ means the x-coordinates are < 256 and therefore fit on\n                        \\ screen, and neither coordinate is off the bottom of\n                        \\ the screen. That means both coordinates are already on\n                        \\ screen, so we don't need to do any clipping, all we\n                        \\ need to do is move the low bytes into (X1, Y1) and\n                        \\ X2, Y2) and return\n\n.LL146\n\n                        \\ If we get here then we have clipped our line to the\n                        \\ screen edge (if we had to clip it at all), so we move\n                        \\ the low bytes from (x1, y1) and (x2, y2) into (X1, Y1)\n                        \\ and (X2, Y2), remembering that they share locations\n                        \\ with XX15:\n                        \\\n                        \\   X1 = XX15\n                        \\   Y1 = XX15+1\n                        \\   X2 = XX15+2\n                        \\   Y2 = XX15+3\n                        \\\n                        \\ X1 already contains x1_lo, so now we do the rest\n\n LDA XX15+2             \\ Set Y1 (aka XX15+1) = y1_lo\n STA XX15+1\n\n LDA XX15+4             \\ Set X2 (aka XX15+2) = x2_lo\n STA XX15+2\n\n LDA XX12               \\ Set Y2 (aka XX15+3) = y2_lo\n STA XX15+3\n\n CLC                    \\ Clear the C flag as the clipped line fits on-screen\n\n RTS                    \\ Return from the subroutine\n\n.LL109\n\n SEC                    \\ Set the C flag to indicate the clipped line does not\n                        \\ fit on-screen\n\n RTS                    \\ Return from the subroutine\n\n.LL108\n\n LSR XX13               \\ If we get here then (x2, y2) is off-screen and XX13 is\n                        \\ 191, so shift XX13 right to halve it to 95\n\n\\ ******************************************************************************\n\\\n\\       Name: LL145 (Part 2 of 4)\n\\       Type: Subroutine\n\\   Category: Drawing lines\n\\    Summary: Clip line: Work out if any part of the line is on-screen\n\\  Deep dive: Line-clipping\n\\             Extended screen coordinates\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This part does a number of tests to see if the line is on or off the screen.\n\\\n\\ If we get here then at least one of (x1, y1) and (x2, y2) is off-screen, with\n\\ XX13 set as follows:\n\\\n\\   * 0   = (x1, y1) off-screen, (x2, y2) on-screen\n\\\n\\   * 95  = (x1, y1) on-screen,  (x2, y2) off-screen\n\\\n\\   * 191 = (x1, y1) off-screen, (x2, y2) off-screen\n\\\n\\ where \"off-screen\" is defined as having a non-zero high byte in one of the\n\\ coordinates, or in the case of y-coordinates, having a low byte > 191, the\n\\ y-coordinate of the bottom of the space view.\n\\\n\\ ******************************************************************************\n\n.LL83\n\n LDA XX13               \\ If XX13 < 128 then only one of the points is on-screen\n BPL LL115              \\ so jump down to LL115 to skip the checks of whether\n                        \\ both points are in the strips to the right or bottom\n                        \\ of the screen\n\n                        \\ If we get here, both points are off-screen\n\n LDA XX15+1             \\ If both x1_hi and x2_hi have bit 7 set, jump to LL109\n AND XX15+5             \\ to return from the subroutine with the C flag set, as\n BMI LL109              \\ the entire line is above the top of the screen\n\n LDA XX15+3             \\ If both y1_hi and y2_hi have bit 7 set, jump to LL109\n AND XX12+1             \\ to return from the subroutine with the C flag set, as\n BMI LL109              \\ the entire line is to the left of the screen\n\n LDX XX15+1             \\ Set A = X = x1_hi - 1\n DEX\n TXA\n\n LDX XX15+5             \\ Set XX12+2 = x2_hi - 1\n DEX\n STX XX12+2\n\n ORA XX12+2             \\ If neither (x1_hi - 1) or (x2_hi - 1) have bit 7 set,\n BPL LL109              \\ jump to LL109 to return from the subroutine with the C\n                        \\ flag set, as the line doesn't fit on-screen\n\n LDA XX15+2             \\ If y1_lo < y-coordinate of screen bottom, clear the C\n CMP #Y*2               \\ flag, otherwise set it\n\n LDA XX15+3             \\ Set XX12+2 = y1_hi - (1 - C), so:\n SBC #0                 \\\n STA XX12+2             \\  * Set XX12+2 = y1_hi - 1 if y1_lo is on-screen\n                        \\  * Set XX12+2 = y1_hi     otherwise\n                        \\\n                        \\ We do this subtraction because we are only interested\n                        \\ in trying to move the points up by a screen if that\n                        \\ might move the point into the space view portion of\n                        \\ the screen, i.e. if y1_lo is on-screen\n\n LDA XX12               \\ If y2_lo < y-coordinate of screen bottom, clear the C\n CMP #Y*2               \\ flag, otherwise set it\n\n LDA XX12+1             \\ Set XX12+2 = y2_hi - (1 - C), so:\n SBC #0                 \\\n                        \\  * Set XX12+1 = y2_hi - 1 if y2_lo is on-screen\n                        \\  * Set XX12+1 = y2_hi     otherwise\n                        \\\n                        \\ We do this subtraction because we are only interested\n                        \\ in trying to move the points up by a screen if that\n                        \\ might move the point into the space view portion of\n                        \\ the screen, i.e. if y1_lo is on-screen\n\n ORA XX12+2             \\ If neither XX12+1 or XX12+2 have bit 7 set, jump to\n BPL LL109              \\ LL109 to return from the subroutine with the C flag\n                        \\ set, as the line doesn't fit on-screen\n\n\\ ******************************************************************************\n\\\n\\       Name: LL145 (Part 3 of 4)\n\\       Type: Subroutine\n\\   Category: Drawing lines\n\\    Summary: Clip line: Calculate the line's gradient\n\\  Deep dive: Line-clipping\n\\             Extended screen coordinates\n\\\n\\ ******************************************************************************\n\n.LL115\n\n TYA                    \\ Store Y on the stack so we can preserve it through the\n PHA                    \\ call to this subroutine\n\n LDA XX15+4             \\ Set XX12+2 = x2_lo - x1_lo\n SEC\n SBC XX15\n STA XX12+2\n\n LDA XX15+5             \\ Set XX12+3 = x2_hi - x1_hi\n SBC XX15+1\n STA XX12+3\n\n LDA XX12               \\ Set XX12+4 = y2_lo - y1_lo\n SEC\n SBC XX15+2\n STA XX12+4\n\n LDA XX12+1             \\ Set XX12+5 = y2_hi - y1_hi\n SBC XX15+3\n STA XX12+5\n\n                        \\ So we now have:\n                        \\\n                        \\   delta_x in XX12(3 2)\n                        \\   delta_y in XX12(5 4)\n                        \\\n                        \\ where the delta is (x1, y1) - (x2, y2))\n\n EOR XX12+3             \\ Set S = the sign of delta_x * the sign of delta_y, so\n STA S                  \\ if bit 7 of S is set, the deltas have different signs\n\n LDA XX12+5             \\ If delta_y_hi is positive, jump down to LL110 to skip\n BPL LL110              \\ the following\n\n LDA #0                 \\ Otherwise flip the sign of delta_y to make it\n SEC                    \\ positive, starting with the low bytes\n SBC XX12+4\n STA XX12+4\n\n LDA #0                 \\ And then doing the high bytes, so now:\n SBC XX12+5             \\\n STA XX12+5             \\   XX12(5 4) = |delta_y|\n\n.LL110\n\n LDA XX12+3             \\ If delta_x_hi is positive, jump down to LL111 to skip\n BPL LL111              \\ the following\n\n SEC                    \\ Otherwise flip the sign of delta_x to make it\n LDA #0                 \\ positive, starting with the low bytes\n SBC XX12+2\n STA XX12+2\n\n LDA #0                 \\ And then doing the high bytes, so now:\n SBC XX12+3             \\\n                        \\   (A XX12+2) = |delta_x|\n\n.LL111\n\n                        \\ We now keep halving |delta_x| and |delta_y| until\n                        \\ both of them have zero in their high bytes\n\n TAX                    \\ If |delta_x_hi| is non-zero, skip the following\n BNE LL112\n\n LDX XX12+5             \\ If |delta_y_hi| = 0, jump down to LL113 (as both\n BEQ LL113              \\ |delta_x_hi| and |delta_y_hi| are 0)\n\n.LL112\n\n LSR A                  \\ Halve the value of delta_x in (A XX12+2)\n ROR XX12+2\n\n LSR XX12+5             \\ Halve the value of delta_y XX12(5 4)\n ROR XX12+4\n\n JMP LL111              \\ Loop back to LL111\n\n.LL113\n\n                        \\ By now, the high bytes of both |delta_x| and |delta_y|\n                        \\ are zero\n\n STX T                  \\ We know that X = 0 as that's what we tested with a BEQ\n                        \\ above, so this sets T = 0\n\n LDA XX12+2             \\ If delta_x_lo < delta_y_lo, so our line is more\n CMP XX12+4             \\ vertical than horizontal, jump to LL114\n BCC LL114\n\n                        \\ If we get here then our line is more horizontal than\n                        \\ vertical, so it is a shallow slope\n\n STA Q                  \\ Set Q = delta_x_lo\n\n LDA XX12+4             \\ Set A = delta_y_lo\n\n JSR LL28               \\ Call LL28 to calculate:\n                        \\\n                        \\   R = 256 * A / Q\n                        \\     = 256 * delta_y_lo / delta_x_lo\n\n JMP LL116              \\ Jump to LL116, as we now have the line's gradient in R\n\n.LL114\n\n                        \\ If we get here then our line is more vertical than\n                        \\ horizontal, so it is a steep slope\n\n LDA XX12+4             \\ Set Q = delta_y_lo\n STA Q\n LDA XX12+2             \\ Set A = delta_x_lo\n\n JSR LL28               \\ Call LL28 to calculate:\n                        \\\n                        \\   R = 256 * A / Q\n                        \\     = 256 * delta_x_lo / delta_y_lo\n\n DEC T                  \\ T was set to 0 above, so this sets T = &FF when our\n                        \\ line is steep\n\n\\ ******************************************************************************\n\\\n\\       Name: LL145 (Part 4 of 4)\n\\       Type: Subroutine\n\\   Category: Drawing lines\n\\    Summary: Clip line: Call the routine in LL188 to do the actual clipping\n\\  Deep dive: Line-clipping\n\\             Extended screen coordinates\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This part sets things up to call the routine in LL188, which does the actual\n\\ clipping.\n\\\n\\ If we get here, then R has been set to the gradient of the line (x1, y1) to\n\\ (x2, y2), with T indicating the gradient of slope:\n\\\n\\   * 0   = shallow slope (more horizontal than vertical)\n\\\n\\   * &FF = steep slope (more vertical than horizontal)\n\\\n\\ and XX13 has been set as follows:\n\\\n\\   * 0   = (x1, y1) off-screen, (x2, y2) on-screen\n\\\n\\   * 95  = (x1, y1) on-screen,  (x2, y2) off-screen\n\\\n\\   * 191 = (x1, y1) off-screen, (x2, y2) off-screen\n\\\n\\ ******************************************************************************\n\n.LL116\n\n LDA R                  \\ Store the gradient in XX12+2\n STA XX12+2\n\n LDA S                  \\ Store the type of slope in XX12+3, bit 7 clear means\n STA XX12+3             \\ top left to bottom right, bit 7 set means top right to\n                        \\ bottom left\n\n LDA XX13               \\ If XX13 = 0, skip the following instruction\n BEQ LL138\n\n BPL LLX117             \\ If XX13 is positive, it must be 95. This means\n                        \\ (x1, y1) is on-screen but (x2, y2) isn't, so we jump\n                        \\ to LLX117 to swap the (x1, y1) and (x2, y2)\n                        \\ coordinates around before doing the actual clipping,\n                        \\ because we need to clip (x2, y2) but the clipping\n                        \\ routine at LL118 only clips (x1, y1)\n\n.LL138\n\n                        \\ If we get here, XX13 = 0 or 191, so (x1, y1) is\n                        \\ off-screen and needs clipping\n\n JSR LL118              \\ Call LL118 to move (x1, y1) along the line onto the\n                        \\ screen, i.e. clip the line at the (x1, y1) end\n\n LDA XX13               \\ If XX13 = 0, i.e. (x2, y2) is on-screen, jump down to\n BPL LL124              \\ LL124 to return with a successfully clipped line\n\n.LL117\n\n                        \\ If we get here, XX13 = 191 (both coordinates are\n                        \\ off-screen)\n\n LDA XX15+1             \\ If either of x1_hi or y1_hi are non-zero, jump to\n ORA XX15+3             \\ LL137 to return from the subroutine with the C flag\n BNE LL137              \\ set, as the line doesn't fit on-screen\n\n LDA XX15+2             \\ If y1_lo > y-coordinate of the bottom of the screen\n CMP #Y*2               \\ jump to LL137 to return from the subroutine with the\n BCS LL137              \\ C flag set, as the line doesn't fit on-screen\n\n.LLX117\n\n                        \\ If we get here, XX13 = 95 or 191, and in both cases\n                        \\ (x2, y2) is off-screen, so we now need to swap the\n                        \\ (x1, y1) and (x2, y2) coordinates around before doing\n                        \\ the actual clipping, because we need to clip (x2, y2)\n                        \\ but the clipping routine at LL118 only clips (x1, y1)\n\n LDX XX15               \\ Swap x1_lo = x2_lo\n LDA XX15+4\n STA XX15\n STX XX15+4\n\n LDA XX15+5             \\ Swap x2_lo = x1_lo\n LDX XX15+1\n STX XX15+5\n STA XX15+1\n\n LDX XX15+2             \\ Swap y1_lo = y2_lo\n LDA XX12\n STA XX15+2\n STX XX12\n\n LDA XX12+1             \\ Swap y2_lo = y1_lo\n LDX XX15+3\n STX XX12+1\n STA XX15+3\n\n JSR LL118              \\ Call LL118 to move (x1, y1) along the line onto the\n                        \\ screen, i.e. clip the line at the (x1, y1) end\n\n DEC SWAP               \\ Set SWAP = &FF to indicate that we just clipped the\n                        \\ line at the (x2, y2) end by swapping the coordinates\n                        \\ (the DEC does this as we set SWAP to 0 at the start of\n                        \\ this subroutine)\n\n.LL124\n\n PLA                    \\ Restore Y from the stack so it gets preserved through\n TAY                    \\ the call to this subroutine\n\n JMP LL146              \\ Jump up to LL146 to move the low bytes of (x1, y1) and\n                        \\ (x2, y2) into (X1, Y1) and (X2, Y2), and return from\n                        \\ the subroutine with a successfully clipped line\n\n.LL137\n\n PLA                    \\ Restore Y from the stack so it gets preserved through\n TAY                    \\ the call to this subroutine\n\n SEC                    \\ Set the C flag to indicate the clipped line does not\n                        \\ fit on-screen\n\n RTS                    \\ Return from the subroutine\n\n\\ ******************************************************************************\n\\\n\\ Save ELTG.bin\n\\\n\\ ******************************************************************************\n\n PRINT \"ELITE G\"\n PRINT \"Assembled at \", ~CODE_G%\n PRINT \"Ends at \", ~P%\n PRINT \"Code size is \", ~(P% - CODE_G%)\n PRINT \"Execute at \", ~LOAD%\n PRINT \"Reload at \", ~LOAD_G%\n\n PRINT \"S.ELTG \", ~CODE_G%, \" \", ~P%, \" \", ~LOAD%, \" \", ~LOAD_G%\n SAVE \"3-assembled-output/ELTG.bin\", CODE_G%, P%, LOAD%\n\n\\ ******************************************************************************\n\\\n\\       Name: checksum0\n\\       Type: Variable\n\\   Category: Copy protection\n\\    Summary: Checksum for the entire main game code\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ This byte contains a checksum for the entire main game code. It is populated\n\\ by elite-checksum.py and is used by the encryption checks in elite-loader.asm\n\\ (see the CHK routine in the loader for more details).\n\\\n\\ ******************************************************************************\n\n.checksum0\n\n SKIP 1                 \\ This value is checked against the calculated checksum\n                        \\ in part 6 of the loader in elite-loader.asm\n\n\\ ******************************************************************************\n\\\n\\ ELITE SHIP BLUEPRINTS FILE\n\\\n\\ Produces the binary file SHIPS.bin that gets loaded by elite-bcfs.asm.\n\\\n\\ ******************************************************************************\n\n CODE_SHIPS% = P%\n\n LOAD_SHIPS% = LOAD% + P% - CODE%\n\n\\ ******************************************************************************\n\\\n\\       Name: XX21\n\\       Type: Variable\n\\   Category: Drawing ships\n\\    Summary: Ship blueprints lookup table\n\\  Deep dive: Ship blueprints\n\\\n\\ ******************************************************************************\n\n.XX21\n\n EQUW SHIP_SIDEWINDER   \\         1 = Sidewinder\n EQUW SHIP_VIPER        \\ COPS =  2 = Viper\n EQUW SHIP_MAMBA        \\         3 = Mamba\n EQUW SHIP_PYTHON       \\         4 = Python\n EQUW SHIP_COBRA_MK_3   \\         5 = Cobra Mk III (bounty hunter)\n EQUW SHIP_THARGOID     \\ THG  =  6 = Thargoid\n EQUW SHIP_COBRA_MK_3   \\ CYL  =  7 = Cobra Mk III (trader)\n EQUW SHIP_CORIOLIS     \\ SST  =  8 = Coriolis space station\n EQUW SHIP_MISSILE      \\ MSL  =  9 = Missile\n EQUW SHIP_ASTEROID     \\ AST  = 10 = Asteroid\n EQUW SHIP_CANISTER     \\ OIL  = 11 = Cargo canister\n EQUW SHIP_THARGON      \\ TGL  = 12 = Thargon\n EQUW SHIP_ESCAPE_POD   \\ ESC  = 13 = Escape pod\n\n\\ ******************************************************************************\n\\\n\\       Name: VERTEX\n\\       Type: Macro\n\\   Category: Drawing ships\n\\    Summary: Macro definition for adding vertices to ship blueprints\n\\  Deep dive: Ship blueprints\n\\             Drawing ships\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The following macro is used to build the ship blueprints:\n\\\n\\   VERTEX x, y, z, face1, face2, face3, face4, visibility\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   x                   The vertex's x-coordinate\n\\\n\\   y                   The vertex's y-coordinate\n\\\n\\   z                   The vertex's z-coordinate\n\\\n\\   face1               The number of face 1 associated with this vertex\n\\\n\\   face2               The number of face 2 associated with this vertex\n\\\n\\   face3               The number of face 3 associated with this vertex\n\\\n\\   face4               The number of face 4 associated with this vertex\n\\\n\\   visibility          The visibility distance, beyond which the vertex is not\n\\                       shown\n\\\n\\ ******************************************************************************\n\nMACRO VERTEX x, y, z, face1, face2, face3, face4, visibility\n\n IF x < 0\n  s_x = 1 << 7\n ELSE\n  s_x = 0\n ENDIF\n\n IF y < 0\n  s_y = 1 << 6\n ELSE\n  s_y = 0\n ENDIF\n\n IF z < 0\n  s_z = 1 << 5\n ELSE\n  s_z = 0\n ENDIF\n\n s = s_x + s_y + s_z + visibility\n f1 = face1 + (face2 << 4)\n f2 = face3 + (face4 << 4)\n ax = ABS(x)\n ay = ABS(y)\n az = ABS(z)\n\n EQUB ax, ay, az, s, f1, f2\n\nENDMACRO\n\n\\ ******************************************************************************\n\\\n\\       Name: EDGE\n\\       Type: Macro\n\\   Category: Drawing ships\n\\    Summary: Macro definition for adding edges to ship blueprints\n\\  Deep dive: Ship blueprints\n\\             Drawing ships\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The following macro is used to build the ship blueprints:\n\\\n\\   EDGE vertex1, vertex2, face1, face2, visibility\n\\\n\\ When stored in memory, bytes #2 and #3 contain the vertex numbers multiplied\n\\ by 4, so we can use them as indices into the heap at XX3 to fetch the screen\n\\ coordinates for each vertex, as they are stored as four bytes containing two\n\\ 16-bit numbers (see part 10 of the LL9 routine for details).\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   vertex1             The number of the vertex at the start of the edge\n\\\n\\   vertex1             The number of the vertex at the end of the edge\n\\\n\\   face1               The number of face 1 associated with this edge\n\\\n\\   face2               The number of face 2 associated with this edge\n\\\n\\   visibility          The visibility distance, beyond which the edge is not\n\\                       shown\n\\\n\\ ******************************************************************************\n\nMACRO EDGE vertex1, vertex2, face1, face2, visibility\n\n f = face1 + (face2 << 4)\n EQUB visibility, f, vertex1 << 2, vertex2 << 2\n\nENDMACRO\n\n\\ ******************************************************************************\n\\\n\\       Name: FACE\n\\       Type: Macro\n\\   Category: Drawing ships\n\\    Summary: Macro definition for adding faces to ship blueprints\n\\  Deep dive: Ship blueprints\n\\             Drawing ships\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The following macro is used to build the ship blueprints:\n\\\n\\   FACE normal_x, normal_y, normal_z, visibility\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ Arguments:\n\\\n\\   normal_x            The face normal's x-coordinate\n\\\n\\   normal_y            The face normal's y-coordinate\n\\\n\\   normal_z            The face normal's z-coordinate\n\\\n\\   visibility          The visibility distance, beyond which the edge is always\n\\                       shown\n\\\n\\ ******************************************************************************\n\nMACRO FACE normal_x, normal_y, normal_z, visibility\n\n IF normal_x < 0\n  s_x = 1 << 7\n ELSE\n  s_x = 0\n ENDIF\n\n IF normal_y < 0\n  s_y = 1 << 6\n ELSE\n  s_y = 0\n ENDIF\n\n IF normal_z < 0\n  s_z = 1 << 5\n ELSE\n  s_z = 0\n ENDIF\n\n s = s_x + s_y + s_z + visibility\n ax = ABS(normal_x)\n ay = ABS(normal_y)\n az = ABS(normal_z)\n\n EQUB s, ax, ay, az\n\nENDMACRO\n\n\\ ******************************************************************************\n\\\n\\       Name: SHIP_SIDEWINDER\n\\       Type: Variable\n\\   Category: Drawing ships\n\\    Summary: Ship blueprint for a Sidewinder\n\\  Deep dive: Ship blueprints\n\\             Comparing ship specifications\n\\\n\\ ******************************************************************************\n\n.SHIP_SIDEWINDER\n\n EQUB 0                 \\ Max. canisters on demise = 0\n EQUW 65 * 65           \\ Targetable area          = 65 * 65\n\n EQUB LO(SHIP_SIDEWINDER_EDGES - SHIP_SIDEWINDER)  \\ Edges data offset (low)\n EQUB LO(SHIP_SIDEWINDER_FACES - SHIP_SIDEWINDER)  \\ Faces data offset (low)\n\n EQUB 61                \\ Max. edge count          = (61 - 1) / 4 = 15\n EQUB 0                 \\ Gun vertex               = 0\n EQUB 30                \\ Explosion count          = 6, as (4 * n) + 6 = 30\n EQUB 60                \\ Number of vertices       = 60 / 6 = 10\n EQUB 15                \\ Number of edges          = 15\n EQUW 50                \\ Bounty                   = 50\n EQUB 28                \\ Number of faces          = 28 / 4 = 7\n EQUB 20                \\ Visibility distance      = 20\n EQUB 70                \\ Max. energy              = 70\n EQUB 37                \\ Max. speed               = 37\n\n EQUB HI(SHIP_SIDEWINDER_EDGES - SHIP_SIDEWINDER)  \\ Edges data offset (high)\n EQUB HI(SHIP_SIDEWINDER_FACES - SHIP_SIDEWINDER)  \\ Faces data offset (high)\n\n EQUB 2                 \\ Normals are scaled by    = 2^2 = 4\n EQUB %00010000         \\ Laser power              = 2\n                        \\ Missiles                 = 0\n\n.SHIP_SIDEWINDER_VERTICES\n\n      \\    x,    y,    z, face1, face2, face3, face4, visibility\n VERTEX  -32,    0,   36,     0,      1,    4,     5,         31    \\ Vertex 0\n VERTEX   32,    0,   36,     0,      2,    5,     6,         31    \\ Vertex 1\n VERTEX   64,    0,  -28,     2,      3,    6,     6,         31    \\ Vertex 2\n VERTEX  -64,    0,  -28,     1,      3,    4,     4,         31    \\ Vertex 3\n VERTEX    0,   16,  -28,     0,      1,    2,     3,         31    \\ Vertex 4\n VERTEX    0,  -16,  -28,     3,      4,    5,     6,         31    \\ Vertex 5\n VERTEX  -12,    6,  -28,     3,      3,    3,     3,         15    \\ Vertex 6\n VERTEX   12,    6,  -28,     3,      3,    3,     3,         15    \\ Vertex 7\n VERTEX   12,   -6,  -28,     3,      3,    3,     3,         12    \\ Vertex 8\n VERTEX  -12,   -6,  -28,     3,      3,    3,     3,         12    \\ Vertex 9\n\n.SHIP_SIDEWINDER_EDGES\n\n    \\ vertex1, vertex2, face1, face2, visibility\n EDGE       0,       1,     0,     5,         31    \\ Edge 0\n EDGE       1,       2,     2,     6,         31    \\ Edge 1\n EDGE       1,       4,     0,     2,         31    \\ Edge 2\n EDGE       0,       4,     0,     1,         31    \\ Edge 3\n EDGE       0,       3,     1,     4,         31    \\ Edge 4\n EDGE       3,       4,     1,     3,         31    \\ Edge 5\n EDGE       2,       4,     2,     3,         31    \\ Edge 6\n EDGE       3,       5,     3,     4,         31    \\ Edge 7\n EDGE       2,       5,     3,     6,         31    \\ Edge 8\n EDGE       1,       5,     5,     6,         31    \\ Edge 9\n EDGE       0,       5,     4,     5,         31    \\ Edge 10\n EDGE       6,       7,     3,     3,         15    \\ Edge 11\n EDGE       7,       8,     3,     3,         12    \\ Edge 12\n EDGE       6,       9,     3,     3,         12    \\ Edge 13\n EDGE       8,       9,     3,     3,         12    \\ Edge 14\n\n.SHIP_SIDEWINDER_FACES\n\n    \\ normal_x, normal_y, normal_z, visibility\n FACE        0,       32,        8,         31      \\ Face 0\n FACE      -12,       47,        6,         31      \\ Face 1\n FACE       12,       47,        6,         31      \\ Face 2\n FACE        0,        0,     -112,         31      \\ Face 3\n FACE      -12,      -47,        6,         31      \\ Face 4\n FACE        0,      -32,        8,         31      \\ Face 5\n FACE       12,      -47,        6,         31      \\ Face 6\n\n\\ ******************************************************************************\n\\\n\\       Name: SHIP_VIPER\n\\       Type: Variable\n\\   Category: Drawing ships\n\\    Summary: Ship blueprint for a Viper\n\\  Deep dive: Ship blueprints\n\\             Comparing ship specifications\n\\\n\\ ******************************************************************************\n\n.SHIP_VIPER\n\n EQUB 0                 \\ Max. canisters on demise = 0\n EQUW 75 * 75           \\ Targetable area          = 75 * 75\n\n EQUB LO(SHIP_VIPER_EDGES - SHIP_VIPER)            \\ Edges data offset (low)\n EQUB LO(SHIP_VIPER_FACES - SHIP_VIPER)            \\ Faces data offset (low)\n\n EQUB 77                \\ Max. edge count          = (77 - 1) / 4 = 19\n EQUB 0                 \\ Gun vertex               = 0\n EQUB 42                \\ Explosion count          = 9, as (4 * n) + 6 = 42\n EQUB 90                \\ Number of vertices       = 90 / 6 = 15\n EQUB 20                \\ Number of edges          = 20\n EQUW 0                 \\ Bounty                   = 0\n EQUB 28                \\ Number of faces          = 28 / 4 = 7\n EQUB 23                \\ Visibility distance      = 23\n EQUB 120               \\ Max. energy              = 120\n EQUB 32                \\ Max. speed               = 32\n\n EQUB HI(SHIP_VIPER_EDGES - SHIP_VIPER)            \\ Edges data offset (high)\n EQUB HI(SHIP_VIPER_FACES - SHIP_VIPER)            \\ Faces data offset (high)\n\n EQUB 1                 \\ Normals are scaled by    = 2^1 = 2\n EQUB %00010001         \\ Laser power              = 2\n                        \\ Missiles                 = 1\n\n.SHIP_VIPER_VERTICES\n\n      \\    x,    y,    z, face1, face2, face3, face4, visibility\n VERTEX    0,    0,   72,     1,      2,    3,     4,         31    \\ Vertex 0\n VERTEX    0,   16,   24,     0,      1,    2,     2,         30    \\ Vertex 1\n VERTEX    0,  -16,   24,     3,      4,    5,     5,         30    \\ Vertex 2\n VERTEX   48,    0,  -24,     2,      4,    6,     6,         31    \\ Vertex 3\n VERTEX  -48,    0,  -24,     1,      3,    6,     6,         31    \\ Vertex 4\n VERTEX   24,  -16,  -24,     4,      5,    6,     6,         30    \\ Vertex 5\n VERTEX  -24,  -16,  -24,     5,      3,    6,     6,         30    \\ Vertex 6\n VERTEX   24,   16,  -24,     0,      2,    6,     6,         31    \\ Vertex 7\n VERTEX  -24,   16,  -24,     0,      1,    6,     6,         31    \\ Vertex 8\n VERTEX  -32,    0,  -24,     6,      6,    6,     6,         19    \\ Vertex 9\n VERTEX   32,    0,  -24,     6,      6,    6,     6,         19    \\ Vertex 10\n VERTEX    8,    8,  -24,     6,      6,    6,     6,         19    \\ Vertex 11\n VERTEX   -8,    8,  -24,     6,      6,    6,     6,         19    \\ Vertex 12\n VERTEX   -8,   -8,  -24,     6,      6,    6,     6,         18    \\ Vertex 13\n VERTEX    8,   -8,  -24,     6,      6,    6,     6,         18    \\ Vertex 14\n\n.SHIP_VIPER_EDGES\n\n    \\ vertex1, vertex2, face1, face2, visibility\n EDGE       0,       3,     2,     4,         31    \\ Edge 0\n EDGE       0,       1,     1,     2,         30    \\ Edge 1\n EDGE       0,       2,     3,     4,         30    \\ Edge 2\n EDGE       0,       4,     1,     3,         31    \\ Edge 3\n EDGE       1,       7,     0,     2,         30    \\ Edge 4\n EDGE       1,       8,     0,     1,         30    \\ Edge 5\n EDGE       2,       5,     4,     5,         30    \\ Edge 6\n EDGE       2,       6,     3,     5,         30    \\ Edge 7\n EDGE       7,       8,     0,     6,         31    \\ Edge 8\n EDGE       5,       6,     5,     6,         30    \\ Edge 9\n EDGE       4,       8,     1,     6,         31    \\ Edge 10\n EDGE       4,       6,     3,     6,         30    \\ Edge 11\n EDGE       3,       7,     2,     6,         31    \\ Edge 12\n EDGE       3,       5,     6,     4,         30    \\ Edge 13\n EDGE       9,      12,     6,     6,         19    \\ Edge 14\n EDGE       9,      13,     6,     6,         18    \\ Edge 15\n EDGE      10,      11,     6,     6,         19    \\ Edge 16\n EDGE      10,      14,     6,     6,         18    \\ Edge 17\n EDGE      11,      14,     6,     6,         16    \\ Edge 18\n EDGE      12,      13,     6,     6,         16    \\ Edge 19\n\n.SHIP_VIPER_FACES\n\n    \\ normal_x, normal_y, normal_z, visibility\n FACE        0,       32,        0,         31      \\ Face 0\n FACE      -22,       33,       11,         31      \\ Face 1\n FACE       22,       33,       11,         31      \\ Face 2\n FACE      -22,      -33,       11,         31      \\ Face 3\n FACE       22,      -33,       11,         31      \\ Face 4\n FACE        0,      -32,        0,         31      \\ Face 5\n FACE        0,        0,      -48,         31      \\ Face 6\n\n\\ ******************************************************************************\n\\\n\\       Name: SHIP_MAMBA\n\\       Type: Variable\n\\   Category: Drawing ships\n\\    Summary: Ship blueprint for a Mamba\n\\  Deep dive: Ship blueprints\n\\             Comparing ship specifications\n\\\n\\ ******************************************************************************\n\n.SHIP_MAMBA\n\n EQUB 1                 \\ Max. canisters on demise = 1\n EQUW 70 * 70           \\ Targetable area          = 70 * 70\n\n EQUB LO(SHIP_MAMBA_EDGES - SHIP_MAMBA)            \\ Edges data offset (low)\n EQUB LO(SHIP_MAMBA_FACES - SHIP_MAMBA)            \\ Faces data offset (low)\n\n EQUB 93                \\ Max. edge count          = (93 - 1) / 4 = 23\n EQUB 0                 \\ Gun vertex               = 0\n EQUB 34                \\ Explosion count          = 7, as (4 * n) + 6 = 34\n EQUB 150               \\ Number of vertices       = 150 / 6 = 25\n EQUB 28                \\ Number of edges          = 28\n EQUW 150               \\ Bounty                   = 150\n EQUB 20                \\ Number of faces          = 20 / 4 = 5\n EQUB 25                \\ Visibility distance      = 25\n EQUB 90                \\ Max. energy              = 90\n EQUB 30                \\ Max. speed               = 30\n\n EQUB HI(SHIP_MAMBA_EDGES - SHIP_MAMBA)            \\ Edges data offset (high)\n EQUB HI(SHIP_MAMBA_FACES - SHIP_MAMBA)            \\ Faces data offset (high)\n\n EQUB 2                 \\ Normals are scaled by    = 2^2 = 4\n EQUB %00010010         \\ Laser power              = 2\n                        \\ Missiles                 = 2\n\n.SHIP_MAMBA_VERTICES\n\n      \\    x,    y,    z, face1, face2, face3, face4, visibility\n VERTEX    0,    0,   64,     0,      1,    2,     3,         31    \\ Vertex 0\n VERTEX  -64,   -8,  -32,     0,      2,    4,     4,         31    \\ Vertex 1\n VERTEX  -32,    8,  -32,     1,      2,    4,     4,         30    \\ Vertex 2\n VERTEX   32,    8,  -32,     1,      3,    4,     4,         30    \\ Vertex 3\n VERTEX   64,   -8,  -32,     0,      3,    4,     4,         31    \\ Vertex 4\n VERTEX   -4,    4,   16,     1,      1,    1,     1,         14    \\ Vertex 5\n VERTEX    4,    4,   16,     1,      1,    1,     1,         14    \\ Vertex 6\n VERTEX    8,    3,   28,     1,      1,    1,     1,         13    \\ Vertex 7\n VERTEX   -8,    3,   28,     1,      1,    1,     1,         13    \\ Vertex 8\n VERTEX  -20,   -4,   16,     0,      0,    0,     0,         20    \\ Vertex 9\n VERTEX   20,   -4,   16,     0,      0,    0,     0,         20    \\ Vertex 10\n VERTEX  -24,   -7,  -20,     0,      0,    0,     0,         20    \\ Vertex 11\n VERTEX  -16,   -7,  -20,     0,      0,    0,     0,         16    \\ Vertex 12\n VERTEX   16,   -7,  -20,     0,      0,    0,     0,         16    \\ Vertex 13\n VERTEX   24,   -7,  -20,     0,      0,    0,     0,         20    \\ Vertex 14\n VERTEX   -8,    4,  -32,     4,      4,    4,     4,         13    \\ Vertex 15\n VERTEX    8,    4,  -32,     4,      4,    4,     4,         13    \\ Vertex 16\n VERTEX    8,   -4,  -32,     4,      4,    4,     4,         14    \\ Vertex 17\n VERTEX   -8,   -4,  -32,     4,      4,    4,     4,         14    \\ Vertex 18\n VERTEX  -32,    4,  -32,     4,      4,    4,     4,          7    \\ Vertex 19\n VERTEX   32,    4,  -32,     4,      4,    4,     4,          7    \\ Vertex 20\n VERTEX   36,   -4,  -32,     4,      4,    4,     4,          7    \\ Vertex 21\n VERTEX  -36,   -4,  -32,     4,      4,    4,     4,          7    \\ Vertex 22\n VERTEX  -38,    0,  -32,     4,      4,    4,     4,          5    \\ Vertex 23\n VERTEX   38,    0,  -32,     4,      4,    4,     4,          5    \\ Vertex 24\n\n.SHIP_MAMBA_EDGES\n\n    \\ vertex1, vertex2, face1, face2, visibility\n EDGE       0,       1,     0,     2,         31    \\ Edge 0\n EDGE       0,       4,     0,     3,         31    \\ Edge 1\n EDGE       1,       4,     0,     4,         31    \\ Edge 2\n EDGE       1,       2,     2,     4,         30    \\ Edge 3\n EDGE       2,       3,     1,     4,         30    \\ Edge 4\n EDGE       3,       4,     3,     4,         30    \\ Edge 5\n EDGE       5,       6,     1,     1,         14    \\ Edge 6\n EDGE       6,       7,     1,     1,         12    \\ Edge 7\n EDGE       7,       8,     1,     1,         13    \\ Edge 8\n EDGE       5,       8,     1,     1,         12    \\ Edge 9\n EDGE       9,      11,     0,     0,         20    \\ Edge 10\n EDGE       9,      12,     0,     0,         16    \\ Edge 11\n EDGE      10,      13,     0,     0,         16    \\ Edge 12\n EDGE      10,      14,     0,     0,         20    \\ Edge 13\n EDGE      13,      14,     0,     0,         14    \\ Edge 14\n EDGE      11,      12,     0,     0,         14    \\ Edge 15\n EDGE      15,      16,     4,     4,         13    \\ Edge 16\n EDGE      17,      18,     4,     4,         14    \\ Edge 17\n EDGE      15,      18,     4,     4,         12    \\ Edge 18\n EDGE      16,      17,     4,     4,         12    \\ Edge 19\n EDGE      20,      21,     4,     4,          7    \\ Edge 20\n EDGE      20,      24,     4,     4,          5    \\ Edge 21\n EDGE      21,      24,     4,     4,          5    \\ Edge 22\n EDGE      19,      22,     4,     4,          7    \\ Edge 23\n EDGE      19,      23,     4,     4,          5    \\ Edge 24\n EDGE      22,      23,     4,     4,          5    \\ Edge 25\n EDGE       0,       2,     1,     2,         30    \\ Edge 26\n EDGE       0,       3,     1,     3,         30    \\ Edge 27\n\n.SHIP_MAMBA_FACES\n\n    \\ normal_x, normal_y, normal_z, visibility\n FACE        0,      -24,        2,         30      \\ Face 0\n FACE        0,       24,        2,         30      \\ Face 1\n FACE      -32,       64,       16,         30      \\ Face 2\n FACE       32,       64,       16,         30      \\ Face 3\n FACE        0,        0,     -127,         30      \\ Face 4\n\n\\ ******************************************************************************\n\\\n\\       Name: SHIP_COBRA_MK_3\n\\       Type: Variable\n\\   Category: Drawing ships\n\\    Summary: Ship blueprint for a Cobra Mk III\n\\  Deep dive: Ship blueprints\n\\             Comparing ship specifications\n\\\n\\ ******************************************************************************\n\n.SHIP_COBRA_MK_3\n\n EQUB 3                 \\ Max. canisters on demise = 3\n EQUW 95 * 95           \\ Targetable area          = 95 * 95\n\n EQUB LO(SHIP_COBRA_MK_3_EDGES - SHIP_COBRA_MK_3)  \\ Edges data offset (low)\n EQUB LO(SHIP_COBRA_MK_3_FACES - SHIP_COBRA_MK_3)  \\ Faces data offset (low)\n\n EQUB 153               \\ Max. edge count          = (153 - 1) / 4 = 38\n EQUB 84                \\ Gun vertex               = 84 / 4 = 21\n EQUB 42                \\ Explosion count          = 9, as (4 * n) + 6 = 42\n EQUB 168               \\ Number of vertices       = 168 / 6 = 28\n EQUB 38                \\ Number of edges          = 38\n EQUW 0                 \\ Bounty                   = 0\n EQUB 52                \\ Number of faces          = 52 / 4 = 13\n EQUB 50                \\ Visibility distance      = 50\n EQUB 150               \\ Max. energy              = 150\n EQUB 28                \\ Max. speed               = 28\n\n EQUB HI(SHIP_COBRA_MK_3_EDGES - SHIP_COBRA_MK_3)  \\ Edges data offset (low)\n EQUB HI(SHIP_COBRA_MK_3_FACES - SHIP_COBRA_MK_3)  \\ Faces data offset (low)\n\n EQUB 1                 \\ Normals are scaled by    = 2^1 = 2\n EQUB %00010011         \\ Laser power              = 2\n                        \\ Missiles                 = 3\n\n.SHIP_COBRA_MK_3_VERTICES\n\n      \\    x,    y,    z, face1, face2, face3, face4, visibility\n VERTEX   32,    0,   76,    15,     15,   15,    15,         31    \\ Vertex 0\n VERTEX  -32,    0,   76,    15,     15,   15,    15,         31    \\ Vertex 1\n VERTEX    0,   26,   24,    15,     15,   15,    15,         31    \\ Vertex 2\n VERTEX -120,   -3,   -8,     3,      7,   10,    10,         31    \\ Vertex 3\n VERTEX  120,   -3,   -8,     4,      8,   12,    12,         31    \\ Vertex 4\n VERTEX  -88,   16,  -40,    15,     15,   15,    15,         31    \\ Vertex 5\n VERTEX   88,   16,  -40,    15,     15,   15,    15,         31    \\ Vertex 6\n VERTEX  128,   -8,  -40,     8,      9,   12,    12,         31    \\ Vertex 7\n VERTEX -128,   -8,  -40,     7,      9,   10,    10,         31    \\ Vertex 8\n VERTEX    0,   26,  -40,     5,      6,    9,     9,         31    \\ Vertex 9\n VERTEX  -32,  -24,  -40,     9,     10,   11,    11,         31    \\ Vertex 10\n VERTEX   32,  -24,  -40,     9,     11,   12,    12,         31    \\ Vertex 11\n VERTEX  -36,    8,  -40,     9,      9,    9,     9,         20    \\ Vertex 12\n VERTEX   -8,   12,  -40,     9,      9,    9,     9,         20    \\ Vertex 13\n VERTEX    8,   12,  -40,     9,      9,    9,     9,         20    \\ Vertex 14\n VERTEX   36,    8,  -40,     9,      9,    9,     9,         20    \\ Vertex 15\n VERTEX   36,  -12,  -40,     9,      9,    9,     9,         20    \\ Vertex 16\n VERTEX    8,  -16,  -40,     9,      9,    9,     9,         20    \\ Vertex 17\n VERTEX   -8,  -16,  -40,     9,      9,    9,     9,         20    \\ Vertex 18\n VERTEX  -36,  -12,  -40,     9,      9,    9,     9,         20    \\ Vertex 19\n VERTEX    0,    0,   76,     0,     11,   11,    11,          6    \\ Vertex 20\n VERTEX    0,    0,   90,     0,     11,   11,    11,         31    \\ Vertex 21\n VERTEX  -80,   -6,  -40,     9,      9,    9,     9,          8    \\ Vertex 22\n VERTEX  -80,    6,  -40,     9,      9,    9,     9,          8    \\ Vertex 23\n VERTEX  -88,    0,  -40,     9,      9,    9,     9,          6    \\ Vertex 24\n VERTEX   80,    6,  -40,     9,      9,    9,     9,          8    \\ Vertex 25\n VERTEX   88,    0,  -40,     9,      9,    9,     9,          6    \\ Vertex 26\n VERTEX   80,   -6,  -40,     9,      9,    9,     9,          8    \\ Vertex 27\n\n.SHIP_COBRA_MK_3_EDGES\n\n    \\ vertex1, vertex2, face1, face2, visibility\n EDGE       0,       1,     0,    11,         31    \\ Edge 0\n EDGE       0,       4,     4,    12,         31    \\ Edge 1\n EDGE       1,       3,     3,    10,         31    \\ Edge 2\n EDGE       3,       8,     7,    10,         31    \\ Edge 3\n EDGE       4,       7,     8,    12,         31    \\ Edge 4\n EDGE       6,       7,     8,     9,         31    \\ Edge 5\n EDGE       6,       9,     6,     9,         31    \\ Edge 6\n EDGE       5,       9,     5,     9,         31    \\ Edge 7\n EDGE       5,       8,     7,     9,         31    \\ Edge 8\n EDGE       2,       5,     1,     5,         31    \\ Edge 9\n EDGE       2,       6,     2,     6,         31    \\ Edge 10\n EDGE       3,       5,     3,     7,         31    \\ Edge 11\n EDGE       4,       6,     4,     8,         31    \\ Edge 12\n EDGE       1,       2,     0,     1,         31    \\ Edge 13\n EDGE       0,       2,     0,     2,         31    \\ Edge 14\n EDGE       8,      10,     9,    10,         31    \\ Edge 15\n EDGE      10,      11,     9,    11,         31    \\ Edge 16\n EDGE       7,      11,     9,    12,         31    \\ Edge 17\n EDGE       1,      10,    10,    11,         31    \\ Edge 18\n EDGE       0,      11,    11,    12,         31    \\ Edge 19\n EDGE       1,       5,     1,     3,         29    \\ Edge 20\n EDGE       0,       6,     2,     4,         29    \\ Edge 21\n EDGE      20,      21,     0,    11,          6    \\ Edge 22\n EDGE      12,      13,     9,     9,         20    \\ Edge 23\n EDGE      18,      19,     9,     9,         20    \\ Edge 24\n EDGE      14,      15,     9,     9,         20    \\ Edge 25\n EDGE      16,      17,     9,     9,         20    \\ Edge 26\n EDGE      15,      16,     9,     9,         19    \\ Edge 27\n EDGE      14,      17,     9,     9,         17    \\ Edge 28\n EDGE      13,      18,     9,     9,         19    \\ Edge 29\n EDGE      12,      19,     9,     9,         19    \\ Edge 30\n EDGE       2,       9,     5,     6,         30    \\ Edge 31\n EDGE      22,      24,     9,     9,          6    \\ Edge 32\n EDGE      23,      24,     9,     9,          6    \\ Edge 33\n EDGE      22,      23,     9,     9,          8    \\ Edge 34\n EDGE      25,      26,     9,     9,          6    \\ Edge 35\n EDGE      26,      27,     9,     9,          6    \\ Edge 36\n EDGE      25,      27,     9,     9,          8    \\ Edge 37\n\n.SHIP_COBRA_MK_3_FACES\n\n    \\ normal_x, normal_y, normal_z, visibility\n FACE        0,       62,       31,         31      \\ Face 0\n FACE      -18,       55,       16,         31      \\ Face 1\n FACE       18,       55,       16,         31      \\ Face 2\n FACE      -16,       52,       14,         31      \\ Face 3\n FACE       16,       52,       14,         31      \\ Face 4\n FACE      -14,       47,        0,         31      \\ Face 5\n FACE       14,       47,        0,         31      \\ Face 6\n FACE      -61,      102,        0,         31      \\ Face 7\n FACE       61,      102,        0,         31      \\ Face 8\n FACE        0,        0,      -80,         31      \\ Face 9\n FACE       -7,      -42,        9,         31      \\ Face 10\n FACE        0,      -30,        6,         31      \\ Face 11\n FACE        7,      -42,        9,         31      \\ Face 12\n\n\\ ******************************************************************************\n\\\n\\       Name: SHIP_THARGOID\n\\       Type: Variable\n\\   Category: Drawing ships\n\\    Summary: Ship blueprint for a Thargoid mothership\n\\  Deep dive: Ship blueprints\n\\             Comparing ship specifications\n\\\n\\ ******************************************************************************\n\n.SHIP_THARGOID\n\n EQUB 0                 \\ Max. canisters on demise = 0\n EQUW 99 * 99           \\ Targetable area          = 99 * 99\n\n EQUB LO(SHIP_THARGOID_EDGES - SHIP_THARGOID)      \\ Edges data offset (low)\n EQUB LO(SHIP_THARGOID_FACES - SHIP_THARGOID)      \\ Faces data offset (low)\n\n EQUB 101               \\ Max. edge count          = (101 - 1) / 4 = 25\n EQUB 60                \\ Gun vertex               = 60 / 4 = 15\n EQUB 38                \\ Explosion count          = 8, as (4 * n) + 6 = 38\n EQUB 120               \\ Number of vertices       = 120 / 6 = 20\n EQUB 26                \\ Number of edges          = 26\n EQUW 500               \\ Bounty                   = 500\n EQUB 40                \\ Number of faces          = 40 / 4 = 10\n EQUB 55                \\ Visibility distance      = 55\n EQUB 240               \\ Max. energy              = 240\n EQUB 39                \\ Max. speed               = 39\n\n EQUB HI(SHIP_THARGOID_EDGES - SHIP_THARGOID)      \\ Edges data offset (high)\n EQUB HI(SHIP_THARGOID_FACES - SHIP_THARGOID)      \\ Faces data offset (high)\n\n EQUB 2                 \\ Normals are scaled by    = 2^2 = 4\n EQUB %00010110         \\ Laser power              = 2\n                        \\ Missiles                 = 6\n\n.SHIP_THARGOID_VERTICES\n\n      \\    x,    y,    z, face1, face2, face3, face4, visibility\n VERTEX   32,  -48,   48,     0,      4,    8,     8,         31    \\ Vertex 0\n VERTEX   32,  -68,    0,     0,      1,    4,     4,         31    \\ Vertex 1\n VERTEX   32,  -48,  -48,     1,      2,    4,     4,         31    \\ Vertex 2\n VERTEX   32,    0,  -68,     2,      3,    4,     4,         31    \\ Vertex 3\n VERTEX   32,   48,  -48,     3,      4,    5,     5,         31    \\ Vertex 4\n VERTEX   32,   68,    0,     4,      5,    6,     6,         31    \\ Vertex 5\n VERTEX   32,   48,   48,     4,      6,    7,     7,         31    \\ Vertex 6\n VERTEX   32,    0,   68,     4,      7,    8,     8,         31    \\ Vertex 7\n VERTEX  -24, -116,  116,     0,      8,    9,     9,         31    \\ Vertex 8\n VERTEX  -24, -164,    0,     0,      1,    9,     9,         31    \\ Vertex 9\n VERTEX  -24, -116, -116,     1,      2,    9,     9,         31    \\ Vertex 10\n VERTEX  -24,    0, -164,     2,      3,    9,     9,         31    \\ Vertex 11\n VERTEX  -24,  116, -116,     3,      5,    9,     9,         31    \\ Vertex 12\n VERTEX  -24,  164,    0,     5,      6,    9,     9,         31    \\ Vertex 13\n VERTEX  -24,  116,  116,     6,      7,    9,     9,         31    \\ Vertex 14\n VERTEX  -24,    0,  164,     7,      8,    9,     9,         31    \\ Vertex 15\n VERTEX  -24,   64,   80,     9,      9,    9,     9,         30    \\ Vertex 16\n VERTEX  -24,   64,  -80,     9,      9,    9,     9,         30    \\ Vertex 17\n VERTEX  -24,  -64,  -80,     9,      9,    9,     9,         30    \\ Vertex 18\n VERTEX  -24,  -64,   80,     9,      9,    9,     9,         30    \\ Vertex 19\n\n.SHIP_THARGOID_EDGES\n\n    \\ vertex1, vertex2, face1, face2, visibility\n EDGE       0,       7,     4,     8,         31    \\ Edge 0\n EDGE       0,       1,     0,     4,         31    \\ Edge 1\n EDGE       1,       2,     1,     4,         31    \\ Edge 2\n EDGE       2,       3,     2,     4,         31    \\ Edge 3\n EDGE       3,       4,     3,     4,         31    \\ Edge 4\n EDGE       4,       5,     4,     5,         31    \\ Edge 5\n EDGE       5,       6,     4,     6,         31    \\ Edge 6\n EDGE       6,       7,     4,     7,         31    \\ Edge 7\n EDGE       0,       8,     0,     8,         31    \\ Edge 8\n EDGE       1,       9,     0,     1,         31    \\ Edge 9\n EDGE       2,      10,     1,     2,         31    \\ Edge 10\n EDGE       3,      11,     2,     3,         31    \\ Edge 11\n EDGE       4,      12,     3,     5,         31    \\ Edge 12\n EDGE       5,      13,     5,     6,         31    \\ Edge 13\n EDGE       6,      14,     6,     7,         31    \\ Edge 14\n EDGE       7,      15,     7,     8,         31    \\ Edge 15\n EDGE       8,      15,     8,     9,         31    \\ Edge 16\n EDGE       8,       9,     0,     9,         31    \\ Edge 17\n EDGE       9,      10,     1,     9,         31    \\ Edge 18\n EDGE      10,      11,     2,     9,         31    \\ Edge 19\n EDGE      11,      12,     3,     9,         31    \\ Edge 20\n EDGE      12,      13,     5,     9,         31    \\ Edge 21\n EDGE      13,      14,     6,     9,         31    \\ Edge 22\n EDGE      14,      15,     7,     9,         31    \\ Edge 23\n EDGE      16,      17,     9,     9,         30    \\ Edge 24\n EDGE      18,      19,     9,     9,         30    \\ Edge 25\n\n.SHIP_THARGOID_FACES\n\n    \\ normal_x, normal_y, normal_z, visibility\n FACE      103,      -60,       25,         31      \\ Face 0\n FACE      103,      -60,      -25,         31      \\ Face 1\n FACE      103,      -25,      -60,         31      \\ Face 2\n FACE      103,       25,      -60,         31      \\ Face 3\n FACE       64,        0,        0,         31      \\ Face 4\n FACE      103,       60,      -25,         31      \\ Face 5\n FACE      103,       60,       25,         31      \\ Face 6\n FACE      103,       25,       60,         31      \\ Face 7\n FACE      103,      -25,       60,         31      \\ Face 8\n FACE      -48,        0,        0,         31      \\ Face 9\n\n\\ ******************************************************************************\n\\\n\\       Name: SHIP_CORIOLIS\n\\       Type: Variable\n\\   Category: Drawing ships\n\\    Summary: Ship blueprint for a Coriolis space station\n\\  Deep dive: Ship blueprints\n\\             Comparing ship specifications\n\\\n\\ ******************************************************************************\n\n.SHIP_CORIOLIS\n\n EQUB 0                 \\ Max. canisters on demise = 0\n EQUW 160 * 160         \\ Targetable area          = 160 * 160\n\n EQUB LO(SHIP_CORIOLIS_EDGES - SHIP_CORIOLIS)      \\ Edges data offset (low)\n EQUB LO(SHIP_CORIOLIS_FACES - SHIP_CORIOLIS)      \\ Faces data offset (low)\n\n EQUB 85                \\ Max. edge count          = (85 - 1) / 4 = 21\n EQUB 0                 \\ Gun vertex               = 0\n EQUB 54                \\ Explosion count          = 12, as (4 * n) + 6 = 54\n EQUB 96                \\ Number of vertices       = 96 / 6 = 16\n EQUB 28                \\ Number of edges          = 28\n EQUW 0                 \\ Bounty                   = 0\n EQUB 56                \\ Number of faces          = 56 / 4 = 14\n EQUB 120               \\ Visibility distance      = 120\n EQUB 240               \\ Max. energy              = 240\n EQUB 0                 \\ Max. speed               = 0\n\n EQUB HI(SHIP_CORIOLIS_EDGES - SHIP_CORIOLIS)      \\ Edges data offset (high)\n EQUB HI(SHIP_CORIOLIS_FACES - SHIP_CORIOLIS)      \\ Faces data offset (high)\n\n EQUB 0                 \\ Normals are scaled by    = 2^0 = 1\n EQUB %00000110         \\ Laser power              = 0\n                        \\ Missiles                 = 6\n\n.SHIP_CORIOLIS_VERTICES\n\n      \\    x,    y,    z, face1, face2, face3, face4, visibility\n VERTEX  160,    0,  160,     0,      1,    2,     6,         31    \\ Vertex 0\n VERTEX    0,  160,  160,     0,      2,    3,     8,         31    \\ Vertex 1\n VERTEX -160,    0,  160,     0,      3,    4,     7,         31    \\ Vertex 2\n VERTEX    0, -160,  160,     0,      1,    4,     5,         31    \\ Vertex 3\n VERTEX  160, -160,    0,     1,      5,    6,    10,         31    \\ Vertex 4\n VERTEX  160,  160,    0,     2,      6,    8,    11,         31    \\ Vertex 5\n VERTEX -160,  160,    0,     3,      7,    8,    12,         31    \\ Vertex 6\n VERTEX -160, -160,    0,     4,      5,    7,     9,         31    \\ Vertex 7\n VERTEX  160,    0, -160,     6,     10,   11,    13,         31    \\ Vertex 8\n VERTEX    0,  160, -160,     8,     11,   12,    13,         31    \\ Vertex 9\n VERTEX -160,    0, -160,     7,      9,   12,    13,         31    \\ Vertex 10\n VERTEX    0, -160, -160,     5,      9,   10,    13,         31    \\ Vertex 11\n VERTEX   10,  -30,  160,     0,      0,    0,     0,         30    \\ Vertex 12\n VERTEX   10,   30,  160,     0,      0,    0,     0,         30    \\ Vertex 13\n VERTEX  -10,   30,  160,     0,      0,    0,     0,         30    \\ Vertex 14\n VERTEX  -10,  -30,  160,     0,      0,    0,     0,         30    \\ Vertex 15\n\n.SHIP_CORIOLIS_EDGES\n\n    \\ vertex1, vertex2, face1, face2, visibility\n EDGE       0,       3,     0,     1,         31    \\ Edge 0\n EDGE       0,       1,     0,     2,         31    \\ Edge 1\n EDGE       1,       2,     0,     3,         31    \\ Edge 2\n EDGE       2,       3,     0,     4,         31    \\ Edge 3\n EDGE       3,       4,     1,     5,         31    \\ Edge 4\n EDGE       0,       4,     1,     6,         31    \\ Edge 5\n EDGE       0,       5,     2,     6,         31    \\ Edge 6\n EDGE       5,       1,     2,     8,         31    \\ Edge 7\n EDGE       1,       6,     3,     8,         31    \\ Edge 8\n EDGE       2,       6,     3,     7,         31    \\ Edge 9\n EDGE       2,       7,     4,     7,         31    \\ Edge 10\n EDGE       3,       7,     4,     5,         31    \\ Edge 11\n EDGE       8,      11,    10,    13,         31    \\ Edge 12\n EDGE       8,       9,    11,    13,         31    \\ Edge 13\n EDGE       9,      10,    12,    13,         31    \\ Edge 14\n EDGE      10,      11,     9,    13,         31    \\ Edge 15\n EDGE       4,      11,     5,    10,         31    \\ Edge 16\n EDGE       4,       8,     6,    10,         31    \\ Edge 17\n EDGE       5,       8,     6,    11,         31    \\ Edge 18\n EDGE       5,       9,     8,    11,         31    \\ Edge 19\n EDGE       6,       9,     8,    12,         31    \\ Edge 20\n EDGE       6,      10,     7,    12,         31    \\ Edge 21\n EDGE       7,      10,     7,     9,         31    \\ Edge 22\n EDGE       7,      11,     5,     9,         31    \\ Edge 23\n EDGE      12,      13,     0,     0,         30    \\ Edge 24\n EDGE      13,      14,     0,     0,         30    \\ Edge 25\n EDGE      14,      15,     0,     0,         30    \\ Edge 26\n EDGE      15,      12,     0,     0,         30    \\ Edge 27\n\n.SHIP_CORIOLIS_FACES\n\n    \\ normal_x, normal_y, normal_z, visibility\n FACE        0,        0,      160,         31      \\ Face 0\n FACE      107,     -107,      107,         31      \\ Face 1\n FACE      107,      107,      107,         31      \\ Face 2\n FACE     -107,      107,      107,         31      \\ Face 3\n FACE     -107,     -107,      107,         31      \\ Face 4\n FACE        0,     -160,        0,         31      \\ Face 5\n FACE      160,        0,        0,         31      \\ Face 6\n FACE     -160,        0,        0,         31      \\ Face 7\n FACE        0,      160,        0,         31      \\ Face 8\n FACE     -107,     -107,     -107,         31      \\ Face 9\n FACE      107,     -107,     -107,         31      \\ Face 10\n FACE      107,      107,     -107,         31      \\ Face 11\n FACE     -107,      107,     -107,         31      \\ Face 12\n FACE        0,        0,     -160,         31      \\ Face 13\n\n\\ ******************************************************************************\n\\\n\\       Name: SHIP_MISSILE\n\\       Type: Variable\n\\   Category: Drawing ships\n\\    Summary: Ship blueprint for a missile\n\\  Deep dive: Ship blueprints\n\\             Comparing ship specifications\n\\\n\\ ******************************************************************************\n\n.SHIP_MISSILE\n\n EQUB 0                 \\ Max. canisters on demise = 0\n EQUW 40 * 40           \\ Targetable area          = 40 * 40\n\n EQUB LO(SHIP_MISSILE_EDGES - SHIP_MISSILE)        \\ Edges data offset (low)\n EQUB LO(SHIP_MISSILE_FACES - SHIP_MISSILE)        \\ Faces data offset (low)\n\n EQUB 81                \\ Max. edge count          = (81 - 1) / 4 = 20\n EQUB 0                 \\ Gun vertex               = 0\n EQUB 10                \\ Explosion count          = 1, as (4 * n) + 6 = 10\n EQUB 102               \\ Number of vertices       = 102 / 6 = 17\n EQUB 24                \\ Number of edges          = 24\n EQUW 0                 \\ Bounty                   = 0\n EQUB 36                \\ Number of faces          = 36 / 4 = 9\n EQUB 14                \\ Visibility distance      = 14\n EQUB 2                 \\ Max. energy              = 2\n EQUB 44                \\ Max. speed               = 44\n\n EQUB HI(SHIP_MISSILE_EDGES - SHIP_MISSILE)        \\ Edges data offset (high)\n EQUB HI(SHIP_MISSILE_FACES - SHIP_MISSILE)        \\ Faces data offset (high)\n\n EQUB 2                 \\ Normals are scaled by    = 2^2 = 4\n EQUB %00000000         \\ Laser power              = 0\n                        \\ Missiles                 = 0\n\n.SHIP_MISSILE_VERTICES\n\n      \\    x,    y,    z, face1, face2, face3, face4, visibility\n VERTEX    0,    0,   68,     0,      1,    2,     3,         31    \\ Vertex 0\n VERTEX    8,   -8,   36,     1,      2,    4,     5,         31    \\ Vertex 1\n VERTEX    8,    8,   36,     2,      3,    4,     7,         31    \\ Vertex 2\n VERTEX   -8,    8,   36,     0,      3,    6,     7,         31    \\ Vertex 3\n VERTEX   -8,   -8,   36,     0,      1,    5,     6,         31    \\ Vertex 4\n VERTEX    8,    8,  -44,     4,      7,    8,     8,         31    \\ Vertex 5\n VERTEX    8,   -8,  -44,     4,      5,    8,     8,         31    \\ Vertex 6\n VERTEX   -8,   -8,  -44,     5,      6,    8,     8,         31    \\ Vertex 7\n VERTEX   -8,    8,  -44,     6,      7,    8,     8,         31    \\ Vertex 8\n VERTEX   12,   12,  -44,     4,      7,    8,     8,          8    \\ Vertex 9\n VERTEX   12,  -12,  -44,     4,      5,    8,     8,          8    \\ Vertex 10\n VERTEX  -12,  -12,  -44,     5,      6,    8,     8,          8    \\ Vertex 11\n VERTEX  -12,   12,  -44,     6,      7,    8,     8,          8    \\ Vertex 12\n VERTEX   -8,    8,  -12,     6,      7,    7,     7,          8    \\ Vertex 13\n VERTEX   -8,   -8,  -12,     5,      6,    6,     6,          8    \\ Vertex 14\n VERTEX    8,    8,  -12,     4,      7,    7,     7,          8    \\ Vertex 15\n VERTEX    8,   -8,  -12,     4,      5,    5,     5,          8    \\ Vertex 16\n\n.SHIP_MISSILE_EDGES\n\n    \\ vertex1, vertex2, face1, face2, visibility\n EDGE       0,       1,     1,     2,         31    \\ Edge 0\n EDGE       0,       2,     2,     3,         31    \\ Edge 1\n EDGE       0,       3,     0,     3,         31    \\ Edge 2\n EDGE       0,       4,     0,     1,         31    \\ Edge 3\n EDGE       1,       2,     4,     2,         31    \\ Edge 4\n EDGE       1,       4,     1,     5,         31    \\ Edge 5\n EDGE       3,       4,     0,     6,         31    \\ Edge 6\n EDGE       2,       3,     3,     7,         31    \\ Edge 7\n EDGE       2,       5,     4,     7,         31    \\ Edge 8\n EDGE       1,       6,     4,     5,         31    \\ Edge 9\n EDGE       4,       7,     5,     6,         31    \\ Edge 10\n EDGE       3,       8,     6,     7,         31    \\ Edge 11\n EDGE       7,       8,     6,     8,         31    \\ Edge 12\n EDGE       5,       8,     7,     8,         31    \\ Edge 13\n EDGE       5,       6,     4,     8,         31    \\ Edge 14\n EDGE       6,       7,     5,     8,         31    \\ Edge 15\n EDGE       6,      10,     5,     8,          8    \\ Edge 16\n EDGE       5,       9,     7,     8,          8    \\ Edge 17\n EDGE       8,      12,     7,     8,          8    \\ Edge 18\n EDGE       7,      11,     5,     8,          8    \\ Edge 19\n EDGE       9,      15,     4,     7,          8    \\ Edge 20\n EDGE      10,      16,     4,     5,          8    \\ Edge 21\n EDGE      12,      13,     6,     7,          8    \\ Edge 22\n EDGE      11,      14,     5,     6,          8    \\ Edge 23\n\n.SHIP_MISSILE_FACES\n\n    \\ normal_x, normal_y, normal_z, visibility\n FACE      -64,        0,       16,         31      \\ Face 0\n FACE        0,      -64,       16,         31      \\ Face 1\n FACE       64,        0,       16,         31      \\ Face 2\n FACE        0,       64,       16,         31      \\ Face 3\n FACE       32,        0,        0,         31      \\ Face 4\n FACE        0,      -32,        0,         31      \\ Face 5\n FACE      -32,        0,        0,         31      \\ Face 6\n FACE        0,       32,        0,         31      \\ Face 7\n FACE        0,        0,     -176,         31      \\ Face 8\n\n\\ ******************************************************************************\n\\\n\\       Name: SHIP_ASTEROID\n\\       Type: Variable\n\\   Category: Drawing ships\n\\    Summary: Ship blueprint for an asteroid\n\\  Deep dive: Ship blueprints\n\\             Comparing ship specifications\n\\\n\\ ******************************************************************************\n\n.SHIP_ASTEROID\n\n EQUB 0                 \\ Max. canisters on demise = 0\n EQUW 80 * 80           \\ Targetable area          = 80 * 80\n\n EQUB LO(SHIP_ASTEROID_EDGES - SHIP_ASTEROID)      \\ Edges data offset (low)\n EQUB LO(SHIP_ASTEROID_FACES - SHIP_ASTEROID)      \\ Faces data offset (low)\n\n EQUB 65                \\ Max. edge count          = (65 - 1) / 4 = 16\n EQUB 0                 \\ Gun vertex               = 0\n EQUB 34                \\ Explosion count          = 7, as (4 * n) + 6 = 34\n EQUB 54                \\ Number of vertices       = 54 / 6 = 9\n EQUB 21                \\ Number of edges          = 21\n EQUW 5                 \\ Bounty                   = 5\n EQUB 56                \\ Number of faces          = 56 / 4 = 14\n EQUB 50                \\ Visibility distance      = 50\n EQUB 60                \\ Max. energy              = 60\n EQUB 30                \\ Max. speed               = 30\n\n EQUB HI(SHIP_ASTEROID_EDGES - SHIP_ASTEROID)      \\ Edges data offset (high)\n EQUB HI(SHIP_ASTEROID_FACES - SHIP_ASTEROID)      \\ Faces data offset (high)\n\n EQUB 1                 \\ Normals are scaled by    = 2^1 = 2\n EQUB %00000000         \\ Laser power              = 0\n                        \\ Missiles                 = 0\n\n.SHIP_ASTEROID_VERTICES\n\n      \\    x,    y,    z, face1, face2, face3, face4, visibility\n VERTEX    0,   80,    0,    15,     15,   15,    15,         31    \\ Vertex 0\n VERTEX  -80,  -10,    0,    15,     15,   15,    15,         31    \\ Vertex 1\n VERTEX    0,  -80,    0,    15,     15,   15,    15,         31    \\ Vertex 2\n VERTEX   70,  -40,    0,    15,     15,   15,    15,         31    \\ Vertex 3\n VERTEX   60,   50,    0,     5,      6,   12,    13,         31    \\ Vertex 4\n VERTEX   50,    0,   60,    15,     15,   15,    15,         31    \\ Vertex 5\n VERTEX  -40,    0,   70,     0,      1,    2,     3,         31    \\ Vertex 6\n VERTEX    0,   30,  -75,    15,     15,   15,    15,         31    \\ Vertex 7\n VERTEX    0,  -50,  -60,     8,      9,   10,    11,         31    \\ Vertex 8\n\n.SHIP_ASTEROID_EDGES\n\n    \\ vertex1, vertex2, face1, face2, visibility\n EDGE       0,       1,     2,     7,         31    \\ Edge 0\n EDGE       0,       4,     6,    13,         31    \\ Edge 1\n EDGE       3,       4,     5,    12,         31    \\ Edge 2\n EDGE       2,       3,     4,    11,         31    \\ Edge 3\n EDGE       1,       2,     3,    10,         31    \\ Edge 4\n EDGE       1,       6,     2,     3,         31    \\ Edge 5\n EDGE       2,       6,     1,     3,         31    \\ Edge 6\n EDGE       2,       5,     1,     4,         31    \\ Edge 7\n EDGE       5,       6,     0,     1,         31    \\ Edge 8\n EDGE       0,       5,     0,     6,         31    \\ Edge 9\n EDGE       3,       5,     4,     5,         31    \\ Edge 10\n EDGE       0,       6,     0,     2,         31    \\ Edge 11\n EDGE       4,       5,     5,     6,         31    \\ Edge 12\n EDGE       1,       8,     8,    10,         31    \\ Edge 13\n EDGE       1,       7,     7,     8,         31    \\ Edge 14\n EDGE       0,       7,     7,    13,         31    \\ Edge 15\n EDGE       4,       7,    12,    13,         31    \\ Edge 16\n EDGE       3,       7,     9,    12,         31    \\ Edge 17\n EDGE       3,       8,     9,    11,         31    \\ Edge 18\n EDGE       2,       8,    10,    11,         31    \\ Edge 19\n EDGE       7,       8,     8,     9,         31    \\ Edge 20\n\n.SHIP_ASTEROID_FACES\n\n    \\ normal_x, normal_y, normal_z, visibility\n FACE        9,       66,       81,         31      \\ Face 0\n FACE        9,      -66,       81,         31      \\ Face 1\n FACE      -72,       64,       31,         31      \\ Face 2\n FACE      -64,      -73,       47,         31      \\ Face 3\n FACE       45,      -79,       65,         31      \\ Face 4\n FACE      135,       15,       35,         31      \\ Face 5\n FACE       38,       76,       70,         31      \\ Face 6\n FACE      -66,       59,      -39,         31      \\ Face 7\n FACE      -67,      -15,      -80,         31      \\ Face 8\n FACE       66,      -14,      -75,         31      \\ Face 9\n FACE      -70,      -80,      -40,         31      \\ Face 10\n FACE       58,     -102,      -51,         31      \\ Face 11\n FACE       81,        9,      -67,         31      \\ Face 12\n FACE       47,       94,      -63,         31      \\ Face 13\n\n\\ ******************************************************************************\n\\\n\\       Name: SHIP_CANISTER\n\\       Type: Variable\n\\   Category: Drawing ships\n\\    Summary: Ship blueprint for a cargo canister\n\\  Deep dive: Ship blueprints\n\\             Comparing ship specifications\n\\\n\\ ******************************************************************************\n\n.SHIP_CANISTER\n\n EQUB 0                 \\ Max. canisters on demise = 0\n EQUW 20 * 20           \\ Targetable area          = 20 * 20\n\n EQUB LO(SHIP_CANISTER_EDGES - SHIP_CANISTER)      \\ Edges data offset (low)\n EQUB LO(SHIP_CANISTER_FACES - SHIP_CANISTER)      \\ Faces data offset (low)\n\n EQUB 49                \\ Max. edge count          = (49 - 1) / 4 = 12\n EQUB 0                 \\ Gun vertex               = 0\n EQUB 18                \\ Explosion count          = 3, as (4 * n) + 6 = 18\n EQUB 60                \\ Number of vertices       = 60 / 6 = 10\n EQUB 15                \\ Number of edges          = 15\n EQUW 0                 \\ Bounty                   = 0\n EQUB 28                \\ Number of faces          = 28 / 4 = 7\n EQUB 12                \\ Visibility distance      = 12\n EQUB 17                \\ Max. energy              = 17\n EQUB 15                \\ Max. speed               = 15\n\n EQUB HI(SHIP_CANISTER_EDGES - SHIP_CANISTER)      \\ Edges data offset (high)\n EQUB HI(SHIP_CANISTER_FACES - SHIP_CANISTER)      \\ Faces data offset (high)\n\n EQUB 2                 \\ Normals are scaled by    = 2^2 = 4\n EQUB %00000000         \\ Laser power              = 0\n                        \\ Missiles                 = 0\n\n.SHIP_CANISTER_VERTICES\n\n      \\    x,    y,    z, face1, face2, face3, face4, visibility\n VERTEX   24,   16,    0,     0,      1,    5,     5,         31    \\ Vertex 0\n VERTEX   24,    5,   15,     0,      1,    2,     2,         31    \\ Vertex 1\n VERTEX   24,  -13,    9,     0,      2,    3,     3,         31    \\ Vertex 2\n VERTEX   24,  -13,   -9,     0,      3,    4,     4,         31    \\ Vertex 3\n VERTEX   24,    5,  -15,     0,      4,    5,     5,         31    \\ Vertex 4\n VERTEX  -24,   16,    0,     1,      5,    6,     6,         31    \\ Vertex 5\n VERTEX  -24,    5,   15,     1,      2,    6,     6,         31    \\ Vertex 6\n VERTEX  -24,  -13,    9,     2,      3,    6,     6,         31    \\ Vertex 7\n VERTEX  -24,  -13,   -9,     3,      4,    6,     6,         31    \\ Vertex 8\n VERTEX  -24,    5,  -15,     4,      5,    6,     6,         31    \\ Vertex 9\n\n.SHIP_CANISTER_EDGES\n\n    \\ vertex1, vertex2, face1, face2, visibility\n EDGE       0,       1,     0,     1,         31    \\ Edge 0\n EDGE       1,       2,     0,     2,         31    \\ Edge 1\n EDGE       2,       3,     0,     3,         31    \\ Edge 2\n EDGE       3,       4,     0,     4,         31    \\ Edge 3\n EDGE       0,       4,     0,     5,         31    \\ Edge 4\n EDGE       0,       5,     1,     5,         31    \\ Edge 5\n EDGE       1,       6,     1,     2,         31    \\ Edge 6\n EDGE       2,       7,     2,     3,         31    \\ Edge 7\n EDGE       3,       8,     3,     4,         31    \\ Edge 8\n EDGE       4,       9,     4,     5,         31    \\ Edge 9\n EDGE       5,       6,     1,     6,         31    \\ Edge 10\n EDGE       6,       7,     2,     6,         31    \\ Edge 11\n EDGE       7,       8,     3,     6,         31    \\ Edge 12\n EDGE       8,       9,     4,     6,         31    \\ Edge 13\n EDGE       9,       5,     5,     6,         31    \\ Edge 14\n\n.SHIP_CANISTER_FACES\n\n    \\ normal_x, normal_y, normal_z, visibility\n FACE       96,        0,        0,         31      \\ Face 0\n FACE        0,       41,       30,         31      \\ Face 1\n FACE        0,      -18,       48,         31      \\ Face 2\n FACE        0,      -51,        0,         31      \\ Face 3\n FACE        0,      -18,      -48,         31      \\ Face 4\n FACE        0,       41,      -30,         31      \\ Face 5\n FACE      -96,        0,        0,         31      \\ Face 6\n\n\\ ******************************************************************************\n\\\n\\       Name: SHIP_THARGON\n\\       Type: Variable\n\\   Category: Drawing ships\n\\    Summary: Ship blueprint for a Thargon\n\\  Deep dive: Ship blueprints\n\\             Comparing ship specifications\n\\\n\\ ------------------------------------------------------------------------------\n\\\n\\ The ship blueprint for the Thargon reuses the edges data from the cargo\n\\ canister, so the edges data offset is negative.\n\\\n\\ ******************************************************************************\n\n.SHIP_THARGON\n\n EQUB 0                 \\ Max. canisters on demise = 0\n EQUW 40 * 40           \\ Targetable area          = 40 * 40\n\n EQUB LO(SHIP_CANISTER_EDGES - SHIP_THARGON)       \\ Edges from canister\n EQUB LO(SHIP_THARGON_FACES - SHIP_THARGON)        \\ Faces data offset (low)\n\n EQUB 65                \\ Max. edge count          = (65 - 1) / 4 = 16\n EQUB 0                 \\ Gun vertex               = 0\n EQUB 18                \\ Explosion count          = 3, as (4 * n) + 6 = 18\n EQUB 60                \\ Number of vertices       = 60 / 6 = 10\n EQUB 15                \\ Number of edges          = 15\n EQUW 50                \\ Bounty                   = 50\n EQUB 28                \\ Number of faces          = 28 / 4 = 7\n EQUB 20                \\ Visibility distance      = 20\n EQUB 20                \\ Max. energy              = 20\n EQUB 30                \\ Max. speed               = 30\n\n EQUB HI(SHIP_CANISTER_EDGES - SHIP_THARGON)       \\ Edges from canister\n EQUB HI(SHIP_THARGON_FACES - SHIP_THARGON)        \\ Faces data offset (high)\n\n EQUB 2                 \\ Normals are scaled by    = 2^2 = 4\n EQUB %00010000         \\ Laser power              = 2\n                        \\ Missiles                 = 0\n\n.SHIP_THARGON_VERTICES\n\n      \\    x,    y,    z, face1, face2, face3, face4, visibility\n VERTEX   -9,    0,   40,     1,      0,    5,     5,         31    \\ Vertex 0\n VERTEX   -9,  -38,   12,     1,      0,    2,     2,         31    \\ Vertex 1\n VERTEX   -9,  -24,  -32,     2,      0,    3,     3,         31    \\ Vertex 2\n VERTEX   -9,   24,  -32,     3,      0,    4,     4,         31    \\ Vertex 3\n VERTEX   -9,   38,   12,     4,      0,    5,     5,         31    \\ Vertex 4\n VERTEX    9,    0,   -8,     5,      1,    6,     6,         31    \\ Vertex 5\n VERTEX    9,  -10,  -15,     2,      1,    6,     6,         31    \\ Vertex 6\n VERTEX    9,   -6,  -26,     3,      2,    6,     6,         31    \\ Vertex 7\n VERTEX    9,    6,  -26,     4,      3,    6,     6,         31    \\ Vertex 8\n VERTEX    9,   10,  -15,     5,      4,    6,     6,         31    \\ Vertex 9\n\n.SHIP_THARGON_FACES\n\n    \\ normal_x, normal_y, normal_z, visibility\n FACE      -36,        0,        0,         31      \\ Face 0\n FACE       20,       -5,        7,         31      \\ Face 1\n FACE       46,      -42,      -14,         31      \\ Face 2\n FACE       36,        0,     -104,         31      \\ Face 3\n FACE       46,       42,      -14,         31      \\ Face 4\n FACE       20,        5,        7,         31      \\ Face 5\n FACE       36,        0,        0,         31      \\ Face 6\n\n\\ ******************************************************************************\n\\\n\\       Name: SHIP_ESCAPE_POD\n\\       Type: Variable\n\\   Category: Drawing ships\n\\    Summary: Ship blueprint for an escape pod\n\\  Deep dive: Ship blueprints\n\\             Comparing ship specifications\n\\\n\\ ******************************************************************************\n\n.SHIP_ESCAPE_POD\n\n EQUB 0                 \\ Max. canisters on demise = 0\n EQUW 16 * 16           \\ Targetable area          = 16 * 16\n\n EQUB LO(SHIP_ESCAPE_POD_EDGES - SHIP_ESCAPE_POD)  \\ Edges data offset (low)\n EQUB LO(SHIP_ESCAPE_POD_FACES - SHIP_ESCAPE_POD)  \\ Faces data offset (low)\n\n EQUB 25                \\ Max. edge count          = (25 - 1) / 4 = 6\n EQUB 0                 \\ Gun vertex               = 0\n EQUB 22                \\ Explosion count          = 4, as (4 * n) + 6 = 22\n EQUB 24                \\ Number of vertices       = 24 / 6 = 4\n EQUB 6                 \\ Number of edges          = 6\n EQUW 0                 \\ Bounty                   = 0\n EQUB 16                \\ Number of faces          = 16 / 4 = 4\n EQUB 8                 \\ Visibility distance      = 8\n EQUB 17                \\ Max. energy              = 17\n EQUB 8                 \\ Max. speed               = 8\n\n EQUB HI(SHIP_ESCAPE_POD_EDGES - SHIP_ESCAPE_POD)  \\ Edges data offset (high)\n EQUB HI(SHIP_ESCAPE_POD_FACES - SHIP_ESCAPE_POD)  \\ Faces data offset (high)\n\n EQUB 3                 \\ Normals are scaled by    =  2^3 = 8\n EQUB %00000000         \\ Laser power              = 0\n                        \\ Missiles                 = 0\n\n.SHIP_ESCAPE_POD_VERTICES\n\n      \\    x,    y,    z, face1, face2, face3, face4, visibility\n VERTEX   -7,    0,   36,     2,      1,    3,     3,         31    \\ Vertex 0\n VERTEX   -7,  -14,  -12,     2,      0,    3,     3,         31    \\ Vertex 1\n VERTEX   -7,   14,  -12,     1,      0,    3,     3,         31    \\ Vertex 2\n VERTEX   21,    0,    0,     1,      0,    2,     2,         31    \\ Vertex 3\n\n.SHIP_ESCAPE_POD_EDGES\n\n    \\ vertex1, vertex2, face1, face2, visibility\n EDGE       0,       1,     3,     2,         31    \\ Edge 0\n EDGE       1,       2,     3,     0,         31    \\ Edge 1\n EDGE       2,       3,     1,     0,         31    \\ Edge 2\n EDGE       3,       0,     2,     1,         31    \\ Edge 3\n EDGE       0,       2,     3,     1,         31    \\ Edge 4\n EDGE       3,       1,     2,     0,         31    \\ Edge 5\n\n.SHIP_ESCAPE_POD_FACES\n\n    \\ normal_x, normal_y, normal_z, visibility\n FACE       26,        0,      -61,         31      \\ Face 0\n FACE       19,       51,       15,         31      \\ Face 1\n FACE       19,      -51,       15,         31      \\ Face 2\n FACE      -56,        0,        0,         31      \\ Face 3\n\n\\ ******************************************************************************\n\\\n\\ Save SHIPS.bin\n\\\n\\ ******************************************************************************\n\n PRINT \"SHIPS\"\n PRINT \"Assembled at \", ~CODE_SHIPS%\n PRINT \"Ends at \", ~P%\n PRINT \"Code size is \", ~(P% - CODE_SHIPS%)\n PRINT \"Execute at \", ~LOAD%\n PRINT \"Reload at \", ~LOAD_SHIPS%\n\n PRINT \"S.SHIPS \", ~CODE_SHIPS%, \" \", ~P%, \" \", ~LOAD%, \" \", ~LOAD_SHIPS%\n SAVE \"3-assembled-output/SHIPS.bin\", CODE_SHIPS%, P%, LOAD%\n\n\\ ******************************************************************************\n\\\n\\ ELITE PYTHON SHIP BLUEPRINT FILE\n\\\n\\ Produces the binary file PYTHON.bin that gets loaded by elite-bcfs.asm.\n\\\n\\ ******************************************************************************\n\n CLEAR 0, &7F00\n\n CODE_PYTHON% = &7F00\n LOAD_PYTHON% = &1B00\n\n ORG CODE_PYTHON%       \\ Set the assembly address to CODE_PYTHON%\n\n\\ ******************************************************************************\n\\\n\\       Name: SHIP_PYTHON\n\\       Type: Variable\n\\   Category: Drawing ships\n\\    Summary: Ship blueprint for a Python\n\\  Deep dive: Ship blueprints\n\\             Comparing ship specifications\n\\\n\\ ******************************************************************************\n\n.SHIP_PYTHON\n\n EQUB 3                 \\ Max. canisters on demise = 3\n EQUW 120 * 120         \\ Targetable area          = 120 * 120\n\n EQUB LO(SHIP_PYTHON_EDGES - SHIP_PYTHON)          \\ Edges data offset (low)\n EQUB LO(SHIP_PYTHON_FACES - SHIP_PYTHON)          \\ Faces data offset (low)\n\n EQUB 85                \\ Max. edge count          = (85 - 1) / 4 = 21\n EQUB 0                 \\ Gun vertex               = 0\n EQUB 46                \\ Explosion count          = 10, as (4 * n) + 6 = 46\n EQUB 66                \\ Number of vertices       = 66 / 6 = 11\n EQUB 26                \\ Number of edges          = 26\n EQUW 200               \\ Bounty                   = 200\n EQUB 52                \\ Number of faces          = 52 / 4 = 13\n EQUB 40                \\ Visibility distance      = 40\n EQUB 250               \\ Max. energy              = 250\n EQUB 20                \\ Max. speed               = 20\n\n EQUB HI(SHIP_PYTHON_EDGES - SHIP_PYTHON)          \\ Edges data offset (high)\n EQUB HI(SHIP_PYTHON_FACES - SHIP_PYTHON)          \\ Faces data offset (high)\n\n EQUB 0                 \\ Normals are scaled by    = 2^0 = 1\n EQUB %00011011         \\ Laser power              = 3\n                        \\ Missiles                 = 3\n\n.SHIP_PYTHON_VERTICES\n\n      \\    x,    y,    z, face1, face2, face3, face4, visibility\n VERTEX    0,    0,  224,     0,      1,    2,     3,         31    \\ Vertex 0\n VERTEX    0,   48,   48,     0,      1,    4,     5,         30    \\ Vertex 1\n VERTEX   96,    0,  -16,    15,     15,   15,    15,         31    \\ Vertex 2\n VERTEX  -96,    0,  -16,    15,     15,   15,    15,         31    \\ Vertex 3\n VERTEX    0,   48,  -32,     4,      5,    8,     9,         30    \\ Vertex 4\n VERTEX    0,   24, -112,     9,      8,   12,    12,         31    \\ Vertex 5\n VERTEX  -48,    0, -112,     8,     11,   12,    12,         31    \\ Vertex 6\n VERTEX   48,    0, -112,     9,     10,   12,    12,         31    \\ Vertex 7\n VERTEX    0,  -48,   48,     2,      3,    6,     7,         30    \\ Vertex 8\n VERTEX    0,  -48,  -32,     6,      7,   10,    11,         30    \\ Vertex 9\n VERTEX    0,  -24, -112,    10,     11,   12,    12,         30    \\ Vertex 10\n\n.SHIP_PYTHON_EDGES\n\n    \\ vertex1, vertex2, face1, face2, visibility\n EDGE       0,       8,     2,     3,         30    \\ Edge 0\n EDGE       0,       3,     0,     2,         31    \\ Edge 1\n EDGE       0,       2,     1,     3,         31    \\ Edge 2\n EDGE       0,       1,     0,     1,         30    \\ Edge 3\n EDGE       2,       4,     9,     5,         29    \\ Edge 4\n EDGE       1,       2,     1,     5,         29    \\ Edge 5\n EDGE       2,       8,     7,     3,         29    \\ Edge 6\n EDGE       1,       3,     0,     4,         29    \\ Edge 7\n EDGE       3,       8,     2,     6,         29    \\ Edge 8\n EDGE       2,       9,     7,    10,         29    \\ Edge 9\n EDGE       3,       4,     4,     8,         29    \\ Edge 10\n EDGE       3,       9,     6,    11,         29    \\ Edge 11\n EDGE       3,       5,     8,     8,          5    \\ Edge 12\n EDGE       3,      10,    11,    11,          5    \\ Edge 13\n EDGE       2,       5,     9,     9,          5    \\ Edge 14\n EDGE       2,      10,    10,    10,          5    \\ Edge 15\n EDGE       2,       7,     9,    10,         31    \\ Edge 16\n EDGE       3,       6,     8,    11,         31    \\ Edge 17\n EDGE       5,       6,     8,    12,         31    \\ Edge 18\n EDGE       5,       7,     9,    12,         31    \\ Edge 19\n EDGE       7,      10,    12,    10,         29    \\ Edge 20\n EDGE       6,      10,    11,    12,         29    \\ Edge 21\n EDGE       4,       5,     8,     9,         29    \\ Edge 22\n EDGE       9,      10,    10,    11,         29    \\ Edge 23\n EDGE       1,       4,     4,     5,         29    \\ Edge 24\n EDGE       8,       9,     6,     7,         29    \\ Edge 25\n\n.SHIP_PYTHON_FACES\n\n    \\ normal_x, normal_y, normal_z, visibility\n FACE      -27,       40,       11,         30      \\ Face 0\n FACE       27,       40,       11,         30      \\ Face 1\n FACE      -27,      -40,       11,         30      \\ Face 2\n FACE       27,      -40,       11,         30      \\ Face 3\n FACE      -19,       38,        0,         30      \\ Face 4\n FACE       19,       38,        0,         30      \\ Face 5\n FACE      -19,      -38,        0,         30      \\ Face 6\n FACE       19,      -38,        0,         30      \\ Face 7\n FACE      -25,       37,      -11,         30      \\ Face 8\n FACE       25,       37,      -11,         30      \\ Face 9\n FACE       25,      -37,      -11,         30      \\ Face 10\n FACE      -25,      -37,      -11,         30      \\ Face 11\n FACE        0,        0,     -112,         30      \\ Face 12\n\n SKIP 11                \\ This space appears to be unused\n\n\\ ******************************************************************************\n\\\n\\       Name: SVN\n\\       Type: Variable\n\\   Category: Save and load\n\\    Summary: The \"saving in progress\" flag\n\\\n\\ ******************************************************************************\n\n.SVN\n\n SKIP 1                 \\ \"Saving in progress\" flag\n                        \\\n                        \\   * Non-zero while we are saving a commander\n                        \\\n                        \\   * 0 otherwise\n\n\\ ******************************************************************************\n\\\n\\       Name: VEC\n\\       Type: Variable\n\\   Category: Drawing the screen\n\\    Summary: The original value of the IRQ1 vector\n\\\n\\ ******************************************************************************\n\n.VEC\n\n SKIP 2                 \\ VEC = &7FFE\n                        \\\n                        \\ This gets set to the value of the original IRQ1 vector\n                        \\ by the loading process\n\n\\ ******************************************************************************\n\\\n\\ Save PYTHON.bin\n\\\n\\ ******************************************************************************\n\n PRINT \"PYTHON\"\n PRINT \"Assembled at \", ~CODE_PYTHON%\n PRINT \"Ends at \", ~P%\n PRINT \"Code size is \", ~(P% - CODE_PYTHON%)\n PRINT \"Execute at \", ~LOAD%\n PRINT \"Reload at \", ~LOAD_PYTHON%\n\n PRINT \"S.PYTHON \", ~CODE_B%, \" \", ~P%, \" \", ~LOAD%, \" \", ~LOAD_PYTHON%\n SAVE \"3-assembled-output/PYTHON.bin\", CODE_PYTHON%, P%, LOAD%\n\n\\ ******************************************************************************\n\\\n\\ Show free space\n\\\n\\ ******************************************************************************\n\n PRINT \"ELITE game code \", ~(&6000-P%), \" bytes free\"\n PRINT \"Ends at \", ~P%\n"
  },
  {
    "path": "1-source-files/original-sources/$.DEFEDIT.inf",
    "content": "$.DEFEDIT 000000 000000 000557\n"
  },
  {
    "path": "1-source-files/original-sources/$.DEFEDIT.txt",
    "content": "   10 REM DEFSHIP EDITOR\n   20 MODE7:@%=3\n   30 PROCPR(\"        DEFSHIP  EDITOR\",3,1)\n   40 INPUT''\"Input filename of DEFSHIPS\",A$:IFA$<>\"\" DF$=A$\n   50 PRINTTAB(0,22):PROCPR(\"  EDITING  \"+DF$+\"  DEFSHIPS\",4,6)\n   60 VDU28,0,22,39,2,10,10:FORN%=&7C50TO&7F80STEP40:?N%=130:NEXT\n   70 MEM=&6000:HIMEM=MEM:OSCLI(\"L.\"+DF$+\" \"+STR$~MEM)\n   80 nodes=MEM+27:lines=MEM+?(MEM+3)+?(MEM+16)*256:norms=MEM+?(MEM+4)+?(MEM+17)*256\n   90 Nnodes=?(MEM+8)/8:Nlines=?(MEM+9):Nnorms=?(MEM+12)/4\n  100 REM PRINT NODES\n  110 PROCPR(\"        Node Definitions\",7,2)\n  115 PRINT\n  120 FORN=0TONnodes-1\n  130 loc=N*8+nodes:x=?loc:y=loc?1:z=loc?2:b=loc?3:PROCSG\n  160@%=2:PRINTN;:@%=4:PRINT\".PV=\"x y z;:@%=3:PRINT\"Pr\"b AND31\"Fs\"loc?4 loc?5 loc?6 loc?7;\n  170A=GET:NEXT\n  180 PROCPR(\"       Node Walk - i.e. lines\",7,4):PRINT\n  190FORN=0TONlines-1\n  200loc=N*5+lines:@%=3:PRINTN,\".Pr\"?loc,\"Faces\"loc?1,loc?2\"From\"loc?3/4\" to\"loc?4/4\n  210A=GET:NEXT\n  220PROCPR(\"        Face Normals\",5,7):PRINT\n  225@%=4\n  230FORN=0TONnorms-1\n  240loc=N*4+norms:b=?loc:x=loc?1:y=loc?2:z=loc?3:PROCSG:PRINTN,\".Pr\"b AND31,\"Vector\"x,y,z\n  250A=GET:NEXT:GOTO80\n  999END\n 1000DEFPROCPR(A$,for,bck):VDU128+bck,157,128+for,141:PRINTA$:VDU128+bck,157,128+for,141:PRINTA$;:ENDPROC\n 2000DEFPROCSG:IFb AND128x=-x\n 2010IFb AND64y=-y\n 2020IFb AND32z=-z\n 2030ENDPROC\n"
  },
  {
    "path": "1-source-files/original-sources/$.DEFGEN.inf",
    "content": "$.DEFGEN  000000 000000 0006BB\n"
  },
  {
    "path": "1-source-files/original-sources/$.DEFGEN.txt",
    "content": ">LIST\n\r   10 REM DEFSHIP EDITOR\n\r   20 MODE7:@%=3:*OPT1,2\n\r   30 PROCPR(\"      DEFSHIP  GENERATOR\",3,1)\n\r   40 INPUT''\"Input filename of DEFSHIPS\",A$:IFA$<>\"\" DF$=A$\n\r   50 PRINTTAB(0,22):PROCPR(\"  CREATING  \"+DF$+\"  DEFSHIPS\",4,6)\n\r   60 VDU28,0,22,39,2,10,10:FORN%=&7C50TO&7F80STEP40:?N%=130:NEXT\n\r   70 MEM=&6000:FORN=MEM TOMEM+&400STEP4:!N=0:NEXT\n\r   75 INPUT\"Number of nodes\",Nnodes\n\r   76 INPUT\"Number of lines\",Nlines\n\r   77 INPUT\"Number of faces\",Nnorms\n\r   80 nodes=MEM+27:lines=nodes+Nnodes*8:norms=lines+Nlines*5:end=norms+Nnorms*4\n\r   90 MEM?3=(lines-MEM)MOD256:MEM?16=(lines-MEM)DIV256:MEM?4=(norms-MEM)MOD256:MEM?17=(norms-MEM)DIV256:MEM?8=Nnodes*8:MEM?9=Nlines:MEM?12=Nnorms*4\n\r  100 REM PRINT NODES\n\r  110 PROCPR(\"        Node Definitions\",7,2)\n\r  115 PRINT\n\r  120 FORN=0TONnodes-1\n\r  130 loc=N*8+nodes:@%=2:PRINTN;:@%=4:INPUT\".PV=\"x,y,z,\"Pr\"b,\"Fs\"loc?4,loc?5,loc?6,loc?7\n\r  160PROCS:?loc=x:loc?1=y:loc?2=z:loc?3=b\n\r  170NEXT\n\r  175OSCLI(\"SAVE C.\"+DF$+\"1 \"+STR$~MEM+\" \"+STR$~end)\n\r  180 PROCPR(\"       Node Walk - i.e. lines\",7,4):PRINT\n\r  190FORN=0TONlines-1\n\r  200loc=N*5+lines:@%=3:PRINTN;:INPUT\".Pr\"?loc,\"Faces\"loc?1,loc?2,\"From\"a,\" to\"b:loc?3=a*4:loc?4=b*4\n\r  210NEXT\n\r  215OSCLI(\"SAVE C.\"+DF$+\"2 \"+STR$~MEM+\" \"+STR$~end)\n\r  220PROCPR(\"         Face Normals\",5,7):PRINT\n\r  225@%=4\n\r  230FORN=0TONnorms-1\n\r  240loc=N*4+norms:PRINTN;:INPUT\".Pr\"b,\"Vector\"x,y,z:PROCS:?loc=b:loc?1=x:loc?2=y:loc?3=z\n\r  250NEXT\n\r  260OSCLI(\"SAVE C.\"+DF$+\"3 \"+STR$~MEM+\" \"+STR$~end)\n\r  999END\n\r 1000DEFPROCPR(A$,for,bck):VDU128+bck,157,128+for,141:PRINTA$:VDU128+bck,157,128+for,141:PRINTA$;:ENDPROC\n\r 2000DEFPROCS:IFx<0 x=-x:b=b OR128\n\r 2010IFy<0 y=-y:b=b OR64\n\r 2020IFz<0 z=-z:b=b OR32\n\r 2030ENDPROC\n\r>*SPOOL\n\r"
  },
  {
    "path": "1-source-files/original-sources/$.DEFTRAN.inf",
    "content": "$.DEFTRAN 000000 000000 0007C4\n"
  },
  {
    "path": "1-source-files/original-sources/$.DEFTRAN.txt",
    "content": ">LIST\n\r   10 REM DEFSHIP EDITOR\n\r   20 MODE7:@%=3\n\r   30 PROCPR(\"        DEFSHIP  EDITOR\",3,1)\n\r   40 INPUT''\"Input filename of DEFSHIPS\",A$:IFA$<>\"\" DF$=A$\n\r   50 PRINTTAB(0,22):PROCPR(\"  EDITING  \"+DF$+\"  DEFSHIPS\",4,6)\n\r   60 VDU28,0,22,39,2,10,10:FORN%=&7C50TO&7F80STEP40:?N%=130:NEXT\n\r   70 MEM=&6000:HIMEM=MEM:OSCLI(\"L.\"+DF$+\" \"+STR$~MEM)\n\r   80 nodes=MEM+27:lines=MEM+?(MEM+3)+?(MEM+16)*256:norms=MEM+?(MEM+4)+?(MEM+17)*256\n\r   90 Nnodes=?(MEM+8)/8:Nlines=?(MEM+9):Nnorms=?(MEM+12)/4\n\r   92 REM Zlines=lines-7:Znorms=norms-\n\r   95 NWS=OPENOUT(\":2.S.\"+DF$):PTR#NWS=20\n\r  100 REM PRINT NODES\n\r  110 PROCPR(\"        Node Definitions\",7,2)\n\r  120 PRINT\n\r  130 FORN=0TONnodes-1\n\r  140 loc=N*8+nodes:x=?loc:y=loc?1:z=loc?2:b=loc?3:PROCSG\n\r  150@%=2:PRINTN;:@%=4:PRINT\".PV=\"x y z;:@%=3:PRINT\"Pr\"b AND31\"Fs\"loc?4 loc?5 loc?6 loc?7;\n\r  155 BPUT#NWS,?loc:BPUT#NWS,loc?1:BPUT#NWS,loc?2:BPUT#NWS,loc?3:BPUT#NWS,(loc?4 OR (loc?5*16)):BPUT#NWS,(loc?6 OR (loc?7*16))\n\r  160NEXT\n\r  165 T%=PTR#NWS:PTR#NWS=3:BPUT#NWS,(T%MOD256):PTR#NWS=16:BPUT#NWS,(T%DIV256):PTR#NWS=T%\n\r  170 PROCPR(\"       Node Walk - i.e. lines\",7,4):PRINT\n\r  180FORN=0TONlines-1\n\r  190loc=N*5+lines:@%=3:PRINTN,\".Pr\"?loc,\"Faces\"loc?1,loc?2\"From\"loc?3/4\" to\"loc?4/4\n\r  195BPUT#NWS,?loc:BPUT#NWS,(loc?1 OR (loc?2 *16)):BPUT#NWS,loc?3:BPUT#NWS,loc?4\n\r  200NEXT\n\r  205 T%=PTR#NWS:PTR#NWS=4:BPUT#NWS,(T%MOD256):PTR#NWS=17:BPUT#NWS,(T%DIV256):PTR#NWS=T%\n\r  210PROCPR(\"        Face Normals\",5,7):PRINT\n\r  220@%=4\n\r  230FORN=0TONnorms-1\n\r  240loc=N*4+norms:b=?loc:x=loc?1:y=loc?2:z=loc?3:PROCSG:PRINTN,\".Pr\"b AND31,\"Vector\"x,y,z\n\r  245BPUT#NWS,?loc:BPUT#NWS,loc?1:BPUT#NWS,loc?2:BPUT#NWS,loc?3\n\r  250NEXT\n\r  255PTR#NWS=6:BPUT#NWS,MEM?6:PTR#NWS=8:BPUT#NWS,MEM?8:BPUT#NWS,MEM?9:PTR#NWS=12:BPUT#NWS,MEM?12\n\r  260CLOSE#NWS:END\n\r  270DEFPROCPR(A$,for,bck):VDU128+bck,157,128+for,141:PRINTA$:VDU128+bck,157,128+for,141:PRINTA$;:ENDPROC\n\r  280DEFPROCSG:IFb AND128x=-x\n\r  290IFb AND64y=-y\n\r  300IFb AND32z=-z\n\r  310ENDPROC\n\r>*SPOOL\n\r"
  },
  {
    "path": "1-source-files/original-sources/$.DIALGEN.inf",
    "content": "$.DIALGEN 000000 000000 00048D\n"
  },
  {
    "path": "1-source-files/original-sources/$.DIALGEN.txt",
    "content": "   10 REM Generate new DIALS bitdump\n   20 \n   30 XMAX=68*4:YMAX=18*4: REM Ellipse\n   32 CYC=53*4:CXC=196*4:RD=11*4\n   35 XC=125*4:YC=35*4\n   36 PHI=PI/10:PSI=3*PI/4.1\n   37 MODE5\n   40 \n   45 DIL%=&6000\n   50 *LOAD :2.NDIALS 7600\n   53 REMGCOL0,3:MOVEXC+XMAX*SINPHI,YC+YMAX*COSPHI:PLOT21,XC,YC:PLOT21,XC-XMAX*SINPHI,YC+YMAX*COSPHI\n   55 GCOL0,1:MOVEXC+XMAX*SINPHI,YC+YMAX*COSPHI:PLOT21,XC+XMAX*SINPSI,YC+YMAX*COSPSI:MOVEXC-XMAX*SINPHI,YC+YMAX*COSPHI:PLOT21,XC-XMAX*SINPSI,YC+YMAX*COSPSI\n   57 MOVEXC-XMAX,YC:PLOT21,XC+XMAX,YC\n   58 MOVEXC,YC-YMAX:PLOT21,XC,YC+YMAX-4\n   60 GCOL0,1:PROCELLIPSE(XMAX,YMAX,.05)\n   65 GCOL0,2:PLOT69,XC,YC:PLOT69,XC-8,YC:PLOT69,XC+8,YC:PLOT69,XC,YC+4:PLOT69,XC,YC-4\n   67 FORTHETA=0TO2*PI STEP.1:PLOT69,RD*COSTHETA+CXC,RD*SINTHETA+CYC:NEXT\n   68 GCOL0,1:MOVECXC+RD,CYC:PLOT21,CXC-RD,CYC:MOVECXC,CYC+RD:PLOT21,CXC,CYC-RD\n   70 FORI%=0TO7:FORJ%=0TO255STEP4:!(J%+DIL%+I%*256)=!(J%+&7600+I%*320):NEXT,\n   80 OSCLI\"SAVE DIALSHP \"+STR$~DIL%+\"+800 0000 7800\"\n  400 END\n  500 DEFPROCELLIPSE(A,B,S)\n  510 FORTHETA=0TO2*PI STEPS\n  520  X%=A*COSTHETA+XC:Y%=B*SINTHETA+YC-4:PLOT69,X%,Y%\n  540 NEXT:ENDPROC\n"
  },
  {
    "path": "1-source-files/original-sources/$.ELITEA.inf",
    "content": "$.ELITEA  000000 000000 002FA2\n"
  },
  {
    "path": "1-source-files/original-sources/$.ELITEA.txt",
    "content": "    1GOTO20\n    2*L.ELITEB\n    3GOTO20\n    4*L.ELITEA\n    5GOTO120\n   20REM ELITE <A>\n   30MODE7:VDU28,0,23,39,19\n   40LOMEM=&3D70\n  100C%=&F40:W%=&7200:L%=&1128:HIMEM=W%:Z=0\n  120D%=&563A:WP=&D40:K%=&900:LS%=WP-1:QQ18=&400:T%=&300\n  220NOST=18:NOSH=12:COPS=2:SH3=COPS:CYL=7:THG=6:SST=8:MSL=9:AST=10:OIL=11:TGL=12:ESC=13:NI%=36:POW=15:B=&30\n 1000FF=&FF:OSWRCH=&FFEE:OSBYTE=&FFF4:OSWORD=&FFF1:OSFILE=&FFDD:SCLI=&FFF7:VIA=&FE40:USVIA=VIA:IRQ1V=&204:VSCAN=57:XX21=D%\n 1020ZP=0:X=128:Y=96:RAND=FNZT(4):TRTB%=FNZ2:T1=FNZ:SC=FNZ2:SCH=SC+1:XX16=FNZT(18):P=FNZT(3)\n 1060XX0=FNZ2:INF=FNZ2:V=FNZ2:XX=FNZ2:YY=FNZ2:SUNX=FNZ2:BETA=FNZ:BET1=FNZ:XC=FNZ:YC=FNZ:QQ22=FNZ2:ECMA=FNZ\n 1120XX15=FNZT(6):XX12=FNZT(6):X1=XX15:Y1=X1+1:X2=Y1+1:Y2=X2+1:K=FNZT(4)\n 1125KL=FNZT(16):LAS=FNZ:MSTG=FNZ\n 1126f0=&20:f1=&71:f2=&72:f3=&73:f4=&14:f5=&74:f6=&75:f7=&16:f8=&76:f9=&77\n 1128KY1=KL+1:KY2=KL+2:KY3=KL+3:KY4=KL+4:KY5=KL+5:KY6=KL+6:KY7=KL+7:KY12=KL+8:KY13=KL+9:KY14=KL+10:KY15=KL+11:KY16=KL+12:KY17=KL+13:KY18=KL+14:KY19=KL+15\n 1130INWK=FNZT(NI%):XX19=INWK+33:XX1=INWK:LSP=FNZ:QQ15=FNZT(6):XX18=FNZT(9):QQ17=XX18:QQ19=QQ17+1:K5=XX18:K6=K5+4:ALP1=FNZ:ALP2=FNZ2\n 1150BET2=FNZ2:DELTA=FNZ:DELT4=FNZ2:U=FNZ:Q=FNZ:R=FNZ:S=FNZ:XSAV=FNZ:YSAV=FNZ:XX17=FNZ\n 1160QQ11=FNZ:ZZ=FNZ:XX13=FNZ:MCNT=FNZ:DL=FNZ:TYPE=FNZ:JSTX=FNZ:JSTY=FNZ:ALPHA=FNZ\n 1195QQ12=FNZ:TGT=FNZ:SWAP=FNZ:COL=FNZ:FLAG=FNZ:CNT=FNZ:CNT2=FNZ:STP=FNZ:XX4=FNZ:XX20=FNZ:XX14=FNZ:RAT=FNZ:RAT2=FNZ:K2=FNZT(4)\n 1400P%=C%:O%=W%:H%=L%+P%-C%\n 1410IFZ=4THENZ=6ELSEZ=4\n 1450FRIN=FNWT(NOSH+1):MANY=FNWT(14):SSPR=MANY+SST\n 1460ECMP=FNW:MJ=FNW:CABTMP=MANY:LAS2=FNW:MSAR=FNW:VIEW=FNW:LASCT=FNW:GNTMP=FNW:HFX=FNW:EV=FNW:DLY=FNW\n 1465de=FNW:T=&D1:XX2=&D2:K3=XX2:K4=K3+14:REM16\n 1470LSO=FNWT(192):LSX=LSO:LSX2=FNWT(78):LSY2=FNWT(78):SY=FNWT(NOST+1):SYL=FNWT(NOST+1):SZ=FNWT(NOST+1):SZL=FNWT(NOST+1)\n 1480XSAV2=FNW:YSAV2=FNW\n 1500TP=FNTP:QQ0=FNTP:QQ1=FNTP:QQ21=FNTPT(6):CASH=FNTPT(4):QQ14=FNTP:COK=FNTP:GCNT=FNTP:LASER=FNTPT(6):CRGO=FNTP:QQ20=FNTPT(17):ECM=FNTP:BST=FNTP:BOMB=FNTP:ENGY=FNTP:DKCMP=FNTP:GHYP=FNTP:ESCP=FNTPT(5)\n 1520NOMSL=FNTP:FIST=FNTP:AVL=FNTPT(17):QQ26=FNTP:TALLY=FNTPT(2):SVC=FNTPT(3):NT%=SVC+2-TP:MCH=FNW\n 1600SX=T%:SXL=SX+NOST+1:XX3=256:REM&70\n 1628FSH=FNW:ASH=FNW:ENERGY=FNW:REMFF\n 1630LASX=FNW:LASY=FNW:COMX=FNW:COMY=FNW:QQ24=FNW:QQ25=FNW:QQ28=FNW:QQ29=FNW:gov=FNW:tek=FNW:SLSP=FNW2:XX24=FNW:ALTIT=FNW:VEC=&7FFE:svn=&7FFD\n 1650QQ2=FNWT(6):QQ3=FNW:QQ4=FNW:QQ5=FNW:QQ6=FNW2:QQ7=FNW2:QQ8=FNW2:QQ9=FNW:QQ10=FNW:NOSTM=FNW\n 1800[OPTZ:.S% EQUWTT170:EQUWTT26:EQUWIRQ1:EQUWBR1\n 1830.COMC brk:.DNOIZ brk:.DAMP brk:.DJD brk:.PATG brk:.FLH brk:.JSTGY brk:.JSTE brk:.JSTK brk\n 4000.M% LDAK%:STARAND\n 4020LDXJSTX:JSRcntr:JSRcntr:TXA:EOR#128:TAY:AND#128:STAALP2:STXJSTX:EOR#128:STAALP2+1:TYA:BPLP%+7:EOR#FF:CLC:ADC#1:LSRA:LSRA:CMP#8:BCSP%+4:LSRA:CLC:STAALP1:ORAALP2:STAALPHA\n 4030LDXJSTY:JSRcntr:TXA:EOR#128:TAY:AND#128:STXJSTY:STABET2+1:EOR#128:STABET2:TYA:BPLP%+4:EOR#FF:ADC#4:LSRA:LSRA:LSRA:LSRA:CMP#3:BCSP%+3:LSRA:STABET1:ORABET2:STABETA\n 4050LDAKY2:BEQMA17:LDADELTA:CMP#40:BCSMA17:INCDELTA:.MA17 LDAKY1:BEQMA4:DECDELTA:BNEMA4:INCDELTA:.MA4\n 4060LDAKY15:ANDNOMSL:BEQMA20:LDY#&EE:JSRABORT:LDA#40:JSRNOISE:.MA31 LDA#0:STAMSAR:.MA20 LDAMSTG:BPLMA25:LDAKY14:BEQMA25:LDXNOMSL:BEQMA25:STAMSAR:LDY#&E0:JSRMSBAR:.MA25\n 4064LDAKY16:BEQMA24:LDAMSTG:BMIMA64:JSRFRMIS:.MA24 LDAKY12:BEQMA76:ASLBOMB:.MA76\n 4070LDAKY13:ANDESCP:BEQP%+5:JMPESCAPE:LDAKY18:BEQP%+5:JSRWARP:LDAKY17:ANDECM:BEQMA64:LDAECMA:BNEMA64:DECECMP:JSRECBLB2:.MA64\n 4075LDAKY19:ANDDKCMP:ANDSSPR:BEQMA68:LDAK%+NI%+32:BMIMA68:JMPGOIN:.MA68\n 4080LDA#0:STALAS:STADELT4:LDADELTA:LSRA:RORDELT4:LSRA:RORDELT4:STADELT4+1\n 4090LDALASCT:BNEMA3:LDAKY7:BEQMA3:LDAGNTMP:CMP#242:BCSMA3:LDXVIEW:LDALASER,X:BEQMA3:PHA:AND#127:STALAS:STALAS2:LDA#0:JSRNOISE:JSRLASLI:PLA:BPLma1:LDA#0:.ma1 AND#&FA:STALASCT:.MA3\n 4100LDX#0:.MAL1\n 4105STXXSAV:LDAFRIN,X:BNEP%+5:JMPMA18:STATYPE:JSRGINF\n 4110LDY#(NI%-1):.MAL2 LDA(INF),Y:STAINWK,Y:DEY:BPLMAL2:LDATYPE:BMIMA21:ASLA:TAY:LDAXX21-2,Y:STAXX0:LDAXX21-1,Y:STAXX0+1\n 4115LDABOMB:BPLMA21:CPY#2*SST:BEQMA21:LDAINWK+31:AND#32:BNEMA21:LDAINWK+31:ORA#128:STAINWK+31:JSREXNO2\n 4130.MA21 JSRMVEIT:LDY#(NI%-1):.MAL3 LDAINWK,Y:STA(INF),Y:DEY:BPLMAL3\n 4134LDAINWK+31:AND#&A0:JSRMAS4:BNEMA65:LDAINWK:ORAINWK+3:ORAINWK+6:BMIMA65:LDXTYPE:BMIMA65:CPX#SST:BEQISDK:AND#&C0:BNEMA65:CPX#MSL:BEQMA65\n 4138CPX#OIL:BCSP%+5:JMPMA58:LDABST:ANDINWK+5:BPLMA58:LDA#3:CPX#TGL:BCCoily:BNEslvy2:LDA#16:BNEslvy2\n 4140.oily JSRDORND:AND#7:.slvy2 STAQQ29:LDA#1:JSRtnpr:LDY#78:BCSMA59:LDYQQ29:ADCQQ20,Y:STAQQ20,Y:TYA:ADC#208:JSRMESS\n 4141JMPMA60:.MA65 JMPMA26\n 4142.ISDK LDAK%+NI%+32:BMIMA62:LDAINWK+14:CMP#&D6:BCCMA62:JSRSPS4:LDAXX15+2:BMIMA62:CMP#89:BCCMA62:LDAINWK+16:AND#&7F:CMP#80:BCCMA62:.GOIN LDA#0:STAQQ22+1:LDA#8:JSRLAUN:JSRRES4:JMPBAY:.MA62 LDADELTA:CMP#5:BCCMA67:JMPDEATH\n 4143.MA59 JSREXNO3:.MA60 ASLINWK+31:SEC:RORINWK+31:.MA61 BNEMA26\n 4144.MA67 LDA#1:STADELTA:LDA#5:BNEMA63:.MA58 ASLINWK+31:SEC:RORINWK+31:LDAINWK+35:SEC:RORA:.MA63 JSROOPS:JSREXNO3:.MA26\n 4146LDAQQ11:BNEMA15:JSRPLUT\n 4150JSRHITCH:BCCMA8:LDAMSAR:BEQMA47:JSRBEEP:LDXXSAV:LDY#&E:JSRABORT2:.MA47 LDALAS:BEQMA8:LDX#15:JSREXNO:LDAINWK+35:SEC:SBCLAS:BCSMA14\n 4155LDATYPE:CMP#SST:BEQMA14+2:LDAINWK+31:ORA#128:STAINWK+31:BCSMA8:JSRDORND:BPLoh:LDY#0:AND(XX0),Y:STACNT:.um BEQoh:LDX#OIL:LDA#0:JSRSFS1:DECCNT:BPLum:.oh JSREXNO2\n 4160.MA14 STAINWK+35:LDATYPE:JSRANGRY:.MA8\n 4180JSRLL9:.MA15 LDY#35:LDAINWK+35:STA(INF),Y\n 4190LDAINWK+31:BPLMAC1:AND#&20:BEQNBOUN:LDATYPE:CMP#COPS:BNEq2:LDAFIST:ORA#64:STAFIST:.q2 LDADLY:ORAMJ:BNEKS1S:LDY#10:LDA(XX0),Y:BEQKS1S:TAX:INY:LDA(XX0),Y:TAY:JSRMCASH:LDA#0:JSRMESS:.KS1S JMPKS1:.NBOUN\n 4240.MAC1 LDATYPE:BMIMA27:JSRFAROF:BCCKS1S:.MA27 LDY#31:LDAINWK+31:STA(INF),Y:LDXXSAV:INX:JMPMAL1:.MA18 LDABOMB:BPLMA77:ASLBOMB:JSRWSCAN:LDA#&30:STA&FE21:.MA77\n 4250LDAMCNT:AND#7:BNEMA22:LDXENERGY:BPLb:LDXASH:JSRSHD:STXASH:LDXFSH:JSRSHD:STXFSH:.b SEC:LDAENGY:ADCENERGY:BCSP%+5:STAENERGY\n 4260LDAMJ:BNEMA23S:LDAMCNT:AND#31:BNEMA93:LDASSPR:BNEMA23S:TAY:JSRMAS2:BNEMA23S\n 4270LDX#28:.MAL4 LDAK%,X:STAINWK,X:DEX:BPLMAL4:INX:LDY#9:JSRMAS1:BNEMA23S:LDX#3:LDY#11:JSRMAS1:BNEMA23S:LDX#6:LDY#13:JSRMAS1:BNEMA23S\n 4280LDA#&C0:JSRFAROF2:BCCMA23S\n 4290LDAQQ11:BNEP%+5\\!:JSRWPLS:JSRNWSPS:.MA23S JMPMA23\n 4300.MA22 LDAMJ:BNEMA23:LDAMCNT:AND#31:.MA93 CMP#10:BNEMA29:LDA#50:CMPENERGY:BCCP%+6:ASLA:JSRMESS:LDY#FF:STYALTIT:INY:JSRm:BNEMA23:JSRMAS3:BCSMA23:SBC#&24:BCCMA28:STAR:JSRLL5:LDAQ:STAALTIT:BNEMA23:.MA28 JMPDEATH\n 4310.MA29 CMP#20:BNEMA23:LDA#30:STACABTMP:LDASSPR:BNEMA23:LDY#NI%:JSRMAS2:BNEMA23:JSRMAS3:EOR#FF:ADC#30:STACABTMP:BCSMA28\n 4320CMP#&E0:BCCMA23:LDABST:BEQMA23:LDADELT4+1:LSRA:ADCQQ14:CMP#70:BCCP%+4:LDA#70:STAQQ14:LDA#160:JSRMESS\n 4350.MA23 LDALAS2:BEQMA16:LDALASCT:CMP#8:BCSMA16:JSRLASLI2:LDA#0:STALAS2:.MA16\n 4360LDAECMP:BEQMA69:JSRDENGY:BEQMA70:.MA69 LDAECMA:BEQMA66:DECECMA:BNEMA66:.MA70 JSRECMOF:.MA66\n 4380LDAQQ11:BNEMA9:JMPSTARS\n 4900.MAS1 LDAINWK,Y:ASLA:STAK+1:LDAINWK+1,Y:ROLA:STAK+2:LDA#0:RORA:STAK+3:JSRMVT3:STAINWK+2,X:LDYK+1:STYINWK,X:LDYK+2:STYINWK+1,X:AND#127:.MA9 RTS:.m LDA#0:.MAS2 ORAK%+2,Y:ORAK%+5,Y:ORAK%+8,Y:AND#127:RTS\n 4940.MAS3 LDAK%+1,Y:JSRSQUA2:STAR:LDAK%+4,Y:JSRSQUA2:ADCR:BCSMA30:STAR:LDAK%+7,Y:JSRSQUA2:ADCR:BCCP%+4:.MA30 LDA#FF:RTS\n 7000.MVEIT LDAINWK+31:AND#&A0:BNEMV30\n 7011LDAMCNT:EORXSAV:AND#15:BNEMV3:JSRTIDY:.MV3 LDXTYPE:BPLP%+5:JMPMV40:LDAINWK+32:BPLMV30:CPX#MSL:BEQMV26\n 7014LDAMCNT:EORXSAV:AND#7:BNEMV30:.MV26 JSRTACTICS:.MV30 JSRSCAN\n 7020LDAINWK+27:ASLA:ASLA:STAQ:LDAINWK+10:AND#127:JSRFMLTU:STAR:LDAINWK+10:LDX#0:JSRMVT1-2\n 7025LDAINWK+12:AND#127:JSRFMLTU:STAR:LDAINWK+12:LDX#3:JSRMVT1-2:LDAINWK+14:AND#127:JSRFMLTU:STAR:LDAINWK+14:LDX#6:JSRMVT1-2\n 7030LDAINWK+27:CLC:ADCINWK+28:BPLP%+4:LDA#0:LDY#15:CMP(XX0),Y:BCCP%+4:LDA(XX0),Y:STAINWK+27\n 7032LDA#0:STAINWK+28\n 7040LDXALP1:LDAINWK:EOR#FF:STAP:LDAINWK+1:JSRMLTU2-2:STAP+2:LDAALP2+1:EORINWK+2:LDX#3:JSRMVT6\n 7045STAK2+3:LDAP+1:STAK2+1:EOR#FF:STAP:LDAP+2:STAK2+2\\K2=Y-aX\n 7050LDXBET1:JSRMLTU2-2:STAP+2:LDAK2+3:EORBET2:LDX#6:JSRMVT6:STAINWK+8:LDAP+1:STAINWK+6:EOR#FF:STAP:LDAP+2:STAINWK+7\\Z=Z+bK2\n 7060JSRMLTU2:STAP+2:LDAK2+3:STAINWK+5:EORBET2:EORINWK+8:BPLMV43:LDAP+1:ADCK2+1:STAINWK+3:LDAP+2:ADCK2+2:STAINWK+4:JMPMV44:.MV43\n 7070LDAK2+1:SBCP+1:STAINWK+3:LDAK2+2:SBCP+2:STAINWK+4:BCSMV44:LDA#1:SBCINWK+3:STAINWK+3:LDA#0:SBCINWK+4:STAINWK+4:LDAINWK+5:EOR#128:STAINWK+5\n 7080.MV44\\Y=K2-bZ:LDXALP1:LDAINWK+3:EOR#FF:STAP:LDAINWK+4:JSRMLTU2-2:STAP+2:LDAALP2:EORINWK+5:LDX#0:JSRMVT6:STAINWK+2:LDAP+2:STAINWK+1:LDAP+1:STAINWK\\X=X+aY\n 7110.MV45 LDADELTA:STAR:LDA#128:LDX#6:JSRMVT1:LDATYPE:AND#&81:CMP#&81:BNEP%+3:RTS \\Z=Z-d\n 7120LDY#9:JSRMVS4:LDY#15:JSRMVS4:LDY#21:JSRMVS4:LDAINWK+30:AND#128:STARAT2:LDAINWK+30:AND#127:BEQMV8:CMP#127:SBC#0:ORARAT2:STAINWK+30\n 7130LDX#15:LDY#9:JSRMVS5:LDX#17:LDY#11:JSRMVS5:LDX#19:LDY#13:JSRMVS5\n 7160.MV8 LDAINWK+29:AND#128:STARAT2:LDAINWK+29:AND#127:BEQMV5:CMP#127:SBC#0:ORARAT2:STAINWK+29\n 7170LDX#15:LDY#21:JSRMVS5:LDX#17:LDY#23:JSRMVS5:LDX#19:LDY#25:JSRMVS5\n 7210.MV5 LDAINWK+31:AND#&A0:BNEMVD1:LDAINWK+31:ORA#16:STAINWK+31:JMPSCAN:.MVD1 LDAINWK+31:AND#&EF:STAINWK+31:RTS\n 7300AND#128:.MVT1 ASLA:STAS:LDA#0:RORA:STAT:LSRS:EORINWK+2,X:BMIMV10:LDAR:ADCINWK,X:STAINWK,X:LDAS:ADCINWK+1,X:STAINWK+1,X:LDAINWK+2,X:ADC#0:ORAT:STAINWK+2,X:RTS\n 7310.MV10 LDAINWK,X:SEC:SBCR:STAINWK,X:LDAINWK+1,X:SBCS:STAINWK+1,X:LDAINWK+2,X:AND#127:SBC#0:ORA#128:EORT:STAINWK+2,X:BCSMV11\n 7320LDA#1:SBCINWK,X:STAINWK,X:LDA#0:SBCINWK+1,X:STAINWK+1,X:LDA#0:SBCINWK+2,X:AND#127:ORAT:STAINWK+2,X:.MV11 RTS\n 7400.MVT3 LDAK+3:STAS:AND#128:STAT:EORINWK+2,X:BMIMV13:LDAK+1:CLC:ADCINWK,X:STAK+1:LDAK+2:ADCINWK+1,X:STAK+2:LDAK+3:ADCINWK+2,X:AND#127:ORAT:STAK+3:RTS\n 7410.MV13 LDAS:AND#127:STAS:LDAINWK,X:SEC:SBCK+1:STAK+1:LDAINWK+1,X:SBCK+2:STAK+2:LDAINWK+2,X:AND#127:SBCS:ORA#128:EORT:STAK+3:BCSMV14\n 7420LDA#1:SBCK+1:STAK+1:LDA#0:SBCK+2:STAK+2:LDA#0:SBCK+3:AND#127:ORAT:STAK+3:.MV14 RTS\n 7500.MVS4 LDAALPHA:STAQ:LDXINWK+2,Y:STXR:LDXINWK+3,Y:STXS:LDXINWK,Y:STXP:LDAINWK+1,Y:EOR#128:JSRMAD:STAINWK+3,Y:STXINWK+2,Y:STXP \\Y=Y-aX\n 7520LDXINWK,Y:STXR:LDXINWK+1,Y:STXS:LDAINWK+3,Y:JSRMAD:STAINWK+1,Y:STXINWK,Y:STXP \\X=X+aY\n 7530LDABETA:STAQ:LDXINWK+2,Y:STXR:LDXINWK+3,Y:STXS:LDXINWK+4,Y:STXP:LDAINWK+5,Y:EOR#128:JSRMAD:STAINWK+3,Y:STXINWK+2,Y:STXP\\Y=Y-bZ\n 7540LDXINWK+4,Y:STXR:LDXINWK+5,Y:STXS:LDAINWK+3,Y:JSRMAD:STAINWK+5,Y:STXINWK+4,Y:RTS\\Z=Z+bY\n 7600.MVS5 LDAINWK+1,X:AND#127:LSRA:STAT:LDAINWK,X:SEC:SBCT:STAR:LDAINWK+1,X:SBC#0:STAS:LDAINWK,Y:STAP:LDAINWK+1,Y:AND#128:STAT:LDAINWK+1,Y:AND#127:LSRA:RORP:LSRA:RORP:LSRA:RORP:LSRA:RORP:ORAT:EORRAT2:STXQ:JSRADD:STAK+1:STXK\n 7610LDXQ:LDAINWK+1,Y:AND#127:LSRA:STAT:LDAINWK,Y:SEC:SBCT:STAR:LDAINWK+1,Y:SBC#0:STAS:LDAINWK,X:STAP:LDAINWK+1,X:AND#128:STAT:LDAINWK+1,X:AND#127:LSRA:RORP:LSRA:RORP:LSRA:RORP:LSRA:RORP:ORAT:EOR#128:EORRAT2\n 7620STXQ:JSRADD:STAINWK+1,Y:STXINWK,Y:LDXQ:LDAK:STAINWK,X:LDAK+1:STAINWK+1,X:RTS\n 7650.MVT6 TAY:EORINWK+2,X:BMIMV50:LDAP+1:CLC:ADCINWK,X:STAP+1:LDAP+2:ADCINWK+1,X:STAP+2:TYA:RTS\n 7660.MV50 LDAINWK,X:SEC:SBCP+1:STAP+1:LDAINWK+1,X:SBCP+2:STAP+2:BCCMV51:TYA:EOR#128:RTS:.MV51 LDA#1:SBCP+1:STAP+1:LDA#0:SBCP+2:STAP+2:TYA:RTS\n 7700.MV40 LDAALPHA:EOR#128:STAQ:LDAINWK:STAP:LDAINWK+1:STAP+1:LDAINWK+2:JSRMULT3:LDX#3:JSRMVT3\\K=Y-aX\n 7710LDAK+1:STAK2+1:STAP:LDAK+2:STAK2+2:STAP+1:LDABETA:STAQ:LDAK+3:STAK2+3:JSRMULT3:LDX#6:JSRMVT3:LDAK+1:STAP:STAINWK+6:LDAK+2:STAP+1:STAINWK+7:LDAK+3:STAINWK+8\\Z=Z+bK2\n 7720EOR#128:JSRMULT3:LDAK+3:AND#128:STAT:EORK2+3:BMIMV1\n 7730LDAK:\\CLC:ADCK2:LDAK+1:ADCK2+1:STAINWK+3:LDAK+2:ADCK2+2:STAINWK+4:LDAK+3:ADCK2+3:JMPMV2\n 7740.MV1 LDAK:SEC:SBCK2:LDAK+1:SBCK2+1:STAINWK+3:LDAK+2:SBCK2+2:STAINWK+4:LDAK2+3:AND#127:STAP:LDAK+3:AND#127:SBCP:STAP:BCSMV2\n 7750LDA#1:SBCINWK+3:STAINWK+3:LDA#0:SBCINWK+4:STAINWK+4:LDA#0:SBCP:ORA#128:.MV2 EORT:STAINWK+5\\Y=K2-bZ\n 7760LDAALPHA:STAQ:LDAINWK+3:STAP:LDAINWK+4:STAP+1:LDAINWK+5:JSRMULT3:LDX#0:JSRMVT3:LDAK+1:STAINWK:LDAK+2:STAINWK+1:LDAK+3:STAINWK+2\\X=X+aY\n 7770JMPMV45:]\n 9510IFZ>4OSCLI\"S.ELTA \"+STR$~W%+\" \"+STR$~O%+\" \"+STR$~L%+\" \"+STR$~H%\n 9520PRINT\"A d,\";:GOTO2\n10100DEFFNZ=FNZT(1)\n10110DEFFNZ2=FNZT(2)\n10120DEFFNZT(N%):ZP=ZP+N%:=ZP-N%\n10300DEFFNW=FNWT(1)\n10310DEFFNW2=FNWT(2)\n10320DEFFNWT(N%):WP=WP+N%:=WP-N%\n10400DEFFNTP=FNTPT(1)\n10410DEFFNTPT(N%):T%=T%+N%:=T%-N%\n"
  },
  {
    "path": "1-source-files/original-sources/$.ELITEB.inf",
    "content": "$.ELITEB  000000 000000 002D20\n"
  },
  {
    "path": "1-source-files/original-sources/$.ELITEB.txt",
    "content": "    1GOTO20\n    2*L.ELITEB\n    3GOTO20\n    4*L.ELITEA\n    6*L.ELITEC\n   20REM ELITE <B>\n 1000O%=W%:H%=L%+P%-C%:Q%=FALSE\n 1010J%=O%:[OPTZ\n 1100.NA% EQUS(\"JAMESON\"):EQUB13:EQUB0\n 1110EQUB20\\QQ0:EQUB173\\QQ1:EQUD&2485A4A\\QQ21:EQUW&B753 \\Base seed\n 1120EQUD(((&E8030000)AND(NOTQ%))+((&CA9A3B)ANDQ%))\\CASH,&80969800\n 1130EQUB70 fuel\n 1135EQUB 0 COK-UP\n 1137EQUB0 GALACTIC COUNT\n 1140EQUBPOW+(128ANDQ%):EQUB(POW):EQUB0:EQUB0:EQUW0 LASER:EQUB22+(15ANDQ%) \\37 CRGO\n 1150EQUD0:EQUD0:EQUD0:EQUD0:EQUB0\\crgo\n 1160EQUB Q% ECM\n 1170EQUB Q% BST\n 1180EQUB Q%AND127 BOMB\n 1190EQUB Q%AND1 ENGY++\n 1200EQUB Q% DCK COMP\n 1203EQUB Q% GHYP\n 1205EQUB Q% ESCP\n 1207EQUD FALSE EXPAND\n 1210EQUB 3+(Q%AND1) MISSILES\n 1220EQUB FALSE FIST\n 1222EQUB16:EQUB15:EQUB17:EQUB0:EQUB3:EQUB28:EQUB14:EQUW0:EQUB10:EQUB0:EQUB17:EQUB58:EQUB7:EQUB9:EQUB8:EQUB0\n 1224EQUB 0 QQ26\n 1230EQUW 0 TALLY\n 1240EQUB 128 SVC\n 1245]CH%=NT%-2:CY%=0:FORI%=CH%+J%TO1+J%STEP-1:CH%=CH%+CY%+(I%?7):CY%=(CH%>255)AND1:CH%=CH%MOD256:CH%=CH%EOR(I%?8):NEXT:[OPTZ\n 1247.CHK2 EQUB CH% EOR&A9\n 1250.CHK EQUB CH%\n 1300.UNIV:]FORI%=0TO12:!O%=K%+I%*NI%:O%=O%+2:P%=P%+2:NEXT:[OPTZ\n 1800.TWOS EQUD&10204080:EQUD&01020408:.TWOS2 EQUD&183060C0:EQUD&0303060C:.CTWOS EQUD&11224488:EQUB&88\n 2000.LL30:.LOIN STYYSAV\n 2020LDA#128:STAS:ASLA:STASWAP:LDAX2:SBCX1:BCSLI1:EOR#FF:ADC#1:SEC:.LI1 STAP\n 2030LDAY2:SBCY1:BCSLI2:EOR#FF:ADC#1:.LI2 STAQ:CMPP:BCCSTPX:JMPSTPY\n 2040.STPX LDXX1:CPXX2:BCCLI3:DECSWAP:LDAX2:STAX1:STXX2:TAX:LDAY2:LDYY1:STAY1:STYY2:.LI3\n 2050LDAY1:LSRA:LSRA:LSRA:ORA#&60:STASCH:LDAY1:AND#7:TAY:TXA:AND#&F8:STASC\n 2060TXA:AND#7:TAX:LDATWOS,X:STAR\n 2064LDAQ:LDX#254:STXQ:.LIL1 ASLA:BCSLI4:CMPP:BCCLI5:.LI4 SBCP:SEC:.LI5 ROLQ:BCSLIL1\n 2070LDXP:INX:LDAY2:SBCY1:BCSDOWN\n 2080LDASWAP:BNELI6:DEX:.LIL2 LDAR:EOR(SC),Y:STA(SC),Y\n 2090.LI6 LSRR:BCCLI7:RORR:LDASC:ADC#8:STASC\n 2100.LI7 LDAS:ADCQ:STAS:BCCLIC2:DEY:BPLLIC2:DECSCH:LDY#7\n 2110.LIC2 DEX:BNELIL2:LDYYSAV:RTS\n 2150.DOWN LDASWAP:BEQLI9:DEX:.LIL3 LDAR:EOR(SC),Y:STA(SC),Y\n 2160.LI9 LSRR:BCCLI10:RORR:LDASC:ADC#8:STASC\n 2170.LI10 LDAS:ADCQ:STAS:BCCLIC3:INY:CPY#8:BNELIC3:INCSCH:LDY#0\n 2180.LIC3 DEX:BNELIL3:LDYYSAV:RTS\n 2200.STPY LDYY1:TYA:LDXX1:CPYY2:BCSLI15:DECSWAP:LDAX2:STAX1:STXX2:TAX:LDAY2:STAY1:STYY2:TAY\n 2210.LI15 LSRA:LSRA:LSRA:ORA#&60:STASCH:TXA:AND#&F8:STASC\n 2214TXA:AND#7:TAX:LDATWOS,X:STAR:LDAY1:AND#7:TAY\n 2220LDAP:LDX#1:STXP:.LIL4 ASLA:BCSLI13:CMPQ:BCCLI14:.LI13 SBCQ:SEC:.LI14 ROLP:BCCLIL4:LDXQ:INX:LDAX2:SBCX1:BCCLFT\n 2230CLC:LDASWAP:BEQLI17:DEX:.LIL5 LDAR:EOR(SC),Y:STA(SC),Y:.LI17 DEY:BPLLI16:DECSCH:LDY#7\n 2240.LI16 LDAS:ADCP:STAS:BCCLIC5:LSRR:BCCLIC5:RORR:LDASC:ADC#8:STASC\n 2250.LIC5 DEX:BNELIL5:LDYYSAV:RTS\n 2300.LFT LDASWAP:BEQLI18:DEX:.LIL6 LDAR:EOR(SC),Y:STA(SC),Y:.LI18 DEY:BPLLI19:DECSCH:LDY#7:.LI19 LDAS:ADCP:STAS:BCCLIC6\n 2310ASLR:BCCLIC6:ROLR:LDASC:SBC#7:STASC:CLC:.LIC6 DEX:BNELIL6:LDYYSAV\n 2390.HL6 RTS\n 2392.NLIN3 JSRTT27:.NLIN4 LDA#19:BNENLIN2:.NLIN LDA#23:INCYC:.NLIN2 STAY1:LDX#2:STXX1:LDX#254:STXX2:BNEHLOIN\n 2395.HLOIN2 JSREDGES:STYY1:LDA#0:STALSO,Y\n 2400.HLOIN STYYSAV:LDXX1:CPXX2:BEQHL6:BCCHL5:LDAX2:STAX1:STXX2:TAX:.HL5 DECX2\n 2410LDAY1:LSRA:LSRA:LSRA:ORA#&60:STASCH:LDAY1:AND#7:STASC:TXA:AND#&F8:TAY\n 2420.HL1 TXA:AND#&F8:STAT:LDAX2:AND#&F8:SEC:SBCT:BEQHL2:LSRA:LSRA:LSRA:STAR\n 2430LDAX1:AND#7:TAX:LDATWFR,X:EOR(SC),Y:STA(SC),Y:TYA:ADC#8:TAY:LDXR:DEX:BEQHL3\n 2440CLC:.HLL1 LDA#FF:EOR(SC),Y:STA(SC),Y:TYA:ADC#8:TAY:DEX:BNEHLL1\n 2450.HL3 LDAX2:AND#7:TAX:LDATWFL,X:EOR(SC),Y:STA(SC),Y:LDYYSAV:RTS\n 2460.HL2 LDAX1:AND#7:TAX:LDATWFR,X:STAT:LDAX2:AND#7:TAX:LDATWFL,X:ANDT:EOR(SC),Y:STA(SC),Y:LDYYSAV:RTS\n 2470.TWFL EQUD&F0E0C080:EQUW&FCF8:EQUB&FE:.TWFR EQUD&1F3F7FFF:EQUD&0103070F\n 2520.PX3 LDATWOS,X:EOR(SC),Y:STA(SC),Y:LDYT1:RTS\n 2580.PIX1 JSRADD:STAYY+1:TXA:STASYL,Y\n 2600.PIXEL2\n 2610LDAX1:BPLPX1:EOR#&7F:CLC:ADC#1:.PX1 EOR#128:TAX:LDAY1:AND#127:CMP#96:BCSPX4:LDAY1:BPLPX2:EOR#&7F:ADC#1:.PX2 STAT:LDA#97:SBCT\n 2620.PIXEL STYT1:TAY:LSRA:LSRA:LSRA:ORA#&60:STASCH:TXA:AND#&F8:STASC:TYA:AND#7:TAY:TXA:AND#7:TAX\n 2630LDAZZ:CMP#&90:BCSPX3:LDATWOS2,X:EOR(SC),Y:STA(SC),Y:LDAZZ:CMP#&50:BCSPX13:DEY:BPLPX14:LDY#1:.PX14 LDATWOS2,X:EOR(SC),Y:STA(SC),Y:.PX13 LDYT1:.PX4 RTS\n 3000.BLINE TXA:ADCK4:STAK6+2:LDAK4+1:ADCT:STAK6+3\n 3010LDAFLAG:BEQBL1:INCFLAG:.BL5 LDYLSP:LDA#FF:CMPLSY2-1,Y:BEQBL7:STALSY2,Y:INCLSP:BNEBL7:.BL1 LDAK5:STAXX15:LDAK5+1:STAXX15+1\n 3012LDAK5+2:STAXX15+2:LDAK5+3:STAXX15+3\n 3014LDAK6:STAXX15+4:LDAK6+1:STAXX15+5\n 3016LDAK6+2:STAXX12:LDAK6+3:STAXX12+1\n 3040JSRLL145:BCSBL5:LDASWAP:BEQBL9:LDAX1:LDYX2:STAX2:STYX1:LDAY1:LDYY2:STAY2:STYY1:.BL9\n 3050LDYLSP:LDALSY2-1,Y:CMP#FF:BNEBL8:LDAX1:STALSX2,Y:LDAY1:STALSY2,Y:INY:.BL8 LDAX2:STALSX2,Y:LDAY2:STALSY2,Y:INY:STYLSP:JSRLOIN\n 3051LDAXX13:BNEBL5\n 3052.BL7 LDAK6:STAK5:LDAK6+1:STAK5+1:LDAK6+2:STAK5+2:LDAK6+3:STAK5+3:LDACNT:CLC:ADCSTP:STACNT\n 3700RTS:.FLIP \\LDAMJ\\BNEFLIP-1:LDYNOSTM:.FLL1 LDXSY,Y:LDASX,Y:STAY1:STASY,Y:TXA:STAX1:STASX,Y:LDASZ,Y:STAZZ:JSRPIXEL2:DEY:BNEFLL1:RTS\n 3800.STARS \\LDA#FF:\\STACOL:LDXVIEW:BEQSTARS1:DEX:BNEST11:JMPSTARS6:.ST11 JMPSTARS2\n 4000.STARS1\n 4010LDYNOSTM:.STL1 JSRDV42:LDAR:LSRP:RORA:LSRP:RORA:ORA#1:STAQ\n 4012LDASZL,Y:SBCDELT4:STASZL,Y:LDASZ,Y:STAZZ:SBCDELT4+1:STASZ,Y\n 4020JSRMLU1:STAYY+1:LDAP:ADCSYL,Y:STAYY:STAR:LDAY1:ADCYY+1:STAYY+1:STAS\n 4030LDASX,Y:STAX1:JSRMLU2:STAXX+1:LDAP:ADCSXL,Y:STAXX:LDAX1:ADCXX+1:STAXX+1\n 4050EORALP2+1:JSRMLS1:JSRADD:STAYY+1:STXYY\n 4060EORALP2:JSRMLS2:JSRADD:STAXX+1:STXXX\n 4070LDXBET1:LDAYY+1:EORBET2+1:JSRMULTS-2:STAQ:JSRMUT2:ASLP:ROLA:STAT:LDA#0:RORA:ORAT:JSRADD:STAXX+1:TXA:STASXL,Y\n 4080LDAYY:STAR:LDAYY+1:STAS:\\JSRMADSTASSTXR:LDA#0:STAP:LDABETA:EOR#128\n 4110JSRPIX1:LDAXX+1:STAX1:STASX,Y:AND#127:CMP#120:BCSKILL1:LDAYY+1:STASY,Y:STAY1:AND#127:CMP#120:BCSKILL1\n 4130LDASZ,Y:CMP#16:BCCKILL1:STAZZ\n 4140.STC1 JSRPIXEL2:DEY:BEQP%+5:JMPSTL1:RTS\n 4150.KILL1 JSRDORND:ORA#4:STAY1:STASY,Y:JSRDORND:ORA#8:STAX1:STASX,Y:JSRDORND:ORA#&90:STASZ,Y:STAZZ:LDAY1:JMPSTC1\n 4200.STARS6\n 4210LDYNOSTM:.STL6 JSRDV42:LDAR:LSRP:RORA:LSRP:RORA:ORA#1:STAQ\n 4220LDASX,Y:STAX1:JSRMLU2:STAXX+1:LDASXL,Y:SBCP:STAXX:LDAX1:SBCXX+1:STAXX+1\n 4230JSRMLU1:STAYY+1:LDASYL,Y:SBCP:STAYY:STAR:LDAY1:SBCYY+1:STAYY+1:STAS\n 4240LDASZL,Y:ADCDELT4:STASZL,Y:LDASZ,Y:STAZZ:ADCDELT4+1:STASZ,Y\n 4250LDAXX+1:EORALP2:JSRMLS1:JSRADD:STAYY+1:STXYY\n 4260EORALP2+1:JSRMLS2:JSRADD:STAXX+1:STXXX\n 4270LDAYY+1:EORBET2+1:LDXBET1:JSRMULTS-2:STAQ:LDAXX+1:STAS:EOR#128:JSRMUT1:ASLP:ROLA:STAT:LDA#0:RORA:ORAT:JSRADD:STAXX+1:TXA:STASXL,Y\n 4280LDAYY:STAR:LDAYY+1:STAS:\\EOR#128:\\JSRMADSTASSTXR:LDA#0:STAP:LDABETA\n 4310JSRPIX1:LDAXX+1:STAX1:STASX,Y:LDAYY+1:STASY,Y:STAY1:AND#127:CMP#110:BCSKILL6\n 4330LDASZ,Y:CMP#160:BCSKILL6:STAZZ\n 4340.STC6 JSRPIXEL2:DEY:BEQST3:JMPSTL6:.ST3 RTS\n 4350.KILL6 JSRDORND:AND#127:ADC#10:STASZ,Y:STAZZ:LSRA:BCSST4:LSRA:LDA#&FC:RORA:STAX1:STASX,Y:JSRDORND:STAY1:STASY,Y:JMPSTC6\n 4360.ST4 JSRDORND:STAX1:STASX,Y:LSRA:LDA#230:RORA:STAY1:STASY,Y:BNESTC6\n 5000.PRXS EQUW1:EQUW300:EQUW4000:EQUW6000:EQUW4000:EQUW10000:EQUW5250:EQUW10000:EQUW9000:EQUW15000:EQUW10000:EQUW50000\n 6990.st4 LDX#9:CMP#25:BCSst3:DEX:CMP#10:BCSst3:DEX:CMP#2:BCSst3:DEX:BNEst3\n 7000.STATUS LDA#8:JSRTT66:JSRTT111:LDA#7:STAXC:LDA#126:JSRNLIN3:LDA#15:LDYQQ12:BNEst6:LDA#230:LDYMANY+AST:LDXFRIN+2,Y:BEQst6:LDYENERGY:CPY#128:ADC#1:.st6 JSRplf:LDA#125:JSRspc:LDA#19:LDYFIST:BEQst5:CPY#50:ADC#1:.st5 JSRplf:LDA#16\n 7010JSRspc:LDATALLY+1:BNEst4:TAX:LDATALLY:LSRA:LSRA:INX:LSRA:BNEP%-2:.st3 TXA:CLC:ADC#21:JSRplf\n 7030LDA#18:JSRplf2:LDACRGO:CMP#26:BCCP%+7:LDA#&6B:JSRplf2:LDABST:BEQP%+7:LDA#111:JSRplf2:LDAECM:BEQP%+7:LDA#&6C:JSRplf2:LDA#113:STAXX4:.stqv TAY:LDXBOMB-113,Y:BEQP%+5:JSRplf2:INCXX4:LDAXX4:CMP#117:BCCstqv\n 7040LDX#0:.st STXCNT:LDYLASER,X:BEQst1:TXA:CLC:ADC#96:JSRspc:LDA#103:LDXCNT:LDYLASER,X:BPLP%+4:LDA#104:JSRplf2:.st1 LDXCNT:INX:CPX#4:BCCst:RTS\n 7100.plf2 JSRplf:LDX#6:STXXC:RTS\n 7600.TENS EQUD&E87648\n 7605.pr2 LDA#3:LDY#0\n 7610.TT11 STAU:LDA#0:STAK:STAK+1:STYK+2:STXK+3:.BPRNT LDX#11:STXT:PHP:BCCTT30:DECT:DECU\n 7630.TT30 LDA#11:SEC:STAXX17:SBCU:STAU:INCU:LDY#0:STYS:JMPTT36\n 7640.TT35 ASLK+3:ROLK+2:ROLK+1:ROLK:ROLS:LDX#3:.tt35 LDAK,X:STAXX15,X:DEX:BPLtt35:LDAS:STAXX15+4\n 7650ASLK+3:ROLK+2:ROLK+1:ROLK:ROLS:ASLK+3:ROLK+2:ROLK+1:ROLK:ROLS:CLC:LDX#3:.tt36 LDAK,X:ADCXX15,X:STAK,X:DEX:BPLtt36:LDAXX15+4:ADCS:STAS\n 7660LDY#0:.TT36 LDX#3:SEC:.tt37 LDAK,X:SBCTENS,X:STAXX15,X:DEX:BPLtt37:LDAS:SBC#23:STAXX15+4\n 7670BCCTT37:LDX#3:.tt38 LDAXX15,X:STAK,X:DEX:BPLtt38:LDAXX15+4:STAS:INY:JMPTT36\n 7680.TT37 TYA:BNETT32:LDAT:BEQTT32:DECU:BPLTT34:LDA#32:BNEtt34:.TT32 LDY#0:STYT:CLC:ADC#B:.tt34 JSRTT26\n 7700.TT34 DECT:BPLP%+4:INCT:DECXX17:BMIRR3+1 \\!!:BNEP%+10:PLP:BCCP%+7:LDA#&2E:JSRTT26:JMPTT35\n 8000.BELL LDA#7\n 8200.TT26 \\PRINT\n 8205STAK3:STYYSAV2:STXXSAV2:LDYQQ17:CPY#FF:BEQRR4\n 8210CMP#7:BEQR5:CMP#32:BCSRR1:CMP#10:BEQRRX1:LDX#1:STXXC:.RRX1 INCYC:BNERR4\n 8220.RR1 \\LDX#(K3 MOD256)\\INX\\STXP+1\\DEX\\LDY#(K3 DIV256)\\STYP+2\\LDA#10\\JSROSWORD\n 8225TAY:LDX#&BF:ASLA:ASLA:BCCP%+4:LDX#&C1:ASLA:BCCP%+3:INX:STAP+1:STXP+2\n 8240LDAXC:ASLA:ASLA:ASLA:STASC:LDAYC:CPY#&7F:BNERR2:DECXC:ADC#&5E:TAX:LDY#&F8:JSRZES2:BEQRR4:.RR2 INCXC:\\LDAYC:CMP#24:BCCRR3:JSRTTX66:JMPRR4\n 8250.RR3 ORA#&60:.RREN STASC+1:LDY#7:.RRL1 LDA(P+1),Y:EOR(SC),Y:STA(SC),Y:DEY:BPLRRL1\n 8260.RR4 LDYYSAV2:LDXXSAV2:LDAK3:CLC:.rT9 RTS\n 8270.R5 JSRBEEP:JMPRR4\n 9500.DIALS LDA#&D0:STASC:LDA#&78:STASC+1:JSRPZW:STXK+1:STAK:LDA#14:STAT1:LDADELTA:\\LSRA:JSRDIL-1\n 9502LDA#0:STAR:STAP:LDA#8:STAS:LDAALP1:LSRA:LSRA:ORAALP2:EOR#128:JSRADD:JSRDIL2:LDABETA:LDXBET1:BEQP%+4:SBC#1:JSRADD:JSRDIL2\n 9503LDAMCNT:AND#3:BNErT9\n 9504LDY#0:JSRPZW:STXK:STAK+1:LDX#3:STXT1:.DLL23 STYXX12,X:DEX:BPLDLL23:LDX#3:LDAENERGY:LSRA:LSRA:STAQ:.DLL24 SEC:SBC#16:BCCDLL26:STAQ:LDA#16:STAXX12,X:LDAQ:DEX:BPLDLL24:BMIDLL9:.DLL26\n 9505LDAQ:STAXX12,X:.DLL9 LDAXX12,Y:STYP:JSRDIL:LDYP:INY:CPY#4:BNEDLL9\n 9506LDA#&78:STASC+1:LDA#16:\\\"<80<:STASC:LDAFSH:JSRDILX:LDAASH:JSRDILX:LDAQQ14:JSRDILX+2\n 9510JSRPZW:STXK+1:STAK:LDX#11:STXT1:LDACABTMP:JSRDILX:LDAGNTMP:JSRDILX\n 9530LDA#&F0:STAT1:STAK+1:LDAALTIT:JSRDILX:JMPCOMPAS\n 9540.PZW LDX#&F0:LDAMCNT:AND#8:ANDFLH:BEQP%+4:TXA:EQUB&2C:LDA#15:RTS\n 9690.DILX LSRA:LSRA:LSRA:LSRA\n 9700.DIL STAQ:LDX#FF:STXR:CMPT1:BCSDL30:LDAK+1:BNEDL31:.DL30 LDAK:.DL31 STACOL:LDY#2:LDX#3:.DL1 LDAQ:CMP#4:BCCDL2:SBC#4:STAQ:LDAR:.DL5 ANDCOL:STA(SC),Y:INY:STA(SC),Y:INY:STA(SC),Y:TYA:CLC:ADC#6:TAY:DEX:BMIDL6:BPLDL1\n 9710.DL2 EOR#3:STAQ:LDAR:.DL3 ASLA:AND#239:DECQ:BPLDL3:PHA:LDA#0:STAR:LDA#99:STAQ:PLA:JMPDL5:.DL6 INCSC+1:.DL9 RTS\n 9712.DIL2 LDY#1:STAQ:.DLL10 SEC:LDAQ:SBC#4:BCSDLL11:LDA#FF:LDXQ:STAQ:LDACTWOS,X:AND#&F0:BNEDLL12:.DLL11 STAQ:LDA#0:.DLL12 STA(SC),Y:INY:STA(SC),Y:INY:STA(SC),Y:INY:STA(SC),Y:TYA:CLC:ADC#5:TAY:CPY#30:BCCDLL10:INCSC+1:RTS\n 9730.TVT1 EQUD&8494C4D4:\\TVT2:EQUD&A5B5E5F5:EQUD&26366676:EQUD&A1B1F1E1:\\TVT3:EQUD&A0B0E0F0:EQUD&8090C0D0:EQUD&27376777\n 9740.LINSCN LDA#30:STADL:STAUSVIA+4:LDA#VSCAN:STAUSVIA+5:LDAHFX:BNEVNT1:LDA#8:STA&FE20:.VNT3 LDATVT1+16,Y:STA&FE21:DEY:BPLVNT3:LDALASCT:BEQP%+5:DECLASCT:\\VNT4:LDAsvn:BNEjvec:PLA:TAY:LDA&FE41:LDA&FC:RTI\n 9750.IRQ1 TYA:PHA:LDY#11:LDA#2:BITVIA+&D:BNELINSCN:BVCjvec:ASLA\\4:STA&FE20:LDAESCP:BNEVNT1:\\VNT2:LDATVT1,Y:STA&FE21:DEY:BPLP%-7:.jvec PLA:TAY:JMP(VEC):.VNT1 LDY#7:LDATVT1+8,Y:STA&FE21:DEY:BPLVNT1+2:BMIjvec\n 9800.ESCAPE LDAMJ:PHA:JSRRES2:LDX#CYL:STXTYPE:JSRFRS1:LDA#8:STAINWK+27:LDA#&C2:STAINWK+30:LSRA:STAINWK+32:.ESL1 JSRMVEIT:JSRLL9:DECINWK+32:BNEESL1\n 9810JSRSCAN:JSRRESET:PLA:BEQP%+5:JMPDEATH:LDX#16:.ESL2 STAQQ20,X:DEX:BPLESL2:STAFIST:STAESCP:LDA#70:STAQQ14:JMPBAY\n 9900]\n 9910IFZ>4OSCLI(\"S.ELTB \"+STR$~W%+\" \"+STR$~O%+\" \"+STR$~L%+\" \"+STR$~H%)\n 9920PRINT\"B done,\";:GOTO6\n\n"
  },
  {
    "path": "1-source-files/original-sources/$.ELITEC.inf",
    "content": "$.ELITEC  000000 000000 002F56\n"
  },
  {
    "path": "1-source-files/original-sources/$.ELITEC.txt",
    "content": "    1GOTO20\n    2*L.ELITEB\n    3GOTO20\n    4*L.ELITEA\n    6*L.ELITEC\n    7GOTO20\n    8*L.ELITED\n   20REM ELITE <C>\n 1000O%=W%:H%=L%+P%-C%\n 1010[OPTZ\n 1880.TA34 LDA#0:JSRMAS4:BEQP%+5:JMPTA21:JSRTA87+3:JSREXNO3:LDA#250:JMPOOPS\n 1900.TA18\\msl\n 1910LDAECMA:BNETA35:LDAINWK+32:ASLA:BMITA34:LSRA\n 1915TAX:LDAUNIV,X:STAV:LDAUNIV+1,X:STAV+1:LDY#2:JSRTAS1:LDY#5:JSRTAS1:LDY#8:JSRTAS1\n 1920LDAK3+2:ORAK3+5:ORAK3+8:AND#127:ORAK3+1:ORAK3+4:ORAK3+7:BNETA64\n 1930LDAINWK+32:CMP#&82:BEQTA35:LDY#31:LDA(V),Y:BITM32+1:BNETA35:ORA#128:STA(V),Y:.TA35 LDAINWK:ORAINWK+3:ORAINWK+6:BNETA87:LDA#80:JSROOPS:.TA87 JSREXNO2:ASLINWK+31:SEC:RORINWK+31\n 1940.TA1 RTS\n 1944.TA64 JSRDORND:CMP#16:BCSTA19:.M32 LDY#32:LDA(V),Y:LSRA:BCCTA19:JMPECBLB2\n 2000.TACTICS\n 2005CPX#MSL:BEQTA18:CPX#ESC:BNEP%+8:JSRSPS1:JMPTA15:CPX#SST:BNETA13:JSRDORND:CMP#140:BCCTA14-1:LDAMANY+SH3:CMP#4:BCSTA14-1:LDX#COPS:LDA#&F1:JMPSFS1:.TA13\n 2008CPX#TGL:BNETA14:LDAMANY+THG:BNETA14:LSRINWK+32:ASLINWK+32:LSRINWK+27:RTS:.TA14 CPX#CYL:BCSTA62:CPX#COPS:BEQTA62:LDASSPR:BEQTA62:LDAINWK+32:AND#129:STAINWK+32\n 2010.TA62 LDY#14:LDAINWK+35:CMP(XX0),Y:BCSTA21:INCINWK+35:.TA21\n 2020LDX#8:.TAL1 LDAINWK,X:STAK3,X:DEX:BPLTAL1\n 2030.TA19 JSRTAS2\\XX15=r~96\n 2040LDY#10:JSRTAS3:STACNT:LDATYPE:CMP#MSL:BNEP%+5:JMPTA20:JSRDORND:CMP#250:BCCTA7:JSRDORND:ORA#&68:STAINWK+29:.TA7\\VRol\n 2100LDY#14:LDA(XX0),Y:LSRA:CMPINWK+35:BCCTA3:LSRA:LSRA:CMPINWK+35:BCCta3:JSRDORND:CMP#230:BCCta3:LDATYPE:CMP#THG:BEQta3:LDA#0:STAINWK+32:JMPSESCP\n 2102.ta3 LDAINWK+31:AND#7:BEQTA3:STAT:JSRDORND:AND#31:CMPT:BCSTA3:LDAECMA:BNETA3:DECINWK+31:LDATYPE:CMP#THG:BNETA16:LDX#TGL:LDAINWK+32:JMPSFS1:.TA16 JMPSFRMIS:.TA3\n 2110LDA#0:JSRMAS4:AND#&E0:BNETA4:LDXCNT:CPX#160:BCCTA4:LDAINWK+31:ORA#64:STAINWK+31:CPX#163:BCCTA4\n 2120LDY#19:LDA(XX0),Y:LSRA:JSROOPS:DECINWK+28:LDAECMA:BNETA10:LDA#8:JMPNOISE:\\frLs\n 2190.TA4 LDAINWK+7:CMP#3:BCSTA5:LDAINWK+1:ORAINWK+4:AND#&FE:BEQTA15:.TA5 JSRDORND:ORA#128:CMPINWK+32:BCSTA15\n 2194.TA20 LDAXX15:EOR#128:STAXX15:LDAXX15+1:EOR#128:STAXX15+1:LDAXX15+2:EOR#128:STAXX15+2:LDACNT:EOR#128:STACNT\n 2200.TA15\\^XX15\n 2220LDY#16:JSRTAS3:EOR#128:AND#128:ORA#3:STAINWK+30\n 2235LDAINWK+29:AND#127:CMP#16:BCSTA6\n 2240LDY#22:JSRTAS3:EORINWK+30:AND#128:EOR#&85:STAINWK+29\n 2260.TA6 LDACNT:BMITA9:CMP#22:BCCTA9:LDA#3:STAINWK+28:RTS\n 2280.TA9 AND#127:CMP#18:BCCTA10:LDA#FF:LDXTYPE:CPX#MSL:BNEP%+3:ASLA:STAINWK+28:.TA10 RTS\n 2900.TAS1 LDA(V),Y:EOR#128:STAK+3:DEY:LDA(V),Y:STAK+2:DEY:LDA(V),Y:STAK+1:STYU:LDXU:JSRMVT3:LDYU\n 2910STAK3+2,X:LDAK+2:STAK3+1,X:LDAK+1:STAK3,X:RTS\n 3000.HITCH CLC:LDAINWK+8:BNEHI1:LDATYPE:BMIHI1:LDAINWK+31:AND#32:ORAINWK+1:ORAINWK+4:BNEHI1\n 3005LDAINWK:JSRSQUA2:STAS:LDAP:STAR\n 3010LDAINWK+3:JSRSQUA2:TAX:LDAP:ADCR:STAR:TXA:ADCS:BCSFR1-2:STAS:LDY#2:LDA(XX0),Y:CMPS:BNEHI1:DEY:LDA(XX0),Y:CMPR:.HI1 RTS\n 3210.FRS1 JSRZINF:LDA#28:STAINWK+3:LSRA:STAINWK+6:LDA#128:STAINWK+5:LDAMSTG:ASLA:ORA#128:STAINWK+32\n 3220.fq1 LDA#96:STAINWK+14:ORA#128:STAINWK+22:LDADELTA:ROLA:STAINWK+27:TXA:JMPNWSHP\n 3230.FRMIS LDX#MSL:JSRFRS1:BCCFR1:LDXMSTG:JSRGINF:LDAFRIN,X:JSRANGRY:LDY#0:JSRABORT:DECNOMSL:LDA#48:JMPNOISE\n 3234.ANGRY CMP#SST:BEQAN2:BCSHI1:CMP#CYL:BNEP%+5:JSRAN2:LDY#32:LDA(INF),Y:BEQHI1:ORA#128:STA(INF),Y:LDY#28:LDA#2:STA(INF),Y:ASLA:LDY#30:STA(INF),Y:RTS\n 3236.AN2 ASLK%+NI%+32:SEC:RORK%+NI%+32:CLC:RTS:.FR1 LDA#201:JMPMESS\n 3310.SESCP LDX#ESC:LDA#&FE:.SFS1 STAT1:LDAXX0:PHA:LDAXX0+1:PHA:LDAINF:PHA:LDAINF+1:PHA:LDY#NI%-1:.FRL2 LDAINWK,Y:STAXX3,Y:LDA(INF),Y:STAINWK,Y:DEY:BPLFRL2\n 3315LDATYPE:CMP#SST:BNErx:TXA:PHA:LDA#32:STAINWK+27:LDX#0:LDAINWK+10:JSRSFS2:LDX#3:LDAINWK+12:JSRSFS2:LDX#6:LDAINWK+14:JSRSFS2:PLA:TAX:.rx\n 3320LDAT1:STAINWK+32:LSRINWK+29:ASLINWK+29:TXA:CMP#OIL:BNENOIL:JSRDORND:ASLA:STAINWK+30:TXA:AND#15:STAINWK+27:LDA#FF:RORA:STAINWK+29:LDA#OIL:.NOIL JSRNWSHP\n 3330PLA:STAINF+1:PLA:STAINF:LDX#NI%-1:.FRL3 LDAXX3,X:STAINWK,X:DEX:BPLFRL3:PLA:STAXX0+1:PLA:STAXX0:RTS\n 3350.SFS2 ASLA:STAR:LDA#0:RORA:JMPMVT1\n 3400.LL164 LDA#56:JSRNOISE:LDA#1:STAHFX:LDA#4:JSRHFS2:DECHFX:RTS\n 3410.LAUN LDA#48:JSRNOISE:LDA#8:.HFS2 STASTP:JSRTTX66:JSRHFS1\n 3510.HFS1 LDA#128:STAK3:LDX#Y:STXK4:ASLA:STAXX4:STAK3+1:STAK4+1:.HFL5 JSRHFL1:INCXX4:LDXXX4:CPX#8:BNEHFL5:RTS\n 3520.HFL1 LDAXX4:AND#7:CLC:ADC#8:STAK:.HFL2 LDA#1:STALSP:JSRCIRCLE2:ASLK:BCSHF8:LDAK:CMP#160:BCCHFL2:.HF8 RTS\n 4400.STARS2 LDA#0:CPX#2:RORA:STARAT:EOR#128:STARAT2:JSRST2\n 4410LDYNOSTM:.STL2 LDASZ,Y:STAZZ:LSRA:LSRA:LSRA:JSRDV41:LDAP:EORRAT2:STAS:LDASXL,Y:STAP:LDASX,Y:STAX1:JSRADD\n 4420STAS:STXR:LDASY,Y:STAY1:EORBET2:LDXBET1:JSRMULTS-2:JSRADD:STXXX:STAXX+1\n 4430LDXSYL,Y:STXR:LDXY1:STXS:LDXBET1:EORBET2+1:JSRMULTS-2:JSRADD:STXYY:STAYY+1\n 4440LDXALP1:EORALP2:JSRMULTS-2:STAQ:LDAXX:STAR:LDAXX+1:STAS:EOR#128:JSRMAD:STAXX+1:TXA:STASXL,Y\n 4450LDAYY:STAR:LDAYY+1:STAS:JSRMAD:STAS:STXR:LDA#0:STAP:LDAALPHA\n 4460JSRPIX1:LDAXX+1:STASX,Y:STAX1\n 4470AND#127:CMP#116:BCSKILL2:LDAYY+1:STASY,Y:STAY1:AND#127:CMP#116:BCSST5:.STC2 JSRPIXEL2:DEY:BEQST2:JMPSTL2\n 4480.ST2 LDAALPHA:EORRAT:STAALPHA:LDAALP2:EORRAT:STAALP2:EOR#128:STAALP2+1:LDABET2:EORRAT:STABET2:EOR#128:STABET2+1:RTS\n 4500.KILL2 JSRDORND:STAY1:STASY,Y:LDA#115:ORARAT:STAX1:STASX,Y:BNESTF1\n 4510.ST5 JSRDORND:STAX1:STASX,Y:LDA#110:ORAALP2+1:STAY1:STASY,Y:.STF1 JSRDORND:ORA#8:STAZZ:STASZ,Y:BNESTC2\n 4700.SNE:]\n 4720FORI%=0TO31:N=ABS(SIN(I%/64*2*PI)):IFN>=1 I%?O%=FF:ELSEI%?O%=INT(256*N+.5)\n 4730NEXT:O%=O%+32:P%=P%+32\n 4740[OPTZ\n 6040.MU5 STAK:STAK+1:STAK+2:STAK+3:CLC:RTS\n 6050.MULT3\\K(4)=AP(2)*Q:STAR:AND#127:STAK+2:LDAQ:AND#127:BEQMU5:SEC:SBC#1:STAT:LDAP+1:LSRK+2:RORA:STAK+1:LDAP:RORA:STAK:LDA#0:LDX#24\n 6060.MUL2 BCCP%+4:ADCT:RORA:RORK+2:RORK+1:RORK:DEX:BNEMUL2:STAT:LDAR:EORQ:AND#128:ORAT:STAK+3:RTS\n 6070.MLS2 LDXXX:STXR:LDXXX+1:STXS:.MLS1 LDXALP1:STXP\n 6080.MULTS\\AP=A*P(P+<32)\n 6090TAX:AND#128:STAT:TXA:AND#127:BEQMU6:TAX:DEX:STXT1:LDA#0\n 6100LSRP:BCCP%+4:ADCT1:RORA:RORP:BCCP%+4:ADCT1:RORA:RORP:BCCP%+4:ADCT1:RORA:RORP:BCCP%+4:ADCT1:RORA:RORP:BCCP%+4:ADCT1:RORA:RORP\n 6110LSRA:RORP:LSRA:RORP:LSRA:RORP:ORAT:RTS\n 6112.SQUA\\AP=A*ApresQ:AND#127:.SQUA2 STAP:TAX:BNEMU11:.MU1 CLC:STXP:TXA:RTS\n 6114.MLU1 LDASY,Y:STAY1:.MLU2 AND#127:STAP\n 6116.MULTU\\AP=P*Qunsg\n 6118LDXQ:BEQMU1:.MU11 DEX:STXT:LDA#0:LDX#8:LSRP:.MUL6 BCCP%+4:ADCT:RORA:RORP:DEX:BNEMUL6:RTS\n 6119.MU6 STAP+1:STAP:RTS\n 6120.FMLTU2 AND#31:TAX:LDASNE,X:STAQ:LDAK\n 6125.FMLTU\\A=A*Q/256unsg:EOR#FF:SEC:RORA:STAP:LDA#0:.MUL3 BCSMU7:ADCQ:RORA:LSRP:BNEMUL3:RTS:.MU7 LSRA:LSRP:BNEMUL3:RTS\n 6130LDXQ:BEQMU1:DEX:STXT:LDA#0:LDX#8:LSRP:.MUL6 BCCP%+4:ADCT:RORA:RORP:DEX:BNEMUL6:RTS\n 6140STXQ:.MLTU2\\AP(2)=AP*Qunsg(EORP)\n 6142EOR#FF:LSRA:STAP+1:LDA#0:LDX#16:RORP:.MUL7 BCSMU21:ADCQ:RORA:RORP+1:RORP:DEX:BNEMUL7:RTS:.MU21 LSRA:RORP+1:RORP:DEX:BNEMUL7:RTS\n 6146.MUT3 LDXALP1:STXP:.MUT2 LDXXX+1:STXS\n 6148.MUT1 LDXXX:STXR\n 6150.MULT1 \\AP=Q*A\n 6160TAX:AND#127:LSRA:STAP:TXA:EORQ:AND#128:STAT:LDAQ:AND#127:BEQmu10:TAX:DEX:STXT1:LDA#0:LDX#7\n 6170.MUL4 BCCP%+4:ADCT1:RORA:RORP:DEX:BNEMUL4:LSRA:RORP:ORAT:RTS:.mu10 STAP:RTS\n 6190.MULT12 JSRMULT1:STAS:LDAP:STAR:RTS\n 6194.TAS3 LDXINWK,Y:STXQ:LDAXX15:JSRMULT12:LDXINWK+2,Y:STXQ:LDAXX15+1:JSRMAD:STAS:STXR\n 6196LDXINWK+4,Y:STXQ:LDAXX15+2:.MAD JSRMULT1\n 6200.ADD\\AX=AP+SR\n 6210STAT1:AND#128:STAT:EORS:BMIMU8:LDAR:CLC:ADCP:TAX:LDAS:ADCT1:ORAT:RTS\n 6220.MU8 LDAS:AND#127:STAU:LDAP:SEC:SBCR:TAX:LDAT1:AND#127:SBCU:BCSMU9:STAU:TXA:EOR#FF:ADC#1:TAX:LDA#0:SBCU:ORA#128:.MU9 EORT:RTS\n 6330\\DVIDT(A=AP/Q)inF\n 6345.TIS1 STXQ:EOR#128:JSRMAD\n 6350.DVID96\\A=A/96:TAX:AND#128:STAT:TXA:AND#127:LDX#254:STXT1:.DVL3 ASLA:CMP#96:BCCDV4:SBC#96:.DV4 ROLT1:BCSDVL3:LDAT1:ORAT:RTS\n 6360.DV42 LDASZ,Y:.DV41 STAQ:LDADELTA\n 6370.DVID4\\P-R=A/Qunsg\n 6380LDX#8:ASLA:STAP:LDA#0:.DVL4 ROLA:BCSDV8:CMPQ:BCCDV5:.DV8 SBCQ:SEC:.DV5 ROLP:DEX:BNEDVL4:JMPLL28+4\n 6395.DVID3B2 STAP+2:LDAINWK+6:STAQ:LDAINWK+7:STAR:LDAINWK+8:STAS\n 6400.DVID3B\\K+1(3)-K=P(3)/SRQaprx\n 6410LDAP:ORA#1:STAP:LDAP+2:EORS:AND#128:STAT:LDY#0:LDAP+2:AND#127:.DVL9 CMP#&40:BCSDV14:ASLP:ROLP+1:ROLA:INY:BNEDVL9\n 6420.DV14 STAP+2:LDAS:AND#127:BMIDV9:.DVL6 DEY:ASLQ:ROLR:ROLA:BPLDVL6:.DV9 STAQ:LDA#254:STAR:LDAP+2:JSRLL31\n 6440LDA#0:STAK+1:STAK+2:STAK+3:TYA:BPLDV12:LDAR:.DVL8 ASLA:ROLK+1:ROLK+2:ROLK+3:INY:BNEDVL8:STAK:LDAK+3:ORAT:STAK+3:RTS\n 6450.DV13 LDAR:STAK:LDAT:STAK+3:RTS\n 6460.DV12 BEQDV13:LDAR:.DVL10 LSRA:DEY:BNEDVL10:STAK:LDAT:STAK+3:RTS\n 6500.cntr LDADAMP:BNERE1:TXA:BPLBUMP:DEX:BMIRE1\n 6530.BUMP INX:BNERE1\n 6540.REDU DEX:BEQBUMP:.RE1 RTS\n 6550.BUMP2 STAT:TXA:CLC:ADCT:TAX:BCCRE2:LDX#FF:.RE2 BPLRE3+2:LDAT:RTS\n 6560.REDU2 STAT:TXA:SEC:SBCT:TAX:BCSRE3:LDX#1:.RE3 BPLRE2+2:LDADJD:BNERE2+2:LDX#128:BMIRE2+2\n 6800.ARCTAN\\A=TAN-1(P/Q)\n 6810LDAP:EORQ:STAT1:LDAQ:BEQAR2:ASLA:STAQ:LDAP:ASLA:CMPQ:BCSAR1:JSRARS1:SEC:.AR4 LDXT1:BMIAR3:RTS\n 6830.AR1 LDXQ:STAQ:STXP:TXA:JSRARS1:STAT:LDA#64:SBCT:BCSAR4:.AR2 LDA#63:RTS:.AR3 STAT:LDA#128:\\SEC:SBCT:RTS\n 6845.ARS1 JSRLL28:LDAR:LSRA:LSRA:LSRA:TAX:LDAACT,X:RTS\n 6850.ACT:]FORI%=0TO31:I%?O%=INT(128/PI*ATN(I%/32)+.5):NEXT:P%=P%+32:O%=O%+32:[OPTZ\n 6900.WARP LDAMANY+AST:CLC:ADCMANY+ESC:CLC:ADCMANY+OIL:TAX:LDAFRIN+2,X:ORASSPR:ORAMJ:BNEWA1:LDYK%+8:BMIWA3:TAY:JSRMAS2:CMP#2:BCCWA1:.WA3 LDYK%+NI%+8:BMIWA2:LDY#NI%:JSRm:CMP#2:BCCWA1:.WA2\n 6910LDA#&81:STAS:STAR:STAP:LDAK%+8:JSRADD:STAK%+8:LDAK%+NI%+8:JSRADD:STAK%+NI%+8\n 6920LDA#1:STAQQ11:STAMCNT:LSRA:STAEV:LDXVIEW:JMPLOOK1:.WA1 LDA#40:JMPNOISE\n 7000.LASLI JSRDORND:AND#7:ADC#Y-4:STALASY:JSRDORND:AND#7:ADC#X-4:STALASX:LDAGNTMP:ADC#8:STAGNTMP:JSRDENGY\n 7005.LASLI2 LDAQQ11:BNEPU1-1:LDA#32:LDY#224:JSRlas:LDA#48:LDY#208\n 7050.las STAX2:LDALASX:STAX1:LDALASY:STAY1:LDA#2*Y-1:STAY2:JSRLOIN:LDALASX:STAX1:LDALASY:STAY1:STYX2:LDA#2*Y-1:STAY2:JMPLOIN\n 8500.PLUT LDXVIEW:BNEPU1:RTS:.PU1 DEX:BNEPU2\n 8510LDAINWK+2:EOR#128:STAINWK+2:LDAINWK+8:EOR#128:STAINWK+8:LDAINWK+10:EOR#128:STAINWK+10:LDAINWK+14:EOR#128:STAINWK+14:LDAINWK+16:EOR#128:STAINWK+16\n 8520LDAINWK+20:EOR#128:STAINWK+20:LDAINWK+22:EOR#128:STAINWK+22:LDAINWK+26:EOR#128:STAINWK+26:RTS\n 8530.PU2 LDA#0:CPX#2:RORA:STARAT2:EOR#128:STARAT\n 8540LDAINWK:LDXINWK+6:STAINWK+6:STXINWK:LDAINWK+1:LDXINWK+7:STAINWK+7:STXINWK+1:LDAINWK+2:EORRAT:TAX:LDAINWK+8:EORRAT2:STAINWK+2:STXINWK+8\n 8550LDY#9:JSRPUS1\n 8560LDY#15:JSRPUS1\n 8570LDY#21\n 8600.PUS1 LDAINWK,Y:LDXINWK+4,Y:STAINWK+4,Y:STXINWK,Y:LDAINWK+1,Y:EORRAT:TAX:LDAINWK+5,Y:EORRAT2:STAINWK+1,Y:STXINWK+5,Y:.LO2 RTS\n 8990.LQ STXVIEW:JSRTT66:JSRSIGHT:JMPNWSTARS\n 9000.LOOK1 LDA#0:LDYQQ11:BNELQ:CPXVIEW:BEQLO2:STXVIEW:JSRTT66:JSRFLIP:JSRWPSHPS\n 9010.SIGHT LDYVIEW:LDALASER,Y:BEQLO2:LDA#128:STAQQ19:LDA#Y-24:STAQQ19+1:LDA#20:STAQQ19+2:JSRTT15:LDA#10:STAQQ19+2:JMPTT15\n 9400LDA#1:.TT66 STAQQ11:.TTX66 LDA#128:STAQQ17:ASLA:STALASCT:STADLY:STAde:LDX#&60:.BOL1 JSRZES1:INX:CPX#&78:BNEBOL1\n 9410LDXQQ22+1:BEQBOX:JSRee3:.BOX LDY#1:STYYC:LDAQQ11:BNEtt66:LDY#11:STYXC:LDAVIEW:ORA#&60:JSRTT27:JSRTT162:LDA#175:JSRTT27:.tt66\n 9420LDX#0:STXX1:STXY1:STXQQ17:DEX:STXX2:JSRHLOIN\n 9430LDA#2:STAX1:STAX2:JSRBOS2\n 9440.BOS2 JSRBOS1:.BOS1 LDA#0:STAY1:LDA#2*Y-1:STAY2:DECX1:DECX2:JMPLOIN\n 9450LDY#2:EQUB&2C:.DEL8 LDY#8:.DELAY JSRWSCAN:DEY:BNEDELAY:RTS\n 9460.hm JSRTT103:JSRTT111:JSRTT103:LDAQQ11:BEQSC5:.CLYNS LDA#20:STAYC:LDA#&75:STASC+1:LDA#7:STASC:JSRTT67:LDA#0:JSRLYN:INCSC+1:JSRLYN:INCSC+1:INY:STYXC\n 9470.LYN LDY#233:.EE2 STA(SC),Y:DEY:BNEEE2:.SC5 RTS\n 9500.SCAN LDAINWK+31:AND#16:BEQSC5:LDATYPE:BMISC5:LDX#FF:\\CMP#TGL\\BEQSC49:CMP#MSL:BNEP%+4:LDX#&F0:\\CMP#AST:\\BCCP%+4:\\LDX#&F:\\SC49:STXCOL:LDAINWK+1:ORAINWK+4:ORAINWK+7:AND#&C0:BNESC5\n 9510LDAINWK+1:CLC:LDXINWK+2:BPLSC2:EOR#FF:ADC#1:.SC2 ADC#123:STAX1\n 9520LDAINWK+7:LSRA:LSRA:CLC:LDXINWK+8:BPLSC3:EOR#FF:SEC:.SC3 ADC#35:EOR#FF:STASC\n 9530LDAINWK+4:LSRA:CLC:LDXINWK+5:BMISCD6:EOR#FF:SEC:.SCD6 ADCSC:BPLld246:CMP#194:BCSP%+4:LDA#194:CMP#247:BCCP%+4:.ld246 LDA#246\n 9535STAY1:SEC:SBCSC:PHP:\\BCSSC48:\\EOR#FF:\\ADC#1:.SC48 PHA:JSRCPIX4:LDACTWOS+1,X:ANDCOL:STAX1:PLA:PLP:TAX:BEQRTS:BCCRTS+1\n 9540.VLL1 DEY:BPLVL1:LDY#7:DECSC+1:.VL1 LDAX1:EOR(SC),Y:STA(SC),Y:DEX:BNEVLL1:.RTS RTS\n 9545INY:CPY#8:BNEP%+6:LDY#0:INCSC+1\n 9550.VLL2 INY:CPY#8:BNEVL2:LDY#0:INCSC+1:.VL2 LDAX1:EOR(SC),Y:STA(SC),Y:INX:BNEVLL2:RTS\n 9700.WSCAN LDA#0:STADL:LDADL:BEQP%-2:RTS\n 9900]\n 9910IFZ>4OSCLI(\"S.ELTC \"+STR$~W%+\" \"+STR$~O%+\" \"+STR$~L%+\" \"+STR$~H%)\n 9920PRINT\"C d,\";:GOTO8\n\n"
  },
  {
    "path": "1-source-files/original-sources/$.ELITED.inf",
    "content": "$.ELITED  000000 000000 002E49\n"
  },
  {
    "path": "1-source-files/original-sources/$.ELITED.txt",
    "content": "    1GOTO20\n    2*L.ELITEB\n    3GOTO20\n    4*L.ELITEA\n    6*L.ELITEC\n    7GOTO20\n    8*L.ELITED\n    9GOTO20\n   10*L.ELITEE\n   20REM ELITE <D>\n   30H%=L%+P%-C%:O%=W%\n  300[OPTZ\n  700.tnpr pha:LDX#12:CPXQQ29:BCCkg:.Tml ADCQQ20,X:DEX:BPLTml:CMPCRGO:pla:RTS:.kg LDYQQ29:ADCQQ20,Y:cmp#200:pla:rts\n  840.TT20 JSRP%+3:JSRP%+3\n  850.TT54 LDAQQ15:CLC:ADCQQ15+2:TAX:LDAQQ15+1:ADCQQ15+3:TAY\n  860LDAQQ15+2:STAQQ15:LDAQQ15+3:STAQQ15+1:LDAQQ15+5:STAQQ15+3:LDAQQ15+4:STAQQ15+2:CLC:TXA:ADCQQ15+2:STAQQ15+4:TYA:ADCQQ15+3:STAQQ15+5:RTS\n  950.TT146 LDAQQ8:ORAQQ8+1:BNETT63:INCYC:RTS:.TT63 LDA#191:JSRTT68\n  955LDXQQ8:LDYQQ8+1:SEC:JSRpr5:LDA#195:.TT60 JSRTT27:.TTX69 INCYC:.TT69 LDA#128:STAQQ17:.TT67 LDA#13:JMPTT27\n  990.TT70 LDA#173:JSRTT27:JMPTT72:.spc JSRTT27:JMPTT162\n 1000.TT25\\ DATA\n 1010JSRTT66-2:LDA#9:STAXC:LDA#163:JSRTT27:JSRNLIN:JSRTTX69:INCYC:JSRTT146:LDA#194\n 1030JSRTT68:LDAQQ3:CLC:ADC#1:LSRA:CMP#2:BEQTT70:LDAQQ3:BCCTT71\n 1040SBC#5:CLC:.TT71 ADC#170:JSRTT27:.TT72 LDAQQ3:LSRA:LSRA:CLC:ADC#168:JSRTT60:LDA#162:JSRTT68:LDAQQ4:CLC:ADC#177:JSRTT60:LDA#196:JSRTT68\n 1070LDXQQ5:INX:CLC:JSRpr2:JSRTTX69:LDA#192:JSRTT68:SEC:LDXQQ6:JSRpr2:LDA#198:JSRTT60:LDA#&28:JSRTT27:LDAQQ15+4:BMITT75:LDA#188:JSRTT27:JMPTT76:.TT75 LDAQQ15+5\n 1110LSRA:LSRA:PHA:AND#7:CMP#3:BCSTT205:ADC#227:JSRspc:.TT205 PLA:LSRA:LSRA:LSRA:CMP#6:BCSTT206:ADC#230:JSRspc:.TT206 LDAQQ15+3:EORQQ15+1:AND#7\n 1116STAQQ19:CMP#6:BCSTT207:ADC#236:JSRspc:.TT207 LDAQQ15+5:AND#3:CLC:ADCQQ19:AND#7:ADC#242:JSRTT27:.TT76 LDA#&53:JSRTT27:LDA#&29:JSRTT60\n 1127LDA#193:JSRTT68:LDXQQ7:LDYQQ7+1:JSRpr6:JSRTT162:LDA#0:STAQQ17:LDA#&4D:JSRTT27:LDA#226:JSRTT60:LDA#250:JSRTT68:LDAQQ15+5:LDXQQ15+3:AND#15:CLC:ADC#11:TAY\n 1150JSRpr5:JSRTT162:LDA#&6B:JSRTT26:LDA#&6D:JMPTT26\n 1200.TT24\n 1210LDAQQ15+1:AND#7:STAQQ3:LDAQQ15+2:LSRA:LSRA:LSRA:AND#7:STAQQ4:LSRA:BNETT77:LDAQQ3:ORA#2:STAQQ3:.TT77 LDAQQ3:EOR#7:CLC:STAQQ5:LDAQQ15+3:AND#3:ADCQQ5:STAQQ5\n 1240LDAQQ4:LSRA:ADCQQ5:STAQQ5:ASLA:ASLA:ADCQQ3:ADCQQ4:ADC#1:STAQQ6:LDAQQ3:EOR#7:ADC#3:STAP:LDAQQ4:ADC#4:STAQ:JSRMULTU:LDAQQ6:STAQ:JSRMULTU:ASLP:ROLA:ASLP:ROLA:ASLP:ROLA:STAQQ7+1:LDAP:STAQQ7:RTS\n 1400.TT22\\Lng Sc\n 1410LDA#64:JSRTT66:LDA#7:STAXC:JSRTT81:LDA#199:JSRTT27:JSRNLIN:LDA#152:JSRNLIN2:JSRTT14\n 1460LDX#0:.TT83 STXXSAV:LDXQQ15+3:LDYQQ15+4:TYA:ORA#&50:STAZZ\n 1470LDAQQ15+1:LSRA:CLC:ADC#24:STAXX15+1:JSRPIXEL:JSRTT20:LDXXSAV:INX:BNETT83:LDAQQ9:STAQQ19:LDAQQ10:LSRA:STAQQ19+1:LDA#4:STAQQ19+2\n 1700.TT15\n 1705LDA#24:LDXQQ11:BPLP%+4:LDA#0:STAQQ19+5:LDAQQ19:SEC:SBCQQ19+2:BCSTT84:LDA#0:.TT84 STAXX15:LDAQQ19:CLC:ADCQQ19+2:BCCP%+4:LDA#FF:STAXX15+2\n 1725LDAQQ19+1:CLC:ADCQQ19+5:STAXX15+1:JSRHLOIN:LDAQQ19+1:SEC:SBCQQ19+2:BCSTT86:LDA#0:.TT86 CLC:ADCQQ19+5:STAXX15+1:LDAQQ19+1:CLC:ADCQQ19+2:ADCQQ19+5:CMP#152:BCCTT87\n 1750LDXQQ11:BMITT87:LDA#151:.TT87 STAXX15+3:LDAQQ19:STAXX15:STAXX15+2:JMPLL30\n 1800.TT126 LDA#104:STAQQ19:LDA#90:STAQQ19+1:LDA#16:STAQQ19+2:JSRTT15:LDAQQ14:STAK:JMPTT128\n 2000.TT14\\Crcl/+\n 2010LDAQQ11:BMITT126:LDAQQ14:LSRA:LSRA:STAK:LDAQQ0:STAQQ19:LDAQQ1:LSRA:STAQQ19+1:LDA#7:STAQQ19+2:JSRTT15:LDAQQ19+1:CLC:ADC#24:STAQQ19+1\n 2300.TT128 LDAQQ19:STAK3:LDAQQ19+1:STAK4:LDX#0:STXK4+1:STXK3+1:\\STXLSX:INX:STXLSP:LDX#2:STXSTP\n 2310JSRCIRCLE2:\\LDA#FFSTALSX:RTS\n 2650.TT219\\Buy\n 2655\\LDA#2:JSRTT66-2:JSRTT163:LDA#128:STAQQ17:\\JSRFLKB:LDA#0:STAQQ29\n 2660.TT220 JSRTT151:LDAQQ25:BNETT224:JMPTT222:.TQ4 LDY#176:.Tc JSRTT162:TYA:JSRprq:.TTX224 JSRdn2:.TT224\n 2671JSRCLYNS:LDA#204:JSRTT27:LDAQQ29:CLC:ADC#208:JSRTT27:LDA#&2F:JSRTT27:JSRTT152:LDA#&3F:JSRTT27:JSRTT67:LDX#0:STXR:LDX#12:STXT1:.TT223\n 2700JSRgnum:BCSTQ4:STAP:JSRtnpr:LDY#206:BCSTc:LDAQQ24:STAQ:JSRGCASH:JSRLCASH:LDY#197:BCCTc\n 2708LDYQQ29:LDAR:PHA:CLC:ADCQQ20,Y:STAQQ20,Y:LDAAVL,Y:SEC:SBCR:STAAVL,Y:PLA:BEQTT222:JSRdn\n 2710.TT222 LDAQQ29:CLC:ADC#5:STAYC:LDA#0:STAXC:INCQQ29:LDAQQ29:CMP#17:BCSBAY2:JMPTT220:.BAY2 LDA#f9:JMPFRCE\n 2750.gnum LDX#0:STXR:LDX#12:STXT1:.TT223 JSRTT217:STAQ:SEC:SBC#&30:BCCOUT:CMP#10:BCSBAY2:STAS:LDAR:CMP#26:BCSOUT:ASLA:STAT:ASLA:ASLA:ADCT:ADCS:STAR:CMPQQ25:BEQTT226:BCSOUT:.TT226 LDAQ:JSRTT26:DECT1:BNETT223:.OUT LDAR:RTS\n 2850.TT208\\Sel\n 2855LDA#4:JSRTT66:LDA#4:STAYC:STAXC:\\JSRFLKB:LDA#205:JSRTT27:LDA#206:JSRTT68\n 2900.TT210\\Crgo\n 2910LDY#0:.TT211 STYQQ29:LDXQQ20,Y:BEQTT212\n 2912TYA:ASLA:ASLA:TAY:LDAQQ23+1,Y:STAQQ19+1\n 2915TXA:PHA:JSRTT69:CLC:LDAQQ29:ADC#208\n 2917JSRTT27:LDA#14:STAXC:PLA:TAX:CLC:JSRpr2:JSRTT152\n 2922LDAQQ11:CMP#4:BNETT212:LDA#205:JSRTT214\n 2923BCCTT212:LDAQQ29:LDX#255:STXQQ17:JSRTT151\n 2925LDYQQ29:LDAQQ20,Y:STAP:LDAQQ24:STAQ:JSRGCASH:JSRMCASH\n 2935LDA#0:LDYQQ29:STAQQ20,Y:STAQQ17\n 2940.TT212 LDYQQ29:INY:CPY#17:BCSP%+5:JMPTT211:LDAQQ11:CMP#4:BNEP%+8:JSRdn2:JMPBAY2:RTS\n 2942.TT213\\Invntry\n 2945LDA#8:JSRTT66:LDA#11:STAXC:LDA#164:JSRTT60:JSRNLIN4:JSRfwl\n 2950LDACRGO:CMP#26:BCCP%+7:LDA#&6B:JSRTT27:JMPTT210\n 2965.TT214 PHA:JSRTT162:PLA:.TT221 JSRTT27:LDA#225:JSRTT27\n 2966JSRTT217:ORA#32:CMP#&79:BEQTT218:LDA#&6E:JMPTT26:.TT218 JSRTT26:SEC:RTS\n 3000.TT16 TXA:PHA:DEY:TYA:EOR#255:PHA:JSRWSCAN:JSRTT103:PLA:STAQQ19+3\n 3010LDAQQ10:JSRTT123:LDAQQ19+4:STAQQ10:STAQQ19+1:PLA\n 3020STAQQ19+3:LDAQQ9:JSRTT123:LDAQQ19+4:STAQQ9:STAQQ19:.TT103\n 3030LDAQQ11:BEQTT180:BMITT105:LDAQQ9:STAQQ19:LDAQQ10:LSRA:STAQQ19+1\n 3040LDA#4:STAQQ19+2:JMPTT15\n 3045.TT123 STAQQ19+4:CLC:ADCQQ19+3:LDXQQ19+3:BMITT124:BCCTT125\n 3047RTS:.TT124 BCCTT180:.TT125 STAQQ19+4:.TT180 RTS\n 3050.TT105 LDAQQ9:SEC:SBCQQ0:CMP#38:BCCTT179:CMP#230:BCCTT180\n 3055.TT179 ASLA:ASLA:CLC:ADC#104:STAQQ19\n 3060LDAQQ10:SEC:SBCQQ1:CMP#38:BCCP%+6:CMP#220:BCCTT180\n 3065ASLA:CLC:ADC#90:STAQQ19+1:LDA#8:STAQQ19+2:JMPTT15\n 3300.TT23\\ShrtSc\n 3310LDA#128:JSRTT66:LDA#7:STAXC:LDA#190:JSRNLIN3:JSRTT14:JSRTT103:JSRTT81\n 3349LDA#0:STAXX20:LDX#24:.EE3 STAINWK,X:DEX:BPLEE3\n 3350.TT182 LDAQQ15+3:SEC:SBCQQ0:BCSTT184:EOR#FF:ADC#1:.TT184 CMP#20:BCSTT187:LDAQQ15+1:SEC:SBCQQ1:BCSTT186:EOR#FF:ADC#1:.TT186 CMP#38:BCSTT187\n 3370LDAQQ15+3:SEC:SBCQQ0:ASLA:ASLA:ADC#104:STAXX12:LSRA:LSRA:LSRA:STAXC:INCXC:LDAQQ15+1:SEC:SBCQQ1:ASLA:ADC#90:STAK4:LSRA:LSRA:LSRA\n 3377TAY:LDXINWK,Y:BEQEE4:INY:LDXINWK,Y:BEQEE4:DEY:DEY:LDXINWK,Y:BNEee1:.EE4 STYYC:CPY#3:BCCTT187:DEX:STXINWK,Y\n 3380LDA#128:STAQQ17:JSRcpl:.ee1\n 3390\\bigstars:LDA#0:STAK3+1:STAK4+1:STAK+1:LDAXX12:STAK3:LDAQQ15+5:AND#1:ADC#2:STAK:JSRFLFLLS:JSRSUN:JSRFLFLLS\n 3400.TT187 JSRTT20:INCXX20:BEQTT111-1:JMPTT182\n 3450.TT81 LDX#5:LDAQQ21,X:STAQQ15,X:DEX:BPLTT81+2\n 3500RTS:.TT111 JSRTT81:LDY#127:STYT:LDA#0:STAU\n 3510.TT130 LDAQQ15+3:SEC:SBCQQ9:BCSTT132:EOR#FF:ADC#1:.TT132 LSRA:STAS:LDAQQ15+1:SEC:SBCQQ10:BCSTT134:EOR#FF:ADC#1:.TT134 LSRA:CLC:ADCS:CMPT:BCSTT135\n 3550STAT:LDX#5:.TT136 LDAQQ15,X:STAQQ19,X:DEX:BPLTT136:.TT135\n 3560JSRTT20:INCU:BNETT130:LDX#5:.TT137 LDAQQ19,X:STAQQ15,X:DEX\n 3570BPLTT137:LDAQQ15+1:STAQQ10:LDAQQ15+3:STAQQ9\n 3575SEC:SBCQQ0:BCSTT139:EOR#FF:ADC#1:.TT139 JSRSQUA2:STAK+1:LDAP:STAK:LDAQQ10\n 3590SEC:SBCQQ1:BCSTT141:EOR#FF:ADC#1:.TT141 LSRA:JSRSQUA2:PHA:LDAP:CLC:ADCK\n 3610STAQ:PLA:ADCK+1:STAR:JSRLL5:LDAQ:ASLA:LDX#0:STXQQ8+1:ROLQQ8+1:ASLA:ROLQQ8+1:STAQQ8:JMPTT24\n 4340.hy6 JSRCLYNS:LDA#15:STAXC:JMPTT27\n 4350.hyp LDAQQ12:BNEhy6:LDAQQ22+1:BNEzZ+1:JSRCTRL:BMIGhy\n 4353JSRhm\n 4355LDAQQ8:ORAQQ8+1:BEQzZ+1:LDA#7:STAXC:LDA#23:STAYC:LDA#0:STAQQ17:LDA#189:JSRTT27:LDAQQ8+1:BNETT147:LDAQQ14:CMPQQ8:BCCTT147\n 4380LDA#&2D:JSRTT27:JSRcpl:.wW LDA#15:STAQQ22+1:STAQQ22:TAX:JMPee3\\hy5 RTS\n 4392.Ghy LDXGHYP:BEQhy5:INX:STXQQ8:STXQQ8+1:STXGHYP:STXFIST:JSRwW:LDX#5:INCGCNT:LDAGCNT:AND#7:STAGCNT:.G1 LDAQQ21,X:ASLA:ROLQQ21,X:DEX:BPLG1:\\JSRDORND:.zZ LDA#&60:STAQQ9:STAQQ10:JSRTT110:LDA#116:JSRMESS:.jmp LDAQQ9:STAQQ0:LDAQQ10\n 4393STAQQ1:.hy5 RTS\n 4395.ee3 LDY#1:STYYC:DEY:STYXC:.pr6 CLC:.pr5 LDA#5:JMPTT11\n 4400.TT147 LDA#202:.prq JSRTT27:LDA#&3F:JMPTT27\n 5000.TT151\\Pmk-A\n 5010PHA:STAQQ19+4:ASLA:ASLA:STAQQ19:LDA#1:STAXC:PLA:ADC#208\n 5015JSRTT27:LDA#14:STAXC:LDXQQ19:LDAQQ23+1,X:STAQQ19+1:LDAQQ26:ANDQQ23+3,X:CLC:ADCQQ23,X:STAQQ24:JSRTT152\n 5050JSRvar:LDAQQ19+1:BMITT155:LDAQQ24:ADCQQ19+3:JMPTT156\n 5060.TT155 LDAQQ24:SEC:SBCQQ19+3:.TT156 STAQQ24:STAP:LDA#0:JSRGC2\n 5070SEC:JSRpr5:LDYQQ19+4:LDA#5:LDXAVL,Y:STXQQ25\n 5100CLC:BEQTT172:JSRpr2+2:JMPTT152:.TT172 LDAXC:ADC#4:STAXC:LDA#&2D:BNETT162+2\n 5110.TT152 LDAQQ19+1:AND#96:BEQTT160:CMP#32:BEQTT161\n 5120JSRTT16a:.TT162 LDA#32:JMPTT27\n 5130.TT160 LDA#&74:JSRTT26:BCCTT162\n 5140.TT161 LDA#&6B:JSRTT26:.TT16a LDA#&67:JMPTT26\n 5160.TT163 LDA#17:STAXC:LDA#FF:BNETT162+2\n 5200.TT167\\MktP\n 5210LDA#16:JSRTT66:LDA#5:STAXC:LDA#167:JSRNLIN3:LDA#3:STAYC:JSRTT163:LDA#0:STAQQ29:.TT168 LDX#128:STXQQ17:JSRTT151:INCYC\n 5250INCQQ29:LDAQQ29:CMP#17:BCCTT168:RTS\n 5900.var LDAQQ19+1:AND#31:LDYQQ28:STAQQ19+2:CLC:LDA#0:STAAVL+16:.TT153 DEY:BMITT154:ADCQQ19+2:JMPTT153:.TT154 STAQQ19+3:RTS\n 5980.hyp1 JSRTT111:JSRjmp:LDX#5:.TT112 LDAQQ15,X:STAQQ2,X:DEX:BPLTT112:INX:STXEV:LDAQQ3:STAQQ28:LDAQQ5:STAtek:LDAQQ4:STAgov:RTS\n 5990.GVL JSRDORND:STAQQ26:LDX#0:STXXX4:.hy9 LDAQQ23+1,X:STAQQ19+1:JSRvar:LDAQQ23+3,X:ANDQQ26:CLC:ADCQQ23+2,X:LDYQQ19+1:BMITT157:SEC:SBCQQ19+3:JMPTT158:.TT157 CLC:ADCQQ19+3:.TT158 BPLTT159:LDA#0:.TT159\n 5994LDYXX4:AND#63:STAAVL,Y:INY:TYA:STAXX4:ASLA:ASLA:TAX:CMP#63:BCChy9:.hyR RTS\n 5995.GTHG JSRZe:LDA#FF:STAINWK+32:LDA#THG:JSRNWSHP:LDA#TGL:JMPNWSHP\n 5996.ptg LSRCOK:SEC:ROLCOK\n 5998.MJP\\LDA#1:JSRTT66-2:JSRLL164:JSRRES2:STYMJ:.MJP1 JSRGTHG:LDA#3:CMPMANY+THG:BCSMJP1:STANOSTM:LDX#0:JSRLOOK1:LDAQQ1:EOR#31:STAQQ1:RTS\n 6000.TT18\\HSPC\n 6005LDAQQ14:SEC:SBCQQ8:STAQQ14:LDAQQ11:BNEee5:JSRTT66:JSRLL164:.ee5 JSRCTRL:ANDPATG:BMIptg:JSRDORND:CMP#253:BCSMJP\\JSRTT111:JSRhyp1+3:JSRGVL:JSRRES2:JSRSOLAR\n 6500LDAQQ11:AND#63:BNEhyR:JSRTTX66:LDAQQ11:BNETT114:INCQQ11:.TT110 LDXQQ12:BEQNLUNCH:JSRLAUN:JSRRES2:JSRTT111:INCINWK+8:JSRSOS1:LDA#128:STAINWK+8:INCINWK+7:JSRNWSPS:LDA#12:STADELTA:JSRBAD:ORAFIST:STAFIST\n 6510.NLUNCH LDX#0:STXQQ12:JMPLOOK1:.TT114 BMITT115:JMPTT22:.TT115 JMPTT23\n 6530.LCASH STXT1:LDACASH+3:SEC:SBCT1:STACASH+3:STYT1:LDACASH+2:SBCT1:STACASH+2:LDACASH+1:SBC#0:STACASH+1:LDACASH:SBC#0:STACASH:BCSTT113\n 6540.MCASH TXA:CLC:ADCCASH+3:STACASH+3:TYA:ADCCASH+2:STACASH+2:LDACASH+1:ADC#0:STACASH+1:LDACASH:ADC#0:STACASH:CLC:.TT113 RTS\n 6550.GCASH JSRMULTU:.GC2 ASLP:ROLA:ASLP:ROLA:TAY:LDXP:RTS\n 6690.bay JMPBAY\n 6700.EQSHP JSRDIALS:LDA#32:JSRTT66:LDA#12:STAXC:LDA#207:JSRspc:LDA#185:JSRNLIN3:LDA#128:STAQQ17:INCYC:LDAtek:CLC:ADC#3:CMP#12:BCCP%+4:LDA#12:STAQ:STAQQ25:INCQ:LDA#70:SEC:SBCQQ14:ASLA:STAPRXS\n 6710LDX#1:.EQL1 STXXX13:JSRTT67:LDXXX13:CLC:JSRpr2:JSRTT162:LDAXX13:CLC:ADC#&68:JSRTT27:LDAXX13:JSRprx-3:SEC:LDA#25:STAXC:LDA#6:JSRTT11:LDXXX13:INX:CPXQ:BCCEQL1\n 6720JSRCLYNS:LDA#127:JSRprq:JSRgnum:beqbay:bcsbay:SBC#0:LDX#2:STXXC:INCYC:PHA:JSReq:PLA:BNEet0:STAMCNT:LDX#70:STXQQ14:.et0 CMP#1:BNEet1:LDXNOMSL:INX:LDY#&75:CPX#5:BCSpres\n 6730STXNOMSL:JSRmsblob:.et1 LDY#&6B:CMP#2:BNEet2:LDX#37:CPXCRGO:BEQpres:STXCRGO:.et2 CMP#3:BNEet3:INY:LDXECM:BNEpres:DECECM:.et3 CMP#4:BNEet4:JSRqv:LDA#4:LDYLASER,X:BEQed4:.ed7 LDY#187:BNEpres:.ed4 LDA#POW:STALASER,X:LDA#4:.et4\n 6740CMP#5:BNEet5:JSRqv:STXT1:LDA#5:LDYLASER,X:BEQed5:\\BPLP%+4:BMIed7:LDA#4:JSRprx:JSRMCASH:.ed5 LDA#POW+128:LDXT1:STALASER,X:.et5\n 6750LDY#&6F:CMP#6:BNEet6:LDXBST:BEQed9:.pres STYK:JSRprx:JSRMCASH:LDAK:JSRspc:LDA#31:JSRTT27:.err JSRdn2:JMPBAY:.ed9 DECBST:.et6 INY:CMP#7:BNEet7:LDXESCP:BNEpres:DECESCP:.et7 INY:CMP#8:BNEet8:LDXBOMB:BNEpres:LDX#&7F:STXBOMB:.et8\n 6800INY:CMP#9:BNEetA:LDXENGY:BNEpres:INCENGY:.etA INY:CMP#10:BNEetB:LDXDKCMP:BNEpres:DECDKCMP:.etB:INY:CMP#11:BNEet9:LDXGHYP:BNEpres:DECGHYP:.et9 JSRdn:JMPEQSHP:.dn JSRTT162:LDA#119:JSRspc:.dn2 JSRBEEP:LDY#50:JMPDELAY\n 6900.eq JSRprx:JSRLCASH:BCSc:LDA#197:JSRprq:JMPerr:SEC:SBC#1:.prx ASLA:TAY:LDXPRXS,Y:LDAPRXS+1,Y:TAY:.c RTS\n 6910.qv LDY#16:STYYC:.qv1 LDX#12:STXXC:TYA:CLC:ADC#B-16:JSRspc:LDAYC:CLC:ADC#&50:JSRTT27:INCYC:LDYYC:CPY#20:BCCqv1:.qv3 JSRCLYNS:.qv2 LDA#175:JSRprq:JSRTT217:SEC:SBC#&30:CMP#4:BCSqv3:TAX:RTS\n 9900]\n 9910IFZ>4OSCLI(\"S.ELTD \"+STR$~W%+\" \"+STR$~O%+\" \"+STR$~L%+\" \"+STR$~H%)\n 9920PRINT\"D d,\";:GOTO10\n"
  },
  {
    "path": "1-source-files/original-sources/$.ELITEE.inf",
    "content": "$.ELITEE  000000 000000 002DDB\n"
  },
  {
    "path": "1-source-files/original-sources/$.ELITEE.txt",
    "content": "    1GOTO20\n    2*L.ELITEB\n    3GOTO20\n    4*L.ELITEA\n    6*L.ELITEC\n    7GOTO20\n    8*L.ELITED\n    9GOTO20\n   10*L.ELITEE\n   11GOTO20\n   12*L.ELITEF\n   20REM ELITE <E>\n  100H%=L%+P%-C%:O%=W%:A$=\"(C)Bell/Braben1984\":B$=STRING$(26,\" \"):B$=\"\":FORI%=1TOLENA$:B$=B$+CHR$(ASC(MID$(A$,I%,1))EOR&A4):NEXT:[OPTZ:EQUSB$\n  190.cpl LDX#5:.TT53 LDAQQ15,X:STAQQ19,X:DEX:BPLTT53:LDY#3:BITQQ15:BVSP%+3:DEY:STYT:.TT55 LDAQQ15+5:AND#31:BEQP%+7:ORA#128:JSRTT27:JSRTT54:DECT:BPLTT55:LDX#5:.TT56 LDAQQ19,X:STAQQ15,X:DEX:BPLTT56:RTS\n  200.cmn LDY#0:.QUL4 LDANA%,Y:CMP#13:BEQypl-1:JSRTT26:INY:BNEQUL4:RTS\n  300.ypl LDAMJ:BNEcmn-1:JSRTT62:JSRcpl:.TT62 LDX#5:.TT78 LDAQQ15,X:LDYQQ2,X:STAQQ2,X:STYQQ15,X:DEX:BPLTT78:RTS\n  500.tal CLC:LDXGCNT:INX:JMPpr2:.fwl LDA#105:JSRTT68:LDXQQ14:SEC:JSRpr2:LDA#195:JSRplf:.PCASH LDA#119:BNETT27\n  510.csh LDX#3:.pc1 LDACASH,X:STAK,X:DEX:BPLpc1:LDA#9:STAU:SEC:JSRBPRNT:LDA#226:.plf JSRTT27:JMPTT67:.TT68 JSRTT27:.TT73 LDA#&3A\n  600.TT27 TAX:BEQcsh:BMITT43:DEX:BEQtal:DEX:BEQypl:dex:bneP%+5:JMPcpl:dex:beqcmn:dex:beqfwl:dex:bneP%+7:LDA#128:STAQQ17:RTS:DEX:DEX:BNEP%+5:STXQQ17:RTS:dex:beqcrlf:CMP#&60:BCSex:CMP#14:BCCP%+6:CMP#32:BCCqw:LDXQQ17\n  620BEQTT74:BMITT41:BITQQ17:BVSTT46:.TT42 CMP#65:BCCTT44:CMP#&5B:BCSTT44:ADC#32:.TT44 JMPTT26:.TT41 BITQQ17:BVSTT45:CMP#65:BCCTT74:PHA:TXA:ORA#64:STAQQ17:PLA:BNETT44\n  630.qw ADC#114:BNEex:.crlf LDA#21:STAXC:BNETT73:.TT45 CPX#FF:BEQTT48:CMP#65:BCSTT42:.TT46 PHA:TXA:AND#191:STAQQ17:PLA:.TT74 JMPTT26:.TT43 CMP#160:BCSTT47:AND#127:ASLA:TAY:LDAQQ16,Y\n  670JSRTT27:LDAQQ16+1,Y:CMP#63:BEQTT48:JMPTT27:.TT47 SBC#160:.ex TAX:LDA#(QQ18 MOD256):STAV:LDA#(QQ18 DIV256):STAV+1:LDY#0:TXA:BEQTT50\n  680.TT51 LDA(V),Y:BEQTT49:INY:BNETT51:INCV+1:BNETT51:.TT49 INY:BNETT59:INCV+1:.TT59 DEX:BNETT51:.TT50\n  693TYA:PHA:LDAV+1:PHA:LDA(V),Y:EOR#35\n  695JSRTT27:PLA:STAV+1:PLA:TAY:INY:BNEP%+4:INCV+1:LDA(V),Y:BNETT50:.TT48 RTS\n 1990.EX2 LDAINWK+31:ORA#&A0:STAINWK+31:RTS\n 2000.DOEXP LDAINWK+31:AND#64:BEQP%+5:JSRPTCLS:LDAINWK+6:STAT:LDAINWK+7:CMP#&20:BCCP%+6:LDA#&FE:BNEyy:ASLT:ROLA:ASLT:ROLA:SEC:ROLA:.yy STAQ:LDY#1:LDA(XX19),Y:ADC#4:BCSEX2\n 2040STA(XX19),Y:JSRDVID4:LDAP:CMP#&1C:BCCP%+6:LDA#&FE:BNE`_:ASLR:ROLA:ASLR:ROLA:ASLR:ROLA:.`_ DEY:STA(XX19),Y:LDAINWK+31:AND#&BF:STAINWK+31:AND#8:BEQTT48\n 2050LDY#2:LDA(XX19),Y:TAY:.EXL1 LDAXX3-7,Y:STA(XX19),Y:DEY:CPY#6:BNEEXL1:LDAINWK+31:ORA#64:STAINWK+31\n 2100.PTCLS LDY#0:LDA(XX19),Y:STAQ:INY:LDA(XX19),Y:BPLP%+4:EOR#FF:LSRA:LSRA:LSRA:ORA#1:STAU:INY:LDA(XX19),Y:STATGT:LDARAND+1:PHA\n 2110LDY#6:.EXL5 LDX#3:.EXL3 INY:LDA(XX19),Y:STAK3,X:DEX:BPLEXL3:STYCNT:LDY#2:.EXL2 INY:LDA(XX19),Y:EORCNT:STARAND-3,Y:CPY#6:BNEEXL2:LDYU\n 2140.EXL4 JSRDORND2:STAZZ:LDAK3+1:STAR:LDAK3:JSREXS1:BNEEX11:CPX#2*Y-1:BCSEX11:STXY1:LDAK3+3:STAR:LDAK3+2:JSREXS1:BNEEX4:LDAY1:JSRPIXEL:.EX4 DEY:BPLEXL4:LDYCNT:CPYTGT:BCCEXL5\n 2180PLA:STARAND+1:LDAK%+6:STARAND+3:RTS:.EX11 JSRDORND2:JMPEX4\n 2200.EXS1 STAS:JSRDORND2:ROLA:BCSEX5:JSRFMLTU:ADCR:TAX:LDAS:ADC#0:RTS\n 2210.EX5 JSRFMLTU:STAT:LDAR:SBCT:TAX:LDAS:SBC#0:RTS\n 3008.SOS1 JSRmsblob:LDA#127:STAINWK+29:STAINWK+30:LDAtek:AND#2:ORA#128:JMPNWSHP\n 3010.SOLAR LSRFIST:JSRZINF:LDAQQ15+1:AND#7:ADC#6:LSRA:STAINWK+8:RORA:STAINWK+2:STAINWK+5\n 3020JSRSOS1:LDAQQ15+3:AND#7:ORA#129:STAINWK+8:LDAQQ15+5:AND#3:STAINWK+2:STAINWK+1:LDA#0:STAINWK+29:STAINWK+30:LDA#&81:JSRNWSHP\n 3600.NWSTARS LDAQQ11:\\ORAMJ:BNEWPSHPS:.nWq LDYNOSTM:.SAL4 JSRDORND:ORA#8:STASZ,Y:STAZZ:JSRDORND:STASX,Y:STAX1:JSRDORND:STASY,Y:STAY1:JSRPIXEL2:DEY:BNESAL4\n 3710.WPSHPS LDX#0:.WSL1 LDAFRIN,X:BEQWS2:BMIWS1:STATYPE:JSRGINF:LDY#31\n 3730.WSL2 LDA(INF),Y:STAINWK,Y:DEY:BPLWSL2:STXXSAV:JSRSCAN:LDXXSAV:LDY#31:LDA(INF),Y:AND#&A7:STA(INF),Y:.WS1 INX:BNEWSL1:.WS2 LDX#FF:STXLSX2:STXLSY2\n 3740.FLFLLS LDY#2*Y-1:LDA#0:.SAL6 STALSO,Y:DEY:BNESAL6:DEY:STYLSX:RTS\n 3810.DET1 LDA#6:SEI:STA&FE00:STX&FE01:CLI:RTS\n 3900DEX:RTS:.SHD INX:BEQSHD-2:.DENGY DECENERGY:PHP:BNEP%+5:INCENERGY:PLP:RTS\n 4000.COMPAS JSRDOT:LDASSPR:BNESP1:JSRSPS1:JMPSP2:.SPS2 ASLA:TAX:LDA#0:RORA:TAY:LDA#20 \\14:STAQ:TXA:JSRDVID4:LDXP\n 4080TYA:BMILL163:LDY#0:RTS:.LL163 LDY#FF:TXA:EOR#FF:TAX:INX:RTS\n 4090.SPS4 LDX#8:.SPL1 LDAK%+NI%,X:STAK3,X:DEX:BPLSPL1:JMPTAS2\n 4100.SP1 JSRSPS4:.SP2 LDAXX15:JSRSPS2:TXA:ADC#195\\X-1:STACOMX:LDAXX15+1:JSRSPS2:STXT:LDA#204:SBCT:STACOMY\n 4130LDA#&F0:LDXXX15+2:BPLP%+4:LDA#FF:STACOMC\n 4200.DOT LDACOMY:STAY1:LDACOMX:STAX1:LDACOMC:STACOL:CMP#&F0:BNECPIX2:.CPIX4 JSRCPIX2:DECY1:.CPIX2 LDAY1\n 4250\\.CPIX:TAY:LSRA:LSRA:LSRA:ORA#&60:STASCH:LDAX1:AND#&F8:STASC:TYA:AND#7:TAY:LDAX1:AND#6:LSRA:TAX:LDACTWOS,X:ANDCOL:EOR(SC),Y:STA(SC),Y\n 4260LDACTWOS+1,X:BPLCP1:LDASC:ADC#8:STASC:LDACTWOS+1,X:.CP1 ANDCOL:EOR(SC),Y:STA(SC),Y:RTS\n 4300.OOPS STAT:LDY#8:LDX#0:LDA(INF),Y:BMIOO1:LDAFSH:SBCT:BCCOO2:STAFSH:RTS:.OO2 \\LDX#0:STXFSH:BCCOO3:.OO1 LDAASH:SBCT:BCCOO5:STAASH:RTS:.OO5 \\LDX#0:STXASH:.OO3 ADCENERGY:STAENERGY:BEQP%+4:BCSP%+5:JMPDEATH:JSREXNO3:JMPOUCH\n 4410.SPS3 LDAK%+1,X:STAK3,X:LDAK%+2,X:TAY:AND#127:STAK3+1,X:TYA:AND#128:STAK3+2,X:RTS\n 4450.GINF TXA:ASLA:TAY:LDAUNIV,Y:STAINF:LDAUNIV+1,Y:STAINF+1:RTS\n 4480.NWSPS JSRSPBLB:LDX#1:STXINWK+32:DEX:STXINWK+30:\\STXINWK+31:STXFRIN+1:DEX:STXINWK+29:LDX#10:JSRNwS1:JSRNwS1:JSRNwS1\n 4490LDA#(LSO MOD256):STAINWK+33:LDA#(LSO DIV256):STAINWK+34:LDA#SST\n 4500.NWSHP STAT:LDX#0:.NWL1 LDAFRIN,X:BEQNW1:INX:CPX#NOSH:BCCNWL1:.NW3 CLC:RTS\n 4510.NW1 JSRGINF:LDAT:BMINW2:ASLA:TAY:LDAXX21-2,Y:STAXX0:LDAXX21-1,Y:STAXX0+1:CPY#2*SST:BEQNW6:LDY#5:LDA(XX0),Y:STAT1:LDASLSP:SEC:SBCT1:STAINWK+33:LDASLSP+1:SBC#0:STAINWK+34\n 4530LDAINWK+33:\\SEC:SBCINF:TAY:LDAINWK+34:SBCINF+1:BCCNW3+1:BNENW4:CPY#NI%:BCCNW3+1:.NW4\n 4550LDAINWK+33:STASLSP:LDAINWK+34:STASLSP+1:.NW6 LDY#14:LDA(XX0),Y:STAINWK+35:LDY#19:LDA(XX0),Y:AND#7:STAINWK+31\n 4560LDAT:.NW2 STAFRIN,X:TAX:BMIP%+5:INCMANY,X:LDY#(NI%-1):.NWL3 LDAINWK,Y:STA(INF),Y:DEY:BPLNWL3:SEC:RTS\n 4600.NwS1 LDAINWK,X:EOR#128:STAINWK,X:INX:INX:RTS\n 4710.ABORT LDX#FF:.ABORT2 STXMSTG:LDXNOMSL:JSRMSBAR:STYMSAR:RTS\n 4730.ECBLB2 LDA#32:STAECMA:ASLA:JSRNOISE:.ECBLB LDA#7*8:\\\" <<120<\":LDX#(ECBT MOD256):LDY#(ECBT DIV256):BNEBULB-2\n 4740.SPBLB LDA#24*8:\\\"<<128<\":LDX#(SPBT MOD256):LDY#(SPBT DIV256):.BULB STASC:STXP+1:STYP+2:LDA#&7D:JMPRREN\n 4800.ECBT EQUW&E0E0:EQUB&80:.SPBT EQUD&E080E0E0:EQUD&E0E020E0\n 4900.MSBAR TXA:ASLA:ASLA:ASLA:STAT:LDA#49\\113:SBCT:STASC:LDA#&7E:STASCH:TYA:LDY#5:.MBL1 STA(SC),Y:DEY:BNEMBL1:RTS\n 5000.PROJ LDAINWK:STAP:LDAINWK+1:STAP+1:LDAINWK+2:JSRPLS6:BCSPL2-1:LDAK:ADC#X:STAK3:TXA:ADC#0:STAK3+1\n 5010LDAINWK+3:STAP:LDAINWK+4:STAP+1:LDAINWK+5:EOR#128:JSRPLS6:BCSPL2-1:LDAK:ADC#Y:STAK4:TXA:ADC#0:STAK4+1:CLC:RTS\n 5020.PL2 LDATYPE:LSRA:BCSP%+5:JMPWPLS2:JMPWPLS\n 5040.PLANET LDAINWK+8:BMIPL2:CMP#48:BCSPL2:ORAINWK+7:BEQPL2:JSRPROJ:BCSPL2\n 5090LDA#96:STAP+1:LDA#0:STAP:JSRDVID3B2:LDAK+1:BEQPL82:LDA#&F8:STAK:.PL82\n 5110LDATYPE:LSRA:BCCPL9:JMPSUN:.PL9 JSRWPLS2:JSRCIRCLE:BCSPL20:LDAK+1:BEQPL25:.PL20 RTS\n 5160.PL25 LDATYPE:CMP#&80:BNEPL26:LDAK:CMP#6:BCCPL20:LDAINWK+14:EOR#128:STAP:LDAINWK+20:JSRPLS4:LDX#9:JSRPLS1:STAK2:STYXX16:JSRPLS1:STAK2+1:STYXX16+1:LDX#15:JSRPLS5\n 5230JSRPLS2:LDAINWK+14:EOR#128:STAP:LDAINWK+26:JSRPLS4\n 5240LDX#21:JSRPLS5:JMPPLS2\n 5270.PL26\\crtr:LDAINWK+20:BMIPL20\n 5280LDX#15:JSRPLS3:CLC:ADCK3:STAK3:TYA:ADCK3+1:STAK3+1:JSRPLS3:STAP:LDAK4:SEC:SBCP:STAK4:STYP:LDAK4+1:SBCP:STAK4+1\n 5300LDX#9:JSRPLS1:LSRA:STAK2:STYXX16:JSRPLS1:LSRA:STAK2+1:STYXX16+1\n 5310LDX#21:JSRPLS1:LSRA:STAK2+2:STYXX16+2:JSRPLS1:LSRA:STAK2+3:STYXX16+3\n 5320LDA#64:STATGT:LDA#0:STACNT2:JMPPLS22\n 5330.PLS1 LDAINWK,X:STAP:LDAINWK+1,X:AND#127:STAP+1:LDAINWK+1,X:AND#128\n 5340JSRDVID3B2:LDAK:LDYK+1:BEQP%+4:LDA#&FE:LDYK+3:INX:INX:RTS\n 5350.PLS2 LDA#31:STATGT:.PLS22 LDX#0:STXCNT:DEX:STXFLAG:.PLL4\n 5360LDACNT2:AND#31:TAX:LDASNE,X:STAQ:LDAK2+2:JSRFMLTU:STAR:LDAK2+3:JSRFMLTU:STAK:LDXCNT2:CPX#33:LDA#0:RORA:STAXX16+5\n 5370LDACNT2:CLC:ADC#16:AND#31:TAX:LDASNE,X:STAQ:LDAK2+1:JSRFMLTU:STAK+2:LDAK2:JSRFMLTU:STAP:LDACNT2:ADC#15:AND#63:CMP#33:LDA#0:RORA:STAXX16+4\n 5380LDAXX16+5:EORXX16+2:STAS:LDAXX16+4:EORXX16:JSRADD:STAT:BPLPL42:TXA:EOR#FF:CLC:ADC#1:TAX:LDAT:EOR#&7F:ADC#0:STAT:.PL42:TXA:ADCK3:STAK6:LDAT:ADCK3+1:STAK6+1\n 5390LDAK:STAR:LDAXX16+5:EORXX16+3:STAS:LDAK+2:STAP:LDAXX16+4:EORXX16+1:JSRADD:EOR#128:STAT:BPLPL43:TXA:EOR#FF:CLC:ADC#1:TAX:LDAT:EOR#&7F:ADC#0:STAT:.PL43\n 5400JSRBLINE:CMPTGT:BEQP%+4:BCSPL40:LDACNT2:CLC:ADCSTP:AND#63:STACNT2:JMPPLL4:.PL40 RTS\n 5410JMPWPLS:.PLF3 TXA:EOR#FF:CLC:ADC#1:TAX:.PLF17 LDA#FF:JMPPLF5\n 5430.SUN LDA#1:STALSX:JSRCHKON:BCSPLF3-3:LDA#0:LDXK:CPX#&60:ROLA:CPX#&28:ROLA:CPX#&10:ROLA\n 5450.PLF18 STACNT:LDA#2*Y-1:LDXP+2:BNEPLF2:CMPP+1:BCCPLF2:LDAP+1:BNEPLF2:LDA#1:.PLF2 STATGT\n 5460LDA#2*Y-1:SEC:SBCK4:TAX:LDA#0:SBCK4+1:BMIPLF3:BNEPLF4:INX:DEX:BEQPLF17:CPXK:BCCPLF5:.PLF4 LDXK:LDA#0:.PLF5 STXV:STAV+1\n 5470LDAK:JSRSQUA2:STAK2+1:LDAP:STAK2:LDY#2*Y-1:LDASUNX:STAYY:LDASUNX+1:STAYY+1:.PLFL2 CPYTGT:BEQPLFL:LDALSO,Y:BEQPLF13:JSRHLOIN2:.PLF13 DEY:BNEPLFL2\n 5480.PLFL LDAV:JSRSQUA2:STAT:LDAK2:SEC:SBCP:STAQ:LDAK2+1:SBCT:STAR:STYY1:JSRLL5:LDYY1:JSRDORND:ANDCNT:CLC:ADCQ:BCCPLF44:LDA#FF:.PLF44\n 5490LDXLSO,Y:STALSO,Y:BEQPLF11:LDASUNX:STAYY:LDASUNX+1:STAYY+1:TXA:JSREDGES:LDAX1:STAXX:LDAX2:STAXX+1\n 5500LDAK3:STAYY:LDAK3+1:STAYY+1:LDALSO,Y:JSREDGES:BCSPLF23:LDAX2:LDXXX:STXX2:STAXX:JSRHLOIN:.PLF23 LDAXX:STAX1:LDAXX+1:STAX2:.PLF16 JSRHLOIN:.PLF6\n 5530DEY:BEQPLF8:LDAV+1:BNEPLF10:DECV:BNEPLFL:DECV+1:.PLFLS JMPPLFL\n 5535.PLF11 LDXK3:STXYY:LDXK3+1:STXYY+1:JSREDGES:BCCPLF16:LDA#0:STALSO,Y:BEQPLF6\n 5540.PLF10 LDXV:INX:STXV:CPXK:BCCPLFLS:BEQPLFLS:LDASUNX:STAYY:LDASUNX+1:STAYY+1:.PLFL3 LDALSO,Y:BEQPLF9:JSRHLOIN2\n 5550.PLF9 DEY:BNEPLFL3:.PLF8 CLC:LDAK3:STASUNX:LDAK3+1:STASUNX+1:.RTS2 RTS\n 5600.CIRCLE JSRCHKON:BCSRTS2\n 5610LDA#0:STALSX2\n 5700LDXK:LDA#8:CPX#8:BCCPL89:LSRA:CPX#60:BCCPL89:LSRA:.PL89 STASTP:.CIRCLE2 LDX#FF:STXFLAG:INX:STXCNT:.PLL3\n 5710LDACNT:JSRFMLTU2:LDX#0:STXT:LDXCNT:CPX#33:BCCPL37:EOR#FF:ADC#0:TAX:LDA#FF:ADC#0:STAT:TXA:CLC\n 5720.PL37 ADCK3:STAK6:LDAK3+1:ADCT:STAK6+1\n 5730LDACNT:CLC:ADC#16:JSRFMLTU2:TAX:LDA#0:STAT:LDACNT:ADC#15:AND#63:CMP#33:BCCPL38:TXA:EOR#FF:ADC#0:TAX:LDA#FF:ADC#0:STAT:CLC\n 5740.PL38 JSRBLINE:CMP#65:BCSP%+5:JMPPLL3:CLC:RTS\n 5750.WPLS2 LDYLSX2:BNEWP1:.WPL1 CPYLSP:BCSWP1:LDALSY2,Y:CMP#FF:BEQWP2:STAY2:LDALSX2,Y:STAX2:JSRLOIN:INY:LDASWAP:BNEWPL1\n 5760LDAX2:STAX1:LDAY2:STAY1:JMPWPL1:.WP2 INY:LDALSX2,Y:STAX1:LDALSY2,Y:STAY1:INY:JMPWPL1:.WP1 LDA#1:STALSP:LDA#FF:STALSX2:RTS\n 5790.WPLS LDALSX:BMIWPLS-1:LDASUNX:STAYY:LDASUNX+1:STAYY+1:LDY#2*Y-1:.WPL2 LDALSO,Y:BEQP%+5:JSRHLOIN2:DEY:BNEWPL2:DEY:STYLSX:RTS\n 5800.EDGES STAT:CLC:ADCYY:STAX2:LDAYY+1:ADC#0:BMIED1:BEQP%+6:LDA#254:STAX2\n 5810LDAYY:SEC:SBCT:STAX1:LDAYY+1:SBC#0:BNEED3:CLC:RTS\n 5820.ED3 BPLED1:LDA#2:STAX1:CLC:RTS:.ED1 LDA#0:STALSO,Y:SEC:RTS\n 5850.CHKON LDAK3:CLC:ADCK:LDAK3+1:ADC#0:BMIPL21:LDAK3:SEC:SBCK:LDAK3+1:SBC#0:BMIPL31:BNEPL21:.PL31\n 5860LDAK4:CLC:ADCK:STAP+1:LDAK4+1:ADC#0:BMIPL21:STAP+2:LDAK4:SEC:SBCK:TAX:LDAK4+1:SBC#0:BMIPL44:BNEPL21:CPX#2*Y-1:RTS:.PL21 SEC:RTS\n 5900.PLS3 JSRPLS1:STAP:LDA#222:STAQ:STXU:JSRMULTU:LDXU:LDYK+3:BPLPL12:EOR#FF:CLC:ADC#1:BEQPL12:LDY#FF:RTS:.PL12 LDY#0:RTS\n 5910.PLS4 STAQ:JSRARCTAN:LDXINWK+14:BMIP%+4:EOR#128:LSRA:LSRA:STACNT2:RTS\n 5920.PLS5 JSRPLS1:STAK2+2:STYXX16+2:JSRPLS1:STAK2+3:STYXX16+3:RTS\n 5930.PLS6 JSRDVID3B2:LDAK+3:AND#127:ORAK+2:BNEPL21:LDXK+1:CPX#4:BCSPL6:LDAK+3:\\CLC:BPLPL6:LDAK:EOR#FF:ADC#1:STAK:TXA:EOR#FF:ADC#0:TAX:.PL44 CLC:.PL6 RTS\n 7200.TT17 JSRDOKEY:LDAJSTK:BEQTJ1:LDAJSTX:EOR#FF:JSRTJS1:TYA:TAX\n 7210LDAJSTY:.TJS1 TAY:LDA#0:CPY#&10:SBC#0:\\CPY#&20SBC#0:CPY#&40:SBC#0:CPY#&C0:ADC#0:CPY#&E0:ADC#0:\\CPY#&F0ADC#0\n 7220TAY:LDAKL:RTS\n 7250.TJ1 LDAKL:LDX#0:LDY#0:CMP#&19:BNEP%+3:DEX:CMP#&79:BNEP%+3:INX:CMP#&39:BNEP%+3:INY:CMP#&29:BNEP%+3:DEY:RTS\n 7550.ping LDX#1:.pl1 LDAQQ0,X:STAQQ9,X:DEX:BPLpl1:RTS\n 9500]PRINT\"E d,\";\n 9710IFZ>4OSCLI(\"S.ELTE \"+STR$~W%+\" \"+STR$~O%+\" \"+STR$~L%+\" \"+STR$~H%)\n 9720GOTO12\n"
  },
  {
    "path": "1-source-files/original-sources/$.ELITEF.inf",
    "content": "$.ELITEF  000000 000000 002ED2\n"
  },
  {
    "path": "1-source-files/original-sources/$.ELITEF.txt",
    "content": "    1GOTO20\n    2*L.ELITEB\n    3GOTO20\n    4*L.ELITEA\n    6*L.ELITEC\n    7GOTO20\n    8*L.ELITED\n    9GOTO20\n   10*L.ELITEE\n   11GOTO20\n   12*L.ELITEF\n   13GOTO20\n   14*L.ELITEG\n   20REM ELITE <F>\n  100 H%=L%+P%-C%:O%=W%\n  900[OPTZ\n 1000.KS3 LDAP:STASLSP:LDAP+1:STASLSP+1:RTS:.KS1 LDXXSAV:JSRKILLSHP:LDXXSAV:JMPMAL1\n 1010.KS4 JSRZINF:JSRFLFLLS:STAFRIN+1:STASSPR:JSRSPBLB:LDA#6:STAINWK+5:LDA#&81:JMPNWSHP\n 1020.KS2 LDX#FF:.KSL4 INX:LDAFRIN,X:BEQKS3:CMP#MSL:BNEKSL4:TXA:ASLA:TAY:LDAUNIV,Y:STASC:LDAUNIV+1,Y:STASC+1\n 1030LDY#32:LDA(SC),Y:BPLKSL4:AND#&7F:LSRA:CMPXX4:BCCKSL4:BEQKS6:SBC#1:ASLA:ORA#128:STA(SC),Y:BNEKSL4:.KS6 LDA#0:STA(SC),Y:BEQKSL4\n 1050.KILLSHP STXXX4:LDAMSTG:CMPXX4:BNEKS5:LDY#&EE:JSRABORT:LDA#200:JSRMESS:.KS5 LDYXX4:LDXFRIN,Y:CPX#SST:BEQKS4:DECMANY,X:LDXXX4\n 1060LDY#5:LDA(XX0),Y:LDY#33:CLC:ADC(INF),Y:STAP:INY:LDA(INF),Y:ADC#0:STAP+1\n 1070.KSL1 INX:LDAFRIN,X:STAFRIN-1,X:BEQKS2:ASLA:TAY:LDAXX21-2,Y:STASC:LDAXX21-1,Y:STASC+1:LDY#5:LDA(SC),Y:STAT:LDAP:SEC:SBCT:STAP:LDAP+1:SBC#0:STAP+1\n 1080TXA:ASLA:TAY:LDAUNIV,Y:STASC:LDAUNIV+1,Y:STASC+1:LDY#35:LDA(SC),Y:STA(INF),Y:DEY\n 1090LDA(SC),Y:STAK+1:LDAP+1:STA(INF),Y:DEY:LDA(SC),Y:STAK:LDAP:STA(INF),Y:DEY:.KSL2 LDA(SC),Y:STA(INF),Y:DEY:BPLKSL2:LDASC:STAINF:LDASC+1:STAINF+1\n 1100LDYT:.KSL3 DEY:LDA(K),Y:STA(P),Y:TYA:BNEKSL3:BEQKSL1\n 1500.SFX EQUS FNS(\"12010010\"):EQUS FNS(\"12022C08\"):EQUS FNS(\"1103F018\"):EQUS FNS(\"10F1071A\")\n 1510EQUS FNS(\"03F1BC01\"):EQUS FNS(\"13F40C08\"):EQUS FNS(\"10F1060C\"):EQUS FNS(\"10026010\") HYP:EQUS FNS(\"1304C2FF\"):EQUS FNS(\"13000000\")\n 3000.RESET \\\"<<<<\":JSRZERO:LDX#6:.SAL3 STABETA,X:DEX:BPLSAL3:STXQQ12:.RES4 LDA#FF:LDX#2:.REL5 STAFSH,X:DEX:BPLREL5\n 3002.RES2 LDA#NOST:STANOSTM:LDX#FF:STXLSX2:STXLSY2:STXMSTG:LDA#128:STAJSTY:STAALP2:STABET2:ASLA:STAALP2+1:STABET2+1:STAMCNT:LDA#3:STADELTA:STAALPHA:STAALP1\n 3005LDASSPR:BEQP%+5:JSRSPBLB:LDAECMA:BEQyu:JSRECMOF:.yu JSRWPSHPS:JSRZERO:LDA#(LS%MOD256):STASLSP:LDA#(LS%DIV256):STASLSP+1:JSRDIALS\n 3006.ZINF LDY#NI%-1:LDA#0:.ZI1 STAINWK,Y:DEY:BPLZI1:LDA#96:STAINWK+18:STAINWK+22:ORA#128:STAINWK+14:RTS\n 3007.msblob LDX#4:.ss CPXNOMSL:BEQSAL8:LDY#0:JSRMSBAR:DEX:BNEss:RTS:.SAL8 LDY#&EE:JSRMSBAR:DEX:BNESAL8:RTS\n 3890.me2 LDAMCH:JSRMESS:LDA#0:STADLY:JMPme3\n 3900.Ze JSRZINF:JSRDORND:STAT1:AND#128:STAINWK+2:TXA:AND#128:STAINWK+5:LDA#32:STAINWK+1:STAINWK+4:STAINWK+7:TXA:CMP#245:ROLA:ORA#&C0:STAINWK+32\n 3904.DORND2 CLC:.DORND LDARAND:ROLA:TAX:ADCRAND+2:STARAND:STXRAND+2:LDARAND+1:TAX:ADCRAND+3:STARAND+1:STXRAND+3:RTS\n 3910.MTT4 LSRA:STAINWK+32:STAINWK+29:ROLINWK+31:AND#31:ORA#16:STAINWK+27:LDA#CYL:JSRNWSHP\n 4000.TT100 JSRM%:DECDLY:BEQme2:BPLme3:INCDLY:.me3 DECMCNT:BEQP%+5:.ytq JMPMLOOP:LDAMJ:BNEytq\n 4020JSRDORND:CMP#35:BCSMTT1:LDAMANY+AST:CMP#3:BCSMTT1:JSRZINF:LDA#38:STAINWK+7:JSRDORND:STAINWK:STXINWK+3:AND#128:STAINWK+2:TXA:AND#128:STAINWK+5:ROLINWK+1:ROLINWK+1\n 4022JSRDORND:BVSMTT4:ORA#&6F:STAINWK+29:LDASSPR:BNEMTT1:TXA:BCSMTT2:AND#31:ORA#16:STAINWK+27:BCCMTT3\n 4025.MTT2 ORA#127:STAINWK+30:.MTT3 JSRDORND:CMP#5:LDA#AST:BCSP%+4:LDA#OIL:JSRNWSHP\n 4030.MTT1\n 4040LDASSPR:BNEMLOOP:JSRBAD:ASLA:LDXMANY+COPS:BEQP%+5:ORAFIST:STAT:JSRZe:CMPT:BCSP%+7:LDA#COPS:JSRNWSHP:LDAMANY+COPS:BNEMLOOP:DECEV:BPLMLOOP:INCEV:JSRDORND:LDYgov:BEQ`:CMP#90:BCSMLOOP:AND#7:CMPgov:BCCMLOOP:.`\n 4050JSRZe:CMP#200:BCSmt1:INCEV:AND#3:ADC#3:TAY:TXA:CMP#200:ROLA:ORA#&C0:CPY#6:BEQtha:STAINWK+32:TYA:JSRNWSHP:.mj1 JMPMLOOP:.mt1 AND#3:STAEV:STAXX13:.mt3 JSRDORND:AND#3:ORA#1:JSRNWSHP\n 4100DECXX13:BPLmt3:.MLOOP LDA#1:STAVIA+&E:LDX#FF:TXS:LDXGNTMP:BEQEE20:DECGNTMP:.EE20 JSRDIALS:LDAQQ11:BEQP%+11:ANDPATG:LSRA:BCSP%+5:JSRDELAY-5\n 4200JSRTT17:.FRCE JSRTT102:LDAQQ12:BNEMLOOP:JMPTT100\n 4250.tha JSRDORND:CMP#200:BCCP%+5:JSRGTHG:JMPMLOOP\n 4500.TT102 CMP#f8:BNEP%+5:JMPSTATUS:CMP#f4:BNEP%+5:JMPTT22:CMP#f5:BNEP%+5:JMPTT23:CMP#f6:BNETT92:JSRTT111:JMPTT25:.TT92 CMP#f9:BNEP%+5:JMPTT213:CMP#f7:BNEP%+5:JMPTT167:CMP#f0:BNEfvw:JMPTT110:.fvw BITQQ12\n 4505BPLINSP:CMP#f3:BNEP%+5:JMPEQSHP:CMP#f1:BNEP%+5:JMPTT219:CMP#&47:BNEP%+5:JMPSVE\n 4510CMP#f2:BNE``:JMPTT208:.INSP CMP#&71:BCC``:CMP#&74:BCS``:AND#3:TAX:JMPLOOK1:.`` CMP#&54:BNEP%+5:JMPhyp:CMP#&32:BEQT95:STAT1:LDAQQ11:AND#192:BEQTT107:LDAQQ22+1:BNETT107:LDAT1:CMP#&36:BNEee2:JSRTT103:JSRping\n 4520JSRTT103:.ee2 JSRTT16:.TT107:LDAQQ22+1:BEQt95:DECQQ22:BNEt95:LDXQQ22+1:DEX:JSRee3:LDA#5:STAQQ22:LDXQQ22+1:JSRee3:DECQQ22+1:BNEt95:JMPTT18:.t95 RTS\n 4550.T95 LDAQQ11:AND#192:BEQt95:JSRhm:STAQQ17:JSRcpl:LDA#128:STAQQ17:LDA#1:STAXC:INCYC:JMPTT146\n 4800.BAD LDAQQ20+3:CLC:ADCQQ20+6:ASLA:ADCQQ20+10:RTS\n 4850.FAROF LDA#&E0:.FAROF2 CMPINWK+1:BCCMA34:CMPINWK+4:BCCMA34:CMPINWK+7:.MA34 RTS:.MAS4 ORAINWK+1:ORAINWK+4:ORAINWK+7:RTS\n 4900.DEATH JSREXNO3:JSRRES2:ASLDELTA:ASLDELTA:LDX#24:JSRDET1:JSRTT66:JSRBOX:JSRnWq:LDA#12:STAYC:STAXC:LDA#146:JSRex:.D1 JSRZe:LSRA:LSRA:STAINWK:LDY#0:STYQQ11:STYINWK+1:STYINWK+4:STYINWK+7:STYINWK+32:DEY:STYMCNT:STYLASCT:EOR#42\n 4905STAINWK+3:ORA#80:STAINWK+6:TXA:AND#&8F:STAINWK+29\n 4910RORA:AND#&87:STAINWK+30:PHP:LDX#OIL:JSRfq1:PLP:LDA#0:RORA:LDY#31:STA(INF),Y:LDAFRIN+3:BEQD1:JSRU%:STADELTA:.D2 JSRM%:LDALASCT:BNED2:LDX#31:JSRDET1:.DEATH2 JSRRES2\n 5000.TT170 LDX#FF:TXS\n 5010.BR1 LDX#3:STXXC:JSRFX200:LDX#CYL:LDA#128:JSRTITLE:CMP#&44:BNEQU5:\\BR1 LDX#3STXXCJSRFX200LDA#1JSRTT66JSRFLKB\n 5015\\LDA#14JSRTT214BCCQU5:JSRGTNME:JSRLOD:JSRTRNME:JSRTTX66\n 5020.QU5 \\JSRTTX66:LDX#NT%:.QUL1 LDANA%+7,X:STATP-1,X:DEX:BNEQUL1:STXQQ11:JSRCHECK:CMPCHK:BNEP%-6:EOR#&A9:TAX:LDACOK:CPXCHK2:BEQtZ:ORA#128:.tZ ORA#2:STACOK:JSRmsblob:LDA#147:LDX#3:JSRTITLE:JSRping:JSRhyp1\n 5021.BAY LDA#FF:STAQQ12:LDA#f8:JMPFRCE\n 5110.TITLE PHA:STXTYPE:JSRRESET:LDA#1:JSRTT66:DECQQ11:LDA#96:STAINWK+14\n 5120\\LSRA:STAINWK+7:LDX#127:STXINWK+29:STXINWK+30:INX:STXQQ17\n 5130LDATYPE:JSRNWSHP\n 5140LDY#6:STYXC:JSRDELAY:LDA#30:JSRplf:LDY#6:STYXC:INCYC:LDAPATG:BEQawe:LDA#254:JSRTT27:.awe JSRCLYNS:STYDELTA:STYJSTK:PLA:JSRex:LDA#148:LDX#7:STXXC:JSRex\n 5150.TLL2 LDAINWK+7:CMP#1:BEQTL1:DECINWK+7:.TL1 JSRMVEIT:LDA#128:STAINWK+6:ASLA:STAINWK:STAINWK+3:JSRLL9:DECMCNT:LDA&FE40:AND#16:\\TAX:BEQTL2:JSRRDKEY:BEQTLL2:RTS:.TL2 DECJSTK:RTS\n 5200.CHECK LDX#NT%-2:CLC:TXA:.QUL2 ADCNA%+7,X:EORNA%+8,X:DEX:BNEQUL2:RTS\n 5250.TRNME LDX#7:.GTL1 LDAINWK,X:STANA%,X:DEX:BPLGTL1:.TR1 LDX#7:.GTL2 LDANA%,X:STAINWK,X:DEX:BPLGTL2:RTS\n 5300.GTNME LDA#1:JSRTT66:LDA#123:JSRTT27:JSRDEL8:LDA#&81:STAVIA+&E:LDA#15:TAX:JSROSBYTE:LDX#(RLINE MOD256):LDY#(RLINE DIV256):LDA#0:JSROSWORD\\LDA#1STAVIA+&E:BCSTR1:TYA:BEQTR1:JMPTT67\n 5350.RLINE EQUWINWK:EQUB7:EQUB33:EQUB&7A\n 5400.ZERO LDX#&D:.ZEL JSRZES1:DEX:CPX#9:BNEZEL\n 5410.ZES1 LDY#0:STYSC:.ZES2 LDA#0:STXSC+1:.ZEL1 STA(SC),Y:INY:BNEZEL1:RTS\n 5500.SVE JSRGTNME:JSRTRNME:JSRZERO:LSRSVC:LDX#NT%:.SVL1 LDATP,X:STA&B00,X:STANA%+8,X:DEX:BPLSVL1:JSRCHECK:STACHK:PHA:ORA#128:STAK:EORCOK:STAK+2:EORCASH+2:STAK+1:EOR#&5A:EORTALLY+1:STAK+3:JSRBPRNT:JSRTT67:JSRTT67:PLA:STA&B00+NT%:EOR#&A9\n 5501STACHK2:STA&AFF+NT%:LDY#&B:STY&C0B:INY:STY&C0F\n 5510LDA#&81:STAVIA+&E:INCsvn:LDA#0:JSRQUS1:LDX#0\\STXVIA+&EDEX:STXsvn:JMPBAY\n 5520.QUS1 LDX#INWK:STX&C00:LDX#0:JMPOSFILE\n 5600.LOD LDX#2:JSRFX200:JSRZERO:LDY#&B:STY&C03:INC&C0B:INY:LDA#FF:JSRQUS1:LDA&B00:BMISPS1+1:LDX#NT%:.LOL1 LDA&B00,X:STANA%+8,X:DEX:BPLLOL1:LDX#3\n 5620.FX200\\MOS:LDY#0:LDA#200:JMPOSBYTE\n 6500RTS:.SPS1 LDX#0:JSRSPS3:LDX#3:JSRSPS3:LDX#6:JSRSPS3\n 6600.TAS2 LDAK3:ORAK3+3:ORAK3+6:ORA#1:STAK3+9:LDAK3+1:ORAK3+4:ORAK3+7\n 6610.TAL2 ASLK3+9:ROLA:BCSTA2:ASLK3:ROLK3+1:ASLK3+3:ROLK3+4:ASLK3+6:ROLK3+7:BCCTAL2\n 6620.TA2 LDAK3+1:LSRA:ORAK3+2:STAXX15:LDAK3+4:LSRA:ORAK3+5:STAXX15+1:LDAK3+7:LSRA:ORAK3+8:STAXX15+2\n 6700.NORM\n 6705LDAXX15:JSRSQUA:STAR:LDAP:STAQ:LDAXX15+1:JSRSQUA:STAT:LDAP:ADCQ:STAQ:LDAT:ADCR:STAR:LDAXX15+2:JSRSQUA:STAT:LDAP:ADCQ:STAQ:LDAT:ADCR:STAR\n 6710JSRLL5\n 6720LDAXX15:JSRTIS2:STAXX15 \\*96/Q\n 6730LDAXX15+1:JSRTIS2:STAXX15+1\n 6740LDAXX15+2:JSRTIS2:STAXX15+2:.NO1 RTS\n 6800.RDKEY \\OSBYTE7A:LDX#16:.Rd1 JSRDKS4:BMIRd2:INX:BPLRd1:TXA:.Rd2 EOR#128:TAX:RTS\n 7000.ECMOF LDA#0:STAECMA:STAECMP:JSRECBLB:LDA#72:BNENOISE\n 7001.EXNO3 LDA#16:JSRNOISE:LDA#24:BNENOISE\n 7003.SFRMIS LDX#MSL:JSRSFS1-2:BCCNO1:LDA#&78:JSRMESS:LDA#48:BNENOISE\n 7004.EXNO2 INCTALLY:BNEEXNO-2:INCTALLY+1:LDA#101:JSRMESS:LDX#7 \\15:.EXNO STXT:LDA#24:JSRNOS1:LDAINWK+7:LSRA:LSRA:ANDT:ORA#&F1:STAXX16+2:JSRNO3:LDA#16\n 7006EQUB&2C:.BEEP LDA#32\n 7010.NOISE JSRNOS1:.NO3 LDXDNOIZ:BNENO1:LDX#(XX16 MOD256):LDY#(XX16 DIV256):LDA#7:JMPOSWORD\n 7015.NOS1 LSRA:ADC#3:TAY:LDX#7:.NOL1 LDA#0:STAXX16,X:DEX:LDASFX,Y:STAXX16,X:DEY:DEX:BPLNOL1\n 7020.KYTB RTS:EQUB&E8:EQUB&E2:EQUB&E6:EQUB&E7:EQUB&C2:EQUB&D1:EQUB&C1:EQUD&35237060:EQUW&2265:EQUB&45:EQUB&52 \\? <>XSA.FBRLtabescTUMEJC\n 7030.DKS1 LDXKYTB,Y:JSRDKS4:BPLDKS2-1:LDX#FF:STXKL,Y:RTS\n 7032.CTRL LDX#1:.DKS4 LDA#3:SEI:STA&FE40:LDA#&7F:STA&FE43:STX&FE4F:LDX&FE4F:LDA#&B:STA&FE40:CLI:TXA\n 7035RTS:.DKS2 LDA#&80:JSROSBYTE:TYA:EORJSTE\n 7037RTS:.DKS3 STYT:CPXT:BNEDk3:LDADAMP-&40,X:EOR#FF:STADAMP-&40,X:JSRBELL:JSRDELAY:LDYT:.Dk3 RTS\n 7040.DKJ1 LDY#1:JSRDKS1:INY:JSRDKS1\n 7050LDA&FE40:TAX:AND#16:EOR#16:STAKL+7:LDX#1:JSRDKS2:ORA#1:STAJSTX:LDX#2:JSRDKS2:EORJSTGY:STAJSTY:JMPDK4\n 7065.U% LDA#0:LDY#15:.DKL3 STAKL,Y:DEY:BNEDKL3:RTS\n 7070.DOKEY JSRU%:LDAJSTK:BNEDKJ1\n 7080LDY#7:.DKL2 JSRDKS1:DEY:BNEDKL2\n 7090LDXJSTX:LDA#7:LDYKL+3:BEQP%+5:JSRBUMP2:LDYKL+4:BEQP%+5:JSRREDU2:STXJSTX\n 7100ASLA:LDXJSTY:LDYKL+5:BEQP%+5:JSRREDU2:LDYKL+6:BEQP%+5:JSRBUMP2:STXJSTY\n 7110.DK4 JSRRDKEY:STXKL:CPX#&69:BNEDK2:.FREEZE JSRWSCAN:JSRRDKEY:CPX#&51:BNEDK6:LDA#0:STADNOIZ\n 7114.DK6 LDY#&40:.DKL4 JSRDKS3:INY:CPY#&47:BNEDKL4:.DK55 CPX#&10:BNEDK7:STXDNOIZ:.DK7 CPX#&70:BNEP%+5:JMPDEATH2:CPX#&59:BNEFREEZE:.DK2 LDAQQ11:BNEDK5:LDY#15:LDA#FF\n 7120.DKL1 LDXKYTB,Y:CPXKL:BNEDK1:STAKL,Y:.DK1 DEY:CPY#7:BNEDKL1\n 7130.DK5 RTS\n 7140.TT217 STYYSAV:.t JSRDELAY-5:JSRRDKEY:BNEt:.t2 JSRRDKEY:BEQt2:TAY:LDA(TRTB%),Y:LDYYSAV:TAX:.out RTS\n 7190.me1 STXDLY:PHA:LDAMCH:JSRmes9:PLA:EQUB&2C:.ou2 lda#108:EQUB&2C:.ou3 lda#111\n 7200.MESS LDX#0:STXQQ17:LDY#9:STYXC:LDY#22:STYYC:CPXDLY:BNEme1:STYDLY:STAMCH:.mes9 JSRTT27:LSRde:BCCout:LDA#253:JMPTT27\n 7300.OUCH JSRDORND:BMIout:CPX#22:BCSout:LDAQQ20,X:BEQout:LDADLY:BNEout:LDY#3:STYde:STAQQ20,X:CPX#17:BCSou1:TXA:ADC#208:BNEMESS:.ou1\n 7310BEQou2:CPX#18:BEQou3:TXA:ADC#113-20:BNEMESS\n 7410.QQ16 EQUS\"ALLEXEGEZACEBISOUSESARMAINDIREA?ERATENBERALAVETIEDORQUANTEISRION\"\n 7420.QQ23\\Prxs:EQUD&1068213:EQUD&30A8114:EQUD&7028341\\Food\n 7430EQUD&1FE28528:EQUD&FFB8553:EQUD&33608C4:EQUD &78081DEB \\slvs..\n 7440EQUD&3380E9A:EQUD&7280675:EQUD&1F11014E:EQUD&71D0D7C \\comps\n 7450EQUD&3FDC89B0:EQUD&03358120:EQUD&742A161:EQUD&1F37A2AB \\pltnm\n 7460EQUD&FFAC12D:EQUD&7C00F35 \\Gms.\n 8000.TI2 TYA:LDY#2:JSRTIS3:STAINWK+20\\Uz=-(FxUx+FyUy)/Fz:JMPTI3\n 8010.TI1 TAX:LDAXX15+1:AND#&60:BEQTI2:LDA#2:JSRTIS3:STAINWK+18:JMPTI3\n 8020.TIDY LDAINWK+10:STAXX15:LDAINWK+12:STAXX15+1:LDAINWK+14:STAXX15+2:JSRNORM:LDAXX15:STAINWK+10:LDAXX15+1:STAINWK+12:LDAXX15+2:STAINWK+14\n 8030LDY#4:LDAXX15:AND#&60:BEQTI1:LDX#2:LDA#0:JSRTIS3:STAINWK+16\n 8040.TI3 LDAINWK+16:STAXX15:LDAINWK+18:STAXX15+1:LDAINWK+20:STAXX15+2:JSRNORM:LDAXX15:STAINWK+16:LDAXX15+1:STAINWK+18:LDAXX15+2:STAINWK+20\n 8050LDAINWK+12:STAQ:LDAINWK+20:JSRMULT12:LDXINWK+14:LDAINWK+18:JSRTIS1:EOR#128:STAINWK+22\n 8060LDAINWK+16:JSRMULT12:LDXINWK+10:LDAINWK+20:JSRTIS1:EOR#128:STAINWK+24\n 8070LDAINWK+18:JSRMULT12:LDXINWK+12:LDAINWK+16:JSRTIS1:EOR#128:STAINWK+26 \\FxU/96(LHS)\n 8080LDA#0:LDX#14:.TIL1 STAINWK+9,X:DEX:DEX:BPLTIL1:RTS\n 8100.TIS2 TAY:AND#127:CMPQ:BCSTI4:LDX#254:STXT:.TIL2 ASLA:CMPQ:BCCP%+4:SBCQ:ROLT:BCSTIL2:LDAT\n 8110LSRA:LSRA:STAT:LSRA:ADCT:STAT:TYA:AND#128:ORAT:RTS:.TI4 TYA:AND#128:ORA#96:RTS\n 8130.TIS3 STAP+2:LDAINWK+10,X:STAQ:LDAINWK+16,X:JSRMULT12:LDXINWK+10,Y:STXQ:LDAINWK+16,Y:JSRMAD\n 8140STXP:LDYP+2:LDXINWK+10,Y:STXQ:EOR#128\n 8150.DVIDT\\A=AP/Q:STAP+1:EORQ:AND#128:STAT:LDA#0:LDX#16:ASLP:ROLP+1:ASLQ:LSRQ:.DVL2 ROLA:CMPQ:BCCP%+4:SBCQ:ROLP:ROLP+1:DEX:BNEDVL2:LDAP:ORAT:RTS\n 9000]:PRINT\"F d,\";\n 9710IFZ>4OSCLI(\"S.ELTF \"+STR$~W%+\" \"+STR$~O%+\" \"+STR$~L%+\" \"+STR$~H%)\n 9720GOTO14\n10200DEFFNS(A$):N%=LEN(A$)DIV2:FORI%=0TON%-1:I%?O%=EVAL(\"&\"+MID$(A$,2*I%+1,2)):NEXT:P%=P%+N%:O%=O%+N%:=\"\"\n\n"
  },
  {
    "path": "1-source-files/original-sources/$.ELITEG.inf",
    "content": "$.ELITEG  000000 000000 002EDB\n"
  },
  {
    "path": "1-source-files/original-sources/$.ELITEG.txt",
    "content": "    1GOTO20\n    2*L.ELITEB\n    3GOTO20\n    4*L.ELITEA\n    6*L.ELITEC\n    7GOTO20\n    8*L.ELITED\n    9GOTO20\n   10*L.ELITEE\n   11GOTO20\n   12*L.ELITEF\n   13GOTO20\n   14*L.ELITEG\n   20REM ELITE <G>\n  100H%=L%+P%-C%:O%=W%\n 1000[OPTZ\n 7000.SHPPT JSREE51:JSRPROJ:ORAK3+1:BNEnono:LDAK4:CMP#Y*2-2:BCSnono:LDY#2:jsrShpt:ldy#6:ldaK4:ADC#1:jsrShpt:LDA#8:ORAXX1+31:STAXX1+31:LDA#8:JMPLL81+2:PLA:PLA:.nono lda#&F7:andXX1+31:staXX1+31:RTS\n 7010.Shpt STA(XX19),Y:iny:iny:STA(XX19),Y:LDAK3:DEY:STA(XX19),Y:ADC#3:BCSnono-2:dey:dey:STA(XX19),Y:rts\n 8040.LL5 \\2BSQRT Q=SQR(RQ)\n 8045LDYR:LDAQ:STAS:LDX#0:STXQ:LDA#8:STAT:.LL6 CPXQ:BCCLL7:BNELL8:CPY#&40:BCCLL7:.LL8 TYA:SBC#&40:TAY:TXA:SBCQ:TAX:.LL7 ROLQ:ASLS:TYA:ROLA:TAY:TXA:ROLA:TAX:ASLS:TYA:ROLA:TAY:TXA:ROLA:TAX:DECT:BNELL6:RTS\n 8065.LL28 \\BFRDIV R=A*256/Q\n 8070CMPQ:BCSLL2:LDX#254:STXR:.LL31 ASLA:BCSLL29:CMPQ:BCCP%+4:SBCQ:ROLR:BCSLL31:RTS:.LL29 SBCQ:SEC:ROLR:BCSLL31:RTS:.LL2 LDA#FF:STAR:RTS\n 8085.LL38 \\BADD(S)A=R+Q(SA)\n 8090EORS:BMILL39:LDAQ:CLC:ADCR:RTS:.LL39 LDAR:SEC:SBCQ\n 8095BCCP%+4:CLC:RTS:PHA:LDAS:EOR#128:STAS:PLA:EOR#255:ADC#1:RTS\n 8100.LL51 \\XX12=XX15.XX16\n 8105LDX#0:LDY#0:.ll51 LDAXX15:STAQ:LDAXX16,X:JSRFMLTU:STAT:LDAXX15+1:EORXX16+1,X:STAS:LDAXX15+2\n 8115STAQ:LDAXX16+2,X:JSRFMLTU:STAQ:LDAT:STAR:LDAXX15+3\n 8120EORXX16+3,X:JSRLL38:STAT:LDAXX15+4:STAQ:LDAXX16+4,X:JSRFMLTU:STAQ:LDAT:STAR:LDAXX15+5:EORXX16+5,X\n 8130JSRLL38:STAXX12,Y:LDAS:STAXX12+1,Y:INY:INY:TXA:CLC:ADC#6:TAX:CMP#17:BCCll51:RTS\n 8132.LL25 JMPPLANET\n 8135.LL9  \\ ENTRY\n 8137LDATYPE:BMILL25\n 8140LDA#31:STAXX4:LDA#32:BITXX1+31:BNEEE28\n 8144BPLEE28:ORAXX1+31:AND#&3F:STAXX1+31:LDA#0:LDY#28:STA(INF),Y:LDY#30:STA(INF),Y:JSREE51:LDY#1:LDA#18:STA(XX19),Y:LDY#7:LDA(XX0),Y:LDY#2:STA(XX19),Y\n 8146\\LDAXX1+32\\AND#&7F\\STAXX1+32:.EE55 INY:JSRDORND:STA(XX19),Y:CPY#6:BNEEE55:.EE28\n 8150LDAXX1+8:.EE49 BPLLL10:.LL14 LDAXX1+31:AND#32:BEQEE51:LDAXX1+31:AND#&F7:STAXX1+31:JMPDOEXP:.EE51\n 8155LDA#8:BITXX1+31:BEQLL10-1:EORXX1+31:STAXX1+31:JMPLL155:\\LL24\n 8165RTS:.LL10\n 8175LDAXX1+7:CMP#&C0:BCSLL14:LDAXX1:CMPXX1+6:LDAXX1+1:SBCXX1+7:BCSLL14:LDAXX1+3:CMPXX1+6:LDAXX1+4:SBCXX1+7:BCSLL14\n 8205LDY#6:LDA(XX0),Y:TAX:LDA#255:STAXX3,X:STAXX3+1,X\n 8215LDAXX1+6:STAT:LDAXX1+7:LSRA:RORT:LSRA:RORT:LSRA:RORT:LSRA:BNELL13:LDAT:RORA:LSRA:LSRA:LSRA:STAXX4\n 8225BPLLL17:.LL13 LDY#13:LDA(XX0),Y:CMPXX1+7:BCSLL17:LDA#32:ANDXX1+31:BNELL17:JMPSHPPT:.LL17\n 8275LDX#5:.LL15 LDAXX1+21,X:STAXX16,X:LDAXX1+15,X:STAXX16+6,X:LDAXX1+9,X:STAXX16+12,X:DEX:BPLLL15\n 8290LDA#197 \\NORM:STAQ:LDY#16:.LL21 LDAXX16,Y:ASLA:LDAXX16+1,Y\n 8295ROLA:JSRLL28:LDXR:STXXX16,Y:DEY:DEY:BPLLL21\n 8300LDX#8:.ll91 LDAXX1,X:STAXX18,X:DEX:BPLll91\n 8315LDA#255:STAXX2+15\n 8320LDY#12:LDAXX1+31:AND#32:BEQEE29:LDA(XX0),Y:LSRA:LSRA:TAX:LDA#FF:.EE30 STAXX2,X:DEX:BPLEE30:INX:STXXX4:.LL41 JMPLL42:.EE29 LDA(XX0),Y:BEQLL41:STAXX20\n 8330\\DtProd^XX2\n 8335LDY#18:LDA(XX0),Y:TAX:LDAXX18+7:.LL90 TAY:BEQLL91:INX:LSRXX18+4:RORXX18+3:LSRXX18+1:RORXX18:LSRA:RORXX18+6:TAY:BNELL90+3:.LL91 STXXX17:LDAXX18+8\n 8350STAXX15+5:LDAXX18:STAXX15:LDAXX18+2:STAXX15+1:LDAXX18+3:STAXX15+2:LDAXX18+5:STAXX15+3:LDAXX18+6:STAXX15+4:JSRLL51:LDAXX12:STAXX18:LDAXX12+1:STAXX18+2:LDAXX12+2\n 8365STAXX18+3:LDAXX12+3:STAXX18+5:LDAXX12+4:STAXX18+6:LDAXX12+5:STAXX18+8\n 8375LDY#4:LDA(XX0),Y:CLC:ADCXX0:STAV:LDY#17:LDA(XX0),Y:ADCXX0+1:STAV+1:LDY#0\n 8385.LL86 LDA(V),Y:STAXX12+1:AND#31:CMPXX4:BCSLL87\n 8390TYA:LSRA:LSRA:TAX:LDA#255:STAXX2,X:TYA:ADC#4\n 8395TAY:JMPLL88:.LL87 LDAXX12+1:ASLA:STAXX12+3:ASLA:STAXX12+5\n 8400INY:LDA(V),Y:STAXX12:INY:LDA(V),Y:STAXX12+2:INY:LDA(V),Y\n 8405STAXX12+4:LDXXX17:CPX#4:BCCLL92:.LL143 \n 8410\\Face offset<<PV\n 8415LDAXX18:STAXX15:LDAXX18+2:STAXX15+1:LDAXX18+3:STAXX15+2:LDAXX18+5:STAXX15+3:LDAXX18+6:STAXX15+4:LDAXX18+8:STAXX15+5\n 8425JMPLL89:.ovflw LSRXX18:LSRXX18+6:LSRXX18+3:LDX#1:.LL92 LDAXX12:STAXX15:LDAXX12+2:STAXX15+2:LDAXX12+4\n 8430.LL93 DEX:BMILL94:LSRXX15:LSRXX15+2:LSRA:DEX:BPLLL93+3\n 8435.LL94 STAR:LDAXX12+5:STAS:LDAXX18+6:STAQ:LDAXX18+8:JSRLL38:BCSovflw\n 8440STAXX15+4:LDAS:STAXX15+5\n 8450LDAXX15:STAR:LDAXX12+1:STAS\n 8455LDAXX18:STAQ:LDAXX18+2:JSRLL38:BCSovflw:STAXX15:LDAS:STAXX15+1\n 8460LDAXX15+2:STAR:LDAXX12+3:STAS:LDAXX18+3:STAQ:LDAXX18+5\n 8465JSRLL38:BCSovflw:STAXX15+2:LDAS:STAXX15+3\n 8470.LL89 LDAXX12:STAQ:LDAXX15:JSRFMLTU:STAT:LDAXX12+1\n 8475EORXX15+1:STAS:LDAXX12+2:STAQ:LDAXX15+2:JSRFMLTU:STAQ\n 8480LDAT:STAR:LDAXX12+3:EORXX15+3:JSRLL38:STAT:LDAXX12+4\n 8485STAQ:LDAXX15+4:JSRFMLTU:STAQ:LDAT:STAR:LDAXX15+5\n 8490EORXX12+5:JSRLL38:PHA:TYA:LSRA:LSRA:TAX:PLA\n 8500BITS:BMIP%+4:LDA#0:STAXX2,X:INY:.LL88 CPYXX20:BCSLL42:JMPLL86\n 8501.LL42 \\DO nodeX-Ycoords\n 8506\\TrnspMat:LDYXX16+2:LDXXX16+3:LDAXX16+6:STAXX16+2:LDAXX16+7:STAXX16+3:STYXX16+6:STXXX16+7\n 8508LDYXX16+4:LDXXX16+5:LDAXX16+12:STAXX16+4:LDAXX16+13\n 8509STAXX16+5:STYXX16+12:STXXX16+13\n 8510LDYXX16+10:LDXXX16+11:LDAXX16+14:STAXX16+10:LDAXX16+15\n 8511STAXX16+11:STYXX16+14:STXXX16+15\n 8518LDY#8:LDA(XX0),Y:STAXX20\n 8520LDAXX0:CLC:ADC#20:STAV:LDAXX0+1:ADC#0:STAV+1:LDY#0:STYCNT\n 8525.LL48 STYXX17:LDA(V),Y:STAXX15:INY:LDA(V),Y:STAXX15+2:INY\n 8530LDA(V),Y:STAXX15+4:INY:LDA(V),Y:STAT:AND#31:CMPXX4:BCCLL49-3:INY:LDA(V),Y:STAP:AND#15:TAX:LDAXX2,X\n 8540BNELL49:LDAP:LSRA:LSRA:LSRA:LSRA:TAX:LDAXX2,X:BNELL49:INY:LDA(V),Y:STAP:AND#15:TAX:LDAXX2,X:BNELL49:LDAP:LSRA:LSRA:LSRA:LSRA:TAX:LDAXX2,X:BNELL49:JMPLL50\n 8545\\\"\n 8555.LL49 LDAT:STAXX15+1:ASLA:STAXX15+3:ASLA:STAXX15+5\n 8560JSRLL51:LDAXX1+2:STAXX15+2:EORXX12+1:BMILL52:CLC:LDAXX12\n 8565ADCXX1:STAXX15:LDAXX1+1:ADC#0:STAXX15+1:JMPLL53\n 8570.LL52 LDAXX1:SEC:SBCXX12:STAXX15:LDAXX1+1:SBC#0:STAXX15+1\n 8575BCSLL53:EOR#FF:STAXX15+1:LDA#1:SBCXX15:STAXX15\n 8580BCCP%+4:INCXX15+1:LDAXX15+2:EOR#128:STAXX15+2\n 8585.LL53 LDAXX1+5:STAXX15+5:EORXX12+3:BMILL54:CLC:LDAXX12+2\n 8590ADCXX1+3:STAXX15+3:LDAXX1+4:ADC#0:STAXX15+4:JMPLL55\n 8595.LL54 LDAXX1+3:SEC:SBCXX12+2:STAXX15+3:LDAXX1+4:SBC#0\n 8600STAXX15+4:BCSLL55:EOR#255:STAXX15+4:LDAXX15+3:EOR#255:ADC#1\n 8605STAXX15+3:LDAXX15+5:EOR#128:STAXX15+5:BCCLL55:INCXX15+4\n 8610.LL55 LDAXX12+5:BMILL56:LDAXX12+4:CLC:ADCXX1+6:STAT\n 8615LDAXX1+7:ADC#0:STAU:JMPLL57\n 8620.LL61 LDXQ:BEQLL84:LDX#0:.LL63 LSRA:INX:CMPQ:BCSLL63\n 8625STXS:JSRLL28:LDXS:LDAR:.LL64 ASLA:ROLU:BMILL84:DEX:BNELL64:STAR:RTS:.LL84 LDA#50:STAR:STAU:RTS\n 8635.LL62 LDA#128:SEC:SBCR:STAXX3,X:INX:LDA#0:SBCU:STAXX3,X:JMPLL66\n 8645.LL56 LDAXX1+6:SEC:SBCXX12+4:STAT:LDAXX1+7:SBC#0:STAU\n 8650BCCLL140:BNELL57:LDAT:CMP#4:BCSLL57:.LL140 LDA#0:STAU\n 8655LDA#4:STAT:.LL57 LDAU:ORAXX15+1:ORAXX15+4:BEQLL60:LSRXX15+1:RORXX15:LSRXX15+4:RORXX15+3:LSRU:RORT:JMPLL57\n 8665.LL60 LDAT:STAQ:LDAXX15:CMPQ:BCCLL69:JSRLL61:JMPLL65\n 8670.LL69 JSRLL28:.LL65 LDXCNT:LDAXX15+2:BMILL62:LDAR\n 8675CLC:ADC#128:STAXX3,X:INX:LDAU:ADC#0:STAXX3,X\n 8680.LL66 TXA:PHA:LDA#0:STAU:LDAT:STAQ:LDAXX15+3:CMPQ:BCCLL67\n 8685JSRLL61:JMPLL68:.LL70 LDA#Y:CLC:ADCR:STAXX3,X:INX\n 8690LDA#0:ADCU:STAXX3,X:JMPLL50\n 8695.LL67 JSRLL28:.LL68 PLA:TAX:INX:LDAXX15+5:BMILL70:LDA#Y\n 8700SEC:SBCR:STAXX3,X:INX:LDA#0:SBCU:STAXX3,X\n 8705.LL50 CLC:LDACNT:ADC#4:STACNT:LDAXX17:ADC#6:TAY:BCSLL72\n 8706\\\"\n 8710CMPXX20:BCSLL72:JMPLL48:.LL72 LDAXX1+31:AND#32:BEQEE31:LDAXX1+31:ORA#8:STAXX1+31:JMPDOEXP:.EE31\n 8715LDA#8:BITXX1+31:BEQLL74:JSRLL155:LDA#8\n 8725.LL74 ORAXX1+31:STAXX1+31\n 8743LDY#9:LDA(XX0),Y:STAXX20\n 8744LDY#0:STYU:STYXX17:INCU:BITXX1+31:BVCLL170:LDAXX1+31:AND#&BF:STAXX1+31\n 8745LDY#6:LDA(XX0),Y:TAY:LDXXX3,Y:STXXX15:INX:BEQLL170:LDXXX3+1,Y:STXXX15+1:INX:BEQLL170:LDXXX3+2,Y:STXXX15+2\n 8750LDXXX3+3,Y:STXXX15+3:LDA#0:STAXX15+4:STAXX15+5:STAXX12+1:LDAXX1+6:STAXX12\n 8752LDAXX1+2:BPLP%+4:DECXX15+4:JSRLL145:BCSLL170:LDYU\n 8753LDAXX15:STA(XX19),Y:INY:LDAXX15+1:STA(XX19),Y:INY:LDAXX15+2:STA(XX19),Y:INY:LDAXX15+3:STA(XX19),Y:INY:STYU:.LL170\n 8755 \\ Calculate new lines\n 8770LDY#3:CLC:LDA(XX0),Y:ADCXX0\n 8775STAV:LDY#16:LDA(XX0),Y:ADCXX0+1:STAV+1:LDY#5:LDA(XX0),Y:STAT1:LDYXX17\n 8785.LL75 LDA(V),Y:CMPXX4:BCCLL78\n 8787INY:LDA(V),Y:INY:STAP:AND#15:TAX:LDAXX2,X:BNELL79:LDAP:LSRA:LSRA:LSRA:LSRA:TAX\n 8788\\\"\n 8790LDAXX2,X:BEQLL78:.LL79 LDA(V),Y\n 8795TAX:INY:LDA(V),Y:STAQ:LDAXX3+1,X:STAXX15+1:LDAXX3,X:STAXX15\n 8800LDAXX3+2,X:STAXX15+2:LDAXX3+3,X:STAXX15+3:LDXQ:LDAXX3,X\n 8805STAXX15+4:LDAXX3+3,X:STAXX12+1:LDAXX3+2,X:STAXX12\n 8810LDAXX3+1,X:STAXX15+5:JSRLL147:BCSLL78\n 8995.LL80 LDYU:LDAXX15:STA(XX19),Y:INY:LDAXX15+1\n 9000STA(XX19),Y:INY:LDAXX15+2:STA(XX19),Y:INY:LDAXX15+3\n 9005STA(XX19),Y:INY:STYU:CPYT1:BCSLL81\n 9010.LL78 INCXX17:LDYXX17:CPYXX20:BCSLL81:LDY#0:LDAV:ADC#4\n 9012\\\"\n 9015STAV:BCCll81:INCV+1:.ll81 JMPLL75\n 9020.LL81 LDAU:LDY#0:STA(XX19),Y\n 9035.LL155\n 9040\\ CLEAR LINEstr\n 9045LDY#0:LDA(XX19),Y:STAXX20:CMP#4:BCCLL118-1:INY\n 9050.LL27 LDA(XX19),Y:STAXX15:INY:LDA(XX19),Y:STAXX15+1\n 9055INY:LDA(XX19),Y:STAXX15+2:INY:LDA(XX19),Y:STAXX15+3\n 9060JSRLL30:INY:CPYXX20:BCCLL27:\\LL82\n 9065RTS:.LL118  \\move XX15,XX15+2 to screen-grad.XX12+2\n 9070LDAXX15+1:BPLLL119:STAS:JSRLL120  \\ X1<0\n 9075TXA:CLC:ADCXX15+2:STAXX15+2:TYA:ADCXX15+3:STAXX15+3\n 9080LDA#0:STAXX15:STAXX15+1:TAX\n 9085.LL119 BEQLL134:STAS:DECS:JSRLL120 \\ X1>255\n 9090TXA:CLC:ADCXX15+2:STAXX15+2:TYA:ADCXX15+3:STAXX15+3\n 9095LDX#FF:STXXX15:INX:STXXX15+1\n 9100.LL134 LDAXX15+3:BPLLL135:STAS:LDAXX15+2:STAR   \\ Y1<0\n 9105JSRLL123:TXA:CLC:ADCXX15:STAXX15:TYA:ADCXX15+1:STAXX15+1\n 9110LDA#0:STAXX15+2:STAXX15+3\n 9115.LL135 \\BNELL139:LDAXX15+2:SEC:SBC#Y*2:STAR     \\ Y1>191\n 9120LDAXX15+3:SBC#0:STAS:BCCLL136:.LL139 JSRLL123:TXA:CLC:ADCXX15\n 9130STAXX15:TYA:ADCXX15+1:STAXX15+1:LDA#Y*2-1:STAXX15+2:LDA#0:STAXX15+3:.LL136 RTS\n 9140\\ YX=SR*M/256\n 9142.LL120 LDAXX15:STAR\n 9145\\.LL120:JSRLL129:PHA:LDXT:BNELL121:.LL122\n 9160LDA#0:TAX:TAY:LSRS:RORR:ASLQ:BCCLL126:.LL125 TXA:CLC\n 9165ADCR:TAX:TYA:ADCS:TAY:.LL126 LSRS:RORR:ASLQ:BCSLL125\n 9170BNELL126:PLA:BPLLL133:RTS\n 9180\\ YX=SR*256/M (M=grad.)\n 9185.LL123 JSRLL129:PHA:LDXT:BNELL122:.LL121\n 9200LDA#255:TAY:ASLA:TAX:.LL130 ASLR:ROLS:LDAS:BCSLL131\n 9205CMPQ:BCCLL132:.LL131 SBCQ:STAS:LDAR:SBC#0:STAR:SEC\n 9210.LL132 TXA:ROLA:TAX:TYA:ROLA:TAY:BCSLL130:PLA:BMILL128\n 9215.LL133 TXA:EOR#FF:\\CLC:ADC#1:TAX:TYA:EOR#FF:ADC#0:TAY:.LL128 RTS\n 9216.LL129 LDXXX12+2:STXQ:LDAS:BPLLL127:LDA#0:SEC:SBCR:STAR:LDAS:PHA:EOR#255:ADC#0:STAS:PLA:.LL127 EORXX12+3:RTS\n 9300.LL145 \\CLIP\n 9305LDA#0:STASWAP\n 9310LDAXX15+5:.LL147 LDX#Y*2-1:ORAXX12+1:BNELL107:CPXXX12\n 9315BCCLL107:LDX#0:.LL107 STXXX13:LDAXX15+1:ORAXX15+3:BNELL83\n 9320LDA#Y*2-1:CMPXX15+2:BCCLL83\n 9325LDAXX13:BNELL108:.LL146 LDAXX15+2\n 9330STAXX15+1:LDAXX15+4:STAXX15+2:LDAXX12:STAXX15+3:CLC:RTS\n 9335.LL109 SEC:RTS:.LL108 LSRXX13:.LL83\n 9340LDAXX13:BPLLL115\n 9345LDAXX15+1:ANDXX15+5:BMILL109:LDAXX15+3:ANDXX12+1:BMILL109\n 9350LDXXX15+1:DEX:TXA:LDXXX15+5:DEX:STXXX12+2:ORAXX12+2\n 9355BPLLL109:LDAXX15+2:CMP#Y*2:LDAXX15+3:SBC#0:STAXX12+2\n 9360LDAXX12:CMP#Y*2:LDAXX12+1:SBC#0:ORAXX12+2:BPLLL109\n 9365.LL115 TYA:PHA:LDAXX15+4:SEC:SBCXX15:STAXX12+2:LDAXX15+5\n 9370SBCXX15+1:STAXX12+3:LDAXX12:SEC:SBCXX15+2:STAXX12+4\n 9375LDAXX12+1:SBCXX15+3:STAXX12+5:EORXX12+3:STAS\n 9380LDAXX12+5:BPLLL110:LDA#0:SEC:SBCXX12+4:STAXX12+4:LDA#0:SBCXX12+5:STAXX12+5\n 9385.LL110 LDAXX12+3:BPLLL111:SEC:LDA#0:SBCXX12+2:STAXX12+2:LDA#0:SBCXX12+3\n 9390\\GETgrad\n 9395.LL111 TAX:BNELL112:LDXXX12+5:BEQLL113:.LL112 LSRA:RORXX12+2\n 9400LSRXX12+5:RORXX12+4:JMPLL111:.LL113 STXT:LDAXX12+2\n 9405CMPXX12+4:BCCLL114:STAQ:LDAXX12+4:JSRLL28\n 9410 \\ Use Y/X grad.\n 9415JMPLL116:.LL114 LDAXX12+4:STAQ:LDAXX12+2:JSRLL28\n 9420 \\ Use X/Y grad.\n 9425DECT:.LL116 LDAR:STAXX12+2:LDAS:STAXX12+3\n 9430LDAXX13:BEQLL138:BPLLLX117:.LL138 JSRLL118\n 9435LDAXX13:BPLLL124\n 9440.LL117 LDAXX15+1:ORAXX15+3:BNELL137:LDAXX15+2:CMP#Y*2\n 9445BCSLL137:.LLX117 LDXXX15:LDAXX15+4:STAXX15:STXXX15+4:LDAXX15+5\n 9450LDXXX15+1:STXXX15+5:STAXX15+1:LDXXX15+2:LDAXX12:STAXX15+2\n 9455STXXX12:LDAXX12+1:LDXXX15+3:STXXX12+1:STAXX15+3:JSRLL118\n 9460DECSWAP\n 9465.LL124 PLA:TAY:JMPLL146:.LL137 PLA:TAY:SEC:RTS\n 9520]\n 9530F%=P%:PRINT\"G d.\"\n 9710IFZ>4OSCLI(\"SAVE ELTG \"+STR$~W%+\" \"+STR$~O%+\" \"+STR$~L%+\" \"+STR$~H%)\n 9720IFZ=4GOTO4\n 9730 PRINT~C% F% S%,D%-F%\n"
  },
  {
    "path": "1-source-files/original-sources/$.ELITES.inf",
    "content": "$.ELITES  000000 000000 002B49\n"
  },
  {
    "path": "1-source-files/original-sources/$.ELITES.txt",
    "content": "    1 DISC=TRUE:PROT=(NOT DISC)\n    5REM Source Code for ELITE  (the loader)\n    7MODE7\n    8HIMEM=&4000:CODE=&4000:DIMTEMP%256\n   10 IF NOT DISC THEN LOD%=&F1F ELSE LOD%=&1100\n   14C%=&F40:S%=C%:L%=LOD%+&28:D%=&563A:LC%=&6000-C%:svn=&7FFD:len1=15:len2=18:len=len1+len2\n   15LE%=&B00:  REM  Move Mover to here while CODE loading\n   16LL%=&E00+(DISC AND&300): REM Where this loader loads\n   20MOS=S%+8:TRTB%=4:NETV=&224\n 1000OSWRCH=&FFEE:OSBYTE=&FFF4:OSWORD=&FFF1:SCLI=&FFF7:IRQ1V=&204:osprnt=&234\n 1010ZP=&70:P=&72:Q=&73:YY=&74:T=&75:sc=&76:BLPTR=&78:V219=&7A:K3=&80:BLCNT=&81:BLN=&83:EXCN=&85\n 1020FF=&FF\n 1030VIA=&FE40:USVIA=VIA:VSCAN=57-1:VEC=&7FFE\n 2000OSCLI(\"L.:0.WORDS9 \"+STR$~CODE)\n 2010OSCLI(\"L.:0.DIALSHP \"+STR$~(CODE+&400))\n 2020OSCLI(\"L.:2.P.ELITE \"+STR$~(CODE+&C00))\n 2030OSCLI(\"L.:2.P.A-SOFT \"+STR$~(CODE+&D00))\n 2040OSCLI(\"L.:2.P.(C)ASFT \"+STR$~(CODE+&E00))\n 2050REMOSCLI(\"L.:2.P.NAME$ \"+STR$~(CODE+&E00))\n 3000FORZ=4TO6STEP2\n 3010P%=LL%+&400+&800+&300:O%=CODE+&400+&800+&300\n 3012[OPTZ:.run JMPENTRY:]\n 3015RESTORE:READN%\n 3020B%=P%:FORI%=0TON%-1:READA:PROCP(A):NEXT\n 3100E%=P%:FORI%=1TO4:FORJ%=1TO14:READA:PROCP(A):NEXT,\n 4000[OPTZ:.swine LDA#&7F:STA&FE4E:JMP(&FFFC)\n 4010\\ This bit runs where it loads\n 4900.OSB LDY#0:JMPOSBYTE:EQUS\"R.ELITEcode\":EQUB13:EQUS\"By D.Braben/I.Bell\":EQUB13:EQUB&B0:.oscliv EQUW&FFF7:.David9 EQUW David5:CLD:.David23 EQUW (512-len)\n 4910.doPROT1 LDY#&DB:STYTRTB%:LDY#&EF \\0.1 look-up keys:STYTRTB%+1:LDY#2:STYV219+1:STAPROT1-255,X:LDY#&18:STYV219+1,X:RTS:.MHCA EQUB&CA:.David7 BCCIan1\n 5000.ENTRY SEI:CLD:]IF NOT DISC THEN[OPTZ:LDA#0:LDX#FF:JSROSBYTE:TXA:BEQOS100:LDY&FFB6:LDA&FFB7:STAZP:LDA&FFB8:STAZP+1:DEY:.ABCDEFG LDA(ZP),Y:STA&200,Y:DEY:BPLABCDEFG:.OS100:]IF0ELSE:[OPTZ\n 5002LDA#&7F:STA&FE4E:STA&FE6E:LDA&FFFC:STA&200:STA&202:STA&206:STA&220:LDA&FFFD:STA&201:STA&203:STA&207:STA&221 \\ Cold reset (Power on) on BRK,USER,& unrecog IRQ\n 5003LDX#&2F-2:.purge LDA&202,X:ORA#&C0:STA&202,X:DEX:DEX:BPLpurge\n 5004LDA#&60:STA&232:LDA#2:STANETV+1:LDA#&32:STANETV \\Knock out NETVEC\n 5005LDA#32:EQUB&2C:.Ian1 BNEDavid3:STADavid2:LSRA:LDX#3:STXBLPTR+1:STXBLN+1:STXEXCN+1:DEX:JSROSBYTE \\ADC\n 5006EQUB&2C:.FRED1 BNEDavid7\n 5007LDX#255:LDA#&48:JSRdoPROT1:LDA#144:JSROSB \\TV\n 5008LDA#247:LDX#0:JSROSB \\BREAK vec\n 5009\\LDA#&81\\LDY#FF\\LDX#1\\JSROSBYTE\\TXA\\BPLOS01 \\Damn 0.1\n 5010LDA#190:LDX#8:JSROSB \\8bitADC\n 5012EQUB&2C:.David8 BNEFRED1\n 5015LDA#&8F:LDX#&C:LDY#FF:JSROSBYTE \\ claim NMIs\n 5030LDA#13:.abrk LDX#0:JSROSB \\otput bffer\n 5050LDA#225:LDX#128:JSROSB \\fn keys\n 5055LDA#172:LDX#0:LDY#255:JSROSBYTE:STXTRTB%:STYTRTB%+1 \\int-ascii table\n 5058LDA#200:LDX#3:JSROSB:]IF PROT AND NOT DISC THEN[OPTZ:CPX#3:BNEabrk+1 \\Clear memory on BREAK :]\n 5059[OPTZ\n 5060LDA#13:LDX#2:JSROSB \\kybrd buffer\n 5062.OS01\n 5065LDX#FF:TXS:INX:.David3 LDABEGIN%,X:.PROT1 INY \\PHA:INX:CPX#len:BNEDavid8 \\^stack\n 5070LDA#(B% MOD256):STAZP:LDA#&C8:STAPROT1:LDA#(B% DIV256):STAZP+1:LDY#0:.LOOP LDA(ZP),Y:JSROSWRCH:INY:CPY#N%:BNELOOP \\set up pokey-mode-4\n 5080LDA#1:TAX:TAY:STA(V219),Y:LDA#4:JSROSB \\cursor\n 5090LDA#9:LDX#0:JSROSB \\flashing\n 5095LDA#&6C:EORcrunchit:STAcrunchit\n 5101EQUS FNE(0):EQUS FNE(1):EQUS FNE(2):EQUS FNE(3) \\envelopes\n 5103\\\n 5110LDX#4:STXP+1:LDA#(LL%DIV256):STAZP+1:LDY#0:LDA#256-len1:STA(V219-4,X):STYZP:STYP:JSRcrunchit \\Move WORDS9 to &400\n 5115LDX#1:LDA#((LL%DIV256)+&C):STAZP+1:LDA#&63:STAP+1:LDY#0:JSRcrunchit:LDX#1:LDA#((LL%DIV256)+&D):STAZP+1:LDA#&61:STAP+1:LDY#0:JSRcrunchit:LDX#1:LDA#((LL%DIV256)+&E):STAZP+1:LDA#&76:STAP+1:LDY#0:JSRcrunchit\n 5117JSRPLL1 \\draw Saturn\n 5120LDX#8:LDA#((LL%DIV256)+4):STAZP+1:LDA#&78:STAP+1:LDY#0:STYZP:STYBLCNT:STYP:JSRcrunchit \\Move DIALSHP to &7800\n 5130LDX#(3-(DISC AND1)):LDA#(UU%DIV256):STAZP+1:LDA#(UU%MOD256):STAZP:LDA#(LE%DIV256):STAP+1:LDY#0:STYP:JSRcrunchit \\Move Part of this program to LE%\n 5135STYDavid3-2:\\LDY#0:.David2 EQUB&AC:EQUW&FFD4 \\JSR&FFD4:.LBLa LDAC%,X:EOR#&A5:STAC%,X:DEX:BNELBLa:JMP(C%+&CF):.swine2 jmpswine:EQUW&4CFF:.crunchit BRK:EQUW David23:.RAND EQUD &6C785349:.David5 INY:CPY#(ENDBLOCK-BLOCK):BNEDavid2\n 5140SEI:LDA#&C2:STAVIA+&E:LDA#&7F:STA&FE6E:LDAIRQ1V:STAVEC:LDAIRQ1V+1:BPLswine2:STAVEC+1:LDA#(IRQ1 DIV256):STAIRQ1V+1:LDA#(IRQ1 MOD256):STAIRQ1V:LDA#VSCAN:STAUSVIA+5:CLI \\ INTERRUPTS NOW OK\n 5145:] IF DISC THEN [OPTZ:LDA#&81:STA&FE4E:LDY#20:JSROSBYTE:LDA#1:STA&FE4E:]\n 5146[OPTZ\n 5190RTS  \\ENTRY2 on stack already\n 5210.PLL1 LDAVIA+4:STARAND+1:JSRDORND:JSRSQUA2:STAZP+1:LDAP:STAZP:JSRDORND:STAYY:JSRSQUA2:TAX:LDAP:ADCZP:STAZP:TXA:ADCZP+1:BCSPLC1\n 5220STAZP+1:LDA#1:SBCZP:STAZP:LDA#&40:SBCZP+1:STAZP+1:BCCPLC1:JSRROOT:LDAZP:LSRA:TAX:LDAYY:CMP#128:RORA:JSRPIX\n 5230.PLC1 DECCNT:BNEPLL1:DECCNT+1:BNEPLL1:LDX#&C2:STXEXCN\n 5240.PLL2 JSRDORND:TAX:JSRSQUA2:STAZP+1:JSRDORND:STAYY:JSRSQUA2:ADCZP+1:CMP#&11:BCCPLC2:LDAYY:JSRPIX\n 5250.PLC2 DECCNT2:BNEPLL2:DECCNT2+1:BNEPLL2:LDXMHCA:STXBLPTR:LDX#&C6:STXBLN\n 5260.PLL3 JSRDORND:STAZP:JSRSQUA2:STAZP+1:JSRDORND:STAYY:JSRSQUA2:STAT\n 5270ADCZP+1:STAZP+1:LDAZP:CMP#128:RORA:CMP#128:RORA:ADCYY:TAX:JSRSQUA2:TAY:ADCZP+1\n 5280BCSPLC3:CMP#&50:BCSPLC3:CMP#&20:BCCPLC3:TYA:ADCT:CMP#&10:BCSPL1:LDAZP:BPLPLC3:.PL1 LDAYY:JSRPIX\n 5290.PLC3 DECCNT3:BNEPLL3:DECCNT3+1:BNEPLL3\n 5300.DORND LDARAND+1:TAX:ADCRAND+3:STARAND+1:STXRAND+3:LDARAND:TAX:ADCRAND+2:STARAND:STXRAND+2:RTS\n 5320.SQUA2 BPLSQUA:EOR#FF:CLC:ADC#1\n 5330.SQUA STAQ:STAP:LDA#0:LDY#8:LSRP:.SQL1 BCCSQ1:CLC:ADCQ:.SQ1 RORA:RORP:DEY:BNESQL1:RTS\n 5340.PIX TAY:EOR#128:LSRA:LSRA:LSRA:ORA#&60:STAZP+1:TXA:EOR#128:AND#&F8:STAZP:TYA:AND#7:TAY:TXA:AND#7:TAX\n 5350LDATWOS,X:ORA(ZP),Y:STA(ZP),Y:RTS\n 5360.TWOS EQUD &10204080:EQUD&01020408\n 5370.CNT EQUW&500:.CNT2 EQUW &1DD:.CNT3 EQUW &500\n 5380.ROOT LDYZP+1:LDAZP:STAQ:LDX#0:STXZP:LDA#8:STAP:.LL6 CPXZP:BCCLL7:BNELL8:CPY#&40:BCCLL7:.LL8 TYA:SBC#&40:TAY:TXA:SBCZP:TAX:.LL7 ROLZP:ASLQ:TYA:ROLA:TAY:TXA:ROLA:TAX:ASLQ:TYA:ROLA:TAY:TXA:ROLA:TAX:DECP:BNELL6:RTS\n 5390.BEGIN% EQUB(David9 DIV256):EQUB(David9 MOD256):EQUB&6C \\JMP:EQUB(TUT DIV256):EQUB(TUT MOD256):EQUB&99 \\STA,Y:EQUB(TUT DIV256):EQUB(TUT MOD256):EQUB&59 \\EOR,Y:PHA:EQUB((BLOCK)DIV256):EQUB((BLOCK)MOD256):EQUB&B9 \\LDA,Y:PLA:PLA\n 5394.DOMOVE RTS:EQUW&D0EF \\BNEMVDL:DEX:EQUBZP+1:INCP+1:EQUB&E6 \\INCP+1 INCZP+1:EQUW&D0F6 \\BNEMVDL:DEY:EQUBP:EQUB&91 \\STA(),Y:EQUB(OSB DIV256):EQUB(OSB MOD256):EQUB&59 \\EOR:EQUBZP:EQUB&B1 \\LDA(),Y        \\ 18 Bytes ^ Stack\n 5400.UU%:]:Q%=P%-LE%:P%=LE%:[OPTZ\n 5450.CHECKbyt BRK:.MAINSUM EQUB&CB:EQUB0:.FOOLV EQUW FOOL:.CHECKV EQUWLOD%+1\n 5460.block1 EQUD&A5B5E5F5:EQUD&26366676:EQUD&8494C4D4:.block2 EQUD&A0B0C0D0:EQUD&8090E0F0:EQUD&27376777 \\ Colours for interrupts\n 5500.TT26\\ PRINT  Please tidy this up!\n 5510STAK3:TYA:PHA:TXA:PHA\n 5520.rr LDAK3:CMP#7:BEQR5:CMP#32:BCSRR1:CMP#13:BEQRRX1:INCYC:.RRX1 LDX#7:STXXC:BNERR4\n 5530.RR1\n 5540LDX#&BF:ASLA:ASLA:BCCP%+4:LDX#&C1:ASLA:BCCP%+3:INX:STAP:STXP+1\n 5550LDAXC:CMP#20:BCCNOLF:LDA#7:STAXC:INCYC:.NOLF ASLA:ASLA:ASLA:STAZP:INCXC:LDAYC:CMP#19:BCCRR3:LDA#7:STAXC:lda#&65:stasc+1:ldy#7*8:ldx#14:stysc:lda#0:tay:.David1 sta(sc),Y:iny:cpy#14*8:bccDavid1:tay:incsc+1:dex:bplDavid1:lda#5:STAYC\n 5560bnerr:.RR3 ORA#&60:STAZP+1:LDY#7:.RRL1 LDA(P),Y:STA(ZP),Y:DEY:BPLRRL1\n 5570.RR4 PLA:TAX:PLA:TAY:LDAK3:.FOOL RTS\n 5580.R5 lda#7:jsrosprint:JMPRR4\n 5590.TUT  \\EOR here onward:.osprint jmp(osprnt):EQUB&6C:.command jmp(oscliv):.MESS1 EQUS FNLSTR:EQUB13 \\*LOAD ELITEcode\n 5800.ENTRY2 lda&20E:staosprnt:LDA#(TT26 MOD256):STA&20E:LDX#(MESS1 MOD256):lda&20F:staosprnt+1:LDA#(TT26 DIV256):LDY#(MESS1 DIV256):STA&20F \\OSWRCH for loading messages\n 5805JSRAFOOL:JSRcommand:JSR512-len+CHECKER-ENDBLOCK :JSRAFOOL: \\ (Gratuitous JSRs)- LOAD Mcode and checksum it.\n 5810]IF DISC THEN [OPTZ:LDA#140:LDX#12:JSROSBYTE \\*TAPE :]\n 5811[OPTZ\n 5820LDA#0:STAsvn\n 5830LDX#(LC% DIV256):LDA#(L% MOD256):STAZP:LDA#(L% DIV256):STAZP+1:LDA#(C% MOD256):STAP:LDA#(C% DIV256):STAP+1:LDY#0\n 5840.ML1 TYA:EOR(ZP),Y:STA(P),Y:INY:BNEML1:INCZP+1:INCP+1:DEX:BPLML1  \\Move code down (d)\n 5850LDAS%+6:STA&202:LDAS%+7:STA&203:LDAS%+2:STA&20E:LDAS%+3:STA&20F \\BRK,OSWRCH     :RTS - ON STACK :.AFOOL JMP(FOOLV)\n 5852.M2 EQUB2:.VIA2 LDA#4:STA&FE20:LDY#11:.inlp1 LDAblock1,Y:STA&FE21:DEY:BPLinlp1:PLA:TAY:JMP(VEC):.IRQ1:TYA:PHA:]\n 5853IF PROT AND NOT DISC THEN [OPTZ:LDY#0:LDA(BLPTR),Y:BITM2:BNEitdone:EOR#128+3:INCBLCNT:BNEZQK:DECBLCNT:.ZQK STA(BLPTR),Y:LDA#&23:CMP(BLN),Y:BEQP%+4:EOR#17:CMP(EXCN),Y:BEQitdone:DECLOD%:.itdone:]\n 5854[OPTZ:LDAVIA+&D:BITM2:BNELINSCN:AND#64:BNEVIA2:PLA:TAY:JMP(VEC)\n 5856.LINSCN LDA#50:STAUSVIA+4:LDA#VSCAN:STAUSVIA+5:LDA#8:STA&FE20:LDY#11:.inlp2 LDAblock2,Y:STA&FE21:DEY:BPLinlp2:PLA:TAY:JMP(VEC)\n 5857\\\n 5859.BLOCK \\ Pushed onto stack for execution   :EQUW ENTRY2-1:EQUW 512-len+BLOCK-ENDBLOCK+3\n 5860LDAVIA+4:STA1:SEI:LDA#&39:STAVIA+&E:\\LDA#&7F:\\STA&FE6E:\\LDAIRQ1V:\\STAVEC:\\LDAIRQ1V+1:\\STAVEC+1  Already done:LDAS%+4:STAIRQ1V:LDAS%+5:STAIRQ1V+1:LDA#VSCAN:STAUSVIA+5:CLI \\Interrupt vectors\n 5870\\LDA#&81LDY#FFLDX#1JSROSBYTETXAEOR#FFSTAMOS \\FF if MOS0.1 else 0\n 5880\\BMIBLAST:LDY#0:LDA#200:LDX#3:JSROSBYTE:.BLAST \\break,escape\n 5890LDA#(S% DIV256):STAZP+1:LDA#(S% MOD256):STAZP:LDX#&45:LDY#0:TYA:.CHK CLC:ADC(ZP),Y:INY:BNECHK:INCZP+1:DEX:BPLCHK:CMPD%-1:BEQitsOK:.nononono STAS%+1:LDA#&7F:STA&FE4E:JMP(&FFFC):.itsOK JMP(S%)\n 5900.CHECKER LDY#0:LDX#4:STXZP+1:STYZP:TYA:.CHKq CLC:ADC(ZP),Y:INY:BNECHKq:INCZP+1:DEX:BNECHKq:CMPMAINSUM+1:BNEnononono\n 5905TYA:.CHKb CLC:ADCLOD%,Y:INY:CPY#&28:BNECHKb:CMPMAINSUM:BNEnononono\n 5910] IF PROT AND NOT DISC THEN [OPTZ:LDABLCNT:CMP#&4F:BCCnononono:]\n 5920[OPTZ:JMP(CHECKV)\n 6050.ENDBLOCK \\ no more on to stack\n 6060.XC EQUB7:.YC EQUB6\n 7000]\n 7020NEXTZ\n 7040FORI%=0TO ENDBLOCK-BLOCK STEP4:I%!TEMP%=I%!(BLOCK-P%+O%):NEXT:FORI%=0TO ENDBLOCK-BLOCK-1:?(ENDBLOCK-P%+O%-I%-1)=I%?TEMP%:NEXT\n 7042A%=0:FORI%=CODE TOCODE+&3FF:A%=A%+?I%:NEXT:?(MAINSUM-P%+O%+1)=A%\n 7045A%=0:FORI%=LE%-P%+O%+1TOLE%-P%+O%+383:A%=A%+?I%:NEXT:?(CHECKbyt-P%+O%)=A%\n 7050FORI%=0TO ENDBLOCK-BLOCK-1:?(I%+TUT-P%+O%)=(?(I%+TUT-P%+O%))EOR(?(I%+BLOCK-P%+O%)):NEXT\n 7060FORI%=0TO2-(DISC AND1):FORJ%=0TO255STEP4:!(J%+I%*256+UU%-P%-Q%+O%)=(!(J%+I%*256+UU%-P%-Q%+O%))EOR(!(OSB-P%-Q%+O%+J%)):NEXT,\n 7070FORI%=0TO&E:FORJ%=0TO255STEP4:!(J%+I%*256+CODE)=(!(J%+I%*256+CODE))EOR(!(OSB-P%-Q%+O%+J%)):NEXT,\n 7100PRINT\"Memory usage: B00 - \";~P%'~LL%;\" - \";~P%+Q%'\"Stack       :\";len+ENDBLOCK-BLOCK\n 7110INPUT'\"Press <RETURN> to save on drive 0\"A$\n 7120OSCLI(\"S.:0.ELITE \"+STR$~CODE +\" \"+STR$~O% +\" \"+STR$~run +\" \"+STR$~LL%)\n 7200END\n 8000DATA67\n 8100DATA 22,4,28,2,17,15,16\n 8110DATA 23,0, 6,31,0,0,0,0,0,0\n 8112DATA 23,0,12,12,0,0,0,0,0,0\n 8114DATA 23,0,13, 0,0,0,0,0,0,0\n 8116DATA 23,0, 1,32,0,0,0,0,0,0\n 8118DATA 23,0, 2,45,0,0,0,0,0,0\n 8120DATA 23,0,10,32,0,0,0,0,0,0\n 9100DATA1,1,0,111,-8,4,1,8, 8,-2,0,-1,112,44\n 9110DATA2,1,14,-18,-1,44,32,50, 6,1,0,-2,120,126\n 9120DATA3,1,1,-1,-3,17,32,128,1,0,0,-1,1,1\n 9130DATA4,1,4,-8,44,4,6,8,22,0,0,-127,126,0\n10000DEFPROCP(A):?O%=A:O%=O%+1:P%=P%+1:ENDPROC\n10100DEF FNE(I%)\n10110[OPTZ\n10120LDX#((E%+I%*14)MOD256):LDY#((E%+I%*14)DIV256):LDA#8:JSROSWORD\n10130]\n10140=\"\"\n10200DEFFNLSTR:IF DISC THEN =\"L.ELTcode 1100\" ELSE =\"L.ELITEcode F1F\"\n"
  },
  {
    "path": "1-source-files/original-sources/$.FINDSC2.inf",
    "content": "$.FINDSC2 000000 000000 0004FB\n"
  },
  {
    "path": "1-source-files/original-sources/$.FINDSC2.txt",
    "content": "   10 REM FIND SOURCE\n   20 R=&76:S=&77:T=&78:J=&79:Q=&7A:FL=&7B\n   40 ctl=&70:add=&74:OSARGS=&FFDA:page=24:OSWRCH=&FFEE\n   43 FORZ=0TO2STEP2\n   45 P%=&C00\n   50[OPTZ\n   70.ENTRY ldapage:staadd+1:ldy#0:styFL:styadd:lda#1:ldx#ctl:jsrOSARGS:ldy#0:.fn2 lda(ctl),Y:cmp#13:bnefn1\n   75brk:brk:EQUS\"DJB Vs1.1\":.err brk:brk:EQUS(\"Can't Find.\"+CHR$0)\n   80.fn1 lda(add),Y:cmp#13:bnesrch:iny:lda(add),Y:bmiend:stactl+2:iny:lda(add),Y:stactl+3:ldaadd:clc:adc#4:staadd:lda#0:tay:adcadd+1:staadd+1\n   90.srch lda(ctl),Y:cmp#13:beqprt:cmp#ASC\"@\":beqfn6:cmp(add),Y:bnenxt:.fn6 iny:bnesrch:.end ldaFL:beqerr:jmp&FFE7:.nxt ldy#0:incadd:bnefn1:incadd+1:bnefn1\n  500.prt lda#ASC\",\":ldxFL:beqfn4:jsrOSWRCH:.fn4 staFL:ldactl+3:staQ:ldactl+2:staR:ldx#8:stxT:lda#5:staJ:ldx#0:stxS:BEQTT36\n  515.nxt2 bminxt\n  520.TT35 LDAQ:ASLA:TAX:STAQ:LDAR:ROLA:TAY:STAR:LDAS:ROLA:PHA\n  530ASLQ:ROLR:ROLA:ASLQ:ROLR:ROLA:STAS:TXA:ADCQ:STAQ:TYA:ADCR\n  540STAR:PLA:ADCS:STAS:LDX#0:.TT36 LDAQ:CMP#&A0:LDAR:SBC#&86\n  542LDAS:SBC#1:BCCTT37:LDAQ:SBC#&A0:STAQ:LDAR:SBC#&86:STAR\n  543LDAS:SBC#1:STAS:INX:BNETT36:.TT37 TXA\n  545BNETT32:LDAT:BNETT34\n  550.TT32 LDY#0:STYT:CLC:ADC#&30:.TT33 JSROSWRCH\n  560.TT34 ASLT:DECJ:BPLTT35:bminxt2\n  999]NEXT\n10000OSCLI(\"SAVE FIND C00 \"+STR$~P%)\n"
  },
  {
    "path": "1-source-files/original-sources/$.GENTOK.inf",
    "content": "$.GENTOK  000000 000000 000931\n"
  },
  {
    "path": "1-source-files/original-sources/$.GENTOK.txt",
    "content": "   10 REM Generate TOKENS file\n   20 words=OPENOUT\"WORDS9\"\n   30 ONERRORGOTO150\n   40 REPEATREADA$:FORN%=1TOLENA$:CH%=ASCMID$(A$,N%,1)\n   50 IFCH%=ASC\"#\"THENGOSUB100:ELSEbyte=CH%\n   60 BPUT#words,byte EOR35:NEXT:BPUT#words,0\n   70 UNTILFALSE\n  100 byte=VAL(MID$(A$,N%+1,3)):N%=N%+4:RETURN\n  150 IFERR=42THENCLOSE#words:END ELSE CLOSE#words:PRINT\"Line \"ERL:REPORT:END\n  160 DATA#111##224##007#,\" CH#138#T\",GO#150#RNM#146#T,D#145#A#224#,#140##150#NT#153#Y#013#,SYS#156#M,P#158##133#,#139#RKET #166#S,#140#D#136#T#158#AL,AG#158#CULTU#148#L\n  170 DATA#158#CH ,A#150##148##131# ,PO#153# ,#139##140#LY ,UNIT,VIEW ,#154##155##151#TY,#155##138#CHY,FEUDAL,MUL#151#-#162#\n  180 DATA#141#CT#145##153##185#,#251#MUN#157#T,C#159#F#152##144#ACY,DEMOC#148#CY,C#153#P#153##145#E ST#145#E,SHIP,PRODUCT,#149#S#144#,HUM#155#,\"HYP#144#SPA#133# \"\n  190 DATASH#153#T #202#,#141#ST#155##133#,POPUL#145#I#159#,GROSS #186#IVITY,EC#159#OMY,\" #203#YE#138#S\",#156#CH.#129##150#L,\" CASH\",\" #134##118#I#159#\",KNOWN GA#149#XY\n  200 DATAT#138##131#T LOST,#106# JAMM#152#,R#155##131#,LIGHT ,\"#176# OF \",SE#118#,\" C#138#GO\",E#154#IP ,FOOD,#156#X#151#L#137#\n  210 DATA#148##141#OAC#151##150#S,S#149##150#S,LI#154##153#/W#140##137#,LUXU#158##137#,N#138#CO#151#CS,#251#PUT#144#S,#139#CH#140##144#Y,S#156#EL,FI#142##138#MS,FURS\n  220 DATASIL#150#R,GOLD,PL#145##140#UM,#131#M-ST#159##137#,\" #159# \",(Y/N)?,\" CR\",L#138##131#,FI#144##133#,S#139##118#\n  230 DATAG#142##146#,YE#118#OW,R#152#,BLUE,B#149#CK,WHI#156#,SLIMY,BUG-EY#152#,H#153#N#152#,B#159#Y\n  240 DATAF#145#,FURRY,ROD#146#T,FROG,LI#132#RD,LOBST#144#,#134#RD,#188#OID,T#152#DY,SPID#144#\n  250 DATA#171##148##141##136#,COM,#251#M#155#D#144#,\" D#137#TROY#152#\",\" D.B#148##147#N & I.#147##118# (C) 1983\"\n  260 DATA\"#174#  #176##013# #186#   #174# #166# F#153# SA#129##013##010#\",FR#159#T,#142##138#,#158#GHT,#129#FT,#121#LOW#007#,#098##224##252#!,EXT#148# ,PULSE ,\"#147#AM \",FUEL\n  270 DATAM#157#SI#129#,#227##206# BAY,E.C.M.#165#,#102##103##187#S,#102##104##187#S,#105# SCOOPS,#137#CAPE POD,#121#BOMB,GA#149#C#151#C #189#,WHICH,\" P#142#S#146#T\",A#118#,LL,\"#197#:#000#\",#140##251##140#G #106#\n  280 DATA\"#146##144#GY \",\"LOAD \",\"#013##252#'S NAME? \",\"PR#137#S FI#142# #153# SPA#133#,#252#.#013##013#\"\n  290DATA\"---- E L I T E ----\",\" DONE#013#\",\"THE #149##156# #252# HAD #001##013#KI#118#S,& #119#\"\n"
  },
  {
    "path": "1-source-files/original-sources/$.GETBIT.inf",
    "content": "$.GETBIT  000000 000000 0000A1\n"
  },
  {
    "path": "1-source-files/original-sources/$.GETBIT.txt",
    "content": "   10 *LOAD :2.O.NDIALS 7600\n   20 *LOAD O.DIALSHP 6800\n   30 FORJ%=0TO255STEP4:!(J%+&7EC0)=!(J%+&6F00):NEXT\n   40 *SAVE :2.NDIALS 7600 8000\n"
  },
  {
    "path": "1-source-files/original-sources/$.MAKER.inf",
    "content": "$.MAKER   000000 000000 00023F\n"
  },
  {
    "path": "1-source-files/original-sources/$.MAKER.txt",
    "content": "    5 HIMEM=&7A00\n   10  REM Create an ELITE software protected file set on cassette\n   12 ON ERROR GOTO 500\n   20 *DISC\n   35  MODE 7\n   40  IF PAGE<>&7000: PAGE=&7000: CHAIN \":2.MAKER\"\n   50 *LOAD :0.ELITE 1900\n   53 P%=&90:[LDA#13:RTS:]\n   55 V%=!&210 AND&FFFF:?&210=&90:?&211=0  :REM  OSRDCH revectored to RTS\n   60 *:2.LTAPE\n   70 *SAVE ELITE 1900+1500 FFFF1D00 FFFF0E00\n   80 *DISC\n   90 *LOAD :0.ELTcode 1900\n  100 *:2.PROTAPE\n  110 *SAVE ELITEcode 1900+5100 0000 0000\n  500 !&210=(!&210 AND&FFFF0000)+V%:REPORT:PRINT\" on line \"ERL:END\n"
  },
  {
    "path": "1-source-files/original-sources/$.SBLOCK.inf",
    "content": "$.SBLOCK  000000 000000 0003E1\n"
  },
  {
    "path": "1-source-files/original-sources/$.SBLOCK.txt",
    "content": "    5REM Prepare DEFAULT and UNIV and serve with WORDS9\n    7MODE0\n   10NA%=&780:POW=15:K%=&C00:NI%=36\n  100GOSUB 1000\n  110INPUT\"Insert assembly disk and hit RETURN \"A$\n  120*SAVE WORDS9 7400 7800 400 400\n  900END\n 1000*LOAD WORDS9 7400\n 1100FORZ=4TO6STEP2\n 1110O%=&7780:CODE%=O%\n 1200[OPTZ\n 1300.NAME EQUS(\"Default\"):EQUB13\n 1310.QQ0 EQUB20:.QQ1 EQUB173:.QQ21 EQUD&2485A4A:EQUW&B753 \\Base seed\n 1315.CASH EQUD &D0070000\n 1320.QQ14 EQUB70 fuel\n 1330.LASER EQUDPOW:EQUW0:.CRGO EQUB16\n 1350.QQ20 EQUD0:EQUD0:EQUD0:EQUD0 \\cargo\n 1360.ECM EQUB FALSE\n 1370.BST EQUB FALSE\n 1400.BOMB EQUB FALSE\n 1410.GHYP EQUB FALSE\n 1415.ESCP EQUB FALSE\n 1420.NOMSL EQUB 3\n 1425.FIST EQUB FALSE\n 1430.TALLY EQUW 0\n 1440.SAVC EQUB 128\n 1450.CHK EQUB 0\n 1460]\n 1480P%=&7E0:O%=&7780+&60\n 1500FORI%=0TO12:!O%=K%+I%*NI%:O%=O%+2:NEXT\n 1550NEXT\n 1600NB%=CHK-NAME:A%=NB%:FORI%=NB%-1TO0STEP-1\n 1610A%=(A%+(I%?CODE%))EOR(I%?CODE%)\n 1620NEXT:REM?(CODE%+NB%)=A%\n 1700RETURN\n"
  },
  {
    "path": "1-source-files/original-sources/$.SFTPROT.inf",
    "content": "$.SFTPROT 000000 000000 000215\n"
  },
  {
    "path": "1-source-files/original-sources/$.SFTPROT.txt",
    "content": "   10 REM SOFTWARE PROTECTION\n   20 REM USING OSFILE\n   25 FILEV=&212:IRQ2=&206:BFLAG=&3CA:USVIA=&FE60\n   30 P%=&C00:[\n   40.VEC EQUW0\n   50.RESET LDA#1:ORABFLAG:STABFLAG:LDAUSVIA+4:LDA&FC:RTI\n   60.START PHP:PHA:SEI:LDA#192:STAUSVIA+14:LDA#(RESET DIV256):STAIRQ2+1:LDA#(RESET MOD256):STAIRQ2:LDA#64:STAUSVIA+11:LDA#255:STAUSVIA+4:STAUSVIA+5:STAUSVIA+6:STAUSVIA+7:PLA:CLI:PLP:JMP(VEC)\n   90.SET SEI:LDAFILEV:STAVEC:LDAFILEV+1:STAVEC+1:LDA#(START DIV256):STAFILEV+1:LDA#(START MOD256):STAFILEV:CLI:RTS\n  100]\n"
  },
  {
    "path": "1-source-files/original-sources/$.SHPPRTE.inf",
    "content": "$.SHPPRTE 000000 000000 000640\n"
  },
  {
    "path": "1-source-files/original-sources/$.SHPPRTE.txt",
    "content": "    1REM  Prepare DIALSHP and SHIPS\n    2MODE1\n    5D%=&5490\n   10HIMEM=&2000\n   18*LOAD DMPDIAL\n   20READN%:C%=D%:B%=&7F00\n   25READ A$,B$,P,Q,R,S,T,U,V,W:!B%=&7F00+2*N%:B%=B%+2\n   30FORI%=2TON%:READ A$,B$,P,Q,R,S,T,U,V,W:!B%=C%:B%=B%+2:C%=C%+EVAL(\"&\"+B$):NEXT\n   40RESTORE1010:C%=D%\n   45READ A$,B$,P,Q,R,S,T,U,V,W:OSCLI(\"LOAD \"+A$+\" \"+STR$~B%):B%?1=P*P MOD256:B%?2=P*P DIV256:B%?14=Q:B%?15=R:B%?5=S:B%?7=T:B%?19=U:B%?10=V MOD256:B%?11=V DIV256:B%?13=W:B%=B%+EVAL(\"&\"+B$)\n   46P%=B%\n   48[OPT2:.PRXS EQUW1:EQUW250:EQUW4000:EQUW5000:EQUW4000:EQUW7500:EQUW1750:EQUW25000:EQUW10000:EQUW50000:]\n   50FORI%=2TON%:READ A$,B$,P,Q,R,S,T,U,V,W\n   60OSCLI(\"LOAD S.\"+A$+\" \"+STR$~C%):C%?1=P*P MOD256:C%?2=P*P DIV256:C%?14=Q:C%?15=R:C%?5=S:C%?7=T:C%?19=U:C%?10=V MOD256:C%?11=V DIV256:C%?13=W:C%=C%+EVAL(\"&\"+B$)\n   80NEXT:PRINT~D% C% PRXS\n   90INPUT\"Insert assembly disk and hit RETURN\"A$\n  100OSCLI(\"S.SHIPS \"+STR$~D%+\" 6000\")\n  110OSCLI(\"S.DIALSHP 7800 8000\")\n 1000DATA 10\n 1005REMDATA SHIP5,80, 50,75,10,37,26,0\n 1010DATA SHIP3,A8, 65,70,37,61,30,0,50,20\n 1030DATA SHIP1+,DA, 75,100,32,77,42,1,0,23\n 1040DATA SHIP4,12E, 70,90,30,93,34,1,200,25\n 1050DATA SHIP2,F2, 80,200,20,85,46,2,250,40\n 1060DATA CYLON,188, 95,150,28,153,42,3,0,50\n 1065DATA THAARG,11C, 99,240,39,101,38,5,500,55\n 1066DATA SPCSTN,11C, 160,240,0,85,54,6,0,120\n 1070DATA MISSILE,FE, 40,2,44,81,10,0,0,14\n 1075DATA TETRA,54, 16,1,10,25,22,0,0,8\n 1080DATA ASTROID,D6, 80,60,40,65,34,0,5,50\n 2000 REM length,hits rad,energy,vel,4*lines+1,4*(exp nodes)+6,no.missiles,Bounty,Distance at which point\n"
  },
  {
    "path": "1-source-files/original-sources/$.TOKPRI.inf",
    "content": "$.TOKPRI  000000 000000 0004B1\n"
  },
  {
    "path": "1-source-files/original-sources/$.TOKPRI.txt",
    "content": ">LIST\n\r  100GOSUB1000\n\r  110FORA%=96TO125:PRINTA%\" \";:CALLTT27:PRINT:NEXT\n\r  120FORA%=129TO255:PRINTA%\" \";:CALLTT27:PRINT:NEXT\n\r  200END\n\r 1000DIM CODE &1000\n\r 1010FORZ=0TO2STEP2\n\r 1020V=&70:QQ17=&72:?QQ17=0\n\r 1050P%=CODE\n\r 1060[OPTZ\n\r 1100.TT27\\\"Detoken\n\r 1110TAX:BMITT43:CMP#&60:BCSex:LDXQQ17:BEQTT74:BMITT41:BITQQ17:BVSTT46:.TT42\n\r 1120CMP#65:BCCTT44:CMP#&5B:BCSTT44:ADC#32:.TT44 JMPTT26:.TT41 BITQQ17:BVSTT45:CMP#65:BCCTT74:PHA:TXA:ORA#64:STAQQ17:PLA:JMPTT26\n\r 1130.TT45 CPX#255:BEQTT48:CMP#65:BCSTT42:.TT46 PHA:TXA:AND#191:STAQQ17:PLA\n\r 1140.TT74 JMPTT26\n\r 1150.TT43 CMP#160:BCSTT47:AND#127:BEQTT48:ASLA:TAY:LDAQQ16-2,Y\n\r 1160JSRTT27:LDAQQ16-1,Y:CMP#&3F:BEQTT48:JMPTT27\n\r 1170.TT47 SBC#160:.ex TAX:LDA#(QQ18 MOD256):STAV:LDA#(QQ18 DIV256):STAV+1:LDY#0:TXA:BEQTT50\n\r 1180.TT51 LDA(V),Y:BEQTT49:INY:BNETT51:INCV+1:BNETT51:.TT49 INY:BNETT59:INCV+1:.TT59 DEX:BNETT51:.TT50\n\r 1190TYA:PHA:LDAV+1:PHA:LDA(V),Y:EOR#35\n\r 1200JSRTT27:PLA:STAV+1:PLA:TAY:INY:BNETT52:INCV+1:.TT52\n\r 1210LDA(V),Y:BNETT50:.TT48 RTS\n\r 1212.QQ16 EQUS\"LEXEGEZACEBISOUSESARMAINDIREA?ERATENBERALAVETIEDORQUANTEISRION\"\n\r 1220.TT26 JMP&FFEE\n\r 1230.QQ18\n\r 1280]\n\r 1290NEXT\n\r 1300OSCLI(\"LOAD WORDS9 \"+STR$~QQ18)\n\r 1400RETURN\n\r>*SPOOL\n\r"
  },
  {
    "path": "1-source-files/original-sources/$.UNPACK.inf",
    "content": "$.UNPACK  000000 000000 00045D\n"
  },
  {
    "path": "1-source-files/original-sources/$.UNPACK.txt",
    "content": "   10 REM  Unpack an ELITE security number\n   20 REM  This works for either disc or tape copies\n   30 REM  This program is the property of D.Braben & I.Bell\n   40 REM  and MUST NOT BE GIVEN AWAY UNDER ANY CIRCUMSTANCES\n   50 \n   60 INPUT\"ELITE security number \",A$\n   70 B1%=(EVAL(RIGHT$(A$,8)))AND255\n   80 N%=INT((EVALA$)/256)\n   90 B2%=N%AND255:B3%=(N%AND&FF00)/256:B4%=(N%AND&FF0000)/65536\n  100 B%=B4%EOR B2%:IFB%AND128 PRINTCHR$7+'\"  <<< THIS FILE HAS BEEN TAMPERED WITH >>>\"':END\n  110 PRINT'\"File has been used on version(s) for \";\n  120 IFB%AND2 PRINT\"BBC cassette, \";\n  130 IFB%AND4 PRINT\"BBC disc, \";\n  140 IFB%AND8 PRINT\"Electron, \";\n  145 IFB%AND&70 PRINT\"Something else??\";\n  150 PRINT\"only.\"\n  160 B%=B2%EOR B3%\n  170 INPUT\"What CASH does this file have\",C:C%=C*10:IF B%=(C%AND&FF00)/256 PRINT\"Tallies.\" ELSE PRINTCHR$7+'\"MISMATCH.\"'\n  180 B%=B3% EOR B1% EOR&5A:PRINT\"Commander was \";:IFB%>24 PRINT\"One of the ... ELITE.\":RUN\n  190 IFB%>10 PRINT\"Deadly.\":RUN\n  200 IFB%>2 PRINT\"Dangerous.\":RUN\n  210 IFB% PRINT\"Competant.\":RUN\n  220 PRINT\"Competant at most.\":RUN\n"
  },
  {
    "path": "1-source-files/original-sources/A.GENTOK.inf",
    "content": "$.GENTOKA 000000 000000 000B18\n"
  },
  {
    "path": "1-source-files/original-sources/A.GENTOK.txt",
    "content": "   10 REM Generate TOKENS file\n   20 words=OPENOUT\"WORDS9\"\n   30 ONERRORGOTO150\n   40 REPEATREADA$:FORN%=1TOLENA$:CH%=ASCMID$(A$,N%,1)\n   50 IFCH%=ASC\"#\"THENGOSUB100:ELSEbyte=CH%\n   60 BPUT#words,byte EOR35:NEXT:BPUT#words,0\n   70 UNTILFALSE\n  100 byte=VAL(MID$(A$,N%+1,3)):N%=N%+4:RETURN\n  150 IFERR=42THENCLOSE#words:END ELSE CLOSE#words:PRINT\"Line \"ERL:REPORT:END\n  160 DATA#111##017##007#,\" CH#138#T\",GO#150#RNM#146#T,D#145#A#017##003#,#140##150#NT#153#Y#013#,SYS#156#M,P#158##133#,#002# #139#RKET #166#S,#140#D#136#T#158##128#,AG#158#CULTU#148#L\n  170 DATA#158#CH ,A#150##148##131# ,PO#153# ,#139##140#LY ,UNIT,VIEW ,#154##155##151#TY,#155##138#CHY,FEUD#128#,MUL#151#-#162#\n  180 DATA#141#CT#145##153##185#,#251#MUN#157#T,C#159#F#152##144#ACY,DEMOC#148#CY,C#153#P#153##145#E #203##145#E,SHIP,PRODUCT,\" #149#S#144#\",HUM#155# COL#159#I#128#,\"HYP#144#SPA#133# \"\n  190 DATASH#153#T #202##161#,#141##203##155##133#,POPUL#145#I#159#,GROSS #186#IVITY,EC#159#OMY,\" LIGHT YE#138#S\",#156#CH.#129##150#L,\"CASH\",\" #134##118#I#159#\",#122##161##001#\n  200 DATAT#138##131#T LO#203#,#106# JAMM#152#,R#155##131#,ST,\"#176# OF \",SE#118#,\" C#138#GO#006#\",E#154#IP,FOOD,#156#X#151#L#137#\n  210 DATA#148##141#OAC#151##150#S,S#149##150#S,LI#154##153#/W#140##137#,LUXU#158##137#,N#138#CO#151#CS,#251#PUT#144#S,#139#CH#140##144#Y,#117#OYS,FI#142##138#MS,FURS\n  220 DATAM#140##144##128#S,GOLD,PL#145##140#UM,#131#M-#203##159##137#,#128#I#146# #127#S,(Y/N)?,\" CR\",L#138##131#,FI#144##133#,S#139##118#\n  230 DATAG#142##146#,R#152#,YE#118#OW,BLUE,B#149#CK,#022#,SLIMY,BUG-EY#152#,H#153#N#152#,B#159#Y\n  240 DATAF#145#,FURRY,ROD#146#T,FROG,LI#132#RD,LOB#203##144#,#134#RD,HUM#155#OID,FEL#140#E,#140#SECT\n  250 DATA#171##148##141##136#,COM,#251#M#155#D#144#,\" D#137#TROY#152#\",\"BY D.B#148##147#N & I.#147##118#\"\n  260 DATA\"#174#  #176##013# #186#   #174# #166# F#153# SA#129##013##010#\",FR#159#T,#142##138#,#129#FT,#158#GHT,#121#LOW#007#,#099##017##252#!,EXT#148# ,PULSE#187#,\"#147#AM#187#\",FUEL\n  270 DATAM#157#SI#129#,#227##206# BAY,E.C.M.#165#,#102##103#S,#102##104#S,#105# SCOOPS,#137#CAPE POD,#121#BOMB,#121##174#,#124##140#G #215#,#122# #189#,A#118#,LL,\"#197#:#000#\",#140##251##140#G #106#\n  280 DATA\"#146##144#GY \",GA#149#C#151#C,\"#013##252#'S NAME? \",DOCK\n  290DATA#005##129#G#128# #203##145##136#:,\"#252# #004##013##013##013##006##031# #165##009##002##013##189##165##009##003##013#C#159##141##151##159##009#\",I#156#M\n  300DATA\"  LOAD NEW #252# #225##013##013#\",#006##124##152#,#148##151#NG:,\" #159# \",\"#013##008##207#M#146#T:#006#\",C#129##155#,OFF#146#D#144#,FUGI#151##150#,H#138#M#129#SS,MO#203#LY #022#,#172#,#171#,ABO#150# #171#,#251#PET#146#T\n  310DATAD#155##131#RO#136#,DEADLY,\"---- E L I T E ----\",P#142#S#146#T,\"#008#GAME O#150#R\",\"PR#137#S FI#142# #153# SPA#133#,#252#.#013##013#\",\"(C) AC#153#N#135#FT 1984\"\n"
  },
  {
    "path": "1-source-files/original-sources/O.ELITED.inf",
    "content": "$.ELITEDO 000000 000000 002E8C\n"
  },
  {
    "path": "1-source-files/original-sources/O.ELITED.txt",
    "content": "    1GOTO20\n    2*L.ELITEB\n    3GOTO20\n    4*L.ELITEA\n    6*L.ELITEC\n    7GOTO20\n    8*L.ELITED\n    9GOTO20\n   10*L.ELITEE\n   20REM ELITE <D>\n   30H%=L%+P%-C%:O%=W%\n  300[OPTZ\n  700.tnpr pha:LDX#12:CPXQQ29:BCCkg:.Tml ADCQQ20,X:DEX:BPLTml:CMPCRGO:pla:RTS:.kg LDYQQ29:ADCQQ20,Y:cmp#200:pla:rts\n  840.TT20 JSRP%+3:JSRP%+3\n  850.TT54 LDAQQ15:CLC:ADCQQ15+2:TAX:LDAQQ15+1:ADCQQ15+3:TAY\n  860LDAQQ15+2:STAQQ15:LDAQQ15+3:STAQQ15+1:LDAQQ15+5:STAQQ15+3:LDAQQ15+4:STAQQ15+2:CLC:TXA:ADCQQ15+2:STAQQ15+4:TYA:ADCQQ15+3:STAQQ15+5:RTS\n  950.TT146 LDAQQ8:ORAQQ8+1:BNETT63:INCYC:RTS:.TT63 LDA#191:JSRTT68\n  955LDXQQ8:LDYQQ8+1:SEC:JSRpr5:LDA#195:.TT60 JSRTT27:.TTX69 INCYC:.TT69 LDA#128:STAQQ17:.TT67 LDA#13:JMPTT27\n  990.TT70 LDA#173:JSRTT27:JMPTT72:.spc JSRTT27:JMPTT162\n 1000.TT25\\ DATA\n 1010\\LDA#1:JSRTT66-2:LDA#9:STAXC:LDA#163:JSRTT27:JSRNLIN:JSRTTX69:INCYC:JSRTT146:LDA#194\n 1030JSRTT68:LDAQQ3:CLC:ADC#1:LSRA:CMP#2:BEQTT70:LDAQQ3:BCCTT71\n 1040SBC#5:CLC:.TT71 ADC#170:JSRTT27:.TT72 LDAQQ3:LSRA:LSRA:CLC:ADC#168:JSRTT60:LDA#162:JSRTT68:LDAQQ4:CLC:ADC#177:JSRTT60:LDA#196:JSRTT68\n 1070LDXQQ5:INX:CLC:JSRpr2:JSRTTX69:LDA#192:JSRTT68:SEC:LDXQQ6:JSRpr2:LDA#198:JSRTT60:LDA#&28:JSRTT27:LDAQQ15+4:BMITT75:LDA#188:JSRTT27:JMPTT76:.TT75 LDAQQ15+5\n 1110LSRA:LSRA:PHA:AND#7:CMP#3:BCSTT205:ADC#227:JSRspc:.TT205 PLA:LSRA:LSRA:LSRA:CMP#6:BCSTT206:ADC#230:JSRspc:.TT206 LDAQQ15+3:EORQQ15+1:AND#7\n 1116STAQQ19:CMP#6:BCSTT207:ADC#236:JSRspc:.TT207 LDAQQ15+5:AND#3:CLC:ADCQQ19:AND#7:ADC#242:JSRTT27:.TT76 LDA#&53:JSRTT27:LDA#&29:JSRTT60\n 1127LDA#193:JSRTT68:LDXQQ7:LDYQQ7+1:JSRpr6:JSRTT162:LDA#0:STAQQ17:LDA#&4D:JSRTT27:LDA#226:JSRTT60:LDA#250:JSRTT68:LDAQQ15+5:LDXQQ15+3:AND#15:CLC:ADC#11:TAY\n 1150JSRpr5:JSRTT162:LDA#&6B:JSRTT26:LDA#&6D:JMPTT26\n 1200.TT24\n 1210LDAQQ15+1:AND#7:STAQQ3:LDAQQ15+2:LSRA:LSRA:LSRA:AND#7:STAQQ4:LSRA:BNETT77:LDAQQ3:ORA#2:STAQQ3:.TT77 LDAQQ3:EOR#7:CLC:STAQQ5:LDAQQ15+3:AND#3:ADCQQ5:STAQQ5\n 1240LDAQQ4:LSRA:ADCQQ5:STAQQ5:ASLA:ASLA:ADCQQ3:ADCQQ4:ADC#1:STAQQ6:LDAQQ3:EOR#7:ADC#3:STAP:LDAQQ4:ADC#4:STAQ:JSRMULTU:LDAQQ6:STAQ:JSRMULTU:ASLP:ROLA:ASLP:ROLA:ASLP:ROLA:STAQQ7+1:LDAP:STAQQ7:RTS\n 1400.TT22\\Lng Sc\n 1410LDA#64:JSRTT66:LDA#7:STAXC:JSRTT81:LDA#199:JSRTT27:JSRNLIN:LDA#152:JSRNLIN2:JSRTT14\n 1460LDX#0:.TT83 STXXSAV:LDXQQ15+3:LDYQQ15+4:TYA:ORA#&50:STAZZ\n 1470LDAQQ15+1:LSRA:CLC:ADC#24:STAXX15+1:JSRPIXEL:JSRTT20:LDXXSAV:INX:BNETT83:LDAQQ9:STAQQ19:LDAQQ10:LSRA:STAQQ19+1:LDA#4:STAQQ19+2\n 1700.TT15\n 1705LDA#24:LDXQQ11:BPLP%+4:LDA#0:STAQQ19+5:LDAQQ19:SEC:SBCQQ19+2:BCSTT84:LDA#0:.TT84 STAXX15:LDAQQ19:CLC:ADCQQ19+2:BCCP%+4:LDA#FF:STAXX15+2\n 1725LDAQQ19+1:CLC:ADCQQ19+5:STAXX15+1:JSRHLOIN:LDAQQ19+1:SEC:SBCQQ19+2:BCSTT86:LDA#0:.TT86 CLC:ADCQQ19+5:STAXX15+1:LDAQQ19+1:CLC:ADCQQ19+2:ADCQQ19+5:CMP#152:BCCTT87\n 1750LDXQQ11:BMITT87:LDA#151:.TT87 STAXX15+3:LDAQQ19:STAXX15:STAXX15+2:JMPLL30\n 1800.TT126 LDA#104:STAQQ19:LDA#90:STAQQ19+1:LDA#16:STAQQ19+2:JSRTT15:LDAQQ14:STAK:JMPTT128\n 2000.TT14\\Crcl/+\n 2010LDAQQ11:BMITT126:LDAQQ14:LSRA:LSRA:STAK:LDAQQ0:STAQQ19:LDAQQ1:LSRA:STAQQ19+1:LDA#7:STAQQ19+2:JSRTT15:LDAQQ19+1:CLC:ADC#24:STAQQ19+1\n 2300.TT128 LDAQQ19:STAK3:LDAQQ19+1:STAK4:LDX#0:STXK4+1:STXK3+1:\\STXLSX:INX:STXLSP:LDX#2:STXSTP\n 2310JSRCIRCLE2:\\LDA#FFSTALSX:RTS\n 2650.TT219\\Buy\n 2655\\LDA#2:JSRTT66-2:JSRTT163:LDA#128:STAQQ17:\\JSRFLKB:LDA#0:STAQQ29\n 2660.TT220 JSRTT151:LDAQQ25:BNETT224:JMPTT222:.TQ4 LDY#176:.Tc JSRTT162:TYA:JSRprq:.TTX224 JSRdn2:.TT224\n 2671JSRCLYNS:LDA#204:JSRTT27:LDAQQ29:CLC:ADC#208:JSRTT27:LDA#&2F:JSRTT27:JSRTT152:LDA#&3F:JSRTT27:JSRTT67:LDX#0:STXR:LDX#12:STXT1:.TT223\n 2700JSRgnum:BCSTQ4:STAP:JSRtnpr:LDY#206:BCSTc:LDAQQ24:STAQ:JSRGCASH:JSRLCASH:LDY#197:BCCTc\n 2708LDYQQ29:LDAR:PHA:CLC:ADCQQ20,Y:STAQQ20,Y:LDAAVL,Y:SEC:SBCR:STAAVL,Y:PLA:BEQTT222:JSRdn\n 2710.TT222 LDAQQ29:CLC:ADC#5:STAYC:LDA#0:STAXC:INCQQ29:LDAQQ29:CMP#17:BCSBAY2:JMPTT220:.BAY2 LDA#f9:JMPFRCE\n 2750.gnum LDX#0:STXR:LDX#12:STXT1:.TT223 JSRTT217:STAQ:SEC:SBC#&30:BCCOUT:CMP#10:BCSBAY2:STAS:LDAR:CMP#26:BCSOUT:ASLA:STAT:ASLA:ASLA:ADCT:ADCS:STAR:CMPQQ25:BEQTT226:BCSOUT:.TT226 LDAQ:JSRTT26:DECT1:BNETT223:.OUT LDAR:RTS\n 2850.TT208\\Sel\n 2855LDA#4:JSRTT66:LDA#4:STAYC:STAXC:\\JSRFLKB:LDA#205:JSRTT27:LDA#206:JSRTT68\n 2900.TT210\\Crgo\n 2910LDY#0:.TT211 STYQQ29:LDXQQ20,Y:BEQTT212\n 2912TYA:ASLA:ASLA:TAY:LDAQQ23+1,Y:STAQQ19+1\n 2915TXA:PHA:JSRTT69:CLC:LDAQQ29:ADC#208\n 2917JSRTT27:LDA#14:STAXC:PLA:TAX:CLC:JSRpr2:JSRTT152\n 2922LDAQQ11:CMP#4:BNETT212:LDA#205:JSRTT214\n 2923BCCTT212:LDAQQ29:LDX#255:STXQQ17:JSRTT151\n 2925LDYQQ29:LDAQQ20,Y:STAP:LDAQQ24:STAQ:JSRGCASH:JSRMCASH\n 2935LDA#0:LDYQQ29:STAQQ20,Y:STAQQ17\n 2940.TT212 LDYQQ29:INY:CPY#17:BCSP%+5:JMPTT211:LDAQQ11:CMP#4:BNEP%+8:JSRdn2:JMPBAY2:RTS\n 2942.TT213\\Invntry\n 2945LDA#8:JSRTT66:LDA#11:STAXC:LDA#164:JSRTT60:JSRNLIN4:JSRfwl\n 2950LDACRGO:CMP#26:BCCP%+7:LDA#&6B:JSRTT27:JMPTT210\n 2965.TT214 PHA:JSRTT162:PLA:.TT221 JSRTT27:LDA#225:JSRTT27\n 2966JSRTT217:ORA#32:CMP#&79:BEQTT218:LDA#&6E:JMPTT26:.TT218 JSRTT26:SEC:RTS\n 3000.TT16 TXA:PHA:DEY:TYA:EOR#255:PHA:JSRWSCAN:JSRTT103:PLA:STAQQ19+3\n 3010LDAQQ10:JSRTT123:LDAQQ19+4:STAQQ10:STAQQ19+1:PLA\n 3020STAQQ19+3:LDAQQ9:JSRTT123:LDAQQ19+4:STAQQ9:STAQQ19:.TT103\n 3030LDAQQ11:BMITT105:LDAQQ9:STAQQ19:LDAQQ10:LSRA:STAQQ19+1\n 3040LDA#4:STAQQ19+2:JMPTT15\n 3045.TT123 STAQQ19+4:CLC:ADCQQ19+3:LDXQQ19+3:BMITT124:BCCTT125\n 3047RTS:.TT124 BCCTT180:.TT125 STAQQ19+4:.TT180 RTS\n 3050.TT105 LDAQQ9:SEC:SBCQQ0:CMP#38:BCCTT179:CMP#230:BCCTT180\n 3055.TT179 ASLA:ASLA:CLC:ADC#104:STAQQ19\n 3060LDAQQ10:SEC:SBCQQ1:CMP#38:BCCP%+6:CMP#220:BCCTT180\n 3065ASLA:CLC:ADC#90:STAQQ19+1:LDA#8:STAQQ19+2:JMPTT15\n 3300.TT23\\ShrtSc\n 3310LDA#128:JSRTT66:LDA#7:STAXC:LDA#190:JSRNLIN3:JSRTT14:JSRTT103:JSRTT81\n 3349LDA#0:STAXX20:LDX#24:.EE3 STAINWK,X:DEX:BPLEE3\n 3350.TT182 LDAQQ15+3:SEC:SBCQQ0:BCSTT184:EOR#FF:ADC#1:.TT184 CMP#20:BCSTT187:LDAQQ15+1:SEC:SBCQQ1:BCSTT186:EOR#FF:ADC#1:.TT186 CMP#38:BCSTT187\n 3370LDAQQ15+3:SEC:SBCQQ0:ASLA:ASLA:ADC#104:STAXX12:LSRA:LSRA:LSRA:STAXC:INCXC:LDAQQ15+1:SEC:SBCQQ1:ASLA:ADC#90:STAK4:LSRA:LSRA:LSRA\n 3377TAY:LDXINWK,Y:BEQEE4:INY:LDXINWK,Y:BEQEE4:DEY:DEY:LDXINWK,Y:BNEee1:.EE4 STYYC:CPY#3:BCCTT187:DEX:STXINWK,Y\n 3380LDA#128:STAQQ17:JSRcpl:.ee1\n 3390\\drawbigstars:LDA#0:STAK3+1:STAK4+1:STAK+1:LDAXX12:STAK3:LDAQQ15+5:AND#1:ADC#2:STAK:JSRFLFLLS:JSRSUN:JSRFLFLLS\n 3400.TT187 JSRTT20:INCXX20:BEQTT111-1:JMPTT182\n 3450.TT81 LDX#5:LDAQQ21,X:STAQQ15,X:DEX:BPLTT81+2\n 3500RTS:.TT111 JSRTT81:LDY#127:STYT:LDA#0:STAU\n 3510.TT130 LDAQQ15+3:SEC:SBCQQ9:BCSTT132:EOR#FF:ADC#1:.TT132 LSRA:STAS:LDAQQ15+1:SEC:SBCQQ10:BCSTT134:EOR#FF:ADC#1:.TT134 LSRA:CLC:ADCS:CMPT:BCSTT135\n 3550STAT:LDX#5:.TT136 LDAQQ15,X:STAQQ19,X:DEX:BPLTT136:.TT135\n 3560JSRTT20:INCU:BNETT130:LDX#5:.TT137 LDAQQ19,X:STAQQ15,X:DEX\n 3570BPLTT137:LDAQQ15+1:STAQQ10:LDAQQ15+3:STAQQ9\n 3575SEC:SBCQQ0:BCSTT139:EOR#FF:ADC#1:.TT139 JSRSQUA2:STAK+1:LDAP:STAK:LDAQQ10\n 3590SEC:SBCQQ1:BCSTT141:EOR#FF:ADC#1:.TT141 LSRA:JSRSQUA2:PHA:LDAP:CLC:ADCK\n 3610STAQ:PLA:ADCK+1:STAR:JSRLL5:LDAQ:ASLA:LDX#0:STXQQ8+1:ROLQQ8+1:ASLA:ROLQQ8+1:STAQQ8:JMPTT24\n 4340.hy6 JSRCLYNS:LDA#15:STAXC:JMPTT27\n 4350.hyp LDAQQ12:BNEhy6:LDAQQ22+1:BNEhy5:JSRCTRL:BMIGhy:LDAQQ11:BEQTTX110:\\AND#192:\\BEQhy5\n 4353JSRhm:.TTX111\n 4355LDAQQ8:ORAQQ8+1:BEQhy5:LDA#7:STAXC:LDA#23:STAYC:LDA#0:STAQQ17:LDA#189:JSRTT27:LDAQQ8+1:BNETT147:LDAQQ14:CMPQQ8:BCCTT147\n 4380LDA#&2D:JSRTT27:JSRcpl:LDA#15:STAQQ22+1:STAQQ22:TAX:JSRee3:.hy5 RTS\n 4390.TTX110 JSRTT111:JMPTTX111\n 4392.Ghy LDXGHYP:BEQhy5:INX:STXQQ8:STXQQ8+1:STXGHYP:STXFIST:INX:STXQQ22+1:LDX#5:STXQQ22:INCGCNT:LDAGCNT:AND#7:STAGCNT:.G1 LDAQQ21,X:ASLA:ROLQQ21,X:DEX:BPLG1:JSRDORND:STAQQ9:STXQQ10:JSRTT110:LDA#116:JSRMESS:.jmp LDAQQ9:STAQQ0:LDAQQ10\n 4393STAQQ1:.rt RTS\n 4395.ee3 LDY#1:STYYC:DEY:STYXC::.pr6 CLC:.pr5 LDA#5:JMPTT11\n 4400.TT147 LDA#202:.prq JSRTT27:LDA#&3F:JMPTT27\n 5000.TT151\\Pmk-A\n 5010PHA:STAQQ19+4:ASLA:ASLA:STAQQ19:LDA#1:STAXC:PLA:ADC#208\n 5015JSRTT27:LDA#14:STAXC:LDXQQ19:LDAQQ23+1,X:STAQQ19+1:LDAQQ26:ANDQQ23+3,X:CLC:ADCQQ23,X:STAQQ24:JSRTT152\n 5050JSRvar:LDAQQ19+1:BMITT155:LDAQQ24:ADCQQ19+3:JMPTT156\n 5060.TT155 LDAQQ24:SEC:SBCQQ19+3:.TT156 STAQQ24:STAP:LDA#0:JSRGC2\n 5070SEC:JSRpr5:LDYQQ19+4:LDA#5:LDXAVL,Y:STXQQ25\n 5100CLC:BEQTT172:JSRpr2+2:JMPTT152:.TT172 LDAXC:ADC#4:STAXC:LDA#&2D:BNETT162+2\n 5110.TT152 LDAQQ19+1:AND#96:BEQTT160:CMP#32:BEQTT161\n 5120JSRTT16a:.TT162 LDA#32:JMPTT27\n 5130.TT160 LDA#&74:JSRTT26:BCCTT162\n 5140.TT161 LDA#&6B:JSRTT26:.TT16a LDA#&67:JMPTT26\n 5160.TT163 LDA#17:STAXC:LDA#FF:BNETT162+2\n 5200.TT167\\MktP\n 5210LDA#16:JSRTT66:LDA#5:STAXC:LDA#167:JSRNLIN3:LDA#3:STAYC:JSRTT163:LDA#0:STAQQ29:.TT168 LDX#128:STXQQ17:JSRTT151:INCYC\n 5250INCQQ29:LDAQQ29:CMP#17:BCCTT168:RTS\n 5900.var LDAQQ19+1:AND#31:LDYQQ28:STAQQ19+2:CLC:LDA#0:STAAVL+16:.TT153 DEY:BMITT154:ADCQQ19+2:JMPTT153:.TT154 STAQQ19+3:RTS\n 5980.hyp1 JSRTT111:JSRjmp:LDX#5:.TT112 LDAQQ15,X:STAQQ2,X:DEX:BPLTT112:INX:STXEV:LDAQQ3:STAQQ28:LDAQQ5:STAtek:LDAQQ4:STAgov:JSRDORND:STAQQ26\n 5990LDX#0:STXXX4:.hy9 LDAQQ23+1,X:STAQQ19+1:JSRvar:LDAQQ23+3,X:ANDQQ26:CLC:ADCQQ23+2,X:LDYQQ19+1:BMITT157:SEC:SBCQQ19+3:JMPTT158:.TT157 CLC:ADCQQ19+3:.TT158 BPLTT159:LDA#0:.TT159\n 5994LDYXX4:AND#63:STAAVL,Y:INY:TYA:STAXX4:ASLA:ASLA:TAX:CMP#63:BCChy9:.hyR RTS\n 5995.GTHG JSRZe:LDA#FF:STAINWK+32:LDA#THG:JSRNWSHP:LDA#TGL:JMPNWSHP\n 5996.ptg LSRCOK:SEC:ROLCOK\n 5998.MJP\\LDA#1:JSRTT66-2:JSRLL164:JSRRES2:STYMJ:.MJP1 JSRGTHG:LDA#3:CMPMANY+THG:BCSMJP1:STANOSTM:LDX#0:JSRLOOK1:LDAQQ1:EOR#31:STAQQ1:RTS\n 6000.TT18\\HSPC\n 6005LDAQQ14:SEC:SBCQQ8:STAQQ14:LDAQQ11:BNEee5:JSRTT66:JSRLL164:.ee5 JSRCTRL:ANDPATG:BMIptg:JSRDORND:CMP#253:BCSMJP\\JSRTT111:JSRhyp1:JSRRES2:JSRSOLAR\n 6500LDAQQ11:AND#63:BNEhyR:JSRTTX66:LDAQQ11:BNETT114:INCQQ11:.TT110 LDXQQ12:BEQNLUNCH:JSRLAUN:JSRRES2:JSRTT111:INCINWK+8:JSRSOS1:LDA#128:STAINWK+8:INCINWK+7:JSRNWSPS:LDA#12:STADELTA:JSRBAD:ORAFIST:STAFIST\n 6510.NLUNCH LDX#0:STXQQ12:JMPLOOK1:.TT114 BMITT115:JMPTT22:.TT115 JMPTT23\n 6530.LCASH STXT1:LDACASH+3:SEC:SBCT1:STACASH+3:STYT1:LDACASH+2:SBCT1:STACASH+2:LDACASH+1:SBC#0:STACASH+1:LDACASH:SBC#0:STACASH:BCSTT113\n 6540.MCASH TXA:CLC:ADCCASH+3:STACASH+3:TYA:ADCCASH+2:STACASH+2:LDACASH+1:ADC#0:STACASH+1:LDACASH:ADC#0:STACASH:CLC:.TT113 RTS\n 6550.GCASH JSRMULTU:.GC2 ASLP:ROLA:ASLP:ROLA:TAY:LDXP:RTS\n 6690.bay JMPBAY\n 6700.EQSHP JSRDIALS:LDA#32:JSRTT66:\\JSRFLKB:LDA#12:STAXC:LDA#207:JSRspc:LDA#185:JSRNLIN3:LDA#128:STAQQ17:INCYC:LDAtek:CLC:ADC#3:CMP#12:BCCP%+4:LDA#12:STAQ:STAQQ25:INCQ:LDA#70:SEC:SBCQQ14:ASLA:STAPRXS\n 6710LDX#1:.EQL1 STXXX13:JSRTT67:LDXXX13:CLC:JSRpr2:JSRTT162:LDAXX13:CLC:ADC#&68:JSRTT27:LDAXX13:JSRprx-3:SEC:LDA#25:STAXC:LDA#6:JSRTT11:LDXXX13:INX:CPXQ:BCCEQL1\n 6720JSRCLYNS:LDA#127:JSRprq:JSRgnum:beqbay:bcsbay:SBC#0:LDX#2:STXXC:INCYC:PHA:JSReq:PLA:BNEet0:STAMCNT:LDX#70:STXQQ14:.et0 CMP#1:BNEet1:LDXNOMSL:INX:LDY#&75:CPX#5:BCSpres\n 6730STXNOMSL:JSRmsblob:.et1 LDY#&6B:CMP#2:BNEet2:LDX#37:CPXCRGO:BEQpres:STXCRGO:.et2 CMP#3:BNEet3:INY:LDXECM:BNEpres:DECECM:.et3 CMP#4:BNEet4:JSRqv:LDA#4:LDYLASER,X:BEQed4:.ed7 LDY#187:BNEpres:.ed4 LDA#POW:STALASER,X:LDA#4:.et4\n 6740CMP#5:BNEet5:JSRqv:STXT1:LDA#5:LDYLASER,X:BEQed5:\\BPLP%+4:BMIed7:LDA#4:JSRprx:JSRMCASH:.ed5 LDA#POW+128:LDXT1:STALASER,X:.et5\n 6750LDY#&6F:CMP#6:BNEet6:LDXBST:BEQed9:.pres STYK:JSRprx:JSRMCASH:LDAK:JSRspc:LDA#31:JSRTT27:.err JSRdn2:JMPBAY:.ed9 DECBST:.et6 INY:CMP#7:BNEet7:LDXESCP:BNEpres:DECESCP:.et7 INY:CMP#8:BNEet8:LDXBOMB:BNEpres:LDX#&7F:STXBOMB:.et8\n 6800INY:CMP#9:BNEetA:LDXENGY:BNEpres:INCENGY:.etA INY:CMP#10:BNEetB:LDXDKCMP:BNEpres:DECDKCMP:.etB:INY:CMP#11:BNEet9:LDXGHYP:BNEpres:DECGHYP:.et9 JSRdn:JMPEQSHP:.dn JSRTT162:LDA#119:JSRspc:.dn2 JSRBEEP:LDY#50:JMPDELAY\n 6900.eq JSRprx:JSRLCASH:BCSc:LDA#197:JSRprq:JMPerr:SEC:SBC#1:.prx ASLA:TAY:LDXPRXS,Y:LDAPRXS+1,Y:TAY:.c RTS\n 6910.qv LDY#16:STYYC:.qv1 LDX#12:STXXC:TYA:CLC:ADC#B-16:JSRspc:LDAYC:CLC:ADC#&50:JSRTT27:INCYC:LDYYC:CPY#20:BCCqv1:.qv3 JSRCLYNS:.qv2 LDA#175:JSRprq:JSRTT217:SEC:SBC#&30:CMP#4:BCSqv3:TAX:RTS\n 9900]\n 9910IFZ>4OSCLI(\"S.ELTD \"+STR$~W%+\" \"+STR$~O%+\" \"+STR$~L%+\" \"+STR$~H%)\n 9920PRINT\"D d,\";:GOTO10\n"
  },
  {
    "path": "1-source-files/original-sources/README.md",
    "content": "# Original source code for the BBC Micro cassette version of Elite\n\nThis folder contains the original source code for the BBC Micro cassette version of Elite from Ian Bell's personal website.\n\n---\n\nRight on, Commanders!\n\n_Mark Moxon_"
  },
  {
    "path": "1-source-files/original-sources/S.BCFS.inf",
    "content": "S.BCFS    000000 000000 000380\n"
  },
  {
    "path": "1-source-files/original-sources/S.BCFS.txt",
    "content": "   10REM    Prepare the Big Code File\n   20 \n   25REM          ELTcode\n   30 \n   35REM   (a provisional name, ahem)\n   40 \n   50MODE7\n  100C%=&F40:L%=&1128:D%=&563A:ZP=&70\n  110IF PAGE<>&6800:PAGE=&6800:CHAIN\"S.BCFS\"\n  120P%=&1100:[ .LBL EQUB&6C:LDX#&60:LDA#&B:STAZP+1:LDY#0:STYZP:TYA:INY:.CHK3 CLC:ADC(ZP),Y:INY:BNECHK3:INCZP+1:.CHK4 CLC:ADC(ZP),Y:INY:BPLCHK4:CMP&B00:BEQLBL+2:LDA#&7F:STA&FE4E:JMP(&FFFC) :]\n  320*L.ELTA\n  330*L.ELTB\n  340*L.ELTC\n  350*L.ELTD\n  360*L.ELTE\n  370*L.ELTF\n  380*L.ELTG\n  385OSCLI(\"L.SHIPS \"+STR$~(D%+L%-C%))\n  390A%=0:FORN%=L%TOL%+&45FF:A%=A%+?N%:NEXT:?(D%+L%-C%-1)=A%\n  395FORN%=0TO&6000-C%:L%?N%=(L%?N%)EOR(N%MOD256):NEXT\n  397A%=0:FORN%=&1100TO&1127:A%=A%+?N%:NEXT:PRINT\"Checksum 1=\";A%\n  450INPUT\"Place Disk in default drive and\"'\"  Press Return\"A$\n  500OSCLI(\"S.ELTcode 1100 \"+STR$~(L%+&6000-C%)+\" \"+STR$~L%+\" \"+STR$~L%)\n"
  },
  {
    "path": "1-source-files/original-sources/S.GENTOK.inf",
    "content": "$.GENTOKS 000000 000000 000B1F\n"
  },
  {
    "path": "1-source-files/original-sources/S.GENTOK.txt",
    "content": "   10 REM Generate TOKENS file\n   20 words=OPENOUT\"WORDS9\"\n   30 ONERRORGOTO150\n   40 REPEATREADA$:FORN%=1TOLENA$:CH%=ASCMID$(A$,N%,1)\n   50 IFCH%=ASC\"#\"THENGOSUB100:ELSEbyte=CH%\n   60 BPUT#words,byte EOR35:NEXT:BPUT#words,0\n   70 UNTILFALSE\n  100 byte=VAL(MID$(A$,N%+1,3)):N%=N%+4:RETURN\n  150 IFERR=42THENCLOSE#words:END ELSE CLOSE#words:PRINT\"Line \"ERL:REPORT:END\n  160 DATA#111##017##007#,\" CH#138#T\",GO#150#RNM#146#T,D#145#A#017##003#,#140##150#NT#153#Y#013#,SYS#156#M,P#158##133#,#002# #139#RKET #166#S,#140#D#136#T#158##128#,AG#158#CULTU#148#L\n  170 DATA#158#CH ,A#150##148##131# ,PO#153# ,#139##140#LY ,UNIT,VIEW ,#154##155##151#TY,#155##138#CHY,FEUD#128#,MUL#151#-#162#\n  180 DATA#141#CT#145##153##185#,#251#MUN#157#T,C#159#F#152##144#ACY,DEMOC#148#CY,C#153#P#153##145#E #203##145#E,SHIP,PRODUCT,\" #149#S#144#\",HUM#155# COL#159#I#128#,\"HYP#144#SPA#133# \"\n  190 DATASH#153#T #202##161#,#141##203##155##133#,POPUL#145#I#159#,GROSS #186#IVITY,EC#159#OMY,\" LIGHT YE#138#S\",#156#CH.#129##150#L,\"CASH\",\" #134##118#I#159#\",#122##161##001#\n  200 DATAT#138##131#T LO#203#,#106# JAMM#152#,R#155##131#,ST,\"#176# OF \",SE#118#,\" C#138#GO#006#\",E#154#IP,FOOD,#156#X#151#L#137#\n  210 DATA#148##141#OAC#151##150#S,S#149##150#S,LI#154##153#/W#140##137#,LUXU#158##137#,N#138#CO#151#CS,#251#PUT#144#S,#139#CH#140##144#Y,#117#OYS,FI#142##138#MS,FURS\n  220 DATAM#140##144##128#S,GOLD,PL#145##140#UM,#131#M-#203##159##137#,#128#I#146# #127#S,(Y/N)?,\" CR\",L#138##131#,FI#144##133#,S#139##118#\n  230 DATAG#142##146#,R#152#,YE#118#OW,BLUE,B#149#CK,#022#,SLIMY,BUG-EY#152#,H#153#N#152#,B#159#Y\n  240 DATAF#145#,FURRY,ROD#146#T,FROG,LI#132#RD,LOB#203##144#,#134#RD,HUM#155#OID,FEL#140#E,#140#SECT\n  250 DATA#171##148##141##136#,COM,#251#M#155#D#144#,\" D#137#TROY#152#\",\"#013##013# (C) D.B#148##147#N & I.#147##118# 1984\"\n  260 DATA\"#174#  #176##013# #186#   #174# #166# F#153# SA#129##013##010#\",FR#159#T,#142##138#,#129#FT,#158#GHT,#121#LOW#007#,#099##017##252#!,EXT#148# ,PULSE#187#,\"#147#AM#187#\",FUEL\n  270 DATAM#157#SI#129#,#227##206# BAY,E.C.M.#165#,#102##103#S,#102##104#S,#105# SCOOPS,#137#CAPE POD,#121#BOMB,#121##174#,#124##140#G #215#,#122# #189#,A#118#,LL,\"#197#:#000#\",#140##251##140#G #106#\n  280 DATA\"#146##144#GY \",GA#149#C#151#C,\"#013##252#'S NAME? \",DOCK\n  290DATA#005##129#G#128# #203##145##136#:,\"#252# #004##013##013##013##006##031# #165##009##002##013##189##165##009##003##013#C#159##141##151##159##009#\",I#156#M\n  300DATA\" LOAD NEW #252# #225##254#\",#006##124##152#,#148##151#NG:,\" #159# \",\"#013##008##207#M#146#T:#006#\",C#129##155#,OFF#146#D#144#,FUGI#151##150#,H#138#M#129#SS,MO#203#LY #022#,#172#,#171#,ABO#150# #171#,#251#PET#146#T\n  310DATAD#155##131#RO#136#,DEADLY,\"---- E L I T E ----\",P#142#S#146#T,\"#008#GAME O#150#R\",\"PR#137#S FI#142# #153# SPA#133#,#252#.#254#\",\"AC#153#N#135#FT#013##013#\"\n"
  },
  {
    "path": "1-source-files/original-sources/S.STEST.inf",
    "content": "$.STEST   000000 000000 0012D3\n"
  },
  {
    "path": "1-source-files/original-sources/S.STEST.txt",
    "content": "    5REM Source Code for Loader\n   10C%=&F40:S%=C%:L%=&1128:D%=&563A:LC%=&6000-C%:svn=&7FFD\n   20MOS=S%+8:TRTB%=4\n  100DIM CODE &1000\n 1000OSWRCH=&FFEE:OSBYTE=&FFF4:OSWORD=&FFF1:SCLI=&FFF7:IRQ1V=&204\n 1010ZP=&70:P=&72:Q=&73:YY=&74:T=&75\n 1020FF=&FF\n 1030VIA=&FE40:USVIA=VIA:VSCAN=57:VEC=&7FFE\n 3000FORZ=4TO6STEP2\n 3010P%=&900:O%=CODE\n 3015RESTORE:READN%\n 3020B%=P%:FORI%=0TON%-1:READA:PROCP(A):NEXT\n 3100E%=P%:FORI%=1TO4:FORJ%=1TO14:READA:PROCP(A):NEXT,\n 4000[OPTZ\n 5000.ENTRY LDA#16:LDX#3:JSROSBYTE \\ADC\n 5001LDA#190:LDX#8:JSROSB \\8bitADC\n 5002LDA#200:LDX#3:JSROSB \\break,escape\n 5004LDA#13:LDX#0:JSROSB \\otput bffer\n 5005LDA#144:LDX#255:JSROSB \\TV\n 5006LDA#225:LDX#128:JSROSB \\fn keys\n 5007LDA#13:LDX#2:JSROSB \\kybrd buffer\n 5008LDA#(B% MOD256):STAZP:LDA#(B% DIV256):STAZP+1:LDY#0:.LOOP LDA(ZP),Y:JSROSWRCH:INY:CPY#N%:BNELOOP \\set up mode\n 5010LDA#4:LDX#1:JSROSB \\cursor\n 5020LDA#9:LDX#0:JSROSB \\flashing\n 5030LDA#172:LDX#0:LDY#FF:JSROSBYTE:STXTRTB%:STYTRTB%+1 \\int-ascii table\n 5050JSRPLL1\n 5100EQUS FNE(0):EQUS FNE(1):EQUS FNE(2):EQUS FNE(3) \\envelopes\n 5110LDX#(MESS2 MOD256):LDY#(MESS2 DIV256):JSRSCLI\n 5120LDX#(MESS3 MOD256):LDY#(MESS3 DIV256):JSRSCLI\n 5130LDX#(MESS4 MOD256):LDY#(MESS4 DIV256):JSRSCLI\n 5140LDX#(MESS5 MOD256):LDY#(MESS5 DIV256):JSRSCLI\n 5150LDX#(MESS6 MOD256):LDY#(MESS6 DIV256):JSRSCLI\n 5160LDX#(MESS7 MOD256):LDY#(MESS7 DIV256):JSRSCLI\n 5170LDX#(MESS8 MOD256):LDY#(MESS8 DIV256):JSRSCLI\n 5180LDX#(MESS9 MOD256):LDY#(MESS9 DIV256):JSRSCLI\n 5190LDX#(MESS10 MOD256):LDY#(MESS10 DIV256):JSRSCLI\n 5200LDX#(MESS11 MOD256):LDY#(MESS11 DIV256):JSRSCLI\n 5310LDA#140:LDX#12:JSROSBYTE\n 5320LDA#0:STAsvn\n 5350LDX#(LC% DIV256):LDA#(L% MOD256):STAZP:LDA#(L% DIV256):STAZP+1:LDA#(C% MOD256):STAP:LDA#(C% DIV256):STAP+1:LDY#0\n 5360.ML1 LDA(ZP),Y:STA(P),Y:INY:BNEML1:INCZP+1:INCP+1:DEX:BPLML1\n 5370LDAS%+6:STA&202:LDAS%+7:STA&203:LDAS%+2:STA&20E:LDAS%+3:STA&20F\n 5380.SETUP SEI:LDAVIA+4:STA1:LDA#&39:STAVIA+&E:LDA#&7F:STA&FE6E:LDAIRQ1V:STAVEC:LDAIRQ1V+1:STAVEC+1:LDAS%+4:STAIRQ1V:LDAS%+5:STAIRQ1V+1:LDA#VSCAN:STAUSVIA+5:CLI\n 5385LDA#&81:LDY#FF:LDX#1:JSROSBYTE:TXA:EOR#FF:STAMOS \\FF if MOS0.1 else 0\n 5390JMP(S%)\n 5400.PLL1 LDAVIA+4:STARAND+1:JSRDORND:JSRSQUA2:STAZP+1:LDAP:STAZP:JSRDORND:STAYY:JSRSQUA2:TAX:LDAP:ADCZP:STAZP:TXA:ADCZP+1:BCSPLC1\n 5410STAZP+1:LDA#1:SBCZP:STAZP:LDA#&40:SBCZP+1:STAZP+1:BCCPLC1:JSRROOT:LDAZP:LSRA:TAX:LDAYY:CMP#128:RORA:JSRPIX\n 5420.PLC1 DECCNT:BNEPLL1:DECCNT+1:BNEPLL1\n 5450.PLL2 JSRDORND:TAX:JSRSQUA2:STAZP+1:JSRDORND:STAYY:JSRSQUA2:ADCZP+1:CMP#&11:BCCPLC2:LDAYY:JSRPIX\n 5460.PLC2 DECCNT2:BNEPLL2:DECCNT2+1:BNEPLL2\n 5500.PLL3 JSRDORND:STAZP:JSRSQUA2:STAZP+1:JSRDORND:STAYY:JSRSQUA2:STAT\n 5510ADCZP+1:STAZP+1:LDAZP:CMP#128:RORA:CMP#128:RORA:ADCYY:TAX:JSRSQUA2:TAY:ADCZP+1\n 5520BCSPLC3:CMP#&50:BCSPLC3:CMP#&20:BCCPLC3:TYA:ADCT:CMP#&10:BCSPL1:LDAZP:BPLPLC3:.PL1 LDAYY:JSRPIX\n 5550.PLC3 DECCNT3:BNEPLL3:DECCNT3+1:BNEPLL3\n 5800.DORND LDARAND+1:TAX:ADCRAND+3:STARAND+1:STXRAND+3:LDARAND:TAX:ADCRAND+2:STARAND:STXRAND+2:RTS\n 5810.RAND EQUD &34785349\n 5815.SQUA2 BPLSQUA:EOR#FF:CLC:ADC#1\n 5820.SQUA STAQ:STAP:LDA#0:LDY#8:LSRP:.SQL1 BCCSQ1:CLC:ADCQ:.SQ1 RORA:RORP:DEY:BNESQL1:RTS\n 5850.PIX TAY:EOR#128:LSRA:LSRA:LSRA:ORA#&60:STAZP+1:TXA:EOR#128:AND#&F8:STAZP:TYA:AND#7:TAY:TXA:AND#7:TAX\n 5860LDATWOS,X:STA(ZP),Y:RTS\n 5870.TWOS EQUD &10204080:EQUD&01020408\n 5880.CNT EQUW&300:.CNT2 EQUW &1DD:.CNT3 EQUW &333\n 5890.ROOT LDYZP+1:LDAZP:STAQ:LDX#0:STXZP:LDA#8:STAP:.LL6 CPXZP:BCCLL7:BNELL8:CPY#&40:BCCLL7:.LL8 TYA:SBC#&40:TAY:TXA:SBCZP:TAX:.LL7 ROLZP:ASLQ:TYA:ROLA:TAY:TXA:ROLA:TAX:ASLQ:TYA:ROLA:TAY:TXA:ROLA:TAX:DECP:BNELL6:RTS\n 5900.OSB LDY#0:JMPOSBYTE\n 6010.MESS2 EQUS(\"L.ELTA\"):EQUB13\n 6020.MESS3 EQUS(\"L.ELTB\"):EQUB13\n 6030.MESS4 EQUS(\"L.ELTC\"):EQUB13\n 6040.MESS5 EQUS(\"L.ELTD\"):EQUB13\n 6050.MESS6 EQUS(\"L.ELTE\"):EQUB13\n 6060.MESS7 EQUS(\"L.ELTF\"):EQUB13\n 6070.MESS8 EQUS(\"L.ELTG\"):EQUB13\n 6100.MESS9 EQUS(\"L.SHIPS \"+STR$~(D%+L%-C%)):EQUB13\n 6110.MESS10 EQUS(\"L.WORDS9\"):EQUB13\n 6120.MESS11 EQUS(\"L.DIALSHP\"):EQUB13\n 7000]\n 7020NEXTZ\n 7100PRINT~CODE O% P% ENTRY\n 7110INPUT\"Insert assembly disk and hit RETURN\"A$\n 7120OSCLI(\"S.MCTEST \"+STR$~CODE +\" \"+STR$~O% +\" \"+STR$~ENTRY +\" 900\")\n 7200END\n 8000DATA67\n 8100DATA 22,4,28,2,17,15,16\n 8110DATA 23,0, 6,31,0,0,0,0,0,0\n 8112DATA 23,0,12,12,0,0,0,0,0,0\n 8114DATA 23,0,13, 0,0,0,0,0,0,0\n 8116DATA 23,0, 1,32,0,0,0,0,0,0\n 8118DATA 23,0, 2,45,0,0,0,0,0,0\n 8120DATA 23,0,10,32,0,0,0,0,0,0\n 9100DATA1,1,0,111,-8,4,1,8, 8,-2,0,-1,126,44\n 9110DATA2,1,14,-18,-1,44,32,50, 6,1,0,-2,120,126\n 9120DATA3,1,1,-1,-3,17,32,128,1,0,0,-1,1,1\n 9130DATA4,1,4,-8,44,4,6,8,22,0,0,-127,126,0\n10000DEFPROCP(A):?O%=A:O%=O%+1:P%=P%+1:ENDPROC\n10100DEF FNE(I%)\n10110[OPTZ\n10120LDX#((E%+I%*14)MOD256):LDY#((E%+I%*14)DIV256):LDA#8:JSROSWORD\n10130]\n10140=\"\"\n"
  },
  {
    "path": "1-source-files/original-sources/text-sources/ELITEA.txt",
    "content": "    1GOTO20\n    2*L.ELITEB\n    3GOTO20\n    4*L.ELITEA\n    5GOTO120\n   20REM ELITE <A>\n   30MODE7:VDU28,0,23,39,19\n   40LOMEM=&3D70\n  100C%=&F40:W%=&7200:L%=&1128:HIMEM=W%:Z=0\n  120D%=&563A:WP=&D40:K%=&900:LS%=WP-1:QQ18=&400:T%=&300\n  220NOST=18:NOSH=12:COPS=2:SH3=COPS:CYL=7:THG=6:SST=8:MSL=9:AST=10:OIL=11:TGL=12:ESC=13:NI%=36:POW=15:B=&30\n 1000FF=&FF:OSWRCH=&FFEE:OSBYTE=&FFF4:OSWORD=&FFF1:OSFILE=&FFDD:SCLI=&FFF7:VIA=&FE40:USVIA=VIA:IRQ1V=&204:VSCAN=57:XX21=D%\n 1020ZP=0:X=128:Y=96:RAND=FNZT(4):TRTB%=FNZ2:T1=FNZ:SC=FNZ2:SCH=SC+1:XX16=FNZT(18):P=FNZT(3)\n 1060XX0=FNZ2:INF=FNZ2:V=FNZ2:XX=FNZ2:YY=FNZ2:SUNX=FNZ2:BETA=FNZ:BET1=FNZ:XC=FNZ:YC=FNZ:QQ22=FNZ2:ECMA=FNZ\n 1120XX15=FNZT(6):XX12=FNZT(6):X1=XX15:Y1=X1+1:X2=Y1+1:Y2=X2+1:K=FNZT(4)\n 1125KL=FNZT(16):LAS=FNZ:MSTG=FNZ\n 1126f0=&20:f1=&71:f2=&72:f3=&73:f4=&14:f5=&74:f6=&75:f7=&16:f8=&76:f9=&77\n 1128KY1=KL+1:KY2=KL+2:KY3=KL+3:KY4=KL+4:KY5=KL+5:KY6=KL+6:KY7=KL+7:KY12=KL+8:KY13=KL+9:KY14=KL+10:KY15=KL+11:KY16=KL+12:KY17=KL+13:KY18=KL+14:KY19=KL+15\n 1130INWK=FNZT(NI%):XX19=INWK+33:XX1=INWK:LSP=FNZ:QQ15=FNZT(6):XX18=FNZT(9):QQ17=XX18:QQ19=QQ17+1:K5=XX18:K6=K5+4:ALP1=FNZ:ALP2=FNZ2\n 1150BET2=FNZ2:DELTA=FNZ:DELT4=FNZ2:U=FNZ:Q=FNZ:R=FNZ:S=FNZ:XSAV=FNZ:YSAV=FNZ:XX17=FNZ\n 1160QQ11=FNZ:ZZ=FNZ:XX13=FNZ:MCNT=FNZ:DL=FNZ:TYPE=FNZ:JSTX=FNZ:JSTY=FNZ:ALPHA=FNZ\n 1195QQ12=FNZ:TGT=FNZ:SWAP=FNZ:COL=FNZ:FLAG=FNZ:CNT=FNZ:CNT2=FNZ:STP=FNZ:XX4=FNZ:XX20=FNZ:XX14=FNZ:RAT=FNZ:RAT2=FNZ:K2=FNZT(4)\n 1400P%=C%:O%=W%:H%=L%+P%-C%\n 1410IFZ=4THENZ=6ELSEZ=4\n 1450FRIN=FNWT(NOSH+1):MANY=FNWT(14):SSPR=MANY+SST\n 1460ECMP=FNW:MJ=FNW:CABTMP=MANY:LAS2=FNW:MSAR=FNW:VIEW=FNW:LASCT=FNW:GNTMP=FNW:HFX=FNW:EV=FNW:DLY=FNW\n 1465de=FNW:T=&D1:XX2=&D2:K3=XX2:K4=K3+14:REM16\n 1470LSO=FNWT(192):LSX=LSO:LSX2=FNWT(78):LSY2=FNWT(78):SY=FNWT(NOST+1):SYL=FNWT(NOST+1):SZ=FNWT(NOST+1):SZL=FNWT(NOST+1)\n 1480XSAV2=FNW:YSAV2=FNW\n 1500TP=FNTP:QQ0=FNTP:QQ1=FNTP:QQ21=FNTPT(6):CASH=FNTPT(4):QQ14=FNTP:COK=FNTP:GCNT=FNTP:LASER=FNTPT(6):CRGO=FNTP:QQ20=FNTPT(17):ECM=FNTP:BST=FNTP:BOMB=FNTP:ENGY=FNTP:DKCMP=FNTP:GHYP=FNTP:ESCP=FNTPT(5)\n 1520NOMSL=FNTP:FIST=FNTP:AVL=FNTPT(17):QQ26=FNTP:TALLY=FNTPT(2):SVC=FNTPT(3):NT%=SVC+2-TP:MCH=FNW\n 1600SX=T%:SXL=SX+NOST+1:XX3=256:REM&70\n 1628FSH=FNW:ASH=FNW:ENERGY=FNW:REMFF\n 1630LASX=FNW:LASY=FNW:COMX=FNW:COMY=FNW:QQ24=FNW:QQ25=FNW:QQ28=FNW:QQ29=FNW:gov=FNW:tek=FNW:SLSP=FNW2:XX24=FNW:ALTIT=FNW:VEC=&7FFE:svn=&7FFD\n 1650QQ2=FNWT(6):QQ3=FNW:QQ4=FNW:QQ5=FNW:QQ6=FNW2:QQ7=FNW2:QQ8=FNW2:QQ9=FNW:QQ10=FNW:NOSTM=FNW\n 1800[OPTZ:.S% EQUWTT170:EQUWTT26:EQUWIRQ1:EQUWBR1\n 1830.COMC brk:.DNOIZ brk:.DAMP brk:.DJD brk:.PATG brk:.FLH brk:.JSTGY brk:.JSTE brk:.JSTK brk\n 4000.M% LDAK%:STARAND\n 4020LDXJSTX:JSRcntr:JSRcntr:TXA:EOR#128:TAY:AND#128:STAALP2:STXJSTX:EOR#128:STAALP2+1:TYA:BPLP%+7:EOR#FF:CLC:ADC#1:LSRA:LSRA:CMP#8:BCSP%+4:LSRA:CLC:STAALP1:ORAALP2:STAALPHA\n 4030LDXJSTY:JSRcntr:TXA:EOR#128:TAY:AND#128:STXJSTY:STABET2+1:EOR#128:STABET2:TYA:BPLP%+4:EOR#FF:ADC#4:LSRA:LSRA:LSRA:LSRA:CMP#3:BCSP%+3:LSRA:STABET1:ORABET2:STABETA\n 4050LDAKY2:BEQMA17:LDADELTA:CMP#40:BCSMA17:INCDELTA:.MA17 LDAKY1:BEQMA4:DECDELTA:BNEMA4:INCDELTA:.MA4\n 4060LDAKY15:ANDNOMSL:BEQMA20:LDY#&EE:JSRABORT:LDA#40:JSRNOISE:.MA31 LDA#0:STAMSAR:.MA20 LDAMSTG:BPLMA25:LDAKY14:BEQMA25:LDXNOMSL:BEQMA25:STAMSAR:LDY#&E0:JSRMSBAR:.MA25\n 4064LDAKY16:BEQMA24:LDAMSTG:BMIMA64:JSRFRMIS:.MA24 LDAKY12:BEQMA76:ASLBOMB:.MA76\n 4070LDAKY13:ANDESCP:BEQP%+5:JMPESCAPE:LDAKY18:BEQP%+5:JSRWARP:LDAKY17:ANDECM:BEQMA64:LDAECMA:BNEMA64:DECECMP:JSRECBLB2:.MA64\n 4075LDAKY19:ANDDKCMP:ANDSSPR:BEQMA68:LDAK%+NI%+32:BMIMA68:JMPGOIN:.MA68\n 4080LDA#0:STALAS:STADELT4:LDADELTA:LSRA:RORDELT4:LSRA:RORDELT4:STADELT4+1\n 4090LDALASCT:BNEMA3:LDAKY7:BEQMA3:LDAGNTMP:CMP#242:BCSMA3:LDXVIEW:LDALASER,X:BEQMA3:PHA:AND#127:STALAS:STALAS2:LDA#0:JSRNOISE:JSRLASLI:PLA:BPLma1:LDA#0:.ma1 AND#&FA:STALASCT:.MA3\n 4100LDX#0:.MAL1\n 4105STXXSAV:LDAFRIN,X:BNEP%+5:JMPMA18:STATYPE:JSRGINF\n 4110LDY#(NI%-1):.MAL2 LDA(INF),Y:STAINWK,Y:DEY:BPLMAL2:LDATYPE:BMIMA21:ASLA:TAY:LDAXX21-2,Y:STAXX0:LDAXX21-1,Y:STAXX0+1\n 4115LDABOMB:BPLMA21:CPY#2*SST:BEQMA21:LDAINWK+31:AND#32:BNEMA21:LDAINWK+31:ORA#128:STAINWK+31:JSREXNO2\n 4130.MA21 JSRMVEIT:LDY#(NI%-1):.MAL3 LDAINWK,Y:STA(INF),Y:DEY:BPLMAL3\n 4134LDAINWK+31:AND#&A0:JSRMAS4:BNEMA65:LDAINWK:ORAINWK+3:ORAINWK+6:BMIMA65:LDXTYPE:BMIMA65:CPX#SST:BEQISDK:AND#&C0:BNEMA65:CPX#MSL:BEQMA65\n 4138CPX#OIL:BCSP%+5:JMPMA58:LDABST:ANDINWK+5:BPLMA58:LDA#3:CPX#TGL:BCCoily:BNEslvy2:LDA#16:BNEslvy2\n 4140.oily JSRDORND:AND#7:.slvy2 STAQQ29:LDA#1:JSRtnpr:LDY#78:BCSMA59:LDYQQ29:ADCQQ20,Y:STAQQ20,Y:TYA:ADC#208:JSRMESS\n 4141JMPMA60:.MA65 JMPMA26\n 4142.ISDK LDAK%+NI%+32:BMIMA62:LDAINWK+14:CMP#&D6:BCCMA62:JSRSPS4:LDAXX15+2:BMIMA62:CMP#89:BCCMA62:LDAINWK+16:AND#&7F:CMP#80:BCCMA62:.GOIN LDA#0:STAQQ22+1:LDA#8:JSRLAUN:JSRRES4:JMPBAY:.MA62 LDADELTA:CMP#5:BCCMA67:JMPDEATH\n 4143.MA59 JSREXNO3:.MA60 ASLINWK+31:SEC:RORINWK+31:.MA61 BNEMA26\n 4144.MA67 LDA#1:STADELTA:LDA#5:BNEMA63:.MA58 ASLINWK+31:SEC:RORINWK+31:LDAINWK+35:SEC:RORA:.MA63 JSROOPS:JSREXNO3:.MA26\n 4146LDAQQ11:BNEMA15:JSRPLUT\n 4150JSRHITCH:BCCMA8:LDAMSAR:BEQMA47:JSRBEEP:LDXXSAV:LDY#&E:JSRABORT2:.MA47 LDALAS:BEQMA8:LDX#15:JSREXNO:LDAINWK+35:SEC:SBCLAS:BCSMA14\n 4155LDATYPE:CMP#SST:BEQMA14+2:LDAINWK+31:ORA#128:STAINWK+31:BCSMA8:JSRDORND:BPLoh:LDY#0:AND(XX0),Y:STACNT:.um BEQoh:LDX#OIL:LDA#0:JSRSFS1:DECCNT:BPLum:.oh JSREXNO2\n 4160.MA14 STAINWK+35:LDATYPE:JSRANGRY:.MA8\n 4180JSRLL9:.MA15 LDY#35:LDAINWK+35:STA(INF),Y\n 4190LDAINWK+31:BPLMAC1:AND#&20:BEQNBOUN:LDATYPE:CMP#COPS:BNEq2:LDAFIST:ORA#64:STAFIST:.q2 LDADLY:ORAMJ:BNEKS1S:LDY#10:LDA(XX0),Y:BEQKS1S:TAX:INY:LDA(XX0),Y:TAY:JSRMCASH:LDA#0:JSRMESS:.KS1S JMPKS1:.NBOUN\n 4240.MAC1 LDATYPE:BMIMA27:JSRFAROF:BCCKS1S:.MA27 LDY#31:LDAINWK+31:STA(INF),Y:LDXXSAV:INX:JMPMAL1:.MA18 LDABOMB:BPLMA77:ASLBOMB:JSRWSCAN:LDA#&30:STA&FE21:.MA77\n 4250LDAMCNT:AND#7:BNEMA22:LDXENERGY:BPLb:LDXASH:JSRSHD:STXASH:LDXFSH:JSRSHD:STXFSH:.b SEC:LDAENGY:ADCENERGY:BCSP%+5:STAENERGY\n 4260LDAMJ:BNEMA23S:LDAMCNT:AND#31:BNEMA93:LDASSPR:BNEMA23S:TAY:JSRMAS2:BNEMA23S\n 4270LDX#28:.MAL4 LDAK%,X:STAINWK,X:DEX:BPLMAL4:INX:LDY#9:JSRMAS1:BNEMA23S:LDX#3:LDY#11:JSRMAS1:BNEMA23S:LDX#6:LDY#13:JSRMAS1:BNEMA23S\n 4280LDA#&C0:JSRFAROF2:BCCMA23S\n 4290LDAQQ11:BNEP%+5\\!:JSRWPLS:JSRNWSPS:.MA23S JMPMA23\n 4300.MA22 LDAMJ:BNEMA23:LDAMCNT:AND#31:.MA93 CMP#10:BNEMA29:LDA#50:CMPENERGY:BCCP%+6:ASLA:JSRMESS:LDY#FF:STYALTIT:INY:JSRm:BNEMA23:JSRMAS3:BCSMA23:SBC#&24:BCCMA28:STAR:JSRLL5:LDAQ:STAALTIT:BNEMA23:.MA28 JMPDEATH\n 4310.MA29 CMP#20:BNEMA23:LDA#30:STACABTMP:LDASSPR:BNEMA23:LDY#NI%:JSRMAS2:BNEMA23:JSRMAS3:EOR#FF:ADC#30:STACABTMP:BCSMA28\n 4320CMP#&E0:BCCMA23:LDABST:BEQMA23:LDADELT4+1:LSRA:ADCQQ14:CMP#70:BCCP%+4:LDA#70:STAQQ14:LDA#160:JSRMESS\n 4350.MA23 LDALAS2:BEQMA16:LDALASCT:CMP#8:BCSMA16:JSRLASLI2:LDA#0:STALAS2:.MA16\n 4360LDAECMP:BEQMA69:JSRDENGY:BEQMA70:.MA69 LDAECMA:BEQMA66:DECECMA:BNEMA66:.MA70 JSRECMOF:.MA66\n 4380LDAQQ11:BNEMA9:JMPSTARS\n 4900.MAS1 LDAINWK,Y:ASLA:STAK+1:LDAINWK+1,Y:ROLA:STAK+2:LDA#0:RORA:STAK+3:JSRMVT3:STAINWK+2,X:LDYK+1:STYINWK,X:LDYK+2:STYINWK+1,X:AND#127:.MA9 RTS:.m LDA#0:.MAS2 ORAK%+2,Y:ORAK%+5,Y:ORAK%+8,Y:AND#127:RTS\n 4940.MAS3 LDAK%+1,Y:JSRSQUA2:STAR:LDAK%+4,Y:JSRSQUA2:ADCR:BCSMA30:STAR:LDAK%+7,Y:JSRSQUA2:ADCR:BCCP%+4:.MA30 LDA#FF:RTS\n 7000.MVEIT LDAINWK+31:AND#&A0:BNEMV30\n 7011LDAMCNT:EORXSAV:AND#15:BNEMV3:JSRTIDY:.MV3 LDXTYPE:BPLP%+5:JMPMV40:LDAINWK+32:BPLMV30:CPX#MSL:BEQMV26\n 7014LDAMCNT:EORXSAV:AND#7:BNEMV30:.MV26 JSRTACTICS:.MV30 JSRSCAN\n 7020LDAINWK+27:ASLA:ASLA:STAQ:LDAINWK+10:AND#127:JSRFMLTU:STAR:LDAINWK+10:LDX#0:JSRMVT1-2\n 7025LDAINWK+12:AND#127:JSRFMLTU:STAR:LDAINWK+12:LDX#3:JSRMVT1-2:LDAINWK+14:AND#127:JSRFMLTU:STAR:LDAINWK+14:LDX#6:JSRMVT1-2\n 7030LDAINWK+27:CLC:ADCINWK+28:BPLP%+4:LDA#0:LDY#15:CMP(XX0),Y:BCCP%+4:LDA(XX0),Y:STAINWK+27\n 7032LDA#0:STAINWK+28\n 7040LDXALP1:LDAINWK:EOR#FF:STAP:LDAINWK+1:JSRMLTU2-2:STAP+2:LDAALP2+1:EORINWK+2:LDX#3:JSRMVT6\n 7045STAK2+3:LDAP+1:STAK2+1:EOR#FF:STAP:LDAP+2:STAK2+2\\K2=Y-aX\n 7050LDXBET1:JSRMLTU2-2:STAP+2:LDAK2+3:EORBET2:LDX#6:JSRMVT6:STAINWK+8:LDAP+1:STAINWK+6:EOR#FF:STAP:LDAP+2:STAINWK+7\\Z=Z+bK2\n 7060JSRMLTU2:STAP+2:LDAK2+3:STAINWK+5:EORBET2:EORINWK+8:BPLMV43:LDAP+1:ADCK2+1:STAINWK+3:LDAP+2:ADCK2+2:STAINWK+4:JMPMV44:.MV43\n 7070LDAK2+1:SBCP+1:STAINWK+3:LDAK2+2:SBCP+2:STAINWK+4:BCSMV44:LDA#1:SBCINWK+3:STAINWK+3:LDA#0:SBCINWK+4:STAINWK+4:LDAINWK+5:EOR#128:STAINWK+5\n 7080.MV44\\Y=K2-bZ:LDXALP1:LDAINWK+3:EOR#FF:STAP:LDAINWK+4:JSRMLTU2-2:STAP+2:LDAALP2:EORINWK+5:LDX#0:JSRMVT6:STAINWK+2:LDAP+2:STAINWK+1:LDAP+1:STAINWK\\X=X+aY\n 7110.MV45 LDADELTA:STAR:LDA#128:LDX#6:JSRMVT1:LDATYPE:AND#&81:CMP#&81:BNEP%+3:RTS \\Z=Z-d\n 7120LDY#9:JSRMVS4:LDY#15:JSRMVS4:LDY#21:JSRMVS4:LDAINWK+30:AND#128:STARAT2:LDAINWK+30:AND#127:BEQMV8:CMP#127:SBC#0:ORARAT2:STAINWK+30\n 7130LDX#15:LDY#9:JSRMVS5:LDX#17:LDY#11:JSRMVS5:LDX#19:LDY#13:JSRMVS5\n 7160.MV8 LDAINWK+29:AND#128:STARAT2:LDAINWK+29:AND#127:BEQMV5:CMP#127:SBC#0:ORARAT2:STAINWK+29\n 7170LDX#15:LDY#21:JSRMVS5:LDX#17:LDY#23:JSRMVS5:LDX#19:LDY#25:JSRMVS5\n 7210.MV5 LDAINWK+31:AND#&A0:BNEMVD1:LDAINWK+31:ORA#16:STAINWK+31:JMPSCAN:.MVD1 LDAINWK+31:AND#&EF:STAINWK+31:RTS\n 7300AND#128:.MVT1 ASLA:STAS:LDA#0:RORA:STAT:LSRS:EORINWK+2,X:BMIMV10:LDAR:ADCINWK,X:STAINWK,X:LDAS:ADCINWK+1,X:STAINWK+1,X:LDAINWK+2,X:ADC#0:ORAT:STAINWK+2,X:RTS\n 7310.MV10 LDAINWK,X:SEC:SBCR:STAINWK,X:LDAINWK+1,X:SBCS:STAINWK+1,X:LDAINWK+2,X:AND#127:SBC#0:ORA#128:EORT:STAINWK+2,X:BCSMV11\n 7320LDA#1:SBCINWK,X:STAINWK,X:LDA#0:SBCINWK+1,X:STAINWK+1,X:LDA#0:SBCINWK+2,X:AND#127:ORAT:STAINWK+2,X:.MV11 RTS\n 7400.MVT3 LDAK+3:STAS:AND#128:STAT:EORINWK+2,X:BMIMV13:LDAK+1:CLC:ADCINWK,X:STAK+1:LDAK+2:ADCINWK+1,X:STAK+2:LDAK+3:ADCINWK+2,X:AND#127:ORAT:STAK+3:RTS\n 7410.MV13 LDAS:AND#127:STAS:LDAINWK,X:SEC:SBCK+1:STAK+1:LDAINWK+1,X:SBCK+2:STAK+2:LDAINWK+2,X:AND#127:SBCS:ORA#128:EORT:STAK+3:BCSMV14\n 7420LDA#1:SBCK+1:STAK+1:LDA#0:SBCK+2:STAK+2:LDA#0:SBCK+3:AND#127:ORAT:STAK+3:.MV14 RTS\n 7500.MVS4 LDAALPHA:STAQ:LDXINWK+2,Y:STXR:LDXINWK+3,Y:STXS:LDXINWK,Y:STXP:LDAINWK+1,Y:EOR#128:JSRMAD:STAINWK+3,Y:STXINWK+2,Y:STXP \\Y=Y-aX\n 7520LDXINWK,Y:STXR:LDXINWK+1,Y:STXS:LDAINWK+3,Y:JSRMAD:STAINWK+1,Y:STXINWK,Y:STXP \\X=X+aY\n 7530LDABETA:STAQ:LDXINWK+2,Y:STXR:LDXINWK+3,Y:STXS:LDXINWK+4,Y:STXP:LDAINWK+5,Y:EOR#128:JSRMAD:STAINWK+3,Y:STXINWK+2,Y:STXP\\Y=Y-bZ\n 7540LDXINWK+4,Y:STXR:LDXINWK+5,Y:STXS:LDAINWK+3,Y:JSRMAD:STAINWK+5,Y:STXINWK+4,Y:RTS\\Z=Z+bY\n 7600.MVS5 LDAINWK+1,X:AND#127:LSRA:STAT:LDAINWK,X:SEC:SBCT:STAR:LDAINWK+1,X:SBC#0:STAS:LDAINWK,Y:STAP:LDAINWK+1,Y:AND#128:STAT:LDAINWK+1,Y:AND#127:LSRA:RORP:LSRA:RORP:LSRA:RORP:LSRA:RORP:ORAT:EORRAT2:STXQ:JSRADD:STAK+1:STXK\n 7610LDXQ:LDAINWK+1,Y:AND#127:LSRA:STAT:LDAINWK,Y:SEC:SBCT:STAR:LDAINWK+1,Y:SBC#0:STAS:LDAINWK,X:STAP:LDAINWK+1,X:AND#128:STAT:LDAINWK+1,X:AND#127:LSRA:RORP:LSRA:RORP:LSRA:RORP:LSRA:RORP:ORAT:EOR#128:EORRAT2\n 7620STXQ:JSRADD:STAINWK+1,Y:STXINWK,Y:LDXQ:LDAK:STAINWK,X:LDAK+1:STAINWK+1,X:RTS\n 7650.MVT6 TAY:EORINWK+2,X:BMIMV50:LDAP+1:CLC:ADCINWK,X:STAP+1:LDAP+2:ADCINWK+1,X:STAP+2:TYA:RTS\n 7660.MV50 LDAINWK,X:SEC:SBCP+1:STAP+1:LDAINWK+1,X:SBCP+2:STAP+2:BCCMV51:TYA:EOR#128:RTS:.MV51 LDA#1:SBCP+1:STAP+1:LDA#0:SBCP+2:STAP+2:TYA:RTS\n 7700.MV40 LDAALPHA:EOR#128:STAQ:LDAINWK:STAP:LDAINWK+1:STAP+1:LDAINWK+2:JSRMULT3:LDX#3:JSRMVT3\\K=Y-aX\n 7710LDAK+1:STAK2+1:STAP:LDAK+2:STAK2+2:STAP+1:LDABETA:STAQ:LDAK+3:STAK2+3:JSRMULT3:LDX#6:JSRMVT3:LDAK+1:STAP:STAINWK+6:LDAK+2:STAP+1:STAINWK+7:LDAK+3:STAINWK+8\\Z=Z+bK2\n 7720EOR#128:JSRMULT3:LDAK+3:AND#128:STAT:EORK2+3:BMIMV1\n 7730LDAK:\\CLC:ADCK2:LDAK+1:ADCK2+1:STAINWK+3:LDAK+2:ADCK2+2:STAINWK+4:LDAK+3:ADCK2+3:JMPMV2\n 7740.MV1 LDAK:SEC:SBCK2:LDAK+1:SBCK2+1:STAINWK+3:LDAK+2:SBCK2+2:STAINWK+4:LDAK2+3:AND#127:STAP:LDAK+3:AND#127:SBCP:STAP:BCSMV2\n 7750LDA#1:SBCINWK+3:STAINWK+3:LDA#0:SBCINWK+4:STAINWK+4:LDA#0:SBCP:ORA#128:.MV2 EORT:STAINWK+5\\Y=K2-bZ\n 7760LDAALPHA:STAQ:LDAINWK+3:STAP:LDAINWK+4:STAP+1:LDAINWK+5:JSRMULT3:LDX#0:JSRMVT3:LDAK+1:STAINWK:LDAK+2:STAINWK+1:LDAK+3:STAINWK+2\\X=X+aY\n 7770JMPMV45:]\n 9510IFZ>4OSCLI\"S.ELTA \"+STR$~W%+\" \"+STR$~O%+\" \"+STR$~L%+\" \"+STR$~H%\n 9520PRINT\"A d,\";:GOTO2\n10100DEFFNZ=FNZT(1)\n10110DEFFNZ2=FNZT(2)\n10120DEFFNZT(N%):ZP=ZP+N%:=ZP-N%\n10300DEFFNW=FNWT(1)\n10310DEFFNW2=FNWT(2)\n10320DEFFNWT(N%):WP=WP+N%:=WP-N%\n10400DEFFNTP=FNTPT(1)\n10410DEFFNTPT(N%):T%=T%+N%:=T%-N%\n"
  },
  {
    "path": "1-source-files/original-sources/text-sources/ELITEB.txt",
    "content": "    1GOTO20\n    2*L.ELITEB\n    3GOTO20\n    4*L.ELITEA\n    6*L.ELITEC\n   20REM ELITE <B>\n 1000O%=W%:H%=L%+P%-C%:Q%=FALSE\n 1010J%=O%:[OPTZ\n 1100.NA% EQUS(\"JAMESON\"):EQUB13:EQUB0\n 1110EQUB20\\QQ0:EQUB173\\QQ1:EQUD&2485A4A\\QQ21:EQUW&B753 \\Base seed\n 1120EQUD(((&E8030000)AND(NOTQ%))+((&CA9A3B)ANDQ%))\\CASH,&80969800\n 1130EQUB70 fuel\n 1135EQUB 0 COK-UP\n 1137EQUB0 GALACTIC COUNT\n 1140EQUBPOW+(128ANDQ%):EQUB(POW+128)ANDQ%:EQUB0:EQUB0:EQUW0 LASER:EQUB22+(15ANDQ%) \\37 CRGO\n 1150EQUD0:EQUD0:EQUD0:EQUD0:EQUB0\\crgo\n 1160EQUB Q% ECM\n 1170EQUB Q% BST\n 1180EQUB Q%AND127 BOMB\n 1190EQUB Q%AND1 ENGY++\n 1200EQUB Q% DCK COMP\n 1203EQUB Q% GHYP\n 1205EQUB Q% ESCP\n 1207EQUD FALSE EXPAND\n 1210EQUB 3+(Q%AND1) MISSILES\n 1220EQUB FALSE FIST\n 1222EQUB16:EQUB15:EQUB17:EQUB0:EQUB3:EQUB28:EQUB14:EQUW0:EQUB10:EQUB0:EQUB17:EQUB58:EQUB7:EQUB9:EQUB8:EQUB0\n 1224EQUB 0 QQ26\n 1230EQUW 0 TALLY\n 1240EQUB 128 SVC\n 1245]CH%=NT%-2:CY%=0:FORI%=CH%+J%TO1+J%STEP-1:CH%=CH%+CY%+(I%?7):CY%=(CH%>255)AND1:CH%=CH%MOD256:CH%=CH%EOR(I%?8):NEXT:[OPTZ\n 1247.CHK2 EQUB CH% EOR&A9\n 1250.CHK EQUB CH%\n 1300.UNIV:]FORI%=0TO12:!O%=K%+I%*NI%:O%=O%+2:P%=P%+2:NEXT:[OPTZ\n 1800.TWOS EQUD&10204080:EQUD&01020408:.TWOS2 EQUD&183060C0:EQUD&0303060C:.CTWOS EQUD&11224488:EQUB&88\n 2000.LL30:.LOIN STYYSAV\n 2020LDA#128:STAS:ASLA:STASWAP:LDAX2:SBCX1:BCSLI1:EOR#FF:ADC#1:SEC:.LI1 STAP\n 2030LDAY2:SBCY1:BCSLI2:EOR#FF:ADC#1:.LI2 STAQ:CMPP:BCCSTPX:JMPSTPY\n 2040.STPX LDXX1:CPXX2:BCCLI3:DECSWAP:LDAX2:STAX1:STXX2:TAX:LDAY2:LDYY1:STAY1:STYY2:.LI3\n 2050LDAY1:LSRA:LSRA:LSRA:ORA#&60:STASCH:LDAY1:AND#7:TAY:TXA:AND#&F8:STASC\n 2060TXA:AND#7:TAX:LDATWOS,X:STAR\n 2064LDAQ:LDX#254:STXQ:.LIL1 ASLA:BCSLI4:CMPP:BCCLI5:.LI4 SBCP:SEC:.LI5 ROLQ:BCSLIL1\n 2070LDXP:INX:LDAY2:SBCY1:BCSDOWN\n 2080LDASWAP:BNELI6:DEX:.LIL2 LDAR:EOR(SC),Y:STA(SC),Y\n 2090.LI6 LSRR:BCCLI7:RORR:LDASC:ADC#8:STASC\n 2100.LI7 LDAS:ADCQ:STAS:BCCLIC2:DEY:BPLLIC2:DECSCH:LDY#7\n 2110.LIC2 DEX:BNELIL2:LDYYSAV:RTS\n 2150.DOWN LDASWAP:BEQLI9:DEX:.LIL3 LDAR:EOR(SC),Y:STA(SC),Y\n 2160.LI9 LSRR:BCCLI10:RORR:LDASC:ADC#8:STASC\n 2170.LI10 LDAS:ADCQ:STAS:BCCLIC3:INY:CPY#8:BNELIC3:INCSCH:LDY#0\n 2180.LIC3 DEX:BNELIL3:LDYYSAV:RTS\n 2200.STPY LDYY1:TYA:LDXX1:CPYY2:BCSLI15:DECSWAP:LDAX2:STAX1:STXX2:TAX:LDAY2:STAY1:STYY2:TAY\n 2210.LI15 LSRA:LSRA:LSRA:ORA#&60:STASCH:TXA:AND#&F8:STASC\n 2214TXA:AND#7:TAX:LDATWOS,X:STAR:LDAY1:AND#7:TAY\n 2220LDAP:LDX#1:STXP:.LIL4 ASLA:BCSLI13:CMPQ:BCCLI14:.LI13 SBCQ:SEC:.LI14 ROLP:BCCLIL4:LDXQ:INX:LDAX2:SBCX1:BCCLFT\n 2230CLC:LDASWAP:BEQLI17:DEX:.LIL5 LDAR:EOR(SC),Y:STA(SC),Y:.LI17 DEY:BPLLI16:DECSCH:LDY#7\n 2240.LI16 LDAS:ADCP:STAS:BCCLIC5:LSRR:BCCLIC5:RORR:LDASC:ADC#8:STASC\n 2250.LIC5 DEX:BNELIL5:LDYYSAV:RTS\n 2300.LFT LDASWAP:BEQLI18:DEX:.LIL6 LDAR:EOR(SC),Y:STA(SC),Y:.LI18 DEY:BPLLI19:DECSCH:LDY#7:.LI19 LDAS:ADCP:STAS:BCCLIC6\n 2310ASLR:BCCLIC6:ROLR:LDASC:SBC#7:STASC:CLC:.LIC6 DEX:BNELIL6:LDYYSAV\n 2390.HL6 RTS\n 2392.NLIN3 JSRTT27:.NLIN4 LDA#19:BNENLIN2:.NLIN LDA#23:INCYC:.NLIN2 STAY1:LDX#2:STXX1:LDX#254:STXX2:BNEHLOIN\n 2395.HLOIN2 JSREDGES:STYY1:LDA#0:STALSO,Y\n 2400.HLOIN STYYSAV:LDXX1:CPXX2:BEQHL6:BCCHL5:LDAX2:STAX1:STXX2:TAX:.HL5 DECX2\n 2410LDAY1:LSRA:LSRA:LSRA:ORA#&60:STASCH:LDAY1:AND#7:STASC:TXA:AND#&F8:TAY\n 2420.HL1 TXA:AND#&F8:STAT:LDAX2:AND#&F8:SEC:SBCT:BEQHL2:LSRA:LSRA:LSRA:STAR\n 2430LDAX1:AND#7:TAX:LDATWFR,X:EOR(SC),Y:STA(SC),Y:TYA:ADC#8:TAY:LDXR:DEX:BEQHL3\n 2440CLC:.HLL1 LDA#FF:EOR(SC),Y:STA(SC),Y:TYA:ADC#8:TAY:DEX:BNEHLL1\n 2450.HL3 LDAX2:AND#7:TAX:LDATWFL,X:EOR(SC),Y:STA(SC),Y:LDYYSAV:RTS\n 2460.HL2 LDAX1:AND#7:TAX:LDATWFR,X:STAT:LDAX2:AND#7:TAX:LDATWFL,X:ANDT:EOR(SC),Y:STA(SC),Y:LDYYSAV:RTS\n 2470.TWFL EQUD&F0E0C080:EQUW&FCF8:EQUB&FE:.TWFR EQUD&1F3F7FFF:EQUD&0103070F\n 2520.PX3 LDATWOS,X:EOR(SC),Y:STA(SC),Y:LDYT1:RTS\n 2580.PIX1 JSRADD:STAYY+1:TXA:STASYL,Y\n 2600.PIXEL2\n 2610LDAX1:BPLPX1:EOR#&7F:CLC:ADC#1:.PX1 EOR#128:TAX:LDAY1:AND#127:CMP#96:BCSPX4:LDAY1:BPLPX2:EOR#&7F:ADC#1:.PX2 STAT:LDA#97:SBCT\n 2620.PIXEL STYT1:TAY:LSRA:LSRA:LSRA:ORA#&60:STASCH:TXA:AND#&F8:STASC:TYA:AND#7:TAY:TXA:AND#7:TAX\n 2630LDAZZ:CMP#&90:BCSPX3:LDATWOS2,X:EOR(SC),Y:STA(SC),Y:LDAZZ:CMP#&50:BCSPX13:DEY:BPLPX14:LDY#1:.PX14 LDATWOS2,X:EOR(SC),Y:STA(SC),Y:.PX13 LDYT1:.PX4 RTS\n 3000.BLINE TXA:ADCK4:STAK6+2:LDAK4+1:ADCT:STAK6+3\n 3010LDAFLAG:BEQBL1:INCFLAG:.BL5 LDYLSP:LDA#FF:CMPLSY2-1,Y:BEQBL7:STALSY2,Y:INCLSP:BNEBL7:.BL1 LDAK5:STAXX15:LDAK5+1:STAXX15+1\n 3012LDAK5+2:STAXX15+2:LDAK5+3:STAXX15+3\n 3014LDAK6:STAXX15+4:LDAK6+1:STAXX15+5\n 3016LDAK6+2:STAXX12:LDAK6+3:STAXX12+1\n 3040JSRLL145:BCSBL5:LDASWAP:BEQBL9:LDAX1:LDYX2:STAX2:STYX1:LDAY1:LDYY2:STAY2:STYY1:.BL9\n 3050LDYLSP:LDALSY2-1,Y:CMP#FF:BNEBL8:LDAX1:STALSX2,Y:LDAY1:STALSY2,Y:INY:.BL8 LDAX2:STALSX2,Y:LDAY2:STALSY2,Y:INY:STYLSP:JSRLOIN\n 3051LDAXX13:BNEBL5\n 3052.BL7 LDAK6:STAK5:LDAK6+1:STAK5+1:LDAK6+2:STAK5+2:LDAK6+3:STAK5+3:LDACNT:CLC:ADCSTP:STACNT\n 3700RTS:.FLIP \\LDAMJ\\BNEFLIP-1:LDYNOSTM:.FLL1 LDXSY,Y:LDASX,Y:STAY1:STASY,Y:TXA:STAX1:STASX,Y:LDASZ,Y:STAZZ:JSRPIXEL2:DEY:BNEFLL1:RTS\n 3800.STARS \\LDA#FF:\\STACOL:LDXVIEW:BEQSTARS1:DEX:BNEST11:JMPSTARS6:.ST11 JMPSTARS2\n 4000.STARS1\n 4010LDYNOSTM:.STL1 JSRDV42:LDAR:LSRP:RORA:LSRP:RORA:ORA#1:STAQ\n 4012LDASZL,Y:SBCDELT4:STASZL,Y:LDASZ,Y:STAZZ:SBCDELT4+1:STASZ,Y\n 4020JSRMLU1:STAYY+1:LDAP:ADCSYL,Y:STAYY:STAR:LDAY1:ADCYY+1:STAYY+1:STAS\n 4030LDASX,Y:STAX1:JSRMLU2:STAXX+1:LDAP:ADCSXL,Y:STAXX:LDAX1:ADCXX+1:STAXX+1\n 4050EORALP2+1:JSRMLS1:JSRADD:STAYY+1:STXYY\n 4060EORALP2:JSRMLS2:JSRADD:STAXX+1:STXXX\n 4070LDXBET1:LDAYY+1:EORBET2+1:JSRMULTS-2:STAQ:JSRMUT2:ASLP:ROLA:STAT:LDA#0:RORA:ORAT:JSRADD:STAXX+1:TXA:STASXL,Y\n 4080LDAYY:STAR:LDAYY+1:STAS:\\JSRMADSTASSTXR:LDA#0:STAP:LDABETA:EOR#128\n 4110JSRPIX1:LDAXX+1:STAX1:STASX,Y:AND#127:CMP#120:BCSKILL1:LDAYY+1:STASY,Y:STAY1:AND#127:CMP#120:BCSKILL1\n 4130LDASZ,Y:CMP#16:BCCKILL1:STAZZ\n 4140.STC1 JSRPIXEL2:DEY:BEQP%+5:JMPSTL1:RTS\n 4150.KILL1 JSRDORND:ORA#4:STAY1:STASY,Y:JSRDORND:ORA#8:STAX1:STASX,Y:JSRDORND:ORA#&90:STASZ,Y:STAZZ:LDAY1:JMPSTC1\n 4200.STARS6\n 4210LDYNOSTM:.STL6 JSRDV42:LDAR:LSRP:RORA:LSRP:RORA:ORA#1:STAQ\n 4220LDASX,Y:STAX1:JSRMLU2:STAXX+1:LDASXL,Y:SBCP:STAXX:LDAX1:SBCXX+1:STAXX+1\n 4230JSRMLU1:STAYY+1:LDASYL,Y:SBCP:STAYY:STAR:LDAY1:SBCYY+1:STAYY+1:STAS\n 4240LDASZL,Y:ADCDELT4:STASZL,Y:LDASZ,Y:STAZZ:ADCDELT4+1:STASZ,Y\n 4250LDAXX+1:EORALP2:JSRMLS1:JSRADD:STAYY+1:STXYY\n 4260EORALP2+1:JSRMLS2:JSRADD:STAXX+1:STXXX\n 4270LDAYY+1:EORBET2+1:LDXBET1:JSRMULTS-2:STAQ:LDAXX+1:STAS:EOR#128:JSRMUT1:ASLP:ROLA:STAT:LDA#0:RORA:ORAT:JSRADD:STAXX+1:TXA:STASXL,Y\n 4280LDAYY:STAR:LDAYY+1:STAS:\\EOR#128:\\JSRMADSTASSTXR:LDA#0:STAP:LDABETA\n 4310JSRPIX1:LDAXX+1:STAX1:STASX,Y:LDAYY+1:STASY,Y:STAY1:AND#127:CMP#110:BCSKILL6\n 4330LDASZ,Y:CMP#160:BCSKILL6:STAZZ\n 4340.STC6 JSRPIXEL2:DEY:BEQST3:JMPSTL6:.ST3 RTS\n 4350.KILL6 JSRDORND:AND#127:ADC#10:STASZ,Y:STAZZ:LSRA:BCSST4:LSRA:LDA#&FC:RORA:STAX1:STASX,Y:JSRDORND:STAY1:STASY,Y:JMPSTC6\n 4360.ST4 JSRDORND:STAX1:STASX,Y:LSRA:LDA#230:RORA:STAY1:STASY,Y:BNESTC6\n 5000.PRXS EQUW1:EQUW300:EQUW4000:EQUW6000:EQUW4000:EQUW10000:EQUW5250:EQUW10000:EQUW9000:EQUW15000:EQUW10000:EQUW50000\n 6990.st4 LDX#9:CMP#25:BCSst3:DEX:CMP#10:BCSst3:DEX:CMP#2:BCSst3:DEX:BNEst3\n 7000.STATUS LDA#8:JSRTT66:JSRTT111:LDA#7:STAXC:LDA#126:JSRNLIN3:LDA#15:LDYQQ12:BNEst6:LDA#230:LDYMANY+AST:LDXFRIN+2,Y:BEQst6:LDYENERGY:CPY#128:ADC#1:.st6 JSRplf:LDA#125:JSRspc:LDA#19:LDYFIST:BEQst5:CPY#50:ADC#1:.st5 JSRplf:LDA#16\n 7010JSRspc:LDATALLY+1:BNEst4:TAX:LDATALLY:LSRA:LSRA:INX:LSRA:BNEP%-2:.st3 TXA:CLC:ADC#21:JSRplf\n 7030LDA#18:JSRplf2:LDACRGO:CMP#26:BCCP%+7:LDA#&6B:JSRplf2:LDABST:BEQP%+7:LDA#111:JSRplf2:LDAECM:BEQP%+7:LDA#&6C:JSRplf2:LDA#113:STAXX4:.stqv TAY:LDXBOMB-113,Y:BEQP%+5:JSRplf2:INCXX4:LDAXX4:CMP#117:BCCstqv\n 7040LDX#0:.st STXCNT:LDYLASER,X:BEQst1:TXA:CLC:ADC#96:JSRspc:LDA#103:LDXCNT:LDYLASER,X:BPLP%+4:LDA#104:JSRplf2:.st1 LDXCNT:INX:CPX#4:BCCst:RTS\n 7100.plf2 JSRplf:LDX#6:STXXC:RTS\n 7600.TENS EQUD&E87648\n 7605.pr2 LDA#3:LDY#0\n 7610.TT11 STAU:LDA#0:STAK:STAK+1:STYK+2:STXK+3:.BPRNT LDX#11:STXT:PHP:BCCTT30:DECT:DECU\n 7630.TT30 LDA#11:SEC:STAXX17:SBCU:STAU:INCU:LDY#0:STYS:JMPTT36\n 7640.TT35 ASLK+3:ROLK+2:ROLK+1:ROLK:ROLS:LDX#3:.tt35 LDAK,X:STAXX15,X:DEX:BPLtt35:LDAS:STAXX15+4\n 7650ASLK+3:ROLK+2:ROLK+1:ROLK:ROLS:ASLK+3:ROLK+2:ROLK+1:ROLK:ROLS:CLC:LDX#3:.tt36 LDAK,X:ADCXX15,X:STAK,X:DEX:BPLtt36:LDAXX15+4:ADCS:STAS\n 7660LDY#0:.TT36 LDX#3:SEC:.tt37 LDAK,X:SBCTENS,X:STAXX15,X:DEX:BPLtt37:LDAS:SBC#23:STAXX15+4\n 7670BCCTT37:LDX#3:.tt38 LDAXX15,X:STAK,X:DEX:BPLtt38:LDAXX15+4:STAS:INY:JMPTT36\n 7680.TT37 TYA:BNETT32:LDAT:BEQTT32:DECU:BPLTT34:LDA#32:BNEtt34:.TT32 LDY#0:STYT:CLC:ADC#B:.tt34 JSRTT26\n 7700.TT34 DECT:BPLP%+4:INCT:DECXX17:BMIRR3+1 \\!!:BNEP%+10:PLP:BCCP%+7:LDA#&2E:JSRTT26:JMPTT35\n 8000.BELL LDA#7\n 8200.TT26 \\PRINT\n 8205STAK3:STYYSAV2:STXXSAV2:LDYQQ17:CPY#FF:BEQRR4\n 8210CMP#7:BEQR5:CMP#32:BCSRR1:CMP#10:BEQRRX1:LDX#1:STXXC:.RRX1 INCYC:BNERR4\n 8220.RR1 \\LDX#(K3 MOD256)\\INX\\STXP+1\\DEX\\LDY#(K3 DIV256)\\STYP+2\\LDA#10\\JSROSWORD\n 8225TAY:LDX#&BF:ASLA:ASLA:BCCP%+4:LDX#&C1:ASLA:BCCP%+3:INX:STAP+1:STXP+2\n 8240LDAXC:ASLA:ASLA:ASLA:STASC:LDAYC:CPY#&7F:BNERR2:DECXC:ADC#&5E:TAX:LDY#&F8:JSRZES2:BEQRR4:.RR2 INCXC:\\LDAYC:CMP#24:BCCRR3:JSRTTX66:JMPRR4\n 8250.RR3 ORA#&60:.RREN STASC+1:LDY#7:.RRL1 LDA(P+1),Y:EOR(SC),Y:STA(SC),Y:DEY:BPLRRL1\n 8260.RR4 LDYYSAV2:LDXXSAV2:LDAK3:CLC:.rT9 RTS\n 8270.R5 JSRBEEP:JMPRR4\n 9500.DIALS LDA#&D0:STASC:LDA#&78:STASC+1:JSRPZW:STXK+1:STAK:LDA#14:STAT1:LDADELTA:\\LSRA:JSRDIL-1\n 9502LDA#0:STAR:STAP:LDA#8:STAS:LDAALP1:LSRA:LSRA:ORAALP2:EOR#128:JSRADD:JSRDIL2:LDABETA:LDXBET1:BEQP%+4:SBC#1:JSRADD:JSRDIL2\n 9503LDAMCNT:AND#3:BNErT9\n 9504LDY#0:JSRPZW:STXK:STAK+1:LDX#3:STXT1:.DLL23 STYXX12,X:DEX:BPLDLL23:LDX#3:LDAENERGY:LSRA:LSRA:STAQ:.DLL24 SEC:SBC#16:BCCDLL26:STAQ:LDA#16:STAXX12,X:LDAQ:DEX:BPLDLL24:BMIDLL9:.DLL26\n 9505LDAQ:STAXX12,X:.DLL9 LDAXX12,Y:STYP:JSRDIL:LDYP:INY:CPY#4:BNEDLL9\n 9506LDA#&78:STASC+1:LDA#16:\\\"<80<:STASC:LDAFSH:JSRDILX:LDAASH:JSRDILX:LDAQQ14:JSRDILX+2\n 9510JSRPZW:STXK+1:STAK:LDX#11:STXT1:LDACABTMP:JSRDILX:LDAGNTMP:JSRDILX\n 9530LDA#&F0:STAT1:STAK+1:LDAALTIT:JSRDILX:JMPCOMPAS\n 9540.PZW LDX#&F0:LDAMCNT:AND#8:ANDFLH:BEQP%+4:TXA:EQUB&2C:LDA#15:RTS\n 9690.DILX LSRA:LSRA:LSRA:LSRA\n 9700.DIL STAQ:LDX#FF:STXR:CMPT1:BCSDL30:LDAK+1:BNEDL31:.DL30 LDAK:.DL31 STACOL:LDY#2:LDX#3:.DL1 LDAQ:CMP#4:BCCDL2:SBC#4:STAQ:LDAR:.DL5 ANDCOL:STA(SC),Y:INY:STA(SC),Y:INY:STA(SC),Y:TYA:CLC:ADC#6:TAY:DEX:BMIDL6:BPLDL1\n 9710.DL2 EOR#3:STAQ:LDAR:.DL3 ASLA:AND#239:DECQ:BPLDL3:PHA:LDA#0:STAR:LDA#99:STAQ:PLA:JMPDL5:.DL6 INCSC+1:.DL9 RTS\n 9712.DIL2 LDY#1:STAQ:.DLL10 SEC:LDAQ:SBC#4:BCSDLL11:LDA#FF:LDXQ:STAQ:LDACTWOS,X:AND#&F0:BNEDLL12:.DLL11 STAQ:LDA#0:.DLL12 STA(SC),Y:INY:STA(SC),Y:INY:STA(SC),Y:INY:STA(SC),Y:TYA:CLC:ADC#5:TAY:CPY#30:BCCDLL10:INCSC+1:RTS\n 9730.TVT1 EQUD&8494C4D4:\\TVT2:EQUD&A5B5E5F5:EQUD&26366676:EQUD&A1B1F1E1:\\TVT3:EQUD&A0B0E0F0:EQUD&8090C0D0:EQUD&27376777\n 9740.LINSCN LDA#30:STADL:STAUSVIA+4:LDA#VSCAN:STAUSVIA+5:LDAHFX:BNEVNT1:LDA#8:STA&FE20:.VNT3 LDATVT1+16,Y:STA&FE21:DEY:BPLVNT3:LDALASCT:BEQP%+5:DECLASCT:\\VNT4:LDAsvn:BNEjvec:PLA:TAY:LDA&FE41:LDA&FC:RTI\n 9750.IRQ1 TYA:PHA:LDY#11:LDA#2:BITVIA+&D:BNELINSCN:BVCjvec:ASLA\\4:STA&FE20:LDAESCP:BNEVNT1:\\VNT2:LDATVT1,Y:STA&FE21:DEY:BPLP%-7:.jvec PLA:TAY:JMP(VEC):.VNT1 LDY#7:LDATVT1+8,Y:STA&FE21:DEY:BPLVNT1+2:BMIjvec\n 9800.ESCAPE LDAMJ:PHA:JSRRES2:LDX#CYL:STXTYPE:JSRFRS1:LDA#8:STAINWK+27:LDA#&C2:STAINWK+30:LSRA:STAINWK+32:.ESL1 JSRMVEIT:JSRLL9:DECINWK+32:BNEESL1\n 9810JSRSCAN:JSRRESET:PLA:BEQP%+5:JMPDEATH:LDX#16:.ESL2 STAQQ20,X:DEX:BPLESL2:STAFIST:STAESCP:LDA#70:STAQQ14:JMPBAY\n 9900]\n 9910IFZ>4OSCLI(\"S.ELTB \"+STR$~W%+\" \"+STR$~O%+\" \"+STR$~L%+\" \"+STR$~H%)\n 9920PRINT\"B done,\";:GOTO6\n\n"
  },
  {
    "path": "1-source-files/original-sources/text-sources/ELITEC.txt",
    "content": "    1GOTO20\n    2*L.ELITEB\n    3GOTO20\n    4*L.ELITEA\n    6*L.ELITEC\n    7GOTO20\n    8*L.ELITED\n   20REM ELITE <C>\n 1000O%=W%:H%=L%+P%-C%\n 1010[OPTZ\n 1880.TA34 LDA#0:JSRMAS4:BEQP%+5:JMPTA21:JSRTA87+3:JSREXNO3:LDA#250:JMPOOPS\n 1900.TA18\\msl\n 1910LDAECMA:BNETA35:LDAINWK+32:ASLA:BMITA34:LSRA\n 1915TAX:LDAUNIV,X:STAV:LDAUNIV+1,X:STAV+1:LDY#2:JSRTAS1:LDY#5:JSRTAS1:LDY#8:JSRTAS1\n 1920LDAK3+2:ORAK3+5:ORAK3+8:AND#127:ORAK3+1:ORAK3+4:ORAK3+7:BNETA64\n 1930LDAINWK+32:CMP#&82:BEQTA35:LDY#31:LDA(V),Y:BITM32+1:BNETA35:ORA#128:STA(V),Y:.TA35 LDAINWK:ORAINWK+3:ORAINWK+6:BNETA87:LDA#80:JSROOPS:.TA87 JSREXNO2:ASLINWK+31:SEC:RORINWK+31\n 1940.TA1 RTS\n 1944.TA64 JSRDORND:CMP#16:BCSTA19:.M32 LDY#32:LDA(V),Y:LSRA:BCCTA19:JMPECBLB2\n 2000.TACTICS\n 2005CPX#MSL:BEQTA18:CPX#ESC:BNEP%+8:JSRSPS1:JMPTA15:CPX#SST:BNETA13:JSRDORND:CMP#140:BCCTA14-1:LDAMANY+SH3:CMP#4:BCSTA14-1:LDX#COPS:LDA#&F1:JMPSFS1:.TA13\n 2008CPX#TGL:BNETA14:LDAMANY+THG:BNETA14:LSRINWK+32:ASLINWK+32:LSRINWK+27:RTS:.TA14 CPX#CYL:BCSTA62:CPX#COPS:BEQTA62:LDASSPR:BEQTA62:LDAINWK+32:AND#129:STAINWK+32\n 2010.TA62 LDY#14:LDAINWK+35:CMP(XX0),Y:BCSTA21:INCINWK+35:.TA21\n 2020LDX#8:.TAL1 LDAINWK,X:STAK3,X:DEX:BPLTAL1\n 2030.TA19 JSRTAS2\\XX15=r~96\n 2040LDY#10:JSRTAS3:STACNT:LDATYPE:CMP#MSL:BNEP%+5:JMPTA20:JSRDORND:CMP#250:BCCTA7:JSRDORND:ORA#&68:STAINWK+29:.TA7\\VRol\n 2100LDY#14:LDA(XX0),Y:LSRA:CMPINWK+35:BCCTA3:LSRA:LSRA:CMPINWK+35:BCCta3:JSRDORND:CMP#230:BCCta3:LDATYPE:CMP#THG:BEQta3:LDA#0:STAINWK+32:JMPSESCP\n 2102.ta3 LDAINWK+31:AND#7:BEQTA3:STAT:JSRDORND:AND#31:CMPT:BCSTA3:LDAECMA:BNETA3:DECINWK+31:LDATYPE:CMP#THG:BNETA16:LDX#TGL:LDAINWK+32:JMPSFS1:.TA16 JMPSFRMIS:.TA3\n 2110LDA#0:JSRMAS4:AND#&E0:BNETA4:LDXCNT:CPX#160:BCCTA4:LDAINWK+31:ORA#64:STAINWK+31:CPX#163:BCCTA4\n 2120LDY#19:LDA(XX0),Y:LSRA:JSROOPS:DECINWK+28:LDAECMA:BNETA10:LDA#8:JMPNOISE:\\frLs\n 2190.TA4 LDAINWK+7:CMP#3:BCSTA5:LDAINWK+1:ORAINWK+4:AND#&FE:BEQTA15:.TA5 JSRDORND:ORA#128:CMPINWK+32:BCSTA15\n 2194.TA20 LDAXX15:EOR#128:STAXX15:LDAXX15+1:EOR#128:STAXX15+1:LDAXX15+2:EOR#128:STAXX15+2:LDACNT:EOR#128:STACNT\n 2200.TA15\\^XX15\n 2220LDY#16:JSRTAS3:EOR#128:AND#128:ORA#3:STAINWK+30\n 2235LDAINWK+29:AND#127:CMP#16:BCSTA6\n 2240LDY#22:JSRTAS3:EORINWK+30:AND#128:EOR#&85:STAINWK+29\n 2260.TA6 LDACNT:BMITA9:CMP#22:BCCTA9:LDA#3:STAINWK+28:RTS\n 2280.TA9 AND#127:CMP#18:BCCTA10:LDA#FF:LDXTYPE:CPX#MSL:BNEP%+3:ASLA:STAINWK+28:.TA10 RTS\n 2900.TAS1 LDA(V),Y:EOR#128:STAK+3:DEY:LDA(V),Y:STAK+2:DEY:LDA(V),Y:STAK+1:STYU:LDXU:JSRMVT3:LDYU\n 2910STAK3+2,X:LDAK+2:STAK3+1,X:LDAK+1:STAK3,X:RTS\n 3000.HITCH CLC:LDAINWK+8:BNEHI1:LDATYPE:BMIHI1:LDAINWK+31:AND#32:ORAINWK+1:ORAINWK+4:BNEHI1\n 3005LDAINWK:JSRSQUA2:STAS:LDAP:STAR\n 3010LDAINWK+3:JSRSQUA2:TAX:LDAP:ADCR:STAR:TXA:ADCS:BCSFR1-2:STAS:LDY#2:LDA(XX0),Y:CMPS:BNEHI1:DEY:LDA(XX0),Y:CMPR:.HI1 RTS\n 3210.FRS1 JSRZINF:LDA#28:STAINWK+3:LSRA:STAINWK+6:LDA#128:STAINWK+5:LDAMSTG:ASLA:ORA#128:STAINWK+32\n 3220.fq1 LDA#96:STAINWK+14:ORA#128:STAINWK+22:LDADELTA:ROLA:STAINWK+27:TXA:JMPNWSHP\n 3230.FRMIS LDX#MSL:JSRFRS1:BCCFR1:LDXMSTG:JSRGINF:LDAFRIN,X:JSRANGRY:LDY#0:JSRABORT:DECNOMSL:LDA#48:JMPNOISE\n 3234.ANGRY CMP#SST:BEQAN2:BCSHI1:CMP#CYL:BNEP%+5:JSRAN2:LDY#32:LDA(INF),Y:BEQHI1:ORA#128:STA(INF),Y:LDY#28:LDA#2:STA(INF),Y:ASLA:LDY#30:STA(INF),Y:RTS\n 3236.AN2 ASLK%+NI%+32:SEC:RORK%+NI%+32:CLC:RTS:.FR1 LDA#201:JMPMESS\n 3310.SESCP LDX#ESC:LDA#&FE:.SFS1 STAT1:LDAXX0:PHA:LDAXX0+1:PHA:LDAINF:PHA:LDAINF+1:PHA:LDY#NI%-1:.FRL2 LDAINWK,Y:STAXX3,Y:LDA(INF),Y:STAINWK,Y:DEY:BPLFRL2\n 3315LDATYPE:CMP#SST:BNErx:TXA:PHA:LDA#32:STAINWK+27:LDX#0:LDAINWK+10:JSRSFS2:LDX#3:LDAINWK+12:JSRSFS2:LDX#6:LDAINWK+14:JSRSFS2:PLA:TAX:.rx\n 3320LDAT1:STAINWK+32:LSRINWK+29:ASLINWK+29:TXA:CMP#OIL:BNENOIL:JSRDORND:ASLA:STAINWK+30:TXA:AND#15:STAINWK+27:LDA#FF:RORA:STAINWK+29:LDA#OIL:.NOIL JSRNWSHP\n 3330PLA:STAINF+1:PLA:STAINF:LDX#NI%-1:.FRL3 LDAXX3,X:STAINWK,X:DEX:BPLFRL3:PLA:STAXX0+1:PLA:STAXX0:RTS\n 3350.SFS2 ASLA:STAR:LDA#0:RORA:JMPMVT1\n 3400.LL164 LDA#56:JSRNOISE:LDA#1:STAHFX:LDA#4:JSRHFS2:DECHFX:RTS\n 3410.LAUN LDA#48:JSRNOISE:LDA#8:.HFS2 STASTP:JSRTTX66:JSRHFS1\n 3510.HFS1 LDA#128:STAK3:LDX#Y:STXK4:ASLA:STAXX4:STAK3+1:STAK4+1:.HFL5 JSRHFL1:INCXX4:LDXXX4:CPX#8:BNEHFL5:RTS\n 3520.HFL1 LDAXX4:AND#7:CLC:ADC#8:STAK:.HFL2 LDA#1:STALSP:JSRCIRCLE2:ASLK:BCSHF8:LDAK:CMP#160:BCCHFL2:.HF8 RTS\n 4400.STARS2 LDA#0:CPX#2:RORA:STARAT:EOR#128:STARAT2:JSRST2\n 4410LDYNOSTM:.STL2 LDASZ,Y:STAZZ:LSRA:LSRA:LSRA:JSRDV41:LDAP:EORRAT2:STAS:LDASXL,Y:STAP:LDASX,Y:STAX1:JSRADD\n 4420STAS:STXR:LDASY,Y:STAY1:EORBET2:LDXBET1:JSRMULTS-2:JSRADD:STXXX:STAXX+1\n 4430LDXSYL,Y:STXR:LDXY1:STXS:LDXBET1:EORBET2+1:JSRMULTS-2:JSRADD:STXYY:STAYY+1\n 4440LDXALP1:EORALP2:JSRMULTS-2:STAQ:LDAXX:STAR:LDAXX+1:STAS:EOR#128:JSRMAD:STAXX+1:TXA:STASXL,Y\n 4450LDAYY:STAR:LDAYY+1:STAS:JSRMAD:STAS:STXR:LDA#0:STAP:LDAALPHA\n 4460JSRPIX1:LDAXX+1:STASX,Y:STAX1\n 4470AND#127:CMP#116:BCSKILL2:LDAYY+1:STASY,Y:STAY1:AND#127:CMP#116:BCSST5:.STC2 JSRPIXEL2:DEY:BEQST2:JMPSTL2\n 4480.ST2 LDAALPHA:EORRAT:STAALPHA:LDAALP2:EORRAT:STAALP2:EOR#128:STAALP2+1:LDABET2:EORRAT:STABET2:EOR#128:STABET2+1:RTS\n 4500.KILL2 JSRDORND:STAY1:STASY,Y:LDA#115:ORARAT:STAX1:STASX,Y:BNESTF1\n 4510.ST5 JSRDORND:STAX1:STASX,Y:LDA#110:ORAALP2+1:STAY1:STASY,Y:.STF1 JSRDORND:ORA#8:STAZZ:STASZ,Y:BNESTC2\n 4700.SNE:]\n 4720FORI%=0TO31:N=ABS(SIN(I%/64*2*PI)):IFN>=1 I%?O%=FF:ELSEI%?O%=INT(256*N+.5)\n 4730NEXT:O%=O%+32:P%=P%+32\n 4740[OPTZ\n 6040.MU5 STAK:STAK+1:STAK+2:STAK+3:CLC:RTS\n 6050.MULT3\\K(4)=AP(2)*Q:STAR:AND#127:STAK+2:LDAQ:AND#127:BEQMU5:SEC:SBC#1:STAT:LDAP+1:LSRK+2:RORA:STAK+1:LDAP:RORA:STAK:LDA#0:LDX#24\n 6060.MUL2 BCCP%+4:ADCT:RORA:RORK+2:RORK+1:RORK:DEX:BNEMUL2:STAT:LDAR:EORQ:AND#128:ORAT:STAK+3:RTS\n 6070.MLS2 LDXXX:STXR:LDXXX+1:STXS:.MLS1 LDXALP1:STXP\n 6080.MULTS\\AP=A*P(P+<32)\n 6090TAX:AND#128:STAT:TXA:AND#127:BEQMU6:TAX:DEX:STXT1:LDA#0\n 6100LSRP:BCCP%+4:ADCT1:RORA:RORP:BCCP%+4:ADCT1:RORA:RORP:BCCP%+4:ADCT1:RORA:RORP:BCCP%+4:ADCT1:RORA:RORP:BCCP%+4:ADCT1:RORA:RORP\n 6110LSRA:RORP:LSRA:RORP:LSRA:RORP:ORAT:RTS\n 6112.SQUA\\AP=A*ApresQ:AND#127:.SQUA2 STAP:TAX:BNEMU11:.MU1 CLC:STXP:TXA:RTS\n 6114.MLU1 LDASY,Y:STAY1:.MLU2 AND#127:STAP\n 6116.MULTU\\AP=P*Qunsg\n 6118LDXQ:BEQMU1:.MU11 DEX:STXT:LDA#0:LDX#8:LSRP:.MUL6 BCCP%+4:ADCT:RORA:RORP:DEX:BNEMUL6:RTS\n 6119.MU6 STAP+1:STAP:RTS\n 6120.FMLTU2 AND#31:TAX:LDASNE,X:STAQ:LDAK\n 6125.FMLTU\\A=A*Q/256unsg:EOR#FF:SEC:RORA:STAP:LDA#0:.MUL3 BCSMU7:ADCQ:RORA:LSRP:BNEMUL3:RTS:.MU7 LSRA:LSRP:BNEMUL3:RTS\n 6130LDXQ:BEQMU1:DEX:STXT:LDA#0:LDX#8:LSRP:.MUL6 BCCP%+4:ADCT:RORA:RORP:DEX:BNEMUL6:RTS\n 6140STXQ:.MLTU2\\AP(2)=AP*Qunsg(EORP)\n 6142EOR#FF:LSRA:STAP+1:LDA#0:LDX#16:RORP:.MUL7 BCSMU21:ADCQ:RORA:RORP+1:RORP:DEX:BNEMUL7:RTS:.MU21 LSRA:RORP+1:RORP:DEX:BNEMUL7:RTS\n 6146.MUT3 LDXALP1:STXP:.MUT2 LDXXX+1:STXS\n 6148.MUT1 LDXXX:STXR\n 6150.MULT1 \\AP=Q*A\n 6160TAX:AND#127:LSRA:STAP:TXA:EORQ:AND#128:STAT:LDAQ:AND#127:BEQmu10:TAX:DEX:STXT1:LDA#0:LDX#7\n 6170.MUL4 BCCP%+4:ADCT1:RORA:RORP:DEX:BNEMUL4:LSRA:RORP:ORAT:RTS:.mu10 STAP:RTS\n 6190.MULT12 JSRMULT1:STAS:LDAP:STAR:RTS\n 6194.TAS3 LDXINWK,Y:STXQ:LDAXX15:JSRMULT12:LDXINWK+2,Y:STXQ:LDAXX15+1:JSRMAD:STAS:STXR\n 6196LDXINWK+4,Y:STXQ:LDAXX15+2:.MAD JSRMULT1\n 6200.ADD\\AX=AP+SR\n 6210STAT1:AND#128:STAT:EORS:BMIMU8:LDAR:CLC:ADCP:TAX:LDAS:ADCT1:ORAT:RTS\n 6220.MU8 LDAS:AND#127:STAU:LDAP:SEC:SBCR:TAX:LDAT1:AND#127:SBCU:BCSMU9:STAU:TXA:EOR#FF:ADC#1:TAX:LDA#0:SBCU:ORA#128:.MU9 EORT:RTS\n 6330\\DVIDT(A=AP/Q)inF\n 6345.TIS1 STXQ:EOR#128:JSRMAD\n 6350.DVID96\\A=A/96:TAX:AND#128:STAT:TXA:AND#127:LDX#254:STXT1:.DVL3 ASLA:CMP#96:BCCDV4:SBC#96:.DV4 ROLT1:BCSDVL3:LDAT1:ORAT:RTS\n 6360.DV42 LDASZ,Y:.DV41 STAQ:LDADELTA\n 6370.DVID4\\P-R=A/Qunsg\n 6380LDX#8:ASLA:STAP:LDA#0:.DVL4 ROLA:BCSDV8:CMPQ:BCCDV5:.DV8 SBCQ:SEC:.DV5 ROLP:DEX:BNEDVL4:JMPLL28+4\n 6395.DVID3B2 STAP+2:LDAINWK+6:STAQ:LDAINWK+7:STAR:LDAINWK+8:STAS\n 6400.DVID3B\\K+1(3)-K=P(3)/SRQaprx\n 6410LDAP:ORA#1:STAP:LDAP+2:EORS:AND#128:STAT:LDY#0:LDAP+2:AND#127:.DVL9 CMP#&40:BCSDV14:ASLP:ROLP+1:ROLA:INY:BNEDVL9\n 6420.DV14 STAP+2:LDAS:AND#127:BMIDV9:.DVL6 DEY:ASLQ:ROLR:ROLA:BPLDVL6:.DV9 STAQ:LDA#254:STAR:LDAP+2:JSRLL31\n 6440LDA#0:STAK+1:STAK+2:STAK+3:TYA:BPLDV12:LDAR:.DVL8 ASLA:ROLK+1:ROLK+2:ROLK+3:INY:BNEDVL8:STAK:LDAK+3:ORAT:STAK+3:RTS\n 6450.DV13 LDAR:STAK:LDAT:STAK+3:RTS\n 6460.DV12 BEQDV13:LDAR:.DVL10 LSRA:DEY:BNEDVL10:STAK:LDAT:STAK+3:RTS\n 6500.cntr LDADAMP:BNERE1:TXA:BPLBUMP:DEX:BMIRE1\n 6530.BUMP INX:BNERE1\n 6540.REDU DEX:BEQBUMP:.RE1 RTS\n 6550.BUMP2 STAT:TXA:CLC:ADCT:TAX:BCCRE2:LDX#FF:.RE2 BPLRE3+2:LDAT:RTS\n 6560.REDU2 STAT:TXA:SEC:SBCT:TAX:BCSRE3:LDX#1:.RE3 BPLRE2+2:LDADJD:BNERE2+2:LDX#128:BMIRE2+2\n 6800.ARCTAN\\A=TAN-1(P/Q)\n 6810LDAP:EORQ:STAT1:LDAQ:BEQAR2:ASLA:STAQ:LDAP:ASLA:CMPQ:BCSAR1:JSRARS1:SEC:.AR4 LDXT1:BMIAR3:RTS\n 6830.AR1 LDXQ:STAQ:STXP:TXA:JSRARS1:STAT:LDA#64:SBCT:BCSAR4:.AR2 LDA#63:RTS:.AR3 STAT:LDA#128:\\SEC:SBCT:RTS\n 6845.ARS1 JSRLL28:LDAR:LSRA:LSRA:LSRA:TAX:LDAACT,X:RTS\n 6850.ACT:]FORI%=0TO31:I%?O%=INT(128/PI*ATN(I%/32)+.5):NEXT:P%=P%+32:O%=O%+32:[OPTZ\n 6900.WARP LDAMANY+AST:CLC:ADCMANY+ESC:ADCMANY+OIL:TAX:LDAFRIN+2,X:ORASSPR:ORAMJ:BNEWA1:LDYK%+8:BMIWA3:TAY:JSRMAS2:LSRA:BEQWA1:.WA3 LDYK%+NI%+8:BMIWA2:LDY#NI%:JSRm:LSRA:BEQWA1:.WA2\n 6910LDA#&81:STAS:STAR:STAP:LDAK%+8:JSRADD:STAK%+8:LDAK%+NI%+8:JSRADD:STAK%+NI%+8\n 6920LDA#1:STAQQ11:STAMCNT:LSRA:STAEV:LDXVIEW:JMPLOOK1:.WA1 LDA#40:JMPNOISE\n 7000.LASLI JSRDORND:AND#7:ADC#Y-4:STALASY:JSRDORND:AND#7:ADC#X-4:STALASX:LDAGNTMP:ADC#8:STAGNTMP:JSRDENGY\n 7005.LASLI2 LDAQQ11:BNEPU1-1:LDA#32:LDY#224:JSRlas:LDA#48:LDY#208\n 7050.las STAX2:LDALASX:STAX1:LDALASY:STAY1:LDA#2*Y-1:STAY2:JSRLOIN:LDALASX:STAX1:LDALASY:STAY1:STYX2:LDA#2*Y-1:STAY2:JMPLOIN\n 8500.PLUT LDXVIEW:BNEPU1:RTS:.PU1 DEX:BNEPU2\n 8510LDAINWK+2:EOR#128:STAINWK+2:LDAINWK+8:EOR#128:STAINWK+8:LDAINWK+10:EOR#128:STAINWK+10:LDAINWK+14:EOR#128:STAINWK+14:LDAINWK+16:EOR#128:STAINWK+16\n 8520LDAINWK+20:EOR#128:STAINWK+20:LDAINWK+22:EOR#128:STAINWK+22:LDAINWK+26:EOR#128:STAINWK+26:RTS\n 8530.PU2 LDA#0:CPX#2:RORA:STARAT2:EOR#128:STARAT\n 8540LDAINWK:LDXINWK+6:STAINWK+6:STXINWK:LDAINWK+1:LDXINWK+7:STAINWK+7:STXINWK+1:LDAINWK+2:EORRAT:TAX:LDAINWK+8:EORRAT2:STAINWK+2:STXINWK+8\n 8550LDY#9:JSRPUS1\n 8560LDY#15:JSRPUS1\n 8570LDY#21\n 8600.PUS1 LDAINWK,Y:LDXINWK+4,Y:STAINWK+4,Y:STXINWK,Y:LDAINWK+1,Y:EORRAT:TAX:LDAINWK+5,Y:EORRAT2:STAINWK+1,Y:STXINWK+5,Y:.LO2 RTS\n 8990.LQ STXVIEW:JSRTT66:JSRSIGHT:JMPNWSTARS\n 9000.LOOK1 LDA#0:LDYQQ11:BNELQ:CPXVIEW:BEQLO2:STXVIEW:JSRTT66:JSRFLIP:JSRWPSHPS\n 9010.SIGHT LDYVIEW:LDALASER,Y:BEQLO2:LDA#128:STAQQ19:LDA#Y-24:STAQQ19+1:LDA#20:STAQQ19+2:JSRTT15:LDA#10:STAQQ19+2:JMPTT15\n 9400LDA#1:.TT66 STAQQ11:.TTX66 LDA#128:STAQQ17:ASLA:STALAS2:STADLY:STAde:LDX#&60:.BOL1 JSRZES1:INX:CPX#&78:BNEBOL1\n 9410LDXQQ22+1:BEQBOX:JSRee3:.BOX LDY#1:STYYC:LDAQQ11:BNEtt66:LDY#11:STYXC:LDAVIEW:ORA#&60:JSRTT27:JSRTT162:LDA#175:JSRTT27:.tt66\n 9420LDX#0:STXX1:STXY1:STXQQ17:DEX:STXX2:JSRHLOIN\n 9430LDA#2:STAX1:STAX2:JSRBOS2\n 9440.BOS2 JSRBOS1:.BOS1 LDA#0:STAY1:LDA#2*Y-1:STAY2:DECX1:DECX2:JMPLOIN\n 9450LDY#2:EQUB&2C:.DEL8 LDY#8:.DELAY JSRWSCAN:DEY:BNEDELAY:RTS\n 9460.hm JSRTT103:JSRTT111:JSRTT103:LDAQQ11:BEQSC5:.CLYNS LDA#20:STAYC:LDA#&75:STASC+1:LDA#7:STASC:JSRTT67:LDA#0:JSRLYN:INCSC+1:JSRLYN:INCSC+1:INY:STYXC\n 9470.LYN LDY#233:.EE2 STA(SC),Y:DEY:BNEEE2:.SC5 RTS\n 9500.SCAN LDAINWK+31:AND#16:BEQSC5:LDATYPE:BMISC5:LDX#FF:\\CMP#TGL\\BEQSC49:CMP#MSL:BNEP%+4:LDX#&F0:\\CMP#AST:\\BCCP%+4:\\LDX#&F:\\SC49:STXCOL:LDAINWK+1:ORAINWK+4:ORAINWK+7:AND#&C0:BNESC5\n 9510LDAINWK+1:CLC:LDXINWK+2:BPLSC2:EOR#FF:ADC#1:.SC2 ADC#123:STAX1\n 9520LDAINWK+7:LSRA:LSRA:CLC:LDXINWK+8:BPLSC3:EOR#FF:SEC:.SC3 ADC#35:EOR#FF:STASC\n 9530LDAINWK+4:LSRA:CLC:LDXINWK+5:BMISCD6:EOR#FF:SEC:.SCD6 ADCSC:BPLld246:CMP#194:BCSP%+4:LDA#194:CMP#247:BCCP%+4:.ld246 LDA#246\n 9535STAY1:SEC:SBCSC:PHP:\\BCSSC48:\\EOR#FF:\\ADC#1:.SC48 PHA:JSRCPIX4:LDACTWOS+1,X:ANDCOL:STAX1:PLA:PLP:TAX:BEQRTS:BCCRTS+1\n 9540.VLL1 DEY:BPLVL1:LDY#7:DECSC+1:.VL1 LDAX1:EOR(SC),Y:STA(SC),Y:DEX:BNEVLL1:.RTS RTS\n 9545INY:CPY#8:BNEP%+6:LDY#0:INCSC+1\n 9550.VLL2 INY:CPY#8:BNEVL2:LDY#0:INCSC+1:.VL2 LDAX1:EOR(SC),Y:STA(SC),Y:INX:BNEVLL2:RTS\n 9700.WSCAN LDA#0:STADL:LDADL:BEQP%-2:RTS\n 9900]\n 9910IFZ>4OSCLI(\"S.ELTC \"+STR$~W%+\" \"+STR$~O%+\" \"+STR$~L%+\" \"+STR$~H%)\n 9920PRINT\"C d,\";:GOTO8\n\n"
  },
  {
    "path": "1-source-files/original-sources/text-sources/ELITED.txt",
    "content": "    1GOTO20\n    2*L.ELITEB\n    3GOTO20\n    4*L.ELITEA\n    6*L.ELITEC\n    7GOTO20\n    8*L.ELITED\n    9GOTO20\n   10*L.ELITEE\n   20REM ELITE <D>\n   30H%=L%+P%-C%:O%=W%\n  300[OPTZ\n  700.tnpr pha:LDX#12:CPXQQ29:BCCkg:.Tml ADCQQ20,X:DEX:BPLTml:CMPCRGO:pla:RTS:.kg LDYQQ29:ADCQQ20,Y:cmp#200:pla:rts\n  840.TT20 JSRP%+3:JSRP%+3\n  850.TT54 LDAQQ15:CLC:ADCQQ15+2:TAX:LDAQQ15+1:ADCQQ15+3:TAY\n  860LDAQQ15+2:STAQQ15:LDAQQ15+3:STAQQ15+1:LDAQQ15+5:STAQQ15+3:LDAQQ15+4:STAQQ15+2:CLC:TXA:ADCQQ15+2:STAQQ15+4:TYA:ADCQQ15+3:STAQQ15+5:RTS\n  950.TT146 LDAQQ8:ORAQQ8+1:BNETT63:INCYC:RTS:.TT63 LDA#191:JSRTT68\n  955LDXQQ8:LDYQQ8+1:SEC:JSRpr5:LDA#195:.TT60 JSRTT27:.TTX69 INCYC:.TT69 LDA#128:STAQQ17:.TT67 LDA#13:JMPTT27\n  990.TT70 LDA#173:JSRTT27:JMPTT72:.spc JSRTT27:JMPTT162\n 1000.TT25\\ DATA\n 1010JSRTT66-2:LDA#9:STAXC:LDA#163:JSRTT27:JSRNLIN:JSRTTX69:INCYC:JSRTT146:LDA#194\n 1030JSRTT68:LDAQQ3:CLC:ADC#1:LSRA:CMP#2:BEQTT70:LDAQQ3:BCCTT71\n 1040SBC#5:CLC:.TT71 ADC#170:JSRTT27:.TT72 LDAQQ3:LSRA:LSRA:CLC:ADC#168:JSRTT60:LDA#162:JSRTT68:LDAQQ4:CLC:ADC#177:JSRTT60:LDA#196:JSRTT68\n 1070LDXQQ5:INX:CLC:JSRpr2:JSRTTX69:LDA#192:JSRTT68:SEC:LDXQQ6:JSRpr2:LDA#198:JSRTT60:LDA#&28:JSRTT27:LDAQQ15+4:BMITT75:LDA#188:JSRTT27:JMPTT76:.TT75 LDAQQ15+5\n 1110LSRA:LSRA:PHA:AND#7:CMP#3:BCSTT205:ADC#227:JSRspc:.TT205 PLA:LSRA:LSRA:LSRA:CMP#6:BCSTT206:ADC#230:JSRspc:.TT206 LDAQQ15+3:EORQQ15+1:AND#7\n 1116STAQQ19:CMP#6:BCSTT207:ADC#236:JSRspc:.TT207 LDAQQ15+5:AND#3:CLC:ADCQQ19:AND#7:ADC#242:JSRTT27:.TT76 LDA#&53:JSRTT27:LDA#&29:JSRTT60\n 1127LDA#193:JSRTT68:LDXQQ7:LDYQQ7+1:JSRpr6:JSRTT162:LDA#0:STAQQ17:LDA#&4D:JSRTT27:LDA#226:JSRTT60:LDA#250:JSRTT68:LDAQQ15+5:LDXQQ15+3:AND#15:CLC:ADC#11:TAY\n 1150JSRpr5:JSRTT162:LDA#&6B:JSRTT26:LDA#&6D:JMPTT26\n 1200.TT24\n 1210LDAQQ15+1:AND#7:STAQQ3:LDAQQ15+2:LSRA:LSRA:LSRA:AND#7:STAQQ4:LSRA:BNETT77:LDAQQ3:ORA#2:STAQQ3:.TT77 LDAQQ3:EOR#7:CLC:STAQQ5:LDAQQ15+3:AND#3:ADCQQ5:STAQQ5\n 1240LDAQQ4:LSRA:ADCQQ5:STAQQ5:ASLA:ASLA:ADCQQ3:ADCQQ4:ADC#1:STAQQ6:LDAQQ3:EOR#7:ADC#3:STAP:LDAQQ4:ADC#4:STAQ:JSRMULTU:LDAQQ6:STAQ:JSRMULTU:ASLP:ROLA:ASLP:ROLA:ASLP:ROLA:STAQQ7+1:LDAP:STAQQ7:RTS\n 1400.TT22\\Lng Sc\n 1410LDA#64:JSRTT66:LDA#7:STAXC:JSRTT81:LDA#199:JSRTT27:JSRNLIN:LDA#152:JSRNLIN2:JSRTT14\n 1460LDX#0:.TT83 STXXSAV:LDXQQ15+3:LDYQQ15+4:TYA:ORA#&50:STAZZ\n 1470LDAQQ15+1:LSRA:CLC:ADC#24:STAXX15+1:JSRPIXEL:JSRTT20:LDXXSAV:INX:BNETT83:LDAQQ9:STAQQ19:LDAQQ10:LSRA:STAQQ19+1:LDA#4:STAQQ19+2\n 1700.TT15\n 1705LDA#24:LDXQQ11:BPLP%+4:LDA#0:STAQQ19+5:LDAQQ19:SEC:SBCQQ19+2:BCSTT84:LDA#0:.TT84 STAXX15:LDAQQ19:CLC:ADCQQ19+2:BCCP%+4:LDA#FF:STAXX15+2\n 1725LDAQQ19+1:CLC:ADCQQ19+5:STAXX15+1:JSRHLOIN:LDAQQ19+1:SEC:SBCQQ19+2:BCSTT86:LDA#0:.TT86 CLC:ADCQQ19+5:STAXX15+1:LDAQQ19+1:CLC:ADCQQ19+2:ADCQQ19+5:CMP#152:BCCTT87\n 1750LDXQQ11:BMITT87:LDA#151:.TT87 STAXX15+3:LDAQQ19:STAXX15:STAXX15+2:JMPLL30\n 1800.TT126 LDA#104:STAQQ19:LDA#90:STAQQ19+1:LDA#16:STAQQ19+2:JSRTT15:LDAQQ14:STAK:JMPTT128\n 2000.TT14\\Crcl/+\n 2010LDAQQ11:BMITT126:LDAQQ14:LSRA:LSRA:STAK:LDAQQ0:STAQQ19:LDAQQ1:LSRA:STAQQ19+1:LDA#7:STAQQ19+2:JSRTT15:LDAQQ19+1:CLC:ADC#24:STAQQ19+1\n 2300.TT128 LDAQQ19:STAK3:LDAQQ19+1:STAK4:LDX#0:STXK4+1:STXK3+1:\\STXLSX:INX:STXLSP:LDX#2:STXSTP\n 2310JSRCIRCLE2:\\LDA#FFSTALSX:RTS\n 2650.TT219\\Buy\n 2655\\LDA#2:JSRTT66-2:JSRTT163:LDA#128:STAQQ17:\\JSRFLKB:LDA#0:STAQQ29\n 2660.TT220 JSRTT151:LDAQQ25:BNETT224:JMPTT222:.TQ4 LDY#176:.Tc JSRTT162:TYA:JSRprq:.TTX224 JSRdn2:.TT224\n 2671JSRCLYNS:LDA#204:JSRTT27:LDAQQ29:CLC:ADC#208:JSRTT27:LDA#&2F:JSRTT27:JSRTT152:LDA#&3F:JSRTT27:JSRTT67:LDX#0:STXR:LDX#12:STXT1:.TT223\n 2700JSRgnum:BCSTQ4:STAP:JSRtnpr:LDY#206:BCSTc:LDAQQ24:STAQ:JSRGCASH:JSRLCASH:LDY#197:BCCTc\n 2708LDYQQ29:LDAR:PHA:CLC:ADCQQ20,Y:STAQQ20,Y:LDAAVL,Y:SEC:SBCR:STAAVL,Y:PLA:BEQTT222:JSRdn\n 2710.TT222 LDAQQ29:CLC:ADC#5:STAYC:LDA#0:STAXC:INCQQ29:LDAQQ29:CMP#17:BCSBAY2:JMPTT220:.BAY2 LDA#f9:JMPFRCE\n 2750.gnum LDX#0:STXR:LDX#12:STXT1:.TT223 JSRTT217:STAQ:SEC:SBC#&30:BCCOUT:CMP#10:BCSBAY2:STAS:LDAR:CMP#26:BCSOUT:ASLA:STAT:ASLA:ASLA:ADCT:ADCS:STAR:CMPQQ25:BEQTT226:BCSOUT:.TT226 LDAQ:JSRTT26:DECT1:BNETT223:.OUT LDAR:RTS\n 2850.TT208\\Sel\n 2855LDA#4:JSRTT66:LDA#4:STAYC:STAXC:\\JSRFLKB:LDA#205:JSRTT27:LDA#206:JSRTT68\n 2900.TT210\\Crgo\n 2910LDY#0:.TT211 STYQQ29:LDXQQ20,Y:BEQTT212\n 2912TYA:ASLA:ASLA:TAY:LDAQQ23+1,Y:STAQQ19+1\n 2915TXA:PHA:JSRTT69:CLC:LDAQQ29:ADC#208\n 2917JSRTT27:LDA#14:STAXC:PLA:TAX:CLC:JSRpr2:JSRTT152\n 2922LDAQQ11:CMP#4:BNETT212:LDA#205:JSRTT214\n 2923BCCTT212:LDAQQ29:LDX#255:STXQQ17:JSRTT151\n 2925LDYQQ29:LDAQQ20,Y:STAP:LDAQQ24:STAQ:JSRGCASH:JSRMCASH\n 2935LDA#0:LDYQQ29:STAQQ20,Y:STAQQ17\n 2940.TT212 LDYQQ29:INY:CPY#17:BCSP%+5:JMPTT211:LDAQQ11:CMP#4:BNEP%+8:JSRdn2:JMPBAY2:RTS\n 2942.TT213\\Invntry\n 2945LDA#8:JSRTT66:LDA#11:STAXC:LDA#164:JSRTT60:JSRNLIN4:JSRfwl\n 2950LDACRGO:CMP#26:BCCP%+7:LDA#&6B:JSRTT27:JMPTT210\n 2965.TT214 PHA:JSRTT162:PLA:.TT221 JSRTT27:LDA#225:JSRTT27\n 2966JSRTT217:ORA#32:CMP#&79:BEQTT218:LDA#&6E:JMPTT26:.TT218 JSRTT26:SEC:RTS\n 3000.TT16 TXA:PHA:DEY:TYA:EOR#255:PHA:JSRWSCAN:JSRTT103:PLA:STAQQ19+3\n 3010LDAQQ10:JSRTT123:LDAQQ19+4:STAQQ10:STAQQ19+1:PLA\n 3020STAQQ19+3:LDAQQ9:JSRTT123:LDAQQ19+4:STAQQ9:STAQQ19:.TT103\n 3030LDAQQ11:BEQTT180:BMITT105:LDAQQ9:STAQQ19:LDAQQ10:LSRA:STAQQ19+1\n 3040LDA#4:STAQQ19+2:JMPTT15\n 3045.TT123 STAQQ19+4:CLC:ADCQQ19+3:LDXQQ19+3:BMITT124:BCCTT125\n 3047RTS:.TT124 BCCTT180:.TT125 STAQQ19+4:.TT180 RTS\n 3050.TT105 LDAQQ9:SEC:SBCQQ0:CMP#38:BCCTT179:CMP#230:BCCTT180\n 3055.TT179 ASLA:ASLA:CLC:ADC#104:STAQQ19\n 3060LDAQQ10:SEC:SBCQQ1:CMP#38:BCCP%+6:CMP#220:BCCTT180\n 3065ASLA:CLC:ADC#90:STAQQ19+1:LDA#8:STAQQ19+2:JMPTT15\n 3300.TT23\\ShrtSc\n 3310LDA#128:JSRTT66:LDA#7:STAXC:LDA#190:JSRNLIN3:JSRTT14:JSRTT103:JSRTT81\n 3349LDA#0:STAXX20:LDX#24:.EE3 STAINWK,X:DEX:BPLEE3\n 3350.TT182 LDAQQ15+3:SEC:SBCQQ0:BCSTT184:EOR#FF:ADC#1:.TT184 CMP#20:BCSTT187:LDAQQ15+1:SEC:SBCQQ1:BCSTT186:EOR#FF:ADC#1:.TT186 CMP#38:BCSTT187\n 3370LDAQQ15+3:SEC:SBCQQ0:ASLA:ASLA:ADC#104:STAXX12:LSRA:LSRA:LSRA:STAXC:INCXC:LDAQQ15+1:SEC:SBCQQ1:ASLA:ADC#90:STAK4:LSRA:LSRA:LSRA\n 3377TAY:LDXINWK,Y:BEQEE4:INY:LDXINWK,Y:BEQEE4:DEY:DEY:LDXINWK,Y:BNEee1:.EE4 STYYC:CPY#3:BCCTT187:DEX:STXINWK,Y\n 3380LDA#128:STAQQ17:JSRcpl:.ee1\n 3390\\bigstars:LDA#0:STAK3+1:STAK4+1:STAK+1:LDAXX12:STAK3:LDAQQ15+5:AND#1:ADC#2:STAK:JSRFLFLLS:JSRSUN:JSRFLFLLS\n 3400.TT187 JSRTT20:INCXX20:BEQTT111-1:JMPTT182\n 3450.TT81 LDX#5:LDAQQ21,X:STAQQ15,X:DEX:BPLTT81+2\n 3500RTS:.TT111 JSRTT81:LDY#127:STYT:LDA#0:STAU\n 3510.TT130 LDAQQ15+3:SEC:SBCQQ9:BCSTT132:EOR#FF:ADC#1:.TT132 LSRA:STAS:LDAQQ15+1:SEC:SBCQQ10:BCSTT134:EOR#FF:ADC#1:.TT134 LSRA:CLC:ADCS:CMPT:BCSTT135\n 3550STAT:LDX#5:.TT136 LDAQQ15,X:STAQQ19,X:DEX:BPLTT136:.TT135\n 3560JSRTT20:INCU:BNETT130:LDX#5:.TT137 LDAQQ19,X:STAQQ15,X:DEX\n 3570BPLTT137:LDAQQ15+1:STAQQ10:LDAQQ15+3:STAQQ9\n 3575SEC:SBCQQ0:BCSTT139:EOR#FF:ADC#1:.TT139 JSRSQUA2:STAK+1:LDAP:STAK:LDAQQ10\n 3590SEC:SBCQQ1:BCSTT141:EOR#FF:ADC#1:.TT141 LSRA:JSRSQUA2:PHA:LDAP:CLC:ADCK\n 3610STAQ:PLA:ADCK+1:STAR:JSRLL5:LDAQ:ASLA:LDX#0:STXQQ8+1:ROLQQ8+1:ASLA:ROLQQ8+1:STAQQ8:JMPTT24\n 4340.hy6 JSRCLYNS:LDA#15:STAXC:JMPTT27\n 4350.hyp LDAQQ12:BNEhy6:LDAQQ22+1:BNEzZ+1:JSRCTRL:BMIGhy\n 4353JSRhm\n 4355LDAQQ8:ORAQQ8+1:BEQzZ+1:LDA#7:STAXC:LDA#23:STAYC:LDA#0:STAQQ17:LDA#189:JSRTT27:LDAQQ8+1:BNETT147:LDAQQ14:CMPQQ8:BCCTT147\n 4380LDA#&2D:JSRTT27:JSRcpl:.wW LDA#15:STAQQ22+1:STAQQ22:TAX:JMPee3\\hy5 RTS\n 4392.Ghy JSRTT111:LDXGHYP:BEQhy5:INX:STXQQ8:STXQQ8+1:STXGHYP:STXFIST:JSRwW:LDX#5:INCGCNT:LDAGCNT:AND#7:STAGCNT:.G1 LDAQQ21,X:ASLA:ROLQQ21,X:DEX:BPLG1:\\JSRDORND:.zZ LDA#&60:STAQQ9:STAQQ10:JSRTT110:LDA#116:JSRMESS:.jmp LDAQQ9:STAQQ0:LDAQQ10\n 4393STAQQ1:.hy5 RTS\n 4395.ee3 LDY#1:STYYC:DEY:STYXC:.pr6 CLC:.pr5 LDA#5:JMPTT11\n 4400.TT147 LDA#202:.prq JSRTT27:LDA#&3F:JMPTT27\n 5000.TT151\\Pmk-A\n 5010PHA:STAQQ19+4:ASLA:ASLA:STAQQ19:LDA#1:STAXC:PLA:ADC#208\n 5015JSRTT27:LDA#14:STAXC:LDXQQ19:LDAQQ23+1,X:STAQQ19+1:LDAQQ26:ANDQQ23+3,X:CLC:ADCQQ23,X:STAQQ24:JSRTT152\n 5050JSRvar:LDAQQ19+1:BMITT155:LDAQQ24:ADCQQ19+3:JMPTT156\n 5060.TT155 LDAQQ24:SEC:SBCQQ19+3:.TT156 STAQQ24:STAP:LDA#0:JSRGC2\n 5070SEC:JSRpr5:LDYQQ19+4:LDA#5:LDXAVL,Y:STXQQ25\n 5100CLC:BEQTT172:JSRpr2+2:JMPTT152:.TT172 LDAXC:ADC#4:STAXC:LDA#&2D:BNETT162+2\n 5110.TT152 LDAQQ19+1:AND#96:BEQTT160:CMP#32:BEQTT161\n 5120JSRTT16a:.TT162 LDA#32:JMPTT27\n 5130.TT160 LDA#&74:JSRTT26:BCCTT162\n 5140.TT161 LDA#&6B:JSRTT26:.TT16a LDA#&67:JMPTT26\n 5160.TT163 LDA#17:STAXC:LDA#FF:BNETT162+2\n 5200.TT167\\MktP\n 5210LDA#16:JSRTT66:LDA#5:STAXC:LDA#167:JSRNLIN3:LDA#3:STAYC:JSRTT163:LDA#0:STAQQ29:.TT168 LDX#128:STXQQ17:JSRTT151:INCYC\n 5250INCQQ29:LDAQQ29:CMP#17:BCCTT168:RTS\n 5900.var LDAQQ19+1:AND#31:LDYQQ28:STAQQ19+2:CLC:LDA#0:STAAVL+16:.TT153 DEY:BMITT154:ADCQQ19+2:JMPTT153:.TT154 STAQQ19+3:RTS\n 5980.hyp1 JSRTT111:JSRjmp:LDX#5:.TT112 LDAQQ15,X:STAQQ2,X:DEX:BPLTT112:INX:STXEV:LDAQQ3:STAQQ28:LDAQQ5:STAtek:LDAQQ4:STAgov:RTS\n 5990.GVL JSRDORND:STAQQ26:LDX#0:STXXX4:.hy9 LDAQQ23+1,X:STAQQ19+1:JSRvar:LDAQQ23+3,X:ANDQQ26:CLC:ADCQQ23+2,X:LDYQQ19+1:BMITT157:SEC:SBCQQ19+3:JMPTT158:.TT157 CLC:ADCQQ19+3:.TT158 BPLTT159:LDA#0:.TT159\n 5994LDYXX4:AND#63:STAAVL,Y:INY:TYA:STAXX4:ASLA:ASLA:TAX:CMP#63:BCChy9:.hyR RTS\n 5995.GTHG JSRZe:LDA#FF:STAINWK+32:LDA#THG:JSRNWSHP:LDA#TGL:JMPNWSHP\n 5996.ptg LSRCOK:SEC:ROLCOK\n 5998.MJP\\LDA#1:JSRTT66-2:JSRLL164:JSRRES2:STYMJ:.MJP1 JSRGTHG:LDA#3:CMPMANY+THG:BCSMJP1:STANOSTM:LDX#0:JSRLOOK1:LDAQQ1:EOR#31:STAQQ1:RTS\n 6000.TT18\\HSPC\n 6005LDAQQ14:SEC:SBCQQ8:STAQQ14:LDAQQ11:BNEee5:JSRTT66:JSRLL164:.ee5 JSRCTRL:ANDPATG:BMIptg:JSRDORND:CMP#253:BCSMJP\\JSRTT111:JSRhyp1+3:JSRGVL:JSRRES2:JSRSOLAR\n 6500LDAQQ11:AND#63:BNEhyR:JSRTTX66:LDAQQ11:BNETT114:INCQQ11:.TT110 LDXQQ12:BEQNLUNCH:JSRLAUN:JSRRES2:JSRTT111:INCINWK+8:JSRSOS1:LDA#128:STAINWK+8:INCINWK+7:JSRNWSPS:LDA#12:STADELTA:JSRBAD:ORAFIST:STAFIST\n 6510.NLUNCH LDX#0:STXQQ12:JMPLOOK1:.TT114 BMITT115:JMPTT22:.TT115 JMPTT23\n 6530.LCASH STXT1:LDACASH+3:SEC:SBCT1:STACASH+3:STYT1:LDACASH+2:SBCT1:STACASH+2:LDACASH+1:SBC#0:STACASH+1:LDACASH:SBC#0:STACASH:BCSTT113\n 6540.MCASH TXA:CLC:ADCCASH+3:STACASH+3:TYA:ADCCASH+2:STACASH+2:LDACASH+1:ADC#0:STACASH+1:LDACASH:ADC#0:STACASH:CLC:.TT113 RTS\n 6550.GCASH JSRMULTU:.GC2 ASLP:ROLA:ASLP:ROLA:TAY:LDXP:RTS\n 6690.bay JMPBAY\n 6700.EQSHP JSRDIALS:LDA#32:JSRTT66:LDA#12:STAXC:LDA#207:JSRspc:LDA#185:JSRNLIN3:LDA#128:STAQQ17:INCYC:LDAtek:CLC:ADC#3:CMP#12:BCCP%+4:LDA#12:STAQ:STAQQ25:INCQ:LDA#70:SEC:SBCQQ14:ASLA:STAPRXS\n 6710LDX#1:.EQL1 STXXX13:JSRTT67:LDXXX13:CLC:JSRpr2:JSRTT162:LDAXX13:CLC:ADC#&68:JSRTT27:LDAXX13:JSRprx-3:SEC:LDA#25:STAXC:LDA#6:JSRTT11:LDXXX13:INX:CPXQ:BCCEQL1\n 6720JSRCLYNS:LDA#127:JSRprq:JSRgnum:beqbay:bcsbay:SBC#0:LDX#2:STXXC:INCYC:PHA:JSReq:PLA:BNEet0:STAMCNT:LDX#70:STXQQ14:.et0 CMP#1:BNEet1:LDXNOMSL:INX:LDY#&75:CPX#5:BCSpres\n 6730STXNOMSL:JSRmsblob:.et1 LDY#&6B:CMP#2:BNEet2:LDX#37:CPXCRGO:BEQpres:STXCRGO:.et2 CMP#3:BNEet3:INY:LDXECM:BNEpres:DECECM:.et3 CMP#4:BNEet4:JSRqv:LDA#4:LDYLASER,X:BEQed4:.ed7 LDY#187:BNEpres:.ed4 LDA#POW:STALASER,X:LDA#4:.et4\n 6740CMP#5:BNEet5:JSRqv:STXT1:LDA#5:LDYLASER,X:BEQed5:\\BPLP%+4:BMIed7:LDA#4:JSRprx:JSRMCASH:.ed5 LDA#POW+128:LDXT1:STALASER,X:.et5\n 6750LDY#&6F:CMP#6:BNEet6:LDXBST:BEQed9:.pres STYK:JSRprx:JSRMCASH:LDAK:JSRspc:LDA#31:JSRTT27:.err JSRdn2:JMPBAY:.ed9 DECBST:.et6 INY:CMP#7:BNEet7:LDXESCP:BNEpres:DECESCP:.et7 INY:CMP#8:BNEet8:LDXBOMB:BNEpres:LDX#&7F:STXBOMB:.et8\n 6800INY:CMP#9:BNEetA:LDXENGY:BNEpres:INCENGY:.etA INY:CMP#10:BNEetB:LDXDKCMP:BNEpres:DECDKCMP:.etB:INY:CMP#11:BNEet9:LDXGHYP:BNEpres:DECGHYP:.et9 JSRdn:JMPEQSHP:.dn JSRTT162:LDA#119:JSRspc:.dn2 JSRBEEP:LDY#50:JMPDELAY\n 6900.eq JSRprx:JSRLCASH:BCSc:LDA#197:JSRprq:JMPerr:SEC:SBC#1:.prx ASLA:TAY:LDXPRXS,Y:LDAPRXS+1,Y:TAY:.c RTS\n 6910.qv LDY#16:STYYC:.qv1 LDX#12:STXXC:TYA:CLC:ADC#B-16:JSRspc:LDAYC:CLC:ADC#&50:JSRTT27:INCYC:LDYYC:CPY#20:BCCqv1:.qv3 JSRCLYNS:.qv2 LDA#175:JSRprq:JSRTT217:SEC:SBC#&30:CMP#4:BCSqv3:TAX:RTS\n 9900]\n 9910IFZ>4OSCLI(\"S.ELTD \"+STR$~W%+\" \"+STR$~O%+\" \"+STR$~L%+\" \"+STR$~H%)\n 9920PRINT\"D d,\";:GOTO10\n"
  },
  {
    "path": "1-source-files/original-sources/text-sources/ELITEE.txt",
    "content": "    1GOTO20\n    2*L.ELITEB\n    3GOTO20\n    4*L.ELITEA\n    6*L.ELITEC\n    7GOTO20\n    8*L.ELITED\n    9GOTO20\n   10*L.ELITEE\n   11GOTO20\n   12*L.ELITEF\n   20REM ELITE <E>\n  100H%=L%+P%-C%:O%=W%:A$=\"(C)Bell/Braben1984\":B$=STRING$(26,\" \"):B$=\"\":FORI%=1TOLENA$:B$=B$+CHR$(ASC(MID$(A$,I%,1))EOR&A4):NEXT:[OPTZ:EQUSB$\n  190.cpl LDX#5:.TT53 LDAQQ15,X:STAQQ19,X:DEX:BPLTT53:LDY#3:BITQQ15:BVSP%+3:DEY:STYT:.TT55 LDAQQ15+5:AND#31:BEQP%+7:ORA#128:JSRTT27:JSRTT54:DECT:BPLTT55:LDX#5:.TT56 LDAQQ19,X:STAQQ15,X:DEX:BPLTT56:RTS\n  200.cmn LDY#0:.QUL4 LDANA%,Y:CMP#13:BEQypl-1:JSRTT26:INY:BNEQUL4:RTS\n  300.ypl LDAMJ:BNEcmn-1:JSRTT62:JSRcpl:.TT62 LDX#5:.TT78 LDAQQ15,X:LDYQQ2,X:STAQQ2,X:STYQQ15,X:DEX:BPLTT78:RTS\n  500.tal CLC:LDXGCNT:INX:JMPpr2:.fwl LDA#105:JSRTT68:LDXQQ14:SEC:JSRpr2:LDA#195:JSRplf:.PCASH LDA#119:BNETT27\n  510.csh LDX#3:.pc1 LDACASH,X:STAK,X:DEX:BPLpc1:LDA#9:STAU:SEC:JSRBPRNT:LDA#226:.plf JSRTT27:JMPTT67:.TT68 JSRTT27:.TT73 LDA#&3A\n  600.TT27 TAX:BEQcsh:BMITT43:DEX:BEQtal:DEX:BEQypl:dex:bneP%+5:JMPcpl:dex:beqcmn:dex:beqfwl:dex:bneP%+7:LDA#128:STAQQ17:RTS:DEX:DEX:BNEP%+5:STXQQ17:RTS:dex:beqcrlf:CMP#&60:BCSex:CMP#14:BCCP%+6:CMP#32:BCCqw:LDXQQ17\n  620BEQTT74:BMITT41:BITQQ17:BVSTT46:.TT42 CMP#65:BCCTT44:CMP#&5B:BCSTT44:ADC#32:.TT44 JMPTT26:.TT41 BITQQ17:BVSTT45:CMP#65:BCCTT74:PHA:TXA:ORA#64:STAQQ17:PLA:BNETT44\n  630.qw ADC#114:BNEex:.crlf LDA#21:STAXC:BNETT73:.TT45 CPX#FF:BEQTT48:CMP#65:BCSTT42:.TT46 PHA:TXA:AND#191:STAQQ17:PLA:.TT74 JMPTT26:.TT43 CMP#160:BCSTT47:AND#127:ASLA:TAY:LDAQQ16,Y\n  670JSRTT27:LDAQQ16+1,Y:CMP#63:BEQTT48:JMPTT27:.TT47 SBC#160:.ex TAX:LDA#(QQ18 MOD256):STAV:LDA#(QQ18 DIV256):STAV+1:LDY#0:TXA:BEQTT50\n  680.TT51 LDA(V),Y:BEQTT49:INY:BNETT51:INCV+1:BNETT51:.TT49 INY:BNETT59:INCV+1:.TT59 DEX:BNETT51:.TT50\n  693TYA:PHA:LDAV+1:PHA:LDA(V),Y:EOR#35\n  695JSRTT27:PLA:STAV+1:PLA:TAY:INY:BNEP%+4:INCV+1:LDA(V),Y:BNETT50:.TT48 RTS\n 1990.EX2 LDAINWK+31:ORA#&A0:STAINWK+31:RTS\n 2000.DOEXP LDAINWK+31:AND#64:BEQP%+5:JSRPTCLS:LDAINWK+6:STAT:LDAINWK+7:CMP#&20:BCCP%+6:LDA#&FE:BNEyy:ASLT:ROLA:ASLT:ROLA:SEC:ROLA:.yy STAQ:LDY#1:LDA(XX19),Y:ADC#4:BCSEX2\n 2040STA(XX19),Y:JSRDVID4:LDAP:CMP#&1C:BCCP%+6:LDA#&FE:BNE`_:ASLR:ROLA:ASLR:ROLA:ASLR:ROLA:.`_ DEY:STA(XX19),Y:LDAINWK+31:AND#&BF:STAINWK+31:AND#8:BEQTT48\n 2050LDY#2:LDA(XX19),Y:TAY:.EXL1 LDAXX3-7,Y:STA(XX19),Y:DEY:CPY#6:BNEEXL1:LDAINWK+31:ORA#64:STAINWK+31\n 2100.PTCLS LDY#0:LDA(XX19),Y:STAQ:INY:LDA(XX19),Y:BPLP%+4:EOR#FF:LSRA:LSRA:LSRA:ORA#1:STAU:INY:LDA(XX19),Y:STATGT:LDARAND+1:PHA\n 2110LDY#6:.EXL5 LDX#3:.EXL3 INY:LDA(XX19),Y:STAK3,X:DEX:BPLEXL3:STYCNT:LDY#2:.EXL2 INY:LDA(XX19),Y:EORCNT:STARAND-3,Y:CPY#6:BNEEXL2:LDYU\n 2140.EXL4 JSRDORND2:STAZZ:LDAK3+1:STAR:LDAK3:JSREXS1:BNEEX11:CPX#2*Y-1:BCSEX11:STXY1:LDAK3+3:STAR:LDAK3+2:JSREXS1:BNEEX4:LDAY1:JSRPIXEL:.EX4 DEY:BPLEXL4:LDYCNT:CPYTGT:BCCEXL5\n 2180PLA:STARAND+1:LDAK%+6:STARAND+3:RTS:.EX11 JSRDORND2:JMPEX4\n 2200.EXS1 STAS:JSRDORND2:ROLA:BCSEX5:JSRFMLTU:ADCR:TAX:LDAS:ADC#0:RTS\n 2210.EX5 JSRFMLTU:STAT:LDAR:SBCT:TAX:LDAS:SBC#0:RTS\n 3008.SOS1 JSRmsblob:LDA#127:STAINWK+29:STAINWK+30:LDAtek:AND#2:ORA#128:JMPNWSHP\n 3010.SOLAR LSRFIST:JSRZINF:LDAQQ15+1:AND#7:ADC#6:LSRA:STAINWK+8:RORA:STAINWK+2:STAINWK+5\n 3020JSRSOS1:LDAQQ15+3:AND#7:ORA#129:STAINWK+8:LDAQQ15+5:AND#3:STAINWK+2:STAINWK+1:LDA#0:STAINWK+29:STAINWK+30:LDA#&81:JSRNWSHP\n 3600.NWSTARS LDAQQ11:\\ORAMJ:BNEWPSHPS:.nWq LDYNOSTM:.SAL4 JSRDORND:ORA#8:STASZ,Y:STAZZ:JSRDORND:STASX,Y:STAX1:JSRDORND:STASY,Y:STAY1:JSRPIXEL2:DEY:BNESAL4\n 3710.WPSHPS LDX#0:.WSL1 LDAFRIN,X:BEQWS2:BMIWS1:STATYPE:JSRGINF:LDY#31\n 3730.WSL2 LDA(INF),Y:STAINWK,Y:DEY:BPLWSL2:STXXSAV:JSRSCAN:LDXXSAV:LDY#31:LDA(INF),Y:AND#&A7:STA(INF),Y:.WS1 INX:BNEWSL1:.WS2 LDX#FF:STXLSX2:STXLSY2\n 3740.FLFLLS LDY#2*Y-1:LDA#0:.SAL6 STALSO,Y:DEY:BNESAL6:DEY:STYLSX:RTS\n 3810.DET1 LDA#6:SEI:STA&FE00:STX&FE01:CLI:RTS\n 3900DEX:RTS:.SHD INX:BEQSHD-2:.DENGY DECENERGY:PHP:BNEP%+5:INCENERGY:PLP:RTS\n 4000.COMPAS JSRDOT:LDASSPR:BNESP1:JSRSPS1:JMPSP2:.SPS2 ASLA:TAX:LDA#0:RORA:TAY:LDA#20 \\14:STAQ:TXA:JSRDVID4:LDXP\n 4080TYA:BMILL163:LDY#0:RTS:.LL163 LDY#FF:TXA:EOR#FF:TAX:INX:RTS\n 4090.SPS4 LDX#8:.SPL1 LDAK%+NI%,X:STAK3,X:DEX:BPLSPL1:JMPTAS2\n 4100.SP1 JSRSPS4:.SP2 LDAXX15:JSRSPS2:TXA:ADC#195\\X-1:STACOMX:LDAXX15+1:JSRSPS2:STXT:LDA#204:SBCT:STACOMY\n 4130LDA#&F0:LDXXX15+2:BPLP%+4:LDA#FF:STACOMC\n 4200.DOT LDACOMY:STAY1:LDACOMX:STAX1:LDACOMC:STACOL:CMP#&F0:BNECPIX2:.CPIX4 JSRCPIX2:DECY1:.CPIX2 LDAY1\n 4250\\.CPIX:TAY:LSRA:LSRA:LSRA:ORA#&60:STASCH:LDAX1:AND#&F8:STASC:TYA:AND#7:TAY:LDAX1:AND#6:LSRA:TAX:LDACTWOS,X:ANDCOL:EOR(SC),Y:STA(SC),Y\n 4260LDACTWOS+1,X:BPLCP1:LDASC:ADC#8:STASC:LDACTWOS+1,X:.CP1 ANDCOL:EOR(SC),Y:STA(SC),Y:RTS\n 4300.OOPS STAT:LDY#8:LDX#0:LDA(INF),Y:BMIOO1:LDAFSH:SBCT:BCCOO2:STAFSH:RTS:.OO2 \\LDX#0:STXFSH:BCCOO3:.OO1 LDAASH:SBCT:BCCOO5:STAASH:RTS:.OO5 \\LDX#0:STXASH:.OO3 ADCENERGY:STAENERGY:BEQP%+4:BCSP%+5:JMPDEATH:JSREXNO3:JMPOUCH\n 4410.SPS3 LDAK%+1,X:STAK3,X:LDAK%+2,X:TAY:AND#127:STAK3+1,X:TYA:AND#128:STAK3+2,X:RTS\n 4450.GINF TXA:ASLA:TAY:LDAUNIV,Y:STAINF:LDAUNIV+1,Y:STAINF+1:RTS\n 4480.NWSPS JSRSPBLB:LDX#1:STXINWK+32:DEX:STXINWK+30:\\STXINWK+31:STXFRIN+1:DEX:STXINWK+29:LDX#10:JSRNwS1:JSRNwS1:JSRNwS1\n 4490LDA#(LSO MOD256):STAINWK+33:LDA#(LSO DIV256):STAINWK+34:LDA#SST\n 4500.NWSHP STAT:LDX#0:.NWL1 LDAFRIN,X:BEQNW1:INX:CPX#NOSH:BCCNWL1:.NW3 CLC:RTS\n 4510.NW1 JSRGINF:LDAT:BMINW2:ASLA:TAY:LDAXX21-2,Y:STAXX0:LDAXX21-1,Y:STAXX0+1:CPY#2*SST:BEQNW6:LDY#5:LDA(XX0),Y:STAT1:LDASLSP:SEC:SBCT1:STAINWK+33:LDASLSP+1:SBC#0:STAINWK+34\n 4530LDAINWK+33:\\SEC:SBCINF:TAY:LDAINWK+34:SBCINF+1:BCCNW3+1:BNENW4:CPY#NI%:BCCNW3+1:.NW4\n 4550LDAINWK+33:STASLSP:LDAINWK+34:STASLSP+1:.NW6 LDY#14:LDA(XX0),Y:STAINWK+35:LDY#19:LDA(XX0),Y:AND#7:STAINWK+31\n 4560LDAT:.NW2 STAFRIN,X:TAX:BMIP%+5:INCMANY,X:LDY#(NI%-1):.NWL3 LDAINWK,Y:STA(INF),Y:DEY:BPLNWL3:SEC:RTS\n 4600.NwS1 LDAINWK,X:EOR#128:STAINWK,X:INX:INX:RTS\n 4710.ABORT LDX#FF:.ABORT2 STXMSTG:LDXNOMSL:JSRMSBAR:STYMSAR:RTS\n 4730.ECBLB2 LDA#32:STAECMA:ASLA:JSRNOISE:.ECBLB LDA#7*8:\\\" <<120<\":LDX#(ECBT MOD256):LDY#(ECBT DIV256):BNEBULB-2\n 4740.SPBLB LDA#24*8:\\\"<<128<\":LDX#(SPBT MOD256):LDY#(SPBT DIV256):.BULB STASC:STXP+1:STYP+2:LDA#&7D:JMPRREN\n 4800.ECBT EQUW&E0E0:EQUB&80:.SPBT EQUD&E080E0E0:EQUD&E0E020E0\n 4900.MSBAR TXA:ASLA:ASLA:ASLA:STAT:LDA#49\\113:SBCT:STASC:LDA#&7E:STASCH:TYA:LDY#5:.MBL1 STA(SC),Y:DEY:BNEMBL1:RTS\n 5000.PROJ LDAINWK:STAP:LDAINWK+1:STAP+1:LDAINWK+2:JSRPLS6:BCSPL2-1:LDAK:ADC#X:STAK3:TXA:ADC#0:STAK3+1\n 5010LDAINWK+3:STAP:LDAINWK+4:STAP+1:LDAINWK+5:EOR#128:JSRPLS6:BCSPL2-1:LDAK:ADC#Y:STAK4:TXA:ADC#0:STAK4+1:CLC:RTS\n 5020.PL2 LDATYPE:LSRA:BCSP%+5:JMPWPLS2:JMPWPLS\n 5040.PLANET LDAINWK+8:BMIPL2:CMP#48:BCSPL2:ORAINWK+7:BEQPL2:JSRPROJ:BCSPL2\n 5090LDA#96:STAP+1:LDA#0:STAP:JSRDVID3B2:LDAK+1:BEQPL82:LDA#&F8:STAK:.PL82\n 5110LDATYPE:LSRA:BCCPL9:JMPSUN:.PL9 JSRWPLS2:JSRCIRCLE:BCSPL20:LDAK+1:BEQPL25:.PL20 RTS\n 5160.PL25 LDATYPE:CMP#&80:BNEPL26:LDAK:CMP#6:BCCPL20:LDAINWK+14:EOR#128:STAP:LDAINWK+20:JSRPLS4:LDX#9:JSRPLS1:STAK2:STYXX16:JSRPLS1:STAK2+1:STYXX16+1:LDX#15:JSRPLS5\n 5230JSRPLS2:LDAINWK+14:EOR#128:STAP:LDAINWK+26:JSRPLS4\n 5240LDX#21:JSRPLS5:JMPPLS2\n 5270.PL26\\crtr:LDAINWK+20:BMIPL20\n 5280LDX#15:JSRPLS3:CLC:ADCK3:STAK3:TYA:ADCK3+1:STAK3+1:JSRPLS3:STAP:LDAK4:SEC:SBCP:STAK4:STYP:LDAK4+1:SBCP:STAK4+1\n 5300LDX#9:JSRPLS1:LSRA:STAK2:STYXX16:JSRPLS1:LSRA:STAK2+1:STYXX16+1\n 5310LDX#21:JSRPLS1:LSRA:STAK2+2:STYXX16+2:JSRPLS1:LSRA:STAK2+3:STYXX16+3\n 5320LDA#64:STATGT:LDA#0:STACNT2:JMPPLS22\n 5330.PLS1 LDAINWK,X:STAP:LDAINWK+1,X:AND#127:STAP+1:LDAINWK+1,X:AND#128\n 5340JSRDVID3B2:LDAK:LDYK+1:BEQP%+4:LDA#&FE:LDYK+3:INX:INX:RTS\n 5350.PLS2 LDA#31:STATGT:.PLS22 LDX#0:STXCNT:DEX:STXFLAG:.PLL4\n 5360LDACNT2:AND#31:TAX:LDASNE,X:STAQ:LDAK2+2:JSRFMLTU:STAR:LDAK2+3:JSRFMLTU:STAK:LDXCNT2:CPX#33:LDA#0:RORA:STAXX16+5\n 5370LDACNT2:CLC:ADC#16:AND#31:TAX:LDASNE,X:STAQ:LDAK2+1:JSRFMLTU:STAK+2:LDAK2:JSRFMLTU:STAP:LDACNT2:ADC#15:AND#63:CMP#33:LDA#0:RORA:STAXX16+4\n 5380LDAXX16+5:EORXX16+2:STAS:LDAXX16+4:EORXX16:JSRADD:STAT:BPLPL42:TXA:EOR#FF:CLC:ADC#1:TAX:LDAT:EOR#&7F:ADC#0:STAT:.PL42:TXA:ADCK3:STAK6:LDAT:ADCK3+1:STAK6+1\n 5390LDAK:STAR:LDAXX16+5:EORXX16+3:STAS:LDAK+2:STAP:LDAXX16+4:EORXX16+1:JSRADD:EOR#128:STAT:BPLPL43:TXA:EOR#FF:CLC:ADC#1:TAX:LDAT:EOR#&7F:ADC#0:STAT:.PL43\n 5400JSRBLINE:CMPTGT:BEQP%+4:BCSPL40:LDACNT2:CLC:ADCSTP:AND#63:STACNT2:JMPPLL4:.PL40 RTS\n 5410JMPWPLS:.PLF3 TXA:EOR#FF:CLC:ADC#1:TAX:.PLF17 LDA#FF:JMPPLF5\n 5430.SUN LDA#1:STALSX:JSRCHKON:BCSPLF3-3:LDA#0:LDXK:CPX#&60:ROLA:CPX#&28:ROLA:CPX#&10:ROLA\n 5450.PLF18 STACNT:LDA#2*Y-1:LDXP+2:BNEPLF2:CMPP+1:BCCPLF2:LDAP+1:BNEPLF2:LDA#1:.PLF2 STATGT\n 5460LDA#2*Y-1:SEC:SBCK4:TAX:LDA#0:SBCK4+1:BMIPLF3:BNEPLF4:INX:DEX:BEQPLF17:CPXK:BCCPLF5:.PLF4 LDXK:LDA#0:.PLF5 STXV:STAV+1\n 5470LDAK:JSRSQUA2:STAK2+1:LDAP:STAK2:LDY#2*Y-1:LDASUNX:STAYY:LDASUNX+1:STAYY+1:.PLFL2 CPYTGT:BEQPLFL:LDALSO,Y:BEQPLF13:JSRHLOIN2:.PLF13 DEY:BNEPLFL2\n 5480.PLFL LDAV:JSRSQUA2:STAT:LDAK2:SEC:SBCP:STAQ:LDAK2+1:SBCT:STAR:STYY1:JSRLL5:LDYY1:JSRDORND:ANDCNT:CLC:ADCQ:BCCPLF44:LDA#FF:.PLF44\n 5490LDXLSO,Y:STALSO,Y:BEQPLF11:LDASUNX:STAYY:LDASUNX+1:STAYY+1:TXA:JSREDGES:LDAX1:STAXX:LDAX2:STAXX+1\n 5500LDAK3:STAYY:LDAK3+1:STAYY+1:LDALSO,Y:JSREDGES:BCSPLF23:LDAX2:LDXXX:STXX2:STAXX:JSRHLOIN:.PLF23 LDAXX:STAX1:LDAXX+1:STAX2:.PLF16 JSRHLOIN:.PLF6\n 5530DEY:BEQPLF8:LDAV+1:BNEPLF10:DECV:BNEPLFL:DECV+1:.PLFLS JMPPLFL\n 5535.PLF11 LDXK3:STXYY:LDXK3+1:STXYY+1:JSREDGES:BCCPLF16:LDA#0:STALSO,Y:BEQPLF6\n 5540.PLF10 LDXV:INX:STXV:CPXK:BCCPLFLS:BEQPLFLS:LDASUNX:STAYY:LDASUNX+1:STAYY+1:.PLFL3 LDALSO,Y:BEQPLF9:JSRHLOIN2\n 5550.PLF9 DEY:BNEPLFL3:.PLF8 CLC:LDAK3:STASUNX:LDAK3+1:STASUNX+1:.RTS2 RTS\n 5600.CIRCLE JSRCHKON:BCSRTS2\n 5610LDA#0:STALSX2\n 5700LDXK:LDA#8:CPX#8:BCCPL89:LSRA:CPX#60:BCCPL89:LSRA:.PL89 STASTP:.CIRCLE2 LDX#FF:STXFLAG:INX:STXCNT:.PLL3\n 5710LDACNT:JSRFMLTU2:LDX#0:STXT:LDXCNT:CPX#33:BCCPL37:EOR#FF:ADC#0:TAX:LDA#FF:ADC#0:STAT:TXA:CLC\n 5720.PL37 ADCK3:STAK6:LDAK3+1:ADCT:STAK6+1\n 5730LDACNT:CLC:ADC#16:JSRFMLTU2:TAX:LDA#0:STAT:LDACNT:ADC#15:AND#63:CMP#33:BCCPL38:TXA:EOR#FF:ADC#0:TAX:LDA#FF:ADC#0:STAT:CLC\n 5740.PL38 JSRBLINE:CMP#65:BCSP%+5:JMPPLL3:CLC:RTS\n 5750.WPLS2 LDYLSX2:BNEWP1:.WPL1 CPYLSP:BCSWP1:LDALSY2,Y:CMP#FF:BEQWP2:STAY2:LDALSX2,Y:STAX2:JSRLOIN:INY:LDASWAP:BNEWPL1\n 5760LDAX2:STAX1:LDAY2:STAY1:JMPWPL1:.WP2 INY:LDALSX2,Y:STAX1:LDALSY2,Y:STAY1:INY:JMPWPL1:.WP1 LDA#1:STALSP:LDA#FF:STALSX2:RTS\n 5790.WPLS LDALSX:BMIWPLS-1:LDASUNX:STAYY:LDASUNX+1:STAYY+1:LDY#2*Y-1:.WPL2 LDALSO,Y:BEQP%+5:JSRHLOIN2:DEY:BNEWPL2:DEY:STYLSX:RTS\n 5800.EDGES STAT:CLC:ADCYY:STAX2:LDAYY+1:ADC#0:BMIED1:BEQP%+6:LDA#254:STAX2\n 5810LDAYY:SEC:SBCT:STAX1:LDAYY+1:SBC#0:BNEED3:CLC:RTS\n 5820.ED3 BPLED1:LDA#2:STAX1:CLC:RTS:.ED1 LDA#0:STALSO,Y:SEC:RTS\n 5850.CHKON LDAK3:CLC:ADCK:LDAK3+1:ADC#0:BMIPL21:LDAK3:SEC:SBCK:LDAK3+1:SBC#0:BMIPL31:BNEPL21:.PL31\n 5860LDAK4:CLC:ADCK:STAP+1:LDAK4+1:ADC#0:BMIPL21:STAP+2:LDAK4:SEC:SBCK:TAX:LDAK4+1:SBC#0:BMIPL44:BNEPL21:CPX#2*Y-1:RTS:.PL21 SEC:RTS\n 5900.PLS3 JSRPLS1:STAP:LDA#222:STAQ:STXU:JSRMULTU:LDXU:LDYK+3:BPLPL12:EOR#FF:CLC:ADC#1:BEQPL12:LDY#FF:RTS:.PL12 LDY#0:RTS\n 5910.PLS4 STAQ:JSRARCTAN:LDXINWK+14:BMIP%+4:EOR#128:LSRA:LSRA:STACNT2:RTS\n 5920.PLS5 JSRPLS1:STAK2+2:STYXX16+2:JSRPLS1:STAK2+3:STYXX16+3:RTS\n 5930.PLS6 JSRDVID3B2:LDAK+3:AND#127:ORAK+2:BNEPL21:LDXK+1:CPX#4:BCSPL6:LDAK+3:\\CLC:BPLPL6:LDAK:EOR#FF:ADC#1:STAK:TXA:EOR#FF:ADC#0:TAX:.PL44 CLC:.PL6 RTS\n 7200.TT17 JSRDOKEY:LDAJSTK:BEQTJ1:LDAJSTX:EOR#FF:JSRTJS1:TYA:TAX\n 7210LDAJSTY:.TJS1 TAY:LDA#0:CPY#&10:SBC#0:\\CPY#&20SBC#0:CPY#&40:SBC#0:CPY#&C0:ADC#0:CPY#&E0:ADC#0:\\CPY#&F0ADC#0\n 7220TAY:LDAKL:RTS\n 7250.TJ1 LDAKL:LDX#0:LDY#0:CMP#&19:BNEP%+3:DEX:CMP#&79:BNEP%+3:INX:CMP#&39:BNEP%+3:INY:CMP#&29:BNEP%+3:DEY:RTS\n 7550.ping LDX#1:.pl1 LDAQQ0,X:STAQQ9,X:DEX:BPLpl1:RTS\n 9500]PRINT\"E d,\";\n 9710IFZ>4OSCLI(\"S.ELTE \"+STR$~W%+\" \"+STR$~O%+\" \"+STR$~L%+\" \"+STR$~H%)\n 9720GOTO12\n"
  },
  {
    "path": "1-source-files/original-sources/text-sources/ELITEF.txt",
    "content": "    1GOTO20\n    2*L.ELITEB\n    3GOTO20\n    4*L.ELITEA\n    6*L.ELITEC\n    7GOTO20\n    8*L.ELITED\n    9GOTO20\n   10*L.ELITEE\n   11GOTO20\n   12*L.ELITEF\n   13GOTO20\n   14*L.ELITEG\n   20REM ELITE <F>\n  100 H%=L%+P%-C%:O%=W%\n  900[OPTZ\n 1000.KS3 LDAP:STASLSP:LDAP+1:STASLSP+1:RTS:.KS1 LDXXSAV:JSRKILLSHP:LDXXSAV:JMPMAL1\n 1010.KS4 JSRZINF:JSRFLFLLS:STAFRIN+1:STASSPR:JSRSPBLB:LDA#6:STAINWK+5:LDA#&81:JMPNWSHP\n 1020.KS2 LDX#FF:.KSL4 INX:LDAFRIN,X:BEQKS3:CMP#MSL:BNEKSL4:TXA:ASLA:TAY:LDAUNIV,Y:STASC:LDAUNIV+1,Y:STASC+1\n 1030LDY#32:LDA(SC),Y:BPLKSL4:AND#&7F:LSRA:CMPXX4:BCCKSL4:BEQKS6:SBC#1:ASLA:ORA#128:STA(SC),Y:BNEKSL4:.KS6 LDA#0:STA(SC),Y:BEQKSL4\n 1050.KILLSHP STXXX4:CPXMSTG:BNEKS5 \\<<**:LDY#&EE:JSRABORT:LDA#200:JSRMESS:.KS5 LDYXX4:LDXFRIN,Y:CPX#SST:BEQKS4:DECMANY,X:LDXXX4\n 1060LDY#5:LDA(XX0),Y:LDY#33:CLC:ADC(INF),Y:STAP:INY:LDA(INF),Y:ADC#0:STAP+1\n 1070.KSL1 INX:LDAFRIN,X:STAFRIN-1,X:BEQKS2:ASLA:TAY:LDAXX21-2,Y:STASC:LDAXX21-1,Y:STASC+1:LDY#5:LDA(SC),Y:STAT:LDAP:SEC:SBCT:STAP:LDAP+1:SBC#0:STAP+1\n 1080TXA:ASLA:TAY:LDAUNIV,Y:STASC:LDAUNIV+1,Y:STASC+1:LDY#35:LDA(SC),Y:STA(INF),Y:DEY\n 1090LDA(SC),Y:STAK+1:LDAP+1:STA(INF),Y:DEY:LDA(SC),Y:STAK:LDAP:STA(INF),Y:DEY:.KSL2 LDA(SC),Y:STA(INF),Y:DEY:BPLKSL2:LDASC:STAINF:LDASC+1:STAINF+1\n 1100LDYT:.KSL3 DEY:LDA(K),Y:STA(P),Y:TYA:BNEKSL3:BEQKSL1\n 1500.SFX EQUS FNS(\"12010010\"):EQUS FNS(\"12022C08\"):EQUS FNS(\"1103F018\"):EQUS FNS(\"10F1071A\")\n 1510EQUS FNS(\"03F1BC01\"):EQUS FNS(\"13F40C08\"):EQUS FNS(\"10F1060C\"):EQUS FNS(\"10026010\") HYP:EQUS FNS(\"1304C2FF\"):EQUS FNS(\"13000000\")\n 3000.RESET \\\"<<<<\":JSRZERO:LDX#6:.SAL3 STABETA,X:DEX:BPLSAL3:STXQQ12:.RES4 LDA#FF:LDX#2:.REL5 STAFSH,X:DEX:BPLREL5\n 3002.RES2 LDA#NOST:STANOSTM:LDX#FF:STXLSX2:STXLSY2:STXMSTG:LDA#128:STAJSTY:STAALP2:STABET2:ASLA:STAALP2+1:STABET2+1:STAMCNT:LDA#3:STADELTA:STAALPHA:STAALP1\n 3005LDASSPR:BEQP%+5:JSRSPBLB:LDAECMA:BEQyu:JSRECMOF:.yu JSRWPSHPS:JSRZERO:LDA#(LS%MOD256):STASLSP:LDA#(LS%DIV256):STASLSP+1:JSRDIALS\n 3006.ZINF LDY#NI%-1:LDA#0:.ZI1 STAINWK,Y:DEY:BPLZI1:LDA#96:STAINWK+18:STAINWK+22:ORA#128:STAINWK+14:RTS\n 3007.msblob LDX#4:.ss CPXNOMSL:BEQSAL8:LDY#0:JSRMSBAR:DEX:BNEss:RTS:.SAL8 LDY#&EE:JSRMSBAR:DEX:BNESAL8:RTS\n 3890.me2 LDAMCH:JSRMESS:LDA#0:STADLY:JMPme3\n 3900.Ze JSRZINF:JSRDORND:STAT1:AND#128:STAINWK+2:TXA:AND#128:STAINWK+5:LDA#32:STAINWK+1:STAINWK+4:STAINWK+7:TXA:CMP#245:ROLA:ORA#&C0:STAINWK+32\n 3904.DORND2 CLC:.DORND LDARAND:ROLA:TAX:ADCRAND+2:STARAND:STXRAND+2:LDARAND+1:TAX:ADCRAND+3:STARAND+1:STXRAND+3:RTS\n 3910.MTT4 LSRA:STAINWK+32:STAINWK+29:ROLINWK+31:AND#31:ORA#16:STAINWK+27:LDA#CYL:JSRNWSHP\n 4000.TT100 JSRM%:DECDLY:BEQme2:BPLme3:INCDLY:.me3 DECMCNT:BEQP%+5:.ytq JMPMLOOP:LDAMJ:BNEytq\n 4020JSRDORND:CMP#35:BCSMTT1:LDAMANY+AST:CMP#3:BCSMTT1:JSRZINF:LDA#38:STAINWK+7:JSRDORND:STAINWK:STXINWK+3:AND#128:STAINWK+2:TXA:AND#128:STAINWK+5:ROLINWK+1:ROLINWK+1\n 4022JSRDORND:BVSMTT4:ORA#&6F:STAINWK+29:LDASSPR:BNEMTT1:TXA:BCSMTT2:AND#31:ORA#16:STAINWK+27:BCCMTT3\n 4025.MTT2 ORA#127:STAINWK+30:.MTT3 JSRDORND:CMP#5:LDA#AST:BCSP%+4:LDA#OIL:JSRNWSHP\n 4030.MTT1\n 4040LDASSPR:BNEMLOOP:JSRBAD:ASLA:LDXMANY+COPS:BEQP%+5:ORAFIST:STAT:JSRZe:CMPT:BCSP%+7:LDA#COPS:JSRNWSHP:LDAMANY+COPS:BNEMLOOP:DECEV:BPLMLOOP:INCEV:JSRDORND:LDYgov:BEQ`:CMP#90:BCSMLOOP:AND#7:CMPgov:BCCMLOOP:.`\n 4050JSRZe:CMP#200:BCSmt1:INCEV:AND#3:ADC#3:TAY:TXA:CMP#200:ROLA:ORA#&C0:CPY#6:BEQtha:STAINWK+32:TYA:JSRNWSHP:.mj1 JMPMLOOP:.mt1 AND#3:STAEV:STAXX13:.mt3 JSRDORND:AND#3:ORA#1:JSRNWSHP\n 4100DECXX13:BPLmt3:.MLOOP LDA#1:STAVIA+&E:LDX#FF:TXS:LDXGNTMP:BEQEE20:DECGNTMP:.EE20 JSRDIALS:LDAQQ11:BEQP%+11:ANDPATG:LSRA:BCSP%+5:JSRDELAY-5\n 4200JSRTT17:.FRCE JSRTT102:LDAQQ12:BNEMLOOP:JMPTT100\n 4250.tha JSRDORND:CMP#200:BCCP%+5:JSRGTHG:JMPMLOOP\n 4500.TT102 CMP#f8:BNEP%+5:JMPSTATUS:CMP#f4:BNEP%+5:JMPTT22:CMP#f5:BNEP%+5:JMPTT23:CMP#f6:BNETT92:JSRTT111:JMPTT25:.TT92 CMP#f9:BNEP%+5:JMPTT213:CMP#f7:BNEP%+5:JMPTT167:CMP#f0:BNEfvw:JMPTT110:.fvw BITQQ12\n 4505BPLINSP:CMP#f3:BNEP%+5:JMPEQSHP:CMP#f1:BNEP%+5:JMPTT219:CMP#&47:BNEP%+5:JMPSVE\n 4510CMP#f2:BNE``:JMPTT208:.INSP CMP#&71:BCC``:CMP#&74:BCS``:AND#3:TAX:JMPLOOK1:.`` CMP#&54:BNEP%+5:JMPhyp:CMP#&32:BEQT95:STAT1:LDAQQ11:AND#192:BEQTT107:LDAQQ22+1:BNETT107:LDAT1:CMP#&36:BNEee2:JSRTT103:JSRping\n 4520JSRTT103:.ee2 JSRTT16:.TT107:LDAQQ22+1:BEQt95:DECQQ22:BNEt95:LDXQQ22+1:DEX:JSRee3:LDA#5:STAQQ22:LDXQQ22+1:JSRee3:DECQQ22+1:BNEt95:JMPTT18:.t95 RTS\n 4550.T95 LDAQQ11:AND#192:BEQt95:JSRhm:STAQQ17:JSRcpl:LDA#128:STAQQ17:LDA#1:STAXC:INCYC:JMPTT146\n 4800.BAD LDAQQ20+3:CLC:ADCQQ20+6:ASLA:ADCQQ20+10:RTS\n 4850.FAROF LDA#&E0:.FAROF2 CMPINWK+1:BCCMA34:CMPINWK+4:BCCMA34:CMPINWK+7:.MA34 RTS:.MAS4 ORAINWK+1:ORAINWK+4:ORAINWK+7:RTS\n 4900.DEATH JSREXNO3:JSRRES2:ASLDELTA:ASLDELTA:LDX#24:JSRDET1:JSRTT66:JSRBOX:JSRnWq:LDA#12:STAYC:STAXC:LDA#146:JSRex:.D1 JSRZe:LSRA:LSRA:STAINWK:LDY#0:STYQQ11:STYINWK+1:STYINWK+4:STYINWK+7:STYINWK+32:DEY:STYMCNT:STYLASCT:EOR#42\n 4905STAINWK+3:ORA#80:STAINWK+6:TXA:AND#&8F:STAINWK+29\n 4910RORA:AND#&87:STAINWK+30:PHP:LDX#OIL:JSRfq1:PLP:LDA#0:RORA:LDY#31:STA(INF),Y:LDAFRIN+3:BEQD1:JSRU%:STADELTA:.D2 JSRM%:LDALASCT:BNED2:LDX#31:JSRDET1:.DEATH2 JSRRES2\n 5000.TT170 LDX#FF:TXS\n 5010.BR1 LDX#3:STXXC:JSRFX200:LDX#CYL:LDA#128:JSRTITLE:CMP#&44:BNEQU5:\\BR1 LDX#3STXXCJSRFX200LDA#1JSRTT66JSRFLKB\n 5015\\LDA#14JSRTT214BCCQU5:JSRGTNME:JSRLOD:JSRTRNME:JSRTTX66\n 5020.QU5 \\JSRTTX66:LDX#NT%:.QUL1 LDANA%+7,X:STATP-1,X:DEX:BNEQUL1:STXQQ11:JSRCHECK:CMPCHK:BNEP%-6:EOR#&A9:TAX:LDACOK:CPXCHK2:BEQtZ:ORA#128:.tZ ORA#2:STACOK:JSRmsblob:LDA#147:LDX#3:JSRTITLE:JSRping:JSRhyp1\n 5021.BAY LDA#FF:STAQQ12:LDA#f8:JMPFRCE\n 5110.TITLE PHA:STXTYPE:JSRRESET:LDA#1:JSRTT66:DECQQ11:LDA#96:STAINWK+14\n 5120\\LSRA:STAINWK+7:LDX#127:STXINWK+29:STXINWK+30:INX:STXQQ17\n 5130LDATYPE:JSRNWSHP\n 5140LDY#6:STYXC:JSRDELAY:LDA#30:JSRplf:LDY#6:STYXC:INCYC:LDAPATG:BEQawe:LDA#254:JSRTT27:.awe JSRCLYNS:STYDELTA:STYJSTK:PLA:JSRex:LDA#148:LDX#7:STXXC:JSRex\n 5150.TLL2 LDAINWK+7:CMP#1:BEQTL1:DECINWK+7:.TL1 JSRMVEIT:LDA#128:STAINWK+6:ASLA:STAINWK:STAINWK+3:JSRLL9:DECMCNT:LDA&FE40:AND#16:\\TAX:BEQTL2:JSRRDKEY:BEQTLL2:RTS:.TL2 DECJSTK:RTS\n 5200.CHECK LDX#NT%-2:CLC:TXA:.QUL2 ADCNA%+7,X:EORNA%+8,X:DEX:BNEQUL2:RTS\n 5250.TRNME LDX#7:.GTL1 LDAINWK,X:STANA%,X:DEX:BPLGTL1:.TR1 LDX#7:.GTL2 LDANA%,X:STAINWK,X:DEX:BPLGTL2:RTS\n 5300.GTNME LDA#1:JSRTT66:LDA#123:JSRTT27:JSRDEL8:LDA#&81:STAVIA+&E:LDA#15:TAX:JSROSBYTE:LDX#(RLINE MOD256):LDY#(RLINE DIV256):LDA#0:JSROSWORD\\LDA#1STAVIA+&E:BCSTR1:TYA:BEQTR1:JMPTT67\n 5350.RLINE EQUWINWK:EQUB7:EQUB33:EQUB&7A\n 5400.ZERO LDX#&D:.ZEL JSRZES1:DEX:CPX#9:BNEZEL\n 5410.ZES1 LDY#0:STYSC:.ZES2 LDA#0:STXSC+1:.ZEL1 STA(SC),Y:INY:BNEZEL1:RTS\n 5500.SVE JSRGTNME:JSRTRNME:JSRZERO:LSRSVC:LDX#NT%:.SVL1 LDATP,X:STA&B00,X:STANA%+8,X:DEX:BPLSVL1:JSRCHECK:STACHK:PHA:ORA#128:STAK:EORCOK:STAK+2:EORCASH+2:STAK+1:EOR#&5A:EORTALLY+1:STAK+3:JSRBPRNT:JSRTT67:JSRTT67:PLA:STA&B00+NT%:EOR#&A9\n 5501STACHK2:STA&AFF+NT%:LDY#&B:STY&C0B:INY:STY&C0F\n 5510LDA#&81:STAVIA+&E:INCsvn:LDA#0:JSRQUS1:LDX#0\\STXVIA+&EDEX:STXsvn:JMPBAY\n 5520.QUS1 LDX#INWK:STX&C00:LDX#0:JMPOSFILE\n 5600.LOD LDX#2:JSRFX200:JSRZERO:LDY#&B:STY&C03:INC&C0B:INY:LDA#FF:JSRQUS1:LDA&B00:BMISPS1+1:LDX#NT%:.LOL1 LDA&B00,X:STANA%+8,X:DEX:BPLLOL1:LDX#3\n 5620.FX200\\MOS:LDY#0:LDA#200:JMPOSBYTE\n 6500RTS:.SPS1 LDX#0:JSRSPS3:LDX#3:JSRSPS3:LDX#6:JSRSPS3\n 6600.TAS2 LDAK3:ORAK3+3:ORAK3+6:ORA#1:STAK3+9:LDAK3+1:ORAK3+4:ORAK3+7\n 6610.TAL2 ASLK3+9:ROLA:BCSTA2:ASLK3:ROLK3+1:ASLK3+3:ROLK3+4:ASLK3+6:ROLK3+7:BCCTAL2\n 6620.TA2 LDAK3+1:LSRA:ORAK3+2:STAXX15:LDAK3+4:LSRA:ORAK3+5:STAXX15+1:LDAK3+7:LSRA:ORAK3+8:STAXX15+2\n 6700.NORM\n 6705LDAXX15:JSRSQUA:STAR:LDAP:STAQ:LDAXX15+1:JSRSQUA:STAT:LDAP:ADCQ:STAQ:LDAT:ADCR:STAR:LDAXX15+2:JSRSQUA:STAT:LDAP:ADCQ:STAQ:LDAT:ADCR:STAR\n 6710JSRLL5\n 6720LDAXX15:JSRTIS2:STAXX15 \\*96/Q\n 6730LDAXX15+1:JSRTIS2:STAXX15+1\n 6740LDAXX15+2:JSRTIS2:STAXX15+2:.NO1 RTS\n 6800.RDKEY \\OSBYTE7A:LDX#16:.Rd1 JSRDKS4:BMIRd2:INX:BPLRd1:TXA:.Rd2 EOR#128:TAX:RTS\n 7000.ECMOF LDA#0:STAECMA:STAECMP:JSRECBLB:LDA#72:BNENOISE\n 7001.EXNO3 LDA#16:JSRNOISE:LDA#24:BNENOISE\n 7003.SFRMIS LDX#MSL:JSRSFS1-2:BCCNO1:LDA#&78:JSRMESS:LDA#48:BNENOISE\n 7004.EXNO2 INCTALLY:BNEEXNO-2:INCTALLY+1:LDA#101:JSRMESS:LDX#7 \\15:.EXNO STXT:LDA#24:JSRNOS1:LDAINWK+7:LSRA:LSRA:ANDT:ORA#&F1:STAXX16+2:JSRNO3:LDA#16\n 7006EQUB&2C:.BEEP LDA#32\n 7010.NOISE JSRNOS1:.NO3 LDXDNOIZ:BNENO1:LDX#(XX16 MOD256):LDY#(XX16 DIV256):LDA#7:JMPOSWORD\n 7015.NOS1 LSRA:ADC#3:TAY:LDX#7:.NOL1 LDA#0:STAXX16,X:DEX:LDASFX,Y:STAXX16,X:DEY:DEX:BPLNOL1\n 7020.KYTB RTS:EQUB&E8:EQUB&E2:EQUB&E6:EQUB&E7:EQUB&C2:EQUB&D1:EQUB&C1:EQUD&35237060:EQUW&2265:EQUB&45:EQUB&52 \\? <>XSA.FBRLtabescTUMEJC\n 7030.DKS1 LDXKYTB,Y:JSRDKS4:BPLDKS2-1:LDX#FF:STXKL,Y:RTS\n 7032.CTRL LDX#1:.DKS4 LDA#3:SEI:STA&FE40:LDA#&7F:STA&FE43:STX&FE4F:LDX&FE4F:LDA#&B:STA&FE40:CLI:TXA\n 7035RTS:.DKS2 LDA#&80:JSROSBYTE:TYA:EORJSTE\n 7037RTS:.DKS3 STYT:CPXT:BNEDk3:LDADAMP-&40,X:EOR#FF:STADAMP-&40,X:JSRBELL:JSRDELAY:LDYT:.Dk3 RTS\n 7040.DKJ1 LDY#1:JSRDKS1:INY:JSRDKS1\n 7050LDA&FE40:TAX:AND#16:EOR#16:STAKL+7:LDX#1:JSRDKS2:ORA#1:STAJSTX:LDX#2:JSRDKS2:EORJSTGY:STAJSTY:JMPDK4\n 7065.U% LDA#0:LDY#15:.DKL3 STAKL,Y:DEY:BNEDKL3:RTS\n 7070.DOKEY JSRU%:LDAJSTK:BNEDKJ1\n 7080LDY#7:.DKL2 JSRDKS1:DEY:BNEDKL2\n 7090LDXJSTX:LDA#7:LDYKL+3:BEQP%+5:JSRBUMP2:LDYKL+4:BEQP%+5:JSRREDU2:STXJSTX\n 7100ASLA:LDXJSTY:LDYKL+5:BEQP%+5:JSRREDU2:LDYKL+6:BEQP%+5:JSRBUMP2:STXJSTY\n 7110.DK4 JSRRDKEY:STXKL:CPX#&69:BNEDK2:.FREEZE JSRWSCAN:JSRRDKEY:CPX#&51:BNEDK6:LDA#0:STADNOIZ\n 7114.DK6 LDY#&40:.DKL4 JSRDKS3:INY:CPY#&47:BNEDKL4:.DK55 CPX#&10:BNEDK7:STXDNOIZ:.DK7 CPX#&70:BNEP%+5:JMPDEATH2:CPX#&59:BNEFREEZE:.DK2 LDAQQ11:BNEDK5:LDY#15:LDA#FF\n 7120.DKL1 LDXKYTB,Y:CPXKL:BNEDK1:STAKL,Y:.DK1 DEY:CPY#7:BNEDKL1\n 7130.DK5 RTS\n 7140.TT217 STYYSAV:.t JSRDELAY-5:JSRRDKEY:BNEt:.t2 JSRRDKEY:BEQt2:TAY:LDA(TRTB%),Y:LDYYSAV:TAX:.out RTS\n 7190.me1 STXDLY:PHA:LDAMCH:JSRmes9:PLA:EQUB&2C:.ou2 lda#108:EQUB&2C:.ou3 lda#111\n 7200.MESS LDX#0:STXQQ17:LDY#9:STYXC:LDY#22:STYYC:CPXDLY:BNEme1:STYDLY:STAMCH:.mes9 JSRTT27:LSRde:BCCout:LDA#253:JMPTT27\n 7300.OUCH JSRDORND:BMIout:CPX#22:BCSout:LDAQQ20,X:BEQout:LDADLY:BNEout:LDY#3:STYde:STAQQ20,X:CPX#17:BCSou1:TXA:ADC#208:BNEMESS:.ou1\n 7310BEQou2:CPX#18:BEQou3:TXA:ADC#113-20:BNEMESS\n 7410.QQ16 EQUS\"ALLEXEGEZACEBISOUSESARMAINDIREA?ERATENBERALAVETIEDORQUANTEISRION\"\n 7420.QQ23\\Prxs:EQUD&1068213:EQUD&30A8114:EQUD&7028341\\Food\n 7430EQUD&1FE28528:EQUD&FFB8553:EQUD&33608C4:EQUD &78081DEB \\slvs..\n 7440EQUD&3380E9A:EQUD&7280675:EQUD&1F11014E:EQUD&71D0D7C \\comps\n 7450EQUD&3FDC89B0:EQUD&03358120:EQUD&742A161:EQUD&1F37A2AB \\pltnm\n 7460EQUD&FFAC12D:EQUD&7C00F35 \\Gms.\n 8000.TI2 TYA:LDY#2:JSRTIS3:STAINWK+20\\Uz=-(FxUx+FyUy)/Fz:JMPTI3\n 8010.TI1 TAX:LDAXX15+1:AND#&60:BEQTI2:LDA#2:JSRTIS3:STAINWK+18:JMPTI3\n 8020.TIDY LDAINWK+10:STAXX15:LDAINWK+12:STAXX15+1:LDAINWK+14:STAXX15+2:JSRNORM:LDAXX15:STAINWK+10:LDAXX15+1:STAINWK+12:LDAXX15+2:STAINWK+14\n 8030LDY#4:LDAXX15:AND#&60:BEQTI1:LDX#2:LDA#0:JSRTIS3:STAINWK+16\n 8040.TI3 LDAINWK+16:STAXX15:LDAINWK+18:STAXX15+1:LDAINWK+20:STAXX15+2:JSRNORM:LDAXX15:STAINWK+16:LDAXX15+1:STAINWK+18:LDAXX15+2:STAINWK+20\n 8050LDAINWK+12:STAQ:LDAINWK+20:JSRMULT12:LDXINWK+14:LDAINWK+18:JSRTIS1:EOR#128:STAINWK+22\n 8060LDAINWK+16:JSRMULT12:LDXINWK+10:LDAINWK+20:JSRTIS1:EOR#128:STAINWK+24\n 8070LDAINWK+18:JSRMULT12:LDXINWK+12:LDAINWK+16:JSRTIS1:EOR#128:STAINWK+26 \\FxU/96(LHS)\n 8080LDA#0:LDX#14:.TIL1 STAINWK+9,X:DEX:DEX:BPLTIL1:RTS\n 8100.TIS2 TAY:AND#127:CMPQ:BCSTI4:LDX#254:STXT:.TIL2 ASLA:CMPQ:BCCP%+4:SBCQ:ROLT:BCSTIL2:LDAT\n 8110LSRA:LSRA:STAT:LSRA:ADCT:STAT:TYA:AND#128:ORAT:RTS:.TI4 TYA:AND#128:ORA#96:RTS\n 8130.TIS3 STAP+2:LDAINWK+10,X:STAQ:LDAINWK+16,X:JSRMULT12:LDXINWK+10,Y:STXQ:LDAINWK+16,Y:JSRMAD\n 8140STXP:LDYP+2:LDXINWK+10,Y:STXQ:EOR#128\n 8150.DVIDT\\A=AP/Q:STAP+1:EORQ:AND#128:STAT:LDA#0:LDX#16:ASLP:ROLP+1:ASLQ:LSRQ:.DVL2 ROLA:CMPQ:BCCP%+4:SBCQ:ROLP:ROLP+1:DEX:BNEDVL2:LDAP:ORAT:RTS\n 9000]:PRINT\"F d,\";\n 9710IFZ>4OSCLI(\"S.ELTF \"+STR$~W%+\" \"+STR$~O%+\" \"+STR$~L%+\" \"+STR$~H%)\n 9720GOTO14\n10200DEFFNS(A$):N%=LEN(A$)DIV2:FORI%=0TON%-1:I%?O%=EVAL(\"&\"+MID$(A$,2*I%+1,2)):NEXT:P%=P%+N%:O%=O%+N%:=\"\"\n\n"
  },
  {
    "path": "1-source-files/original-sources/text-sources/ELITEG.txt",
    "content": "    1GOTO20\n    2*L.ELITEB\n    3GOTO20\n    4*L.ELITEA\n    6*L.ELITEC\n    7GOTO20\n    8*L.ELITED\n    9GOTO20\n   10*L.ELITEE\n   11GOTO20\n   12*L.ELITEF\n   13GOTO20\n   14*L.ELITEG\n   20REM ELITE <G>\n  100H%=L%+P%-C%:O%=W%\n 1000[OPTZ\n 7000.SHPPT JSREE51:JSRPROJ:ORAK3+1:BNEnono:LDAK4:CMP#Y*2-2:BCSnono:LDY#2:jsrShpt:ldy#6:ldaK4:ADC#1:jsrShpt:LDA#8:ORAXX1+31:STAXX1+31:LDA#8:JMPLL81+2:PLA:PLA:.nono lda#&F7:andXX1+31:staXX1+31:RTS\n 7010.Shpt STA(XX19),Y:iny:iny:STA(XX19),Y:LDAK3:DEY:STA(XX19),Y:ADC#3:BCSnono-2:dey:dey:STA(XX19),Y:rts\n 8040.LL5 \\2BSQRT Q=SQR(RQ)\n 8045LDYR:LDAQ:STAS:LDX#0:STXQ:LDA#8:STAT:.LL6 CPXQ:BCCLL7:BNELL8:CPY#&40:BCCLL7:.LL8 TYA:SBC#&40:TAY:TXA:SBCQ:TAX:.LL7 ROLQ:ASLS:TYA:ROLA:TAY:TXA:ROLA:TAX:ASLS:TYA:ROLA:TAY:TXA:ROLA:TAX:DECT:BNELL6:RTS\n 8065.LL28 \\BFRDIV R=A*256/Q\n 8070CMPQ:BCSLL2:LDX#254:STXR:.LL31 ASLA:BCSLL29:CMPQ:BCCP%+4:SBCQ:ROLR:BCSLL31:RTS:.LL29 SBCQ:SEC:ROLR:BCSLL31:RTS:.LL2 LDA#FF:STAR:RTS\n 8085.LL38 \\BADD(S)A=R+Q(SA)\n 8090EORS:BMILL39:LDAQ:CLC:ADCR:RTS:.LL39 LDAR:SEC:SBCQ\n 8095BCCP%+4:CLC:RTS:PHA:LDAS:EOR#128:STAS:PLA:EOR#255:ADC#1:RTS\n 8100.LL51 \\XX12=XX15.XX16\n 8105LDX#0:LDY#0:.ll51 LDAXX15:STAQ:LDAXX16,X:JSRFMLTU:STAT:LDAXX15+1:EORXX16+1,X:STAS:LDAXX15+2\n 8115STAQ:LDAXX16+2,X:JSRFMLTU:STAQ:LDAT:STAR:LDAXX15+3\n 8120EORXX16+3,X:JSRLL38:STAT:LDAXX15+4:STAQ:LDAXX16+4,X:JSRFMLTU:STAQ:LDAT:STAR:LDAXX15+5:EORXX16+5,X\n 8130JSRLL38:STAXX12,Y:LDAS:STAXX12+1,Y:INY:INY:TXA:CLC:ADC#6:TAX:CMP#17:BCCll51:RTS\n 8132.LL25 JMPPLANET\n 8135.LL9  \\ ENTRY\n 8137LDATYPE:BMILL25\n 8140LDA#31:STAXX4:LDA#32:BITXX1+31:BNEEE28\n 8144BPLEE28:ORAXX1+31:AND#&3F:STAXX1+31:LDA#0:LDY#28:STA(INF),Y:LDY#30:STA(INF),Y:JSREE51:LDY#1:LDA#18:STA(XX19),Y:LDY#7:LDA(XX0),Y:LDY#2:STA(XX19),Y\n 8146\\LDAXX1+32\\AND#&7F\\STAXX1+32:.EE55 INY:JSRDORND:STA(XX19),Y:CPY#6:BNEEE55:.EE28\n 8150LDAXX1+8:.EE49 BPLLL10:.LL14 LDAXX1+31:AND#32:BEQEE51:LDAXX1+31:AND#&F7:STAXX1+31:JMPDOEXP:.EE51\n 8155LDA#8:BITXX1+31:BEQLL10-1:EORXX1+31:STAXX1+31:JMPLL155:\\LL24\n 8165RTS:.LL10\n 8175LDAXX1+7:CMP#&C0:BCSLL14:LDAXX1:CMPXX1+6:LDAXX1+1:SBCXX1+7:BCSLL14:LDAXX1+3:CMPXX1+6:LDAXX1+4:SBCXX1+7:BCSLL14\n 8205LDY#6:LDA(XX0),Y:TAX:LDA#255:STAXX3,X:STAXX3+1,X\n 8215LDAXX1+6:STAT:LDAXX1+7:LSRA:RORT:LSRA:RORT:LSRA:RORT:LSRA:BNELL13:LDAT:RORA:LSRA:LSRA:LSRA:STAXX4\n 8225BPLLL17:.LL13 LDY#13:LDA(XX0),Y:CMPXX1+7:BCSLL17:LDA#32:ANDXX1+31:BNELL17:JMPSHPPT:.LL17\n 8275LDX#5:.LL15 LDAXX1+21,X:STAXX16,X:LDAXX1+15,X:STAXX16+6,X:LDAXX1+9,X:STAXX16+12,X:DEX:BPLLL15\n 8290LDA#197 \\NORM:STAQ:LDY#16:.LL21 LDAXX16,Y:ASLA:LDAXX16+1,Y\n 8295ROLA:JSRLL28:LDXR:STXXX16,Y:DEY:DEY:BPLLL21\n 8300LDX#8:.ll91 LDAXX1,X:STAXX18,X:DEX:BPLll91\n 8315LDA#255:STAXX2+15\n 8320LDY#12:LDAXX1+31:AND#32:BEQEE29:LDA(XX0),Y:LSRA:LSRA:TAX:LDA#FF:.EE30 STAXX2,X:DEX:BPLEE30:INX:STXXX4:.LL41 JMPLL42:.EE29 LDA(XX0),Y:BEQLL41:STAXX20\n 8330\\DtProd^XX2\n 8335LDY#18:LDA(XX0),Y:TAX:LDAXX18+7:.LL90 TAY:BEQLL91:INX:LSRXX18+4:RORXX18+3:LSRXX18+1:RORXX18:LSRA:RORXX18+6:TAY:BNELL90+3:.LL91 STXXX17:LDAXX18+8\n 8350STAXX15+5:LDAXX18:STAXX15:LDAXX18+2:STAXX15+1:LDAXX18+3:STAXX15+2:LDAXX18+5:STAXX15+3:LDAXX18+6:STAXX15+4:JSRLL51:LDAXX12:STAXX18:LDAXX12+1:STAXX18+2:LDAXX12+2\n 8365STAXX18+3:LDAXX12+3:STAXX18+5:LDAXX12+4:STAXX18+6:LDAXX12+5:STAXX18+8\n 8375LDY#4:LDA(XX0),Y:CLC:ADCXX0:STAV:LDY#17:LDA(XX0),Y:ADCXX0+1:STAV+1:LDY#0\n 8385.LL86 LDA(V),Y:STAXX12+1:AND#31:CMPXX4:BCSLL87\n 8390TYA:LSRA:LSRA:TAX:LDA#255:STAXX2,X:TYA:ADC#4\n 8395TAY:JMPLL88:.LL87 LDAXX12+1:ASLA:STAXX12+3:ASLA:STAXX12+5\n 8400INY:LDA(V),Y:STAXX12:INY:LDA(V),Y:STAXX12+2:INY:LDA(V),Y\n 8405STAXX12+4:LDXXX17:CPX#4:BCCLL92:.LL143 \n 8410\\Face offset<<PV\n 8415LDAXX18:STAXX15:LDAXX18+2:STAXX15+1:LDAXX18+3:STAXX15+2:LDAXX18+5:STAXX15+3:LDAXX18+6:STAXX15+4:LDAXX18+8:STAXX15+5\n 8425JMPLL89:.ovflw LSRXX18:LSRXX18+6:LSRXX18+3:LDX#1:.LL92 LDAXX12:STAXX15:LDAXX12+2:STAXX15+2:LDAXX12+4\n 8430.LL93 DEX:BMILL94:LSRXX15:LSRXX15+2:LSRA:DEX:BPLLL93+3\n 8435.LL94 STAR:LDAXX12+5:STAS:LDAXX18+6:STAQ:LDAXX18+8:JSRLL38:BCSovflw\n 8440STAXX15+4:LDAS:STAXX15+5\n 8450LDAXX15:STAR:LDAXX12+1:STAS\n 8455LDAXX18:STAQ:LDAXX18+2:JSRLL38:BCSovflw:STAXX15:LDAS:STAXX15+1\n 8460LDAXX15+2:STAR:LDAXX12+3:STAS:LDAXX18+3:STAQ:LDAXX18+5\n 8465JSRLL38:BCSovflw:STAXX15+2:LDAS:STAXX15+3\n 8470.LL89 LDAXX12:STAQ:LDAXX15:JSRFMLTU:STAT:LDAXX12+1\n 8475EORXX15+1:STAS:LDAXX12+2:STAQ:LDAXX15+2:JSRFMLTU:STAQ\n 8480LDAT:STAR:LDAXX12+3:EORXX15+3:JSRLL38:STAT:LDAXX12+4\n 8485STAQ:LDAXX15+4:JSRFMLTU:STAQ:LDAT:STAR:LDAXX15+5\n 8490EORXX12+5:JSRLL38:PHA:TYA:LSRA:LSRA:TAX:PLA\n 8500BITS:BMIP%+4:LDA#0:STAXX2,X:INY:.LL88 CPYXX20:BCSLL42:JMPLL86\n 8501.LL42 \\DO nodeX-Ycoords\n 8506\\TrnspMat:LDYXX16+2:LDXXX16+3:LDAXX16+6:STAXX16+2:LDAXX16+7:STAXX16+3:STYXX16+6:STXXX16+7\n 8508LDYXX16+4:LDXXX16+5:LDAXX16+12:STAXX16+4:LDAXX16+13\n 8509STAXX16+5:STYXX16+12:STXXX16+13\n 8510LDYXX16+10:LDXXX16+11:LDAXX16+14:STAXX16+10:LDAXX16+15\n 8511STAXX16+11:STYXX16+14:STXXX16+15\n 8518LDY#8:LDA(XX0),Y:STAXX20\n 8520LDAXX0:CLC:ADC#20:STAV:LDAXX0+1:ADC#0:STAV+1:LDY#0:STYCNT\n 8525.LL48 STYXX17:LDA(V),Y:STAXX15:INY:LDA(V),Y:STAXX15+2:INY\n 8530LDA(V),Y:STAXX15+4:INY:LDA(V),Y:STAT:AND#31:CMPXX4:BCCLL49-3:INY:LDA(V),Y:STAP:AND#15:TAX:LDAXX2,X\n 8540BNELL49:LDAP:LSRA:LSRA:LSRA:LSRA:TAX:LDAXX2,X:BNELL49:INY:LDA(V),Y:STAP:AND#15:TAX:LDAXX2,X:BNELL49:LDAP:LSRA:LSRA:LSRA:LSRA:TAX:LDAXX2,X:BNELL49:JMPLL50\n 8545\\\"\n 8555.LL49 LDAT:STAXX15+1:ASLA:STAXX15+3:ASLA:STAXX15+5\n 8560JSRLL51:LDAXX1+2:STAXX15+2:EORXX12+1:BMILL52:CLC:LDAXX12\n 8565ADCXX1:STAXX15:LDAXX1+1:ADC#0:STAXX15+1:JMPLL53\n 8570.LL52 LDAXX1:SEC:SBCXX12:STAXX15:LDAXX1+1:SBC#0:STAXX15+1\n 8575BCSLL53:EOR#FF:STAXX15+1:LDA#1:SBCXX15:STAXX15\n 8580BCCP%+4:INCXX15+1:LDAXX15+2:EOR#128:STAXX15+2\n 8585.LL53 LDAXX1+5:STAXX15+5:EORXX12+3:BMILL54:CLC:LDAXX12+2\n 8590ADCXX1+3:STAXX15+3:LDAXX1+4:ADC#0:STAXX15+4:JMPLL55\n 8595.LL54 LDAXX1+3:SEC:SBCXX12+2:STAXX15+3:LDAXX1+4:SBC#0\n 8600STAXX15+4:BCSLL55:EOR#255:STAXX15+4:LDAXX15+3:EOR#255:ADC#1\n 8605STAXX15+3:LDAXX15+5:EOR#128:STAXX15+5:BCCLL55:INCXX15+4\n 8610.LL55 LDAXX12+5:BMILL56:LDAXX12+4:CLC:ADCXX1+6:STAT\n 8615LDAXX1+7:ADC#0:STAU:JMPLL57\n 8620.LL61 LDXQ:BEQLL84:LDX#0:.LL63 LSRA:INX:CMPQ:BCSLL63\n 8625STXS:JSRLL28:LDXS:LDAR:.LL64 ASLA:ROLU:BMILL84:DEX:BNELL64:STAR:RTS:.LL84 LDA#50:STAR:STAU:RTS\n 8635.LL62 LDA#128:SEC:SBCR:STAXX3,X:INX:LDA#0:SBCU:STAXX3,X:JMPLL66\n 8645.LL56 LDAXX1+6:SEC:SBCXX12+4:STAT:LDAXX1+7:SBC#0:STAU\n 8650BCCLL140:BNELL57:LDAT:CMP#4:BCSLL57:.LL140 LDA#0:STAU\n 8655LDA#4:STAT:.LL57 LDAU:ORAXX15+1:ORAXX15+4:BEQLL60:LSRXX15+1:RORXX15:LSRXX15+4:RORXX15+3:LSRU:RORT:JMPLL57\n 8665.LL60 LDAT:STAQ:LDAXX15:CMPQ:BCCLL69:JSRLL61:JMPLL65\n 8670.LL69 JSRLL28:.LL65 LDXCNT:LDAXX15+2:BMILL62:LDAR\n 8675CLC:ADC#128:STAXX3,X:INX:LDAU:ADC#0:STAXX3,X\n 8680.LL66 TXA:PHA:LDA#0:STAU:LDAT:STAQ:LDAXX15+3:CMPQ:BCCLL67\n 8685JSRLL61:JMPLL68:.LL70 LDA#Y:CLC:ADCR:STAXX3,X:INX\n 8690LDA#0:ADCU:STAXX3,X:JMPLL50\n 8695.LL67 JSRLL28:.LL68 PLA:TAX:INX:LDAXX15+5:BMILL70:LDA#Y\n 8700SEC:SBCR:STAXX3,X:INX:LDA#0:SBCU:STAXX3,X\n 8705.LL50 CLC:LDACNT:ADC#4:STACNT:LDAXX17:ADC#6:TAY:BCSLL72\n 8706\\\"\n 8710CMPXX20:BCSLL72:JMPLL48:.LL72 LDAXX1+31:AND#32:BEQEE31:LDAXX1+31:ORA#8:STAXX1+31:JMPDOEXP:.EE31\n 8715LDA#8:BITXX1+31:BEQLL74:JSRLL155:LDA#8\n 8725.LL74 ORAXX1+31:STAXX1+31\n 8743LDY#9:LDA(XX0),Y:STAXX20\n 8744LDY#0:STYU:STYXX17:INCU:BITXX1+31:BVCLL170:LDAXX1+31:AND#&BF:STAXX1+31\n 8745LDY#6:LDA(XX0),Y:TAY:LDXXX3,Y:STXXX15:INX:BEQLL170:LDXXX3+1,Y:STXXX15+1:INX:BEQLL170:LDXXX3+2,Y:STXXX15+2\n 8750LDXXX3+3,Y:STXXX15+3:LDA#0:STAXX15+4:STAXX15+5:STAXX12+1:LDAXX1+6:STAXX12\n 8752LDAXX1+2:BPLP%+4:DECXX15+4:JSRLL145:BCSLL170:LDYU\n 8753LDAXX15:STA(XX19),Y:INY:LDAXX15+1:STA(XX19),Y:INY:LDAXX15+2:STA(XX19),Y:INY:LDAXX15+3:STA(XX19),Y:INY:STYU:.LL170\n 8755 \\ Calculate new lines\n 8770LDY#3:CLC:LDA(XX0),Y:ADCXX0\n 8775STAV:LDY#16:LDA(XX0),Y:ADCXX0+1:STAV+1:LDY#5:LDA(XX0),Y:STAT1:LDYXX17\n 8785.LL75 LDA(V),Y:CMPXX4:BCCLL78\n 8787INY:LDA(V),Y:INY:STAP:AND#15:TAX:LDAXX2,X:BNELL79:LDAP:LSRA:LSRA:LSRA:LSRA:TAX\n 8788\\\"\n 8790LDAXX2,X:BEQLL78:.LL79 LDA(V),Y\n 8795TAX:INY:LDA(V),Y:STAQ:LDAXX3+1,X:STAXX15+1:LDAXX3,X:STAXX15\n 8800LDAXX3+2,X:STAXX15+2:LDAXX3+3,X:STAXX15+3:LDXQ:LDAXX3,X\n 8805STAXX15+4:LDAXX3+3,X:STAXX12+1:LDAXX3+2,X:STAXX12\n 8810LDAXX3+1,X:STAXX15+5:JSRLL147:BCSLL78\n 8995.LL80 LDYU:LDAXX15:STA(XX19),Y:INY:LDAXX15+1\n 9000STA(XX19),Y:INY:LDAXX15+2:STA(XX19),Y:INY:LDAXX15+3\n 9005STA(XX19),Y:INY:STYU:CPYT1:BCSLL81\n 9010.LL78 INCXX17:LDYXX17:CPYXX20:BCSLL81:LDY#0:LDAV:ADC#4\n 9012\\\"\n 9015STAV:BCCll81:INCV+1:.ll81 JMPLL75\n 9020.LL81 LDAU:LDY#0:STA(XX19),Y\n 9035.LL155\n 9040\\ CLEAR LINEstr\n 9045LDY#0:LDA(XX19),Y:STAXX20:CMP#4:BCCLL118-1:INY\n 9050.LL27 LDA(XX19),Y:STAXX15:INY:LDA(XX19),Y:STAXX15+1\n 9055INY:LDA(XX19),Y:STAXX15+2:INY:LDA(XX19),Y:STAXX15+3\n 9060JSRLL30:INY:CPYXX20:BCCLL27:\\LL82\n 9065RTS:.LL118  \\move XX15,XX15+2 to screen-grad.XX12+2\n 9070LDAXX15+1:BPLLL119:STAS:JSRLL120  \\ X1<0\n 9075TXA:CLC:ADCXX15+2:STAXX15+2:TYA:ADCXX15+3:STAXX15+3\n 9080LDA#0:STAXX15:STAXX15+1:TAX\n 9085.LL119 BEQLL134:STAS:DECS:JSRLL120 \\ X1>255\n 9090TXA:CLC:ADCXX15+2:STAXX15+2:TYA:ADCXX15+3:STAXX15+3\n 9095LDX#FF:STXXX15:INX:STXXX15+1\n 9100.LL134 LDAXX15+3:BPLLL135:STAS:LDAXX15+2:STAR   \\ Y1<0\n 9105JSRLL123:TXA:CLC:ADCXX15:STAXX15:TYA:ADCXX15+1:STAXX15+1\n 9110LDA#0:STAXX15+2:STAXX15+3\n 9115.LL135 \\BNELL139:LDAXX15+2:SEC:SBC#Y*2:STAR     \\ Y1>191\n 9120LDAXX15+3:SBC#0:STAS:BCCLL136:.LL139 JSRLL123:TXA:CLC:ADCXX15\n 9130STAXX15:TYA:ADCXX15+1:STAXX15+1:LDA#Y*2-1:STAXX15+2:LDA#0:STAXX15+3:.LL136 RTS\n 9140\\ YX=SR*M/256\n 9142.LL120 LDAXX15:STAR\n 9145\\.LL120:JSRLL129:PHA:LDXT:BNELL121:.LL122\n 9160LDA#0:TAX:TAY:LSRS:RORR:ASLQ:BCCLL126:.LL125 TXA:CLC\n 9165ADCR:TAX:TYA:ADCS:TAY:.LL126 LSRS:RORR:ASLQ:BCSLL125\n 9170BNELL126:PLA:BPLLL133:RTS\n 9180\\ YX=SR*256/M (M=grad.)\n 9185.LL123 JSRLL129:PHA:LDXT:BNELL122:.LL121\n 9200LDA#255:TAY:ASLA:TAX:.LL130 ASLR:ROLS:LDAS:BCSLL131\n 9205CMPQ:BCCLL132:.LL131 SBCQ:STAS:LDAR:SBC#0:STAR:SEC\n 9210.LL132 TXA:ROLA:TAX:TYA:ROLA:TAY:BCSLL130:PLA:BMILL128\n 9215.LL133 TXA:EOR#FF:\\CLC:ADC#1:TAX:TYA:EOR#FF:ADC#0:TAY:.LL128 RTS\n 9216.LL129 LDXXX12+2:STXQ:LDAS:BPLLL127:LDA#0:SEC:SBCR:STAR:LDAS:PHA:EOR#255:ADC#0:STAS:PLA:.LL127 EORXX12+3:RTS\n 9300.LL145 \\CLIP\n 9305LDA#0:STASWAP\n 9310LDAXX15+5:.LL147 LDX#Y*2-1:ORAXX12+1:BNELL107:CPXXX12\n 9315BCCLL107:LDX#0:.LL107 STXXX13:LDAXX15+1:ORAXX15+3:BNELL83\n 9320LDA#Y*2-1:CMPXX15+2:BCCLL83\n 9325LDAXX13:BNELL108:.LL146 LDAXX15+2\n 9330STAXX15+1:LDAXX15+4:STAXX15+2:LDAXX12:STAXX15+3:CLC:RTS\n 9335.LL109 SEC:RTS:.LL108 LSRXX13:.LL83\n 9340LDAXX13:BPLLL115\n 9345LDAXX15+1:ANDXX15+5:BMILL109:LDAXX15+3:ANDXX12+1:BMILL109\n 9350LDXXX15+1:DEX:TXA:LDXXX15+5:DEX:STXXX12+2:ORAXX12+2\n 9355BPLLL109:LDAXX15+2:CMP#Y*2:LDAXX15+3:SBC#0:STAXX12+2\n 9360LDAXX12:CMP#Y*2:LDAXX12+1:SBC#0:ORAXX12+2:BPLLL109\n 9365.LL115 TYA:PHA:LDAXX15+4:SEC:SBCXX15:STAXX12+2:LDAXX15+5\n 9370SBCXX15+1:STAXX12+3:LDAXX12:SEC:SBCXX15+2:STAXX12+4\n 9375LDAXX12+1:SBCXX15+3:STAXX12+5:EORXX12+3:STAS\n 9380LDAXX12+5:BPLLL110:LDA#0:SEC:SBCXX12+4:STAXX12+4:LDA#0:SBCXX12+5:STAXX12+5\n 9385.LL110 LDAXX12+3:BPLLL111:SEC:LDA#0:SBCXX12+2:STAXX12+2:LDA#0:SBCXX12+3\n 9390\\GETgrad\n 9395.LL111 TAX:BNELL112:LDXXX12+5:BEQLL113:.LL112 LSRA:RORXX12+2\n 9400LSRXX12+5:RORXX12+4:JMPLL111:.LL113 STXT:LDAXX12+2\n 9405CMPXX12+4:BCCLL114:STAQ:LDAXX12+4:JSRLL28\n 9410 \\ Use Y/X grad.\n 9415JMPLL116:.LL114 LDAXX12+4:STAQ:LDAXX12+2:JSRLL28\n 9420 \\ Use X/Y grad.\n 9425DECT:.LL116 LDAR:STAXX12+2:LDAS:STAXX12+3\n 9430LDAXX13:BEQLL138:BPLLLX117:.LL138 JSRLL118\n 9435LDAXX13:BPLLL124\n 9440.LL117 LDAXX15+1:ORAXX15+3:BNELL137:LDAXX15+2:CMP#Y*2\n 9445BCSLL137:.LLX117 LDXXX15:LDAXX15+4:STAXX15:STXXX15+4:LDAXX15+5\n 9450LDXXX15+1:STXXX15+5:STAXX15+1:LDXXX15+2:LDAXX12:STAXX15+2\n 9455STXXX12:LDAXX12+1:LDXXX15+3:STXXX12+1:STAXX15+3:JSRLL118\n 9460DECSWAP\n 9465.LL124 PLA:TAY:JMPLL146:.LL137 PLA:TAY:SEC:RTS\n 9520]\n 9530F%=P%:PRINT\"G d.\"\n 9710IFZ>4OSCLI(\"SAVE ELTG \"+STR$~W%+\" \"+STR$~O%+\" \"+STR$~L%+\" \"+STR$~H%)\n 9720IFZ=4GOTO4\n 9730 PRINT~C% F% S%,D%-F%\n"
  },
  {
    "path": "2-build-files/README.md",
    "content": "# Build files for the BBC Micro cassette version of Elite\n\nThis folder contains support scripts for building the BBC Micro cassette version of Elite.\n\n* [crc32.py](crc32.py) calculates checksums during the verify stage and compares the results with the relevant binaries in the [4-reference-binaries](../4-reference-binaries) folder\n\n* [elite-checksum.py](elite-checksum.py) adds checksums and encryption to the assembled output\n\n* [elite-decrypt.py](elite-decrypt.py) decrypts an encrypted game binary by doing the opposite to the elite-checksum.py script (this is not used in the build process, but is useful when trying to decrypt any new releases that might be found)\n\n* mktibet.php and tibetuef.php are used to create UEFs from files.\n\nIt also contains the `make.exe` executable for Windows, plus the required DLL files.\n\n---\n\nRight on, Commanders!\n\n_Mark Moxon_"
  },
  {
    "path": "2-build-files/crc32.py",
    "content": "#!/usr/bin/env python\n#\n# ******************************************************************************\n#\n# ELITE VERIFICATION SCRIPT\n#\n# Written by Kieran Connell, extended by Mark Moxon\n#\n# This script performs checksums on the compiled files from the build process,\n# and checks them against the extracted files from the original source disc\n#\n# ******************************************************************************\n\nfrom __future__ import print_function\nimport sys\nimport os\nimport os.path\nimport zlib\n\n\ndef main():\n    if len(sys.argv) <= 2:\n        # Do CRC on single folder\n        folder = sys.argv[1] if len(sys.argv) == 2 else \".\"\n        names = sorted(os.listdir(folder))\n\n        print()\n        print('Checksum   Size  Filename')\n        print('------------------------------------------')\n\n        for name in names:\n            if name.endswith(\".bin\"):\n                full_name = os.path.join(folder, name)\n                if not os.path.isfile(full_name):\n                    continue\n                with open(full_name, 'rb') as f:\n                    data = f.read()\n                print('%08x  %5d  %s' % (\n                    zlib.crc32(data) & 0xffffffff,\n                    len(data),\n                    full_name)\n                )\n        print()\n    else:\n        # Do CRC on two folders\n        folder1 = sys.argv[1]\n        names1 = sorted(os.listdir(folder1))\n        folder2 = sys.argv[2]\n        names2 = sorted(os.listdir(folder2))\n        names = list(names1)\n        names.extend(x for x in names2 if x not in names)\n\n        if '4-reference-binaries' in folder1:\n            src = '[--originals--]'\n        elif 'output' in folder1:\n            src = '[---output----]'\n        else:\n            src = '[{0: ^13}]'.format(folder1[0:13]).replace(' ', '-')\n\n        if '4-reference-binaries' in folder2:\n            dest = '[--originals--]'\n        elif 'output' in folder2:\n            dest = '[---output----]'\n        else:\n            dest = '[{0: ^13}]'.format(folder2[0:13]).replace(' ', '-')\n\n        print('Results for variant: ' + os.path.basename(folder1))\n        print(src + '  ' + dest)\n        print('Checksum   Size  Checksum   Size  Match  Filename')\n        print('-----------------------------------------------------------')\n\n        for name in names:\n            if name.endswith(\".bin\"):\n                full_name1 = os.path.join(folder1, name)\n                full_name2 = os.path.join(folder2, name)\n\n                if name in names1 and name in names2 and os.path.isfile(full_name1) and os.path.isfile(full_name2):\n                    with open(full_name1, 'rb') as f:\n                        data1 = f.read()\n                    with open(full_name2, 'rb') as f:\n                        data2 = f.read()\n                    crc1 = zlib.crc32(data1) & 0xffffffff\n                    crc2 = zlib.crc32(data2) & 0xffffffff\n                    match = ' Yes ' if crc1 == crc2 and len(data1) == len(data2) else ' No  '\n                    print('%08x  %5d  %08x  %5d  %s  %s' % (\n                        crc1,\n                        len(data1),\n                        crc2,\n                        len(data2),\n                        match,\n                        name)\n                    )\n                elif name in names1 and os.path.isfile(full_name1):\n                    with open(full_name1, 'rb') as f:\n                        data = f.read()\n                    print('%08x  %5d  %s  %s  %s  %s' % (\n                        zlib.crc32(data) & 0xffffffff,\n                        len(data),\n                        '-       ',\n                        '    -',\n                        '  -  ',\n                        name)\n                    )\n                elif name in names2 and os.path.isfile(full_name2):\n                    with open(full_name2, 'rb') as f:\n                        data = f.read()\n                    print('%s  %s  %08x  %5d  %s  %s' % (\n                        '-       ',\n                        '    -',\n                        zlib.crc32(data) & 0xffffffff,\n                        len(data),\n                        '  -  ',\n                        name)\n                    )\n        print()\n\n\nif __name__ == '__main__':\n    main()\n"
  },
  {
    "path": "2-build-files/elite-checksum.py",
    "content": "#!/usr/bin/env python\n#\n# ******************************************************************************\n#\n# CASSETTE ELITE CHECKSUM SCRIPT\n#\n# Written by Kieran Connell and Mark Moxon\n#\n# This script applies encryption, checksums and obfuscation to the compiled\n# binaries for the main game and the loader. The script has two parts:\n#\n#   * The first part generates an encrypted version of the main game's \"ELTcode\"\n#     binary, based on the code in the original \"S.BCFS\" BASIC source program\n#\n#   * The second part generates an encrypted version of the main game's \"ELITE\"\n#     binary, based on the code in the original \"ELITES\" BASIC source program\n#\n# ******************************************************************************\n\nfrom __future__ import print_function\nimport sys\n\nargv = sys.argv\nargc = len(argv)\nencrypt = True\ndisc = True\nprot = False\nrelease = 1\n\nfor arg in argv[1:]:\n    if arg == \"-u\":\n        encrypt = False\n    if arg == \"-t\":\n        disc = False\n    if arg == \"-p\":\n        prot = True\n    if arg == \"-rel1\":\n        release = 1\n    if arg == \"-rel2\":\n        release = 2\n    if arg == \"-rel3\":\n        release = 3\n\nprint(\"Cassette Elite Checksum\")\nprint(\"Encryption = \", encrypt)\nprint(\"Build for disc = \", disc)\nprint(\"Add tape protection = \", prot)\n\n# Configuration variables for scrambling code and calculating checksums\n#\n# Values must match those in 3-assembled-output/compile.txt\n#\n# If you alter the source code, then you should extract the correct values for\n# the following variables and plug them into the following, otherwise the game\n# will fail the checksum process and will hang on loading\n#\n# You can find the correct values for these variables by building your updated\n# source, and then searching compile.txt for \"elite-checksum.py\", where the new\n# values will be listed\n\nif release == 1 or release == 2:\n\n    BLOCK_offset = 0x14B0\n    ENDBLOCK_offset = 0x1530\n    MAINSUM_offset = 0x1335\n    TUT_offset = 0x13E1\n    CHECKbyt_offset = 0x1334\n    CODE_offset = 0x0F86\n\nelif release == 3:\n\n    if disc:\n        BLOCK_offset = 0x14B0\n        ENDBLOCK_offset = 0x1530\n        MAINSUM_offset = 0x1335\n        TUT_offset = 0x13E1\n        CHECKbyt_offset = 0x1334\n        CODE_offset = 0x0F86\n\n    else:\n        if prot:\n            BLOCK_offset = 0x14E1\n            ENDBLOCK_offset = 0x1567\n            MAINSUM_offset = 0x134A\n            TUT_offset = 0x13F6\n            CHECKbyt_offset = 0x1349\n            CODE_offset = 0x0F86\n\n        else:\n            BLOCK_offset = 0x14BB\n            ENDBLOCK_offset = 0x153B\n            MAINSUM_offset = 0x1346\n            TUT_offset = 0x13F2\n            CHECKbyt_offset = 0x1345\n            CODE_offset = 0x0F86\n\n# Load assembled code files that make up big code file\n\ndata_block = bytearray()\neliteb_offset = 0\n\n# Append all assembled code files\n\nelite_names = (\"ELThead\", \"ELTA\", \"ELTB\", \"ELTC\", \"ELTD\", \"ELTE\", \"ELTF\", \"ELTG\")\n\nfor file_name in elite_names:\n    print(str(len(data_block)), file_name)\n    if file_name == \"ELTB\":\n        eliteb_offset = len(data_block)\n    elite_file = open(\"3-assembled-output/\" + file_name + \".bin\", \"rb\")\n    data_block.extend(elite_file.read())\n    elite_file.close()\n\n# Commander data checksum\n\ncommander_offset = 0x52\nCH = 0x4B - 2\nCY = 0\nfor i in range(CH, 0, -1):\n    CH = CH + CY + data_block[eliteb_offset + i + 7]\n    CY = (CH > 255) & 1\n    CH = CH % 256\n    CH = CH ^ data_block[eliteb_offset + i + 8]\n\nprint(\"Commander checksum = \", hex(CH))\n\ndata_block[eliteb_offset + commander_offset] = CH ^ 0xA9\ndata_block[eliteb_offset + commander_offset + 1] = CH\n\n# Skip one byte for checksum0\n\nchecksum0_offset = len(data_block)\ndata_block.append(0)\n\n# Append SHIPS file\n\nships_file = open(\"3-assembled-output/SHIPS.bin\", \"rb\")\ndata_block.extend(ships_file.read())\nships_file.close()\n\nprint(\"3-assembled-output/SHIPS.bin file read\")\n\n# Calculate checksum0\n\nchecksum0 = 0\nfor n in range(0x0, 0x4600):\n    checksum0 += data_block[n + 0x28]\n\nprint(\"checksum 0 = \", hex(checksum0))\n\nif encrypt:\n    data_block[checksum0_offset] = checksum0 % 256\n\n# Encrypt data block\n\nif encrypt:\n    for n in range(0x0, len(data_block) - 0x28):\n        data_block[n + 0x28] ^= (n % 256)\n\n# Calculate checksum1\n\nchecksum1 = 0\nfor n in range(0x0, 0x28):\n    checksum1 += data_block[n]\n\nprint(\"checksum 1 = \", hex(checksum1))\n\n# Write output file for ELTcode\n\noutput_file = open(\"3-assembled-output/ELTcode.bin\", \"wb\")\noutput_file.write(data_block)\noutput_file.close()\n\nprint(\"3-assembled-output/ELTcode.bin file saved\")\n\noutput_file = None\n\ndata_block = None\n\n# Start again but for loader\nprint(\"Elite Loader Checksums\")\n\nloader_block = bytearray()\n\nloader_file = open(\"3-assembled-output/ELITE.unprot.bin\", \"rb\")\nloader_block.extend(loader_file.read())\nloader_file.close()\n\n# Reverse bytes between BLOCK and ENDBLOCK\n\nfor i in range(0, int((ENDBLOCK_offset - BLOCK_offset) / 2)):\n    temp = loader_block[BLOCK_offset + i]\n    loader_block[BLOCK_offset + i] = loader_block[ENDBLOCK_offset - i - 1]\n    loader_block[ENDBLOCK_offset - i - 1] = temp\n\n#  Compute MAINSUM\n\nMAINSUM = 0\nfor i in range(0, 0x400):\n    MAINSUM += loader_block[i]\n\nprint(\"MAINSUM = \", hex(MAINSUM))\n\nif encrypt:\n    loader_block[MAINSUM_offset + 1] = MAINSUM % 256\n\n# Compute CHECKbyt\n\nCHECKbyt = 0\nfor i in range(1, 384):\n    CHECKbyt += loader_block[CHECKbyt_offset + i]\n\nprint(\"CHECKbyt = \", hex(CHECKbyt))\n\nif encrypt:\n    loader_block[CHECKbyt_offset] = CHECKbyt % 256\n\nif encrypt:\n    print(\"Encypting...\")\n\n    #  EOR code in BLOCK to ENDBLOCK\n\n    for i in range(0, ENDBLOCK_offset - BLOCK_offset):\n        loader_block[TUT_offset + i] ^= loader_block[BLOCK_offset + i]\n\n    # EOR checksum code from CHECKbyt to end of loader\n    # See Elite loader (Part 3 of 6) for decryption routine where we\n    # EOR 2 pages for Ian Bell's variants, and 3 pages for STH variant\n\n    if release == 1 or release == 2:\n\n        for i in range(0, 2):\n            for j in range(0, 256):\n                if (j + i * 256 + CHECKbyt_offset) < len(loader_block):\n                    loader_block[j + i * 256 + CHECKbyt_offset] ^= loader_block[j + CODE_offset]\n\n    elif release == 3:\n\n        for i in range(0, 3):\n            for j in range(0, 256):\n                if (j + i * 256 + CHECKbyt_offset) < len(loader_block):\n                    loader_block[j + i * 256 + CHECKbyt_offset] ^= loader_block[j + CODE_offset]\n\n    # EOR 15 pages of data at beginning of loader\n\n    for i in range(0, 0xf):\n        for j in range(0, 256):\n            loader_block[j + i * 256] ^= loader_block[j + CODE_offset]\n\n# Write output file for ELITE\n\noutput_file = open(\"3-assembled-output/ELITE.bin\", \"wb\")\noutput_file.write(loader_block)\noutput_file.close()\nprint(\"3-assembled-output/ELITE.bin file saved\")\n"
  },
  {
    "path": "2-build-files/elite-decrypt.py",
    "content": "#!/usr/bin/env python\n#\n# ******************************************************************************\n#\n# CASSETTE ELITE DECRYPTION SCRIPT\n#\n# Written by Mark Moxon\n#\n# This script removes encryption and checksums from the compiled binaries for\n# the main game code. It reads the encrypted \"ELTcode.bin\" binary and generates\n# a decrypted version as \"ELTcode.decrypt.bin\"\n#\n# Files are saved using the decrypt.bin suffix so they don't overwrite any\n# existing unprot.bin files, so they can be compared if required\n#\n# Run this script by changing directory to the repository's root folder and\n# running the script with \"python 2-build-files/elite-decrypt.py\"\n#\n# You can decrypt specific releases by adding the following arguments, as in\n# \"python 2-build-files/elite-decrypt.py -rel1\" for example:\n#\n#   -rel1   Decrypt the source discs from Ian Bell's site\n#   -rel2   Decrypt the text source discs from Ian Bell's site\n#   -rel3   Decrypt the Stairway to Hell release\n#\n# If unspecified, the default is rel3\n#\n# ******************************************************************************\n\nfrom __future__ import print_function\nimport sys\n\nprint()\nprint(\"BBC cassette Elite decryption\")\n\nargv = sys.argv\nrelease = 3\nfolder = \"sth\"\n\nfor arg in argv[1:]:\n    if arg == \"-rel1\":\n        release = 1\n        folder = \"source-disc\"\n    if arg == \"-rel2\":\n        release = 2\n        folder = \"text-sources\"\n    if arg == \"-rel3\":\n        release = 3\n        folder = \"sth\"\n\n# Configuration variables\n\nif release == 1 or release == 2:\n\n    BLOCK_offset = 0x14B0\n    ENDBLOCK_offset = 0x1530\n    MAINSUM_offset = 0x1335\n    TUT_offset = 0x13E1\n    CHECKbyt_offset = 0x1334\n    CODE_offset = 0x0F86\n    checksum0_offset = 0x4721\n\nelif release == 3:\n\n    BLOCK_offset = 0x14B0\n    ENDBLOCK_offset = 0x1530\n    MAINSUM_offset = 0x1335\n    TUT_offset = 0x13E1\n    CHECKbyt_offset = 0x1334\n    CODE_offset = 0x0F86\n\nif release == 1:\n\n    checksum0_offset = 0x4721\n\nelif release == 2:\n\n    checksum0_offset = 0x471F\n\n# Decrypt ELTcode\n\ndata_block = bytearray()\n\n# Load assembled code file\n\nelite_file = open(\"4-reference-binaries/\" + folder + \"/ELTcode.bin\", \"rb\")\ndata_block.extend(elite_file.read())\nelite_file.close()\n\nprint()\nprint(\"[ Read    ] 4-reference-binaries/\" + folder + \"/ELTcode.bin\")\n\n# Do decryption\n\nfor n in range(0x0, len(data_block) - 0x28):\n    data_block[n + 0x28] ^= (n % 256)\n\nif release == 1 or release == 2:\n    data_block[checksum0_offset] = 0\n\nif release == 2:\n    data_block.append(0)\n    data_block.append(0)\n\nprint(\"[ Decrypt ] 4-reference-binaries/\" + folder + \"/ELTcode.bin\")\n\n# Write output file for ELTcode.decrypt\n\noutput_file = open(\"4-reference-binaries/\" + folder + \"/ELTcode.decrypt.bin\", \"wb\")\noutput_file.write(data_block)\noutput_file.close()\n\nprint(\"[ Save    ] 4-reference-binaries/\" + folder + \"/ELTcode.decrypt.bin\")\n\n# Configuration variables for ELITE\n\nloader_block = bytearray()\n\n# Load assembled code file\n\nelite_file = open(\"4-reference-binaries/\" + folder + \"/ELITE.bin\", \"rb\")\nloader_block.extend(elite_file.read())\nelite_file.close()\n\nprint()\nprint(\"[ Read    ] 4-reference-binaries/\" + folder + \"/ELITE.bin\")\n\n# Do decryption\n\n# EOR 15 pages of data at beginning of loader\n\nfor i in range(0xe, -1, -1):\n    for j in range(255, -1, -1):\n        loader_block[j + i * 256] ^= loader_block[j + CODE_offset]\n\n# EOR checksum code from CHECKbyt to end of loader\n# See Elite loader (Part 3 of 6) for decryption routine where we\n# EOR 2 pages for Ian Bell's variants, and 3 pages for STH variant\n\nif release == 1 or release == 2:\n\n    for i in range(1, -1, -1):\n        for j in range(255, -1, -1):\n            if (j + i * 256 + CHECKbyt_offset) < len(loader_block):\n                loader_block[j + i * 256 + CHECKbyt_offset] ^= loader_block[j + CODE_offset]\n\nelif release == 3:\n\n    for i in range(2, -1, -1):\n        for j in range(255, -1, -1):\n            if (j + i * 256 + CHECKbyt_offset) < len(loader_block):\n                loader_block[j + i * 256 + CHECKbyt_offset] ^= loader_block[j + CODE_offset]\n\n#  EOR code in BLOCK to ENDBLOCK\n\nfor i in range(ENDBLOCK_offset - BLOCK_offset - 1, -1, -1):\n    loader_block[TUT_offset + i] ^= loader_block[BLOCK_offset + i]\n\n# Reverse bytes between BLOCK and ENDBLOCK\n\nfor i in range(0, int((ENDBLOCK_offset - BLOCK_offset) / 2)):\n    temp = loader_block[BLOCK_offset + i]\n    loader_block[BLOCK_offset + i] = loader_block[ENDBLOCK_offset - i - 1]\n    loader_block[ENDBLOCK_offset - i - 1] = temp\n\n# Zero two checksum bytes to match assembled code\n\nloader_block[CHECKbyt_offset] = 0\nloader_block[MAINSUM_offset + 1] = 0\n\nprint(\"[ Decrypt ] 4-reference-binaries/\" + folder + \"/ELITE.bin\")\n\n# Write output file for ELITE.decrypt\n\noutput_file = open(\"4-reference-binaries/\" + folder + \"/ELITE.decrypt.bin\", \"wb\")\noutput_file.write(loader_block)\noutput_file.close()\n\nprint(\"[ Save    ] 4-reference-binaries/\" + folder + \"/ELITE.decrypt.bin\")\nprint()\n"
  },
  {
    "path": "2-build-files/mktibet-0.3.php",
    "content": "<?php\n\n/*\n *  Quadbike 2\n *  Copyright (C) 2023 'Diminished'\n\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n*/\n\n  // TODO\n  // [ ] override gap lengths for next file\n  // [ ] override leader lengths for next file\n  // [x] persist baud behaviour, so +b 300 on file 1 causes other files to be 300 unless changed\n\n  // PHP >=7, reduce stupidity\n  declare (strict_types=1);\n\n  define (\"MKT_E_OK\",         0);\n  define (\"MKT_E_CLI\",        1);\n  define (\"MKT_E_LOAD\",       2);\n  define (\"MKT_E_LARGE_FILE\", 3);\n  define (\"MKT_E_SAVE\",       4);\n  \n  define (\"CLI_STATE_IDLE\",   0);\n  define (\"CLI_STATE_LOAD\",   1);\n  define (\"CLI_STATE_EXEC\",   2);\n  define (\"CLI_STATE_NAME\",   3);\n  define (\"CLI_STATE_TIBET\",  4);\n  define (\"CLI_STATE_BAUD\",   5);\n  \n  define (\"MAX_FILE_SIZE\",        32 * 1024);\n  \n  define (\"DURATION_PRE_GAP_S\",      2.0);\n  define (\"DURATION_MID_GAP_S\",      1.0);\n  define (\"DURATION_POST_GAP_S\",     2.0);\n  define (\"DURATION_LEADER_S\",       1.0);\n  define (\"TIBET_VERSION\",           0.4);\n  \n  define (\"MKTIBET_VERSION\",         0.3);\n  \n  define (\"DURATION_LEADER_CYCS\", (int) (DURATION_LEADER_S * 2400.0));\n\n  $argv = $_SERVER['argv'];\n  \n  print \"\\n$argv[0] v\".MKTIBET_VERSION.\"\\n\\n\";\n\n  $e = process($argv);\n  \n  return $e;\n\n  \n  class FileOpts {\n  \n    var $load;\n    var $exec;\n    var $baud;\n    var $prepend_dummy_byte; // 0.3\n    \n    var $have_load;\n    var $have_exec;\n    var $have_baud;\n    var $have_no_dummy; // 0.3\n    \n    function __construct() {\n      $this->load = 0xffff1900;\n      $this->exec = 0xffff8023;\n      $this->baud = 1200;\n      $this->prepend_dummy_byte = TRUE; // 0.3\n      $this->have_load = 0;\n      $this->have_exec = 0;\n      $this->have_baud = 0;\n      $this->have_no_dummy = 0; // 0.3\n    }\n    \n    function to_string() : string {\n      $s=\"(\";\n      $s .= sprintf(\"load &%x; \", $this->load);\n      $s .= sprintf(\"exec &%x; \", $this->exec);\n      $s .= \"baud \".$this->baud.\"; \";\n      $s .= \"prepend_dummy $this->prepend_dummy_byte\"; // 0.3\n      $s .= \")\";\n      return $s;\n    }\n    \n  }\n  \n  \n  class TibetFile {\n  \n    var $mos_name;\n    var $path_to_src;\n    var $opts;\n    var $data;\n    var $have_mos_name;\n    \n    function __construct (int $baud) {\n      $this->mos_name=NULL;\n      $this->data=\"\";\n      $this->path_to_src = \"\";\n      $this->have_mos_name = 0;\n      $this->opts = new FileOpts;\n      $this->opts->baud = $baud;\n      $this->opts->prepend_dummy_byte = TRUE; // v0.3: BeebEm fail\n    }\n    \n    function to_string() : string {\n      $s=\"\";\n      $s .= \"MOS: \\\"$this->mos_name\\\", \";\n      //$s .= \"path: \\\"$this->path_to_src\\\", \";\n      $s .= $this->opts->to_string();\n      return $s;\n    }\n    \n  }\n\n  \n  function process(array $argv) {\n  \n    $files = array();\n    $tibet_fn=\"tibet.tibet\";\n    \n    $e = parse_cli ($argv, $files, $tibet_fn); // files, tibet_fn populated\n    if (MKT_E_OK != $e) {\n      usage($argv[0]);\n      return $e;\n    }\n    \n    $e = fill_missing_names ($files);\n    if (MKT_E_OK != $e) { return $e; }\n\n    $e = load_files ($files);\n    if (MKT_E_OK != $e) { return $e; }\n    \n    foreach ($files as $k=>$v) {\n      print $v->path_to_src.\"\\n\";\n      print \"  \".$v->to_string();\n      print \"\\n\";\n    }\n    \n    $tibet_s = \"\";\n    $e = build_tibet ($files, $tibet_s);\n    if (MKT_E_OK != $e) { return $e; }\n    \n    if (FALSE === @file_put_contents ($tibet_fn, $tibet_s)) {\n      print \"E: Could not write output file: $tibet_fn\\n\";\n      return MKT_E_SAVE;\n    }\n    \n    print \"Wrote \".strlen($tibet_s).\" bytes: $tibet_fn\\n\";\n    \n    return MKT_E_OK;\n  }\n  \n  \n  \n  function build_tibet (array $files, string &$out) : int {\n    $out .= \"tibet \".TIBET_VERSION.\"\\n\\n\";\n    $out .= \"silence \".DURATION_PRE_GAP_S.\"\\n\\n\";\n    $num_files = count($files);\n    $prev_baud = 0;\n    for ($n=0; $n < $num_files; $n++) {\n      $f = $files[$n];\n      $d = $f->data;\n      $len = strlen($d);\n      // v0.3: Maddeningly, BeebEm misses the start of the first block unless you\n      // send some dummy data first, because ... no, I've no idea why on earth it would do this\n      if ($f->opts->prepend_dummy_byte) {\n        $out .= \"leader \".DURATION_LEADER_CYCS.\"\\n\";\n        $out .= \"data\\n----..--..--..--....\\nend\\n\"; // standard MOS 1.2 &AA dummy byte\n        $out .= \"leader \".DURATION_LEADER_CYCS.\"\\n\\n\";\n      }\n      // split into blocks\n      for ($i=0, $rem=$len, $bn=0;\n           $i < $len;\n           $i += 256, $rem -= 256, $bn++) {\n        if ($rem < 256) {\n          $blklen = $rem;\n        } else {\n          $blklen = 256;\n        }\n        $blk_payload = substr ($d, $i, $blklen);\n        $blk_built = \"\";\n        $e = build_block ($bn, $rem <= 256, FALSE, $blk_payload, $f, $blk_built);\n        if (MKT_E_OK != $e) { return $e; }\n        $blk_encoded = \"\";\n        $e = tibet_encode ($blk_built,\n                           $f->opts->baud,\n                           $prev_baud != $f->opts->baud, // baud changed?\n                           $blk_encoded);\n        if (MKT_E_OK != $e) { return $e; }\n        $leader_cycs = DURATION_LEADER_CYCS;\n        $out .= \"leader \".$leader_cycs.\"\\n\\n\";\n        $out .= $blk_encoded;\n        //printf(\"%02x len %u\\n\", $bn, strlen($blk));\n        $prev_baud = $f->opts->baud;\n      }\n      $out .= \"leader \".DURATION_LEADER_CYCS.\"\\n\\n\";\n      if ($n < ($num_files - 1)) {\n        $out .= \"silence \".DURATION_MID_GAP_S.\"\\n\\n\";\n      }\n    }\n    $out .= \"silence \".DURATION_POST_GAP_S.\"\\n\\n\";\n    return MKT_E_OK;\n  }\n  \n  \n  function tibet_encode (string $in, int $baud, bool $baud_changed, string &$out) : int {\n    $out = \"\";\n    if ($baud_changed) {\n      $out .= \"/baud \".$baud.\"\\n\";\n    }\n    $out .= \"data\\n\";\n    $len = strlen($in);\n    $one  = ($baud == 1200) ? \"..\" : \"........\";\n    $zero = ($baud == 1200) ? \"--\" : \"--------\";\n    $newline_limit = ($baud == 1200) ? 3 : 0;\n    for ($n=0, $x=0; $n < $len; $n++, $x++) {\n      $c = ord($in[$n]);\n      $out .= $zero; // start bit\n      for ($i=0; $i < 8; $i++) {\n        $out .= ($c&1) ? $one : $zero;\n        $c = ($c >> 1) & 0x7f;\n      }\n      $out .= $one; // stop bit\n      if ($x == $newline_limit) {\n        $out .= \"\\n\";\n        $x = -1;\n      }\n    }\n    if ($x!=0) { $out .= \"\\n\"; }\n    $out .= \"end\\n\\n\";\n    return MKT_E_OK;\n  }\n  \n  \n  function build_block (int $bn,\n                        bool $final,\n                        bool $locked,\n                        string $payload,\n                        TibetFile $tf,\n                        string &$out) : int {\n    $len = strlen($payload);\n    $flags = ($final ? 0x80 : 0) | (($len == 0) ? 0x40 : 0) | ($locked ? 1 : 0);\n    $hdr = $tf->mos_name.\n           \"\\x00\".\n           to_le32($tf->opts->load).\n           to_le32($tf->opts->exec).\n           to_le16($bn).\n           to_le16($len).\n           chr($flags).\n           \"\\x00\\x00\\x00\\x00\";\n    $hcrc = acorn_crc($hdr);\n    $out = \"*\" . $hdr . to_be16($hcrc);\n    if ($len > 0) {\n      $dcrc = acorn_crc($payload);\n      $out .= $payload . to_be16($dcrc);\n    }\n    return MKT_E_OK;\n  }\n  \n  \n  function acorn_crc (string $s) : int {\n    $crc = 0;\n    for ($n=0; $n < strlen($s); $n++) {\n      //u8_t i;\n      //u32_t c;\n      //u16_t h;\n      $b = ord($s[$n]);\n      $c = $crc;\n      $h = ($c>>8) & 0xff;\n      $h = $b ^ $h;\n      $c = ($c & 0x00ff) | (($h << 8) & 0xff00);\n      for ($i=0; $i<8; $i++) {\n        //u32_t t;\n        $t = 0;\n        if ($c & 0x8000) {\n          $c = $c ^ 0x810;\n          $t = 1;\n        }\n        $c = 0xffff & ($t | (($c<<1) & 0xfffe));\n      }\n      $crc = $c;\n    }\n    return $crc;\n  }\n  \n  \n  function to_be16 (int $i) : string {\n    $s = \"\";\n    $s .= chr(($i >> 8) & 0xff);\n    $s .= chr($i & 0xff);\n    return $s;\n  }\n  \n  \n  function to_le16 (int $i) : string {\n    $s = \"\";\n    $s .= chr($i & 0xff);\n    $s .= chr(($i >> 8) & 0xff);\n    return $s;\n  }\n  \n  \n  function to_le32 (int $i) : string {\n    $s = \"\";\n    $s .= chr($i & 0xff);\n    $s .= chr(($i >> 8) & 0xff);\n    $s .= chr(($i >> 16) & 0xff);\n    $s .= chr(($i >> 24) & 0xff);\n    return $s;\n  }\n  \n  \n  function load_files (array &$files) : int {\n    foreach ($files as $k=>$file) {\n      $p = $file->path_to_src;\n      $f = @file_get_contents($p);\n      if (FALSE === $f) {\n        print \"E: Could not load file: $p\\n\";\n        return MKT_E_LOAD;\n      }\n      if (strlen($f) > MAX_FILE_SIZE) {\n        print \"E: File was too large: $p\\n\";\n        return MKT_E_LARGE_FILE;\n      }\n      $file->data = $f;\n      $files[$k] = $file;\n    }\n    return MKT_E_OK;\n  }\n  \n  \n  function fill_missing_names (array &$a) : int {\n    foreach ($a as $k=>$file) {\n      if ( ! isset($file->mos_name) ) {\n        $basename = basename($file->path_to_src);\n        $e = check_mos_filename($basename);\n        if (MKT_E_OK != $e) { return $e; }\n        $file->mos_name = $basename;\n        $a[$k] = $file; // replace in array\n      }\n    }\n    return MKT_E_OK;\n  }\n  \n  \n  function parse_cli (array $argv, array &$files, string &$tibet_fn) : int {\n  \n    $opts_done = 0;\n    $state = 0;\n    $argc = count($argv) - 1;\n    \n    $have_tibet_filename = 0;\n    \n    // current working file\n    $f = new TibetFile(1200);\n    \n    $state = CLI_STATE_IDLE;\n    \n    for ($n=1; $n <= $argc; $n++) {\n      $v = $argv[$n];\n      if ($state == CLI_STATE_IDLE) {\n        if ($v[0] == \"+\") {\n          // opt\n          if ($v == \"+x\") {\n            // execution address\n            if ($f->opts->have_exec) {\n              print \"E: Cannot specify exec address twice.\\n\";\n              return MKT_E_CLI;\n            }\n            $f->opts->have_exec = 1;\n            $state = CLI_STATE_EXEC;\n          } else if ($v == \"+d\") {\n            // load address\n            if ($f->opts->have_load) {\n              print \"E: Cannot specify load address twice.\\n\";\n              return MKT_E_CLI;\n            }\n            $f->opts->have_load = 1;\n            $state = CLI_STATE_LOAD;\n          } else if ($v == \"+b\") {\n            // baud\n            if ($f->opts->have_baud) {\n              print \"E: Cannot specify baud rate twice.\\n\";\n              return MKT_E_CLI;\n            }\n            $f->opts->have_baud = 1;\n            $state = CLI_STATE_BAUD;\n          } else if ($v == \"+n\") {\n            // overridden MOS filename\n            if ($f->have_mos_name) {\n              print \"E: Cannot specify MOS filename twice.\\n\";\n              return MKT_E_CLI;\n            }\n            $f->have_mos_name = 1;\n            $state = CLI_STATE_NAME;\n          } else if ($v == \"+t\") {\n            // TIBET filename\n            if ($have_tibet_filename) {\n              print \"E: Cannot specify TIBET filename twice.\\n\";\n              return MKT_E_CLI;\n            }\n            $have_tibet_filename = 1;\n            $state = CLI_STATE_TIBET;\n          } else if ($v == \"+no-dummy\") {\n            if ($f->opts->have_no_dummy) {\n              print \"E: Cannot specify no-dummy twice.\\n\";\n              return MKT_E_CLI;\n            }\n            $f->have_no_dummy = 1;\n            $f->opts->prepend_dummy_byte = FALSE;\n          } else {\n            print \"E: unknown option $v\\n\";\n            $e = MKT_E_CLI;\n            return $e;\n          }\n        } else {\n          // no '+' => filename, completes file\n          $f->path_to_src = $v;\n          $files[] = $f;\n          // start a new one, but persist the baud from previous one\n          $f = new TibetFile($f->opts->baud);\n        }\n      } else if ($state == CLI_STATE_LOAD) {\n        $i=0;\n        $e = cli_parse_x32($v, $i);\n        if (MKT_E_OK != $e) { return $e; }\n        $f->opts->load = $i;\n        $state = CLI_STATE_IDLE;\n      } else if ($state == CLI_STATE_EXEC) {\n        $i=0;\n        $e = cli_parse_x32($v, $i);\n        if (MKT_E_OK != $e) { return $e; }\n        $f->opts->exec = $i;\n        $state = CLI_STATE_IDLE;\n      } else if ($state == CLI_STATE_BAUD) {\n        $i=0;\n        $e = cli_parse_baud($v, $i);\n        if (MKT_E_OK != $e) { return $e; }\n        $f->opts->baud = $i;\n        $state = CLI_STATE_IDLE;\n      } else if ($state == CLI_STATE_NAME) {\n        $e = check_mos_filename($v);\n        if (MKT_E_OK != $e) { return $e; }\n        $f->mos_name = $v;\n        $state = CLI_STATE_IDLE;\n      } else if ($state == CLI_STATE_TIBET) {\n        $tibet_fn = $v;\n        $state = CLI_STATE_IDLE;\n      }\n    } // next arg\n    \n    if ( ! $have_tibet_filename ) {\n      print \"\\nE: Must specify output TIBET filename with +t.\\n\";\n      return MKT_E_CLI;\n    }\n    \n    return MKT_E_OK;\n    \n  }\n  \n  \n  function check_mos_filename (string $v) : int {\n    if (strlen($v) > 10) {\n      print \"E: overridden MOS filename is too long (max 10 chars): $v\\n\";\n      return MKT_E_CLI;\n    } else if (strlen($v) == 0) {\n      print \"E: overridden MOS filename is empty: $v\\n\";\n      return MKT_E_CLI;\n    }\n    $len = strlen($v);\n    for ($n=0; $n < $len; $n++) {\n      if ($v[$n] == \"\\x00\") {\n        print \"E: overridden MOS filename contains null byte\\n\";\n        return MKT_E_CLI;\n      }\n    }\n    return MKT_E_OK;\n  }\n  \n  \n  function cli_parse_baud (string $v, int &$baud_out) : int {\n    if ($v == \"300\") {\n      $baud_out = 300;\n    } else if ($v == \"1200\") {\n      $baud_out = 1200;\n    } else {\n      print \"E: Illegal baud: $v\\n\";\n      return MKT_E_CLI;\n    }\n    return MKT_E_OK;\n  }\n  \n  \n  function cli_parse_x32 (string $v, int &$out) : int {\n    $len = strlen($v);\n    if ($len == 0) {\n      print \"E: illegal 32-bit hex: $v\\n\";\n      return MKT_E_CLI;\n    }\n    // removed because it causes backgrounding on Unix!\n    //if ($v[0]==\"&\") {\n    //  $v = substr($v, 1);\n    //}\n    if (($v[0]==\"0\") && (($v[1]==\"x\") || ($v[1]==\"X\"))) {\n      $v = substr($v, 2);\n    }\n    $len = strlen($v);\n    if ($len > 8) {\n      print \"E: illegal 32-bit hex: $v\\n\";\n      return MKT_E_CLI;\n    }\n    for ($n=0; $n < $len; $n++) {\n      if ( ! ctype_xdigit($v[$n]) ) {\n        print \"E: illegal 32-bit hex: $v\\n\";\n        return MKT_E_CLI;\n      }\n    }\n    $i=0;\n    $e = sscanf($v, \"%x\", $i);\n    if (FALSE === $e) {\n      print \"E: illegal 32-bit hex: $v\\n\";\n      return MKT_E_CLI;\n    }\n    $out = $i;\n    return MKT_E_OK;\n  }\n  \n  \n  function usage (string $argv0) {\n    print \"\\n\\nUsage:\\n\\n\";\n    print \"  php -f $argv0 +t <output TIBET> [opts] <file1> [opts] <file2> [opts] <file3> ...\\n\\n\";\n    print \"where each per-file [opts] may be:\\n\\n\";\n    print \"  +x <hex>        specify execute address for next file\\n\";\n    print \"  +d <hex>        specify load address for next file\\n\";\n    print \"  +b <1200|300>   specify baud rate for next file\\n\";\n    print \"  +n <filename>   override MOS filename for next file\\n\";\n    print \"  +no-dummy       disable prepending &AA byte before next file\\n\";\n    print \"\\n\";\n  }\n\n?>\n"
  },
  {
    "path": "2-build-files/tibetuef-0.8.php",
    "content": "<?php\n\n/*\n *  Quadbike 2\n *  Copyright (C) 2024 'Diminished'\n\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n*/\n\n  // PHP >=7, reduce stupidity\n  declare (strict_types=1);\n  \n  define (\"APPNAME\",                  \"tibetuef.php\");\n  define (\"TIBETUEF_VERSION\",         \"0.8\");\n  //define (\"TIBET_VERSION_STG\",        \"0.4\");\n  define (\"TIBET_MAJOR_VERSION\",      \"0\");\n\n  define (\"TBT_E_OK\",                 0);\n  define (\"TBT_E_USAGE\",              1);\n  define (\"TBT_E_LOAD\",               2);\n  define (\"TBT_E_IPFN_MATCHES_OPFN\",  3);\n  define (\"TBT_E_PARSE_VERSION\",      4);\n  define (\"TBT_E_BAD_VERSION\",        5);\n  define (\"TBT_E_PARSE_BAD_LINE\",     6);\n  define (\"TBT_E_PARSE_SILENCE\",      7);\n  define (\"TBT_E_BAD_SILENCE\",        8);\n  define (\"TBT_E_PARSE_LEADER\",       9);\n  define (\"TBT_E_BAD_LEADER\",         10);\n  define (\"TBT_E_PARSE_DATA\",         11);\n  define (\"TBT_E_BAD_PHASE\",          12);\n  define (\"TBT_E_PARSE_CYCLES\",       13);\n  define (\"TBT_E_BUG\",                14);\n  define (\"TBT_E_WRITE_FILE\",         15);\n  define (\"TBT_E_PARSE_HINT\",         16);\n  define (\"TBT_E_BAD_FRAMING\",        17);\n  define (\"TBT_E_PARSE_DUP_VERSION\",  18);\n  define (\"TBT_E_BAD_INT\",            19);\n  define (\"TBT_E_BAD_FLOAT\",          20);\n  define (\"TBT_E_GZIP\",               21);\n  // 0.7: handle void chunks\n  define (\"TBT_E_ZL_CHUNK\",           22);\n  // 0.8: major version mismatch\n  define (\"TBT_E_INCOMPATIBLE\",       23);\n \n  define (\"STATE_VERSION\", 0);\n  define (\"STATE_IDLE\",    1);\n  define (\"STATE_CYCLES\",  2);\n  \n  class Span {\n    var $linenum;\n    var $span_ix;\n  }\n  \n  class TimeHint extends Span {\n    var $timestamp;\n  }\n  \n  class ParsedTibet {\n    var $version;\n    var $spans;\n    function __construct() {\n      $this->spans   = array();\n      $this->version = \"\";\n    }\n  }\n  \n  class TibetSilence extends Span {\n    var $secs;\n  }\n  \n  class TibetLeader extends Span {\n    var $cycles;\n  }\n  \n  class DataFraming extends Span {\n    var $framelen;    // 7 or 8: FIXME: rename to wordlen\n    var $parity; // string; \"N\", \"O\", \"E\"\n    var $stops;  // 1 or 2\n    //var $autodetected;\n    function to_string() : string {\n      return \"$this->framelen$this->parity$this->stops\";\n    }\n    function __construct() {\n      // defaults\n      $this->framelen = 8;\n      $this->parity   = \"N\";\n      $this->stops    = 1;\n    }\n  }\n  \n  class BaudRate extends Span {\n    var $rate;\n    function to_string() : string {\n      return \"$this->rate\";\n    }\n    function __construct() {\n      // default\n      $this->rate = 1200;\n    }\n  }\n  \n  class TibetData extends Span {\n    var $squawk;\n    var $cycles; // array\n    var $bits;\n    var $framing; // DataFraming\n    function __construct() {\n      $this->cycles = array(); // TibetCycles\n      $this->bits   = array(); // also TibetCycles ...\n      $this->squawk = 0;\n    }\n  }\n  \n  class TibetCycle extends Span {\n    var $value;\n  }\n  \n  class DummyByte extends Span {\n    var $pre_leader_cycs;\n    var $post_leader_cycs;\n    var $byte_value;\n  }\n  \n  $e = tbt_main ($_SERVER['argc'], $_SERVER['argv']);\n  if (TBT_E_USAGE == $e) { usage($_SERVER['argv'][0]); }\n  return $e;\n  \n  die();\n  \n  function tbt_main ($argc, $argv) : int {\n  \n    print \"\\ntibetuef.php \".TIBETUEF_VERSION.\"\\n\\n\";\n    \n    $insert_timestamps = 0;\n    \n    $use_chunk_102 = 0;\n    //$use_chunk_102b = 0;\n    $use_chunk_104 = 0;\n    $use_chunk_114 = 0;\n    // 0.8: option to use &112 for silence\n    $use_chunk_112_for_silence = 0;\n    $have_nz = 0;\n    $have_no_117 = 0; // 0.6\n    \n    if ($argc < 3) { // PHP filename, ipfn, opfn\n      return TBT_E_USAGE;\n    }\n    \n    $chunk_change_count = 0;\n    \n    // -2 for ipfn, opfn\n    for ($i=1, $dupe=0; $i < ($argc - 2); $i++) {\n      $a = $argv[$i];\n      if ($a[0] != \"+\") { break; }\n      //if (CLI_STATE_IDLE == $state) {\n      //if ($a == \"+f\") {\n      //  if ($autodetect_framings) { return TBT_E_USAGE; } // dup\n      //  $autodetect_framings = 1;\n      //} else\n      if ($a == \"+t\") {\n        if ($insert_timestamps) { $dupe = 1; } // dup\n        $insert_timestamps = 1;\n      } else if ($a == \"+102\") {\n        if ($use_chunk_102) { $dupe = 1; }\n        $use_chunk_102 = 1;\n        $chunk_change_count++;\n      //} else if ($a == \"+102b\") {\n      //  if ($use_chunk_102b) { $dupe = 1; }\n      //  $use_chunk_102b = 1;\n      //  $chunk_change_count++;\n      } else if ($a == \"+104\") {\n        if ($use_chunk_104) { $dupe = 1; }\n        $use_chunk_104 = 1;\n        $chunk_change_count++;\n      } else if ($a == \"+114\") {\n        if ($use_chunk_114) { $dupe = 1; }\n        $use_chunk_114 = 1;\n        $chunk_change_count++;\n      } else if ($a == \"+112\") { // 0.8\n        if ($use_chunk_112_for_silence) { $dupe = 1; }\n        $use_chunk_112_for_silence = 1;\n      } else if ($a == \"+nz\") {\n        if ($have_nz) { $dupe = 1; }\n        $have_nz = 1;\n      } else if ($a == \"+no-117\") { // 0.6\n        if ($have_no_117) { $dupe = 1; }\n        $have_no_117 = 1;\n      } else {\n        print \"E: Unknown option $a\\n\\n\";\n        return TBT_E_USAGE;\n      }\n      \n      if ($dupe) {\n        print \"E: Duplicate option $a specified.\\n\\n\";\n        return TBT_E_USAGE;\n      }\n      \n    }\n    \n    if ($chunk_change_count > 1) {\n      print \"E: Can only supply one of +102, +104 and +114.\\n\\n\";\n      return TBT_E_USAGE;\n    }\n    \n    $ipfn = $argv[$argc - 2];\n    $opfn = $argv[$argc - 1];\n    \n    print \"Input file:  $ipfn\\n\";\n    print \"Output file: $opfn\\n\";\n    if ($insert_timestamps) {\n      print \"Inserting &120 chunks for /time hints.\\n\";\n    }\n    \n    // 0.8\n    if ($use_chunk_112_for_silence) {\n      print \"Using &112 for silence instead of &116.\\n\";\n    }\n    \n    //$chunk_102_interpretation = -1;\n    \n    $chunk_to_use_for_data = 0x100;\n    if ($use_chunk_102) { // || $use_chunk_102b) {\n      $chunk_to_use_for_data = 0x102;\n      //$chunk_102_interpretation = $use_chunk_102b;\n    } else if ($use_chunk_104) {\n      $chunk_to_use_for_data = 0x104;\n    } else if ($use_chunk_114) {\n      $chunk_to_use_for_data = 0x114;\n    }\n    if ($chunk_change_count > 0) {\n      print \"Using chunk type &\".sprintf(\"%x\", $chunk_to_use_for_data).\" for data.\\n\";\n    }\n    \n    if ($have_nz) {\n      print \"Will not compress output UEF file.\\n\";\n    }\n    \n    //if ($autodetect_framings) {\n    //  print \"Autodetecting framings.\\n\";\n    //} else {\n    //  print \"Taking framings from TIBET file.\\n\";\n    //}\n    \n    print \"\\n\";\n    \n    if ($ipfn == $opfn) {\n      print \"E: Input and output filenames cannot match.\\n\";\n      return TBT_E_IPFN_MATCHES_OPFN;\n    }\n    \n    if (FALSE === ($ip = file_get_contents($ipfn))) {\n      print \"E: Could not load file: $ipfn\\n\";\n      return TBT_E_LOAD;\n    }\n    \n    $len = strlen($ip);\n    \n    print \"Loaded $len bytes.\\n\";\n    \n    // try gzdecode\n    $ip_unz = @gzdecode($ip);\n    if (FALSE === $ip_unz) {\n      print \"Input TIBET was uncompressed.\\n\";\n    } else {\n      print \"Decompressed input TIBET: \".strlen($ip).\" -> \".strlen($ip_unz).\" bytes.\\n\";\n      $ip = $ip_unz;\n    }\n    \n    $tbt = new ParsedTibet;\n    $e = tbt_process ($ip, ($insert_timestamps == 1), $tbt); // tbt populated\n    if (TBT_E_OK != $e) { return $e; }\n    \n    $e = cycles_to_bits ($tbt);   // tbt modified\n    if (TBT_E_OK != $e) { return $e; }\n    \n    //if ($autodetect_framings) {\n      // override framings that may have been read from the TIBET file earlier\n      //$e = autopopulate_framings($tbt); // tbt modified\n      //if (TBT_E_OK != $e) { return $e; }\n    //} else {\n    //$e = populate_framings_from_tibet ($tbt); // tbt modified\n    //if (TBT_E_OK != $e) { return $e; }\n    //}\n    \n    // 0.4\n    $e = spans_fix_up_long_leader($tbt);\n    if (TBT_E_OK != $e) { return $e; }\n    \n    // 0.4\n    $e = spans_detect_and_convert_dummy_bits($tbt);\n    if (TBT_E_OK != $e) { return $e; }\n    \n    $uef = \"\";\n    $msg = \"\";\n    $e = build_uef ($tbt,\n                    $chunk_to_use_for_data,\n                    $use_chunk_112_for_silence, // 0.8\n                    //$chunk_102_interpretation,\n                    $have_no_117, // 0.6\n                    $uef,\n                    $msg);\n    if (TBT_E_OK != $e) { return $e; }\n    print \"\\nChunks: (type-len)\\n\";\n    print_chunk_messages($msg);\n    print \"\\n\";\n    \n    if ( ! $have_nz ) {\n      $uef_z = gzencode($uef, 9, FORCE_GZIP);\n      if (FALSE === $uef_z) {\n        print \"E: Could not compress output UEF.\\n\";\n        return TBT_E_GZIP;\n      }\n      print \"Compressed output UEF: \".strlen($uef).\" -> \".strlen($uef_z).\" bytes.\\n\";\n      $uef = $uef_z;\n    }\n    \n    if (FALSE === file_put_contents($opfn, $uef)) {\n      print \"E: Could not write file: $opfn\\n\";\n      return TBT_E_WRITE_FILE;\n    }\n    \n    return TBT_E_OK;\n    \n  }\n  \n  \n  // 0.4\n  function spans_fix_up_long_leader (ParsedTibet &$tbt) : int {\n    $spans_new = array();\n    foreach ($tbt->spans as $k=>$span) {\n      if ((get_class($span) != \"TibetLeader\") || ($span->cycles <= 0xffff)) {\n        $spans_new[] = $span;\n        continue;\n      }\n      for ($rem = $span->cycles; $rem > 0; $rem -= 0xffff) {\n        $num_cycs = $rem;\n        if ($num_cycs > 0xffff) {\n          $num_cycs = 0xffff;\n        }\n        $new_span = new TibetLeader;\n        $new_span->linenum = $span->linenum;\n        $new_span->span_ix = $span->span_ix; // preserve this\n        $new_span->cycles = $num_cycs;\n        $spans_new[] = $new_span;\n        //~ print \"M: L$span->linenum, span $span->span_ix: Leader: $num_cycs cycs\\n\";\n      }\n    }\n    $tbt->spans = $spans_new;\n//foreach ($tbt->spans as $k=>$v) { if (\"TibetLeader\"==get_class($v)) { print \"L: $v->cycles\\n\"; } }\n    return TBT_E_OK;\n  }\n  \n  \n  function print_chunk_messages ($msg) {\n    print wordwrap($msg);\n  }\n  \n  \n  function cycles_to_bits (ParsedTibet &$tbt) : int {\n  \n    $current_baud = 1200;\n    \n    foreach ($tbt->spans as $sn => $span) {\n    \n      if (gettype($span) != \"object\") {\n        print \"B: cycles_to_bits: Bad span type: \\\"\".gettype($span).\"\\\"\\n\";\n        return TBT_E_BUG;\n      }\n      \n      $type = get_class($span);\n      \n      if (\"BaudRate\" == $type) {\n        print \"span #$span->span_ix: Baud rate change: $current_baud -> $span->rate\\n\";\n        $current_baud = $span->rate;\n      }\n      \n      if (\"TibetData\" != $type) {\n        continue;\n      }\n    \n      //print count($tbd->cycles).\" cycles in span\\n\";\n      \n      $span->bits = array();\n      $i=0;\n      \n//print_r($span); die();\n\n      $bitlen = 2;\n      if ($current_baud == 300) {\n        $bitlen = 8;\n      }\n      \n      $num_atoms = count($span->cycles);\n      \n      //for ($i=0; $i < (count($span->cycles) - 1); $i+=2) {\n      for ($i=0; $i < ($num_atoms - ($bitlen - 1)); $i += $bitlen) {\n        //$atoms = array();\n        $ln = $span->cycles[$i]->linenum;\n        $zeros = 0;\n        $ones = 0;\n        for ($j=0; ($j < $bitlen) && (($i + $j) < $num_atoms); $j++) {\n          //$atoms[$j] = $span->cycles[$i + $j];\n          if ($span->cycles[$i + $j]->value) {\n            $ones++;\n          } else {\n            $zeros++;\n          }\n        }\n        if ($j != $bitlen) {\n          print \"W: cycles_to_bits: line $ln, span #$span->span_ix: Partial bit\\n\";\n          $atom = $span->cycles[$i]; // partial bit: use the first atom's value\n        } else {\n          /*\n          for ($j=0; $j < $bitlen; $j++) {\n            if ($span->cycles[$i + $j]->value) {\n              $ones++;\n            } else {\n              $zeros++;\n            }\n          }\n          */\n          if (($ones == $bitlen) || ($zeros == $bitlen)) {\n            // unanimous\n            $atom = $span->cycles[$i];\n          } else {\n            // bad bit\n            print \"W: cycles_to_bits: line $ln, span #$span->span_ix: Fuzzy bit\\n\";\n            // skip one atom and resynchronise\n            $i -= ($bitlen - 1);\n            continue;\n          }\n          \n          // this is the old code that allowed voting on\n          // 300 baud bits; it now violates the TIBET\n          // specification on decode, so it's been replaced\n          // with the simple skip-one-atom-and-resync logic from the spec\n          /*\n          } else {\n            print \"W: cycles_to_bits: line $ln, span #$span->span_ix: Fuzzy bit\\n\";\n            if ($ones > $zeros) {\n              // find first one\n              for ($j=0; $j < $bitlen; $j++) {\n                if ($span->cycles[$i + $j]->value) {\n                  $atom = $span->cycles[$i];\n                }\n              }\n            } else if ($ones < $zeros) {\n              // find first zero\n              for ($j=0; $j < $bitlen; $j++) {\n                if ( ! $span->cycles[$i + $j]->value ) {\n                  $atom = $span->cycles[$i];\n                }\n              }\n            } else {\n              // it's a tie, just use first atom\n              $atom = $span->cycles[$i];\n            }\n          }\n          */\n          \n        }\n        \n        // at this point we should have an atom\n        //$a = $span->cycles[$i]->value;\n        //$b = $span->cycles[$i+1]->value;\n\n        /*\n        if ($a != $b) {\n          print \"W: cycles_to_bits: L$ln, span #$span->span_ix: Cycle pair mismatch\\n\";\n          // skip one and resynchronise\n          $i--;\n          continue;\n        }\n        $span->bits[] = $span->cycles[$i];\n        */\n        \n        $span->bits[] = $atom;\n        \n      }\n      \n      //print count($bits).\" bits in span\\n\";\n    \n    } // next span\n    \n    return TBT_E_OK;\n    \n  }\n  \n  \n  function populate_framings_from_tibet (ParsedTibet &$tbt) : int {\n    // use \"framing ...\" lines to set framings on subsequent data spans\n    $framing = new DataFraming; // 8N1 default\n    foreach ($tbt->spans as $sn => $span) {\n      if (gettype($span) != \"object\") {\n        print \"B: populate_framings_from_tibet: Bad span type: \\\"\".gettype($span).\"\\\"\\n\";\n        return TBT_E_BUG;\n      }\n      $type = get_class($span);\n      if (\"TibetData\" == $type) {\n        // note that this means the framing field on the data span\n        // is itself a span, with a span_ix and a line number, which\n        // will be the originating span where this framing was programmed.\n        $tbt->spans[$sn]->framing = $framing;\n      } else if (\"DataFraming\" == $type) {\n        $framing = $span;\n      }\n    }\n    return TBT_E_OK;\n  }\n  \n/*\n  function autopopulate_framings (ParsedTibet &$tbt) : int {\n  \n    // default to 8N1 framing, since BASIC always needs this to load\n    $prev_framing = new DataFraming;\n  \n    foreach ($tbt->spans as $sn => $span) {\n    \n      if (gettype($span) != \"object\") {\n        print \"B: autopopulate_framings: Bad span type: \\\"\".gettype($span).\"\\\"\\n\";\n        return TBT_E_BUG;\n      }\n      \n      $type = get_class($span);\n      \n      if (\"TibetData\" != $type) {\n        continue;\n      }\n      \n      if ($span->squawk) {\n        continue;\n      }\n      \n      // need to identify framing format\n      \n      // \"For the BBC/Electron, the following formats may be encountered:\n      //  7E1, 7E2, 7O1, 7O2, 8E1, 8N2, 8O1.\n      //  Format 8N1 would produce the same output as chunk &0100.\"\n      \n      // 7E1/7O1: 0xxxxxxxP1  }\n      // 8N1:     0xxxxxxxx1  } \"short\"\n      //                   ^ short_stops_score counts these\n      \n      // 7E2/7O2: 0xxxxxxxP11 } \"long\"\n      // 8N2:     0xxxxxxxx11 }\n      // 8E1/8O1: 0xxxxxxxxP1 }\n      //                    ^ long_stops_score counts these\n      //                   ^ double_stop_score counts these\n      \n      $bits = $span->bits;\n      $nb = count($bits);\n      \n      if ($nb < 1000) {\n        print \"W: L$span->linenum, span #$span->span_ix, $nb bits: too short to derive framing, using previous \".$prev_framing->to_string().\"\\n\";\n        $span->framing = $prev_framing;\n        continue;\n      }\n      \n      // find first start bit (should be right at the start)\n      for ($i=0; $i < $nb; $i++) {\n        $b = $bits[$i];\n        if (0 == $b->value) {\n          break;\n        }\n      }\n      \n      if ($i != 0) {\n        print \"W: autopopulate_framings: L$b->linenum, span #$b->span_ix, $nb bits: Late start bit (i=$i)\\n\";\n      }\n      \n      $i++; // first data bit\n      \n      $short_stops_score = 0;\n      $short_odd_score = 0;\n      $short_even_score = 0;\n      \n      // assume frame len of 10\n      for ($j=$i; $j < ($nb - 9); $j += 10) {\n        $short_stops_score += $bits[$j+8]->value;\n        $ones = 0;\n        // check all data bits, plus the parity bit (8 bits); count the ones\n        for ($k=$j; $k < $j+8; $k++) {\n          $ones += $bits[$k]->value;\n        }\n        if ($ones & 1) {\n          $short_odd_score++;\n        } else {\n          $short_even_score++;\n        }\n      }\n      \n      $long_stops_score     = 0;\n      $double_stop_score    = 0;\n      $long_7bit_odd_score  = 0;\n      $long_7bit_even_score = 0;\n      $long_8bit_odd_score  = 0;\n      $long_8bit_even_score = 0;\n      \n      // now assume frame len of 11\n      for ($j=$i; $j < ($nb - 10); $j+=11) {\n        $long_stops_score += $bits[$j+9]->value;\n        $double_stop_score += $bits[$j+8]->value;\n        $ones = 0;\n        // check all data bits, plus the potential parity bit (8 bits); count the ones\n        for ($k=$j+1; $k < $j+9; $k++) {\n          $ones += $bits[$k]->value;\n        }\n        if ($ones & 1) {\n          $long_7bit_odd_score++;\n        } else {\n          $long_7bit_even_score++;\n        }\n        // do it again but include an extra bit, another potential parity bit\n        $ones += $bits[$j+9]->value;\n        if ($ones & 1) {\n          $long_8bit_odd_score++;\n        } else {\n          $long_8bit_even_score++;\n        }\n      }\n\n      //print \"short_stops_score = $short_stops_score\\n\";\n      //print \"short_even_score = $short_even_score\\n\";\n      //print \"short_odd_score = $short_odd_score\\n\";\n      \n      //print \"long_stops_score = $long_stops_score\\n\";\n      //print \"double_stop_score = $double_stop_score\\n\";\n      \n      // if short_stops_score > long_stops_score\n      //   7E1, 7O1, 8N1\n      // else\n      //   if double_stop_score ~= long_stops_score\n      //     7E2, 7O2, 8N2\n      //   else\n      //     8E1, 8O1\n      \n      $framelen = 0;\n      $parity = \"\";\n      $stops = 0;\n      \n      // $epsilon is \"approximately zero\"\n      $epsilon = $nb / 320;\n      \n      if ($short_stops_score > ($long_stops_score * 1.1)) {\n        // 7E1/7O1: 0xxxxxxxP1  }\n        // 8N1:     0xxxxxxxx1  } \"short\"\n        // for a perfect signal,\n        // 7E1: short_odd_score = 0, short_even_score = lots\n        // 7O1: short_odd_score = lots, short_even_score = 0\n        // 8N1: short_odd_score = some, short_even_score = some\n        $stops = 1;\n        if ($short_odd_score < $epsilon) {\n          // 7E1\n          $framelen = 7;\n          $parity = \"E\";\n        } else if ($short_even_score < $epsilon) {\n          // 7O1\n          $framelen = 7;\n          $parity = \"O\";\n        } else {\n          // 8N1\n          $framelen = 8;\n          $parity = \"N\";\n        }\n      } else if (abs($double_stop_score - $long_stops_score) < $epsilon) {\n        // 7E2/7O2: 0xxxxxxxP11 } \"long\"\n        // 8N2:     0xxxxxxxx11 }\n        $stops = 2;\n        if ($long_7bit_odd_score < $epsilon) {\n          // 7E2\n          $framelen = 7;\n          $parity = \"E\";\n        } else if ($long_7bit_even_score < $epsilon) {\n          // 7O2\n          $framelen = 7;\n          $parity = \"O\";\n        } else {\n          // 8N2\n          $framelen = 8;\n          $parity = \"N\";\n        }\n      } else {\n        // 8E1/8O1: 0xxxxxxxxP1\n        $stops = 1;\n        $framelen = 8;\n        if ($long_8bit_odd_score < $epsilon) {\n          // 8E1\n          $parity = \"E\";\n        } else {\n          // 8O1\n          $parity = \"O\";\n        }\n      }\n      \n      $framing = new DataFraming;\n      $framing->stops        = $stops;\n      $framing->framelen     = $framelen;\n      $framing->parity       = $parity;\n      //$framing->autodetected = TRUE;\n      \n      $tbt->spans[$sn]->framing = $framing;\n      $prev_framing = $framing;\n      \n      print \"Framing: L$b->linenum, span #$b->span_ix, $nb bits: \".$span->framing->to_string().\"\\n\";\n      \n    }\n    \n    return TBT_E_OK;\n    \n  }\n*/\n\n\n  function spans_detect_and_convert_dummy_bits (ParsedTibet &$tbt) : int {\n  \n    $dummies = array();\n  \n    // for a dummy bit span, we need <leader> <data> <leader>,\n    // so we start at 1 and end at N-2\n    for ($i=1; $i < (count($tbt->spans) - 1); $i++) {\n      $prev = $tbt->spans[$i-1];\n      $cur  = $tbt->spans[$i];\n      $next = $tbt->spans[$i+1];\n      if (    (get_class($prev) != \"TibetLeader\")\n           || (get_class($cur)  != \"TibetData\")\n           || (get_class($next) != \"TibetLeader\")) {\n        continue; // nope\n      }\n      $num_bits = count($cur->bits);\n      if ($num_bits < 10) {\n        continue; // nope\n      }\n      // candidate span may have some leader tone following the\n      // data burst, so we need to ignore that.\n      for ($end=($num_bits - 1); ($end>=0) && ($cur->bits[$end]->value == 1); $end--) { }\n      \n      // $end should now point to the last zero in the chunk\n      if ($end != 7) {\n        continue; // nope\n      }\n      \n      // OK, expect &AA\n      $bits = $cur->bits;\n      \n      if (    !$bits[0]->value\n           && !$bits[1]->value\n           &&  $bits[2]->value\n           && !$bits[3]->value\n           &&  $bits[4]->value\n           && !$bits[5]->value\n           &&  $bits[6]->value\n           && !$bits[7]->value) {\n        print \"M: line $cur->linenum: Dummy byte detected.\\n\";\n        $dummies[] = $i;\n      }\n      \n    }\n    \n    // rather than mess about trying to delete elements from\n    // the spans list, which would mess up the numbering in\n    // dummies, we'll just set them to NULL.\n    foreach ($dummies as $k=>$span_ix) {\n      $tdb = new DummyByte;\n      \n      $tdb->linenum          = $tbt->spans[$span_ix]->linenum;\n      $tdb->pre_leader_cycs  = $tbt->spans[$span_ix-1]->cycles;\n      $tdb->post_leader_cycs = $tbt->spans[$span_ix+1]->cycles;\n      $tdb->value            = 0xAA;\n      \n      $tbt->spans[$span_ix] = $tdb;\n      \n      // delete the formerly leader spans:\n      $tbt->spans[$span_ix - 1] = NULL;\n      $tbt->spans[$span_ix + 1] = NULL;\n    }\n    \n    $spans_new = array();\n    for ($i=0; $i < count($tbt->spans); $i++) {\n      // DON'T rewrite the span indices. We want these to reflect\n      // the original lineup in the TIBET file, so <leader N-1> <data N> <leader N+1>\n      // will end up with a pair of discontinuities: ... N-3, N-2, N, N+2, N+3 ...\n      if (isset($tbt->spans[$i])) { // now skip the NULLs\n        $spans_new[] = $tbt->spans[$i];\n      }\n    }\n    \n    //print \"orig: \".count($tbt->spans).\", final: \".count($spans_new).\"\\n\";\n\n    $tbt->spans = $spans_new; // replace orig array\n    \n    return TBT_E_OK;\n  }\n\n  \n  function build_uef (ParsedTibet $tbt,\n                      int $chunk_to_use_for_data,\n                      int $use_chunk_112_for_silence,\n                      int $omit_chunk_117, // 0.6\n                      string &$uef,\n                      string &$msg) : int {\n  \n    // header, versions\n    $uef = \"UEF File!\\x00\\x0a\\x00\";\n      \n    // origin chunk\n    $origin = \"Created with \".APPNAME.\" v\".TIBETUEF_VERSION.\"\\0\";\n    $orglen = strlen($origin);\n    $uef .= \"\\x00\\x00\".le32($orglen).$origin;\n    \n    $limit = count($tbt->spans);\n    \n    $framing = new DataFraming;\n    \n    $cycs_to_steal = 0;\n    \n    // 0.5\n    $cur_active_baud = 1200;\n    \n    foreach ($tbt->spans as $sn => $span) {\n    \n      if (gettype($span) != \"object\") {\n        print \"B: Bad span type: \\\"\".gettype($span).\"\\\"\\n\";\n        return TBT_E_BUG;\n      }\n      $type = get_class($span);\n      $chunkbuf=\"\";\n      $chunktype = 0;\n      \n      if (\"TibetLeader\" == $type) {\n        // we (maybe) stole some 1-cycles from this leader to pad the\n        // preceding data cycle\n        $span->cycles -= $cycs_to_steal;\n      }\n      \n      $cycs_to_steal = 0;\n      \n      if (\"TibetLeader\" == $type) {\n        $chunktype = 0x110;\n        // may need multiple chunks\n        // 0.4 -- not any more -- we handle this earlier now,\n        // in a separate span-processing pass,\n        // because there's a potential problem with chunk &111\n        // which amalgamates leader spans\n        /*\n        for ($rem = $span->cycles; $rem > 0; $rem -= 0xffff) {\n          $num_cycs = $rem;\n          if ($num_cycs > 0xffff) {\n            $num_cycs = 0xffff;\n          }\n          //~ print \"M: L$span->linenum, span $span->span_ix: Leader: $num_cycs cycs\\n\";\n          $e = build_uef_leader ($num_cycs, $chunkbuf);\n          if (TBT_E_OK != $e) { return $e; }\n          $uef .= wrap_chunk ($chunktype, $chunkbuf, $msg);\n        }\n        */\n        $e = build_uef_leader ($span->cycles, $chunkbuf);\n        if (TBT_E_OK != $e) { return $e; }\n        $uef .= wrap_chunk ($chunktype, $chunkbuf, $msg);\n      } else if (\"TibetSilence\" == $type) {\n        // 0.8\n        if ($use_chunk_112_for_silence) {\n            // complicated: multiple chunks may be needed\n          $e = build_uef_silence_112($span, $uef, $msg);\n        } else {\n          $e = build_uef_silence_116($span, $chunkbuf);\n          $uef .= wrap_chunk (0x116, $chunkbuf, $msg);\n        }\n        if (TBT_E_OK != $e) { return $e; }\n      } else if (\"TibetData\" == $type) {\n        if (count($span->cycles) > 0) {\n          $span->framing = $framing; // assign current framing value\n          $trailing_1_cycles = 0;\n          if ($span->squawk) {\n            $chunktype = 0x114;\n            $e = build_uef_squawk($span, $chunkbuf, $trailing_1_cycles);\n          } else {\n            $e = build_uef_data ($span,\n                                 $cur_active_baud, // 0.5\n                                 $chunkbuf,\n                                 $chunktype,\n                                 $cycs_to_steal, // 0.7: can be -ve now, => same as trailing_1_cycles\n                                 $chunk_to_use_for_data);\n          }\n          // 0.7: error handling for chunk &114:\n          if (TBT_E_OK == $e) {\n            // do not create chunk on error, or void-chunk condition\n            $uef .= wrap_chunk ($chunktype, $chunkbuf, $msg);\n          }\n          // trap & nullify void-chunk error:\n          if (TBT_E_ZL_CHUNK == $e) { $e = TBT_E_OK; }\n          // abort on any other error:\n          if (TBT_E_OK != $e) { return $e; }\n          \n          // assign unused trailing 1-cycles to subsequent leader cycle\n          // FIXME: consider doing this in prior separate pass, in separate function\n          \n          // 0.7\n          if ($cycs_to_steal < 0) {\n            // negative cycs_to_steal is same as trailing_1_cycles\n            $trailing_1_cycles = -$cycs_to_steal;\n            $cycs_to_steal = 0;\n          }\n          \n          //if ($span->squawk && ($sn+1 < $limit) && (get_class($tbt->spans[$sn+1]) == \"TibetLeader\")) {\n          if (($trailing_1_cycles > 0) && ($sn+1 < $limit) && (get_class($tbt->spans[$sn+1]) == \"TibetLeader\")) {\n            print \"M: Assign $trailing_1_cycles trailing 1-cycles to subsequent leader\\n\";\n            $tbt->spans[$sn+1]->cycles += $trailing_1_cycles;\n          }\n          \n        } else {\n          print \"W: skipped zero-length data section\\n\";\n        }\n      } else if (\"DataFraming\" == $type) {\n        $framing = $span;\n      } else if (\"BaudRate\" == $type) {\n        if ($span->rate != $cur_active_baud) {\n          // 0.6:\n          if ( $omit_chunk_117 ) {\n            print \"W: Omitting chunk &117 (baud rate) as instructed.\\n\";\n          } else {\n            $baudrate = $span;\n            $baud_uef = \"\";\n            build_uef_baud($baudrate->rate, $baud_uef);\n            $uef .= wrap_chunk (0x117, $baud_uef, $msg);\n            // 0.5:\n            $cur_active_baud = $baudrate->rate;\n          }\n        }\n      } else if (\"TimeHint\" == $type) {\n        // paste this text into the UEF\n        $chunkbuf = sprintf(\"time: %f seconds\\0\", $span->timestamp);\n        $uef .= wrap_chunk (0x120, $chunkbuf, $msg);\n      } else if (\"DummyByte\" == $type) {\n        $dummy_byte=\"\";\n        build_dummy_byte($span, $dummy_byte); // dummy_byte populated\n        $uef .= wrap_chunk (0x111, $dummy_byte, $msg);\n      } else {\n        print \"B: Bad span class: \\\"$type\\\"\\n\";\n        return TBT_E_BUG;\n      }\n    }\n    return TBT_E_OK;\n  }\n  \n  function build_dummy_byte (DummyByte $db, string &$chunkbuf) : int {\n    $chunkbuf = le16($db->pre_leader_cycs).le16($db->post_leader_cycs);\n    return TBT_E_OK;\n  }\n  \n  function build_uef_baud (int $baud, string &$chunkbuf) : int {\n    $chunkbuf = le16($baud);\n    return TBT_E_OK;\n  }\n  \n  function build_uef_leader (int $num_cycs, string &$chunkbuf) : int {\n    $chunkbuf = le16($num_cycs);\n    return TBT_E_OK;\n  }\n  \n  function build_uef_silence_116 (TibetSilence $tbs, string &$chunkbuf) : int {\n    $chunkbuf = uef_float($tbs->secs);\n    return TBT_E_OK;\n  }\n  \n  // 0.8\n  // more complicated than the others, as it may generate multiple chunks\n  // $uef is passed in\n  function build_uef_silence_112 (TibetSilence $tbs, string &$uef, string &$msg) : int {\n    // chunk 112 expresses silence as equivalent 2403.8 Hz cycles\n    // if gap is large, multiple chunks will be needed ...\n    // two byte field, so maximum gap in a single chunk is (65535 / 2403.8) = 27.263 seconds\n    // not very long!\n    $num_cycs = (int) round($tbs->secs * (2000000.0 / 832.0)); // correct frequency value\n    if ($num_cycs == 0) {\n      print \"W: silence as &112: tiny gap (\".$tbs->secs.\" s); round up to 1/2400\\n\";\n      $num_cycs = 1;\n    }\n    // multiple chunks needed\n    for ( $rem = $num_cycs; $rem > 0; $rem -= 65535 ) {\n      $chunkbuf = le16(($rem > 65535) ? 65535 : $rem);\n      $uef .= wrap_chunk(0x112, $chunkbuf, $msg);\n    }\n    return TBT_E_OK;\n  }\n  \n  function build_uef_squawk (TibetData $tbd,\n                             string &$chunkbuf,\n                             int &$trailing_unused_1_cycles) : int {\n                             \n    $num_cycles = 0.0;\n    $cycs_buf = \"\";\n    $bitcount=0;\n    $b=0;\n    $cycle_count=0;\n    $zero_half_cycle_count = 0;\n    \n    // determine length of trailing leader section\n    \n    // e.g., count=2, one trailing 2400\n    // 01\n    //  ^ count-1\n    // ^ limit\n    \n//print \"cyc_count = \".count($tbd->cycles).\"\\n\";\n    \n    // count down from num cycles to 0, expecting cycle value of 1\n    // (i.e. trailing 1-cycles which should be leader instead);\n    // stop when first 0-cycle is found; this becomes the limit\n    for ($limit = count($tbd->cycles) - 1; $limit >= 0; $limit--) {\n      if (0 == $tbd->cycles[$limit]->value) {\n        break;\n      }\n    }\n    \n    // and what remains at the end is the trailing unused 1-cycles\n    // to be returned to the caller\n    $trailing_unused_1_cycles = count($tbd->cycles) - (1 + $limit);\n    \n    // 0.7: prevent void squawk chunks from happening\n    if ($limit == -1) {\n      print \"W: squawk: all cycles are 1-cycles! no actual squawk data! \".\n            \"do not create chunk &114\\n\";\n      return TBT_E_ZL_CHUNK;\n    }\n    \n//print \"M: L#$tbd->linenum, span $tbd->span_ix: Squawk: \";\n    for ($i=0; $i <= $limit; $i++) {\n      if (0 == $tbd->cycles[$i]->value) {\n        $zero_half_cycle_count++; // number of '-' chars in TIBET\n      }\n      // a cycle is either two '-'s or one '.'\n      if ((2 == $zero_half_cycle_count) || (1 == $tbd->cycles[$i]->value)) {\n        // cycle available\n//print $tbd->cycles[$i]->value ? \"S\" : \"L\";\n        $zero_half_cycle_count = 0; // reset\n        $b <<= 1;\n        $b |= $tbd->cycles[$i]->value;\n        $bitcount++;\n        $cycle_count++;\n        if (8 == $bitcount) {\n          // bit complete\n          $cycs_buf .= chr($b);\n          $b = 0;\n          $bitcount = 0;\n        }\n      }\n    }\n//print \"\\n\";\n    if ($zero_half_cycle_count != 0) {\n      $ln = $tbd->cycles[$i-1]->linenum;\n      $span_ix = $tbd->cycles[$i-1]->span_ix;\n      print \"W: line $ln, span $span_ix: \".\n            \"finished squawk with zero_half_cycle_count=$zero_half_cycle_count (want 0)\\n\";\n    }\n    if ($bitcount != 0) {\n      // there are bits remaining; add them to the buffer\n      $b <<= (8 - $bitcount);\n      $cycs_buf .= chr($b);\n    }\n    \n//print \"build_uef_squawk: num_cycles = $num_cycles\\n\";\n//for ($i=0; $i < strlen($cycs_buf); $i++) {\n//  printf (\"%02x \", ord($cycs_buf[$i]));\n//}\n//print \"\\n\";\n    \n    // fix in v0.4: cycle count field incorrectly contained byte count\n    $chunkbuf = le24($cycle_count).\"WW\".$cycs_buf;\n\n    return TBT_E_OK;\n    \n  }\n  \n  \n  function build_uef_data (TibetData $tbd,\n                           int $baud, // 0.5: baud, for chunk &114\n                           string &$chunkbuf,\n                           int &$chunktype_used,\n                           int &$cycs_to_steal,\n                           int $chunk_to_use_for_data) {\n                           //int $chunk_102_interpretation) : int {\n                           \n    $cycs_to_steal = 0;\n    $e = TBT_E_OK;\n    \n    //~ print \"build_uef_data: framing is \".$tbd->framing->to_string().\"\\n\";\n\n    // If chunk &100 is requested but framing is incompatible,\n    // use chunk &104 instead.\n    if ($tbd->framing->to_string() != \"8N1\") {\n      /* cannot use chunk &100 */\n      if (0x100 == $chunk_to_use_for_data) {\n        $chunk_to_use_for_data = 0x104;\n      }\n    }\n    \n    // 0.7: sanity check for zero-length chunk errors\n    $chunkbuf_local = \"\";\n    \n    // Otherwise just use whatever chunk type was requested.\n    \n    if (0x100 == $chunk_to_use_for_data) {\n        $e = build_uef_data_100($tbd, $chunkbuf_local, $cycs_to_steal);\n    } else if (0x102 == $chunk_to_use_for_data) {\n        $e = build_uef_data_102($tbd, $chunkbuf_local, $cycs_to_steal); //, $chunk_102_interpretation);\n    } else if (0x104 == $chunk_to_use_for_data) {\n        $e = build_uef_data_104($tbd, $chunkbuf_local, $cycs_to_steal);\n    } else if (0x114 == $chunk_to_use_for_data) {\n        $e = build_uef_data_114($tbd, $baud, $chunkbuf_local, $cycs_to_steal); // 0.5: baud\n    }\n    \n    // 0.7: suppress zero-length generated chunk, it's probably all 1-bits\n    // (not sure why this happens, something to do with concatenating TIBETs)\n    if (strlen($chunkbuf_local) == 0) {\n      printf(\"W: Zero-length data chunk, type &%x\\n\", $chunk_to_use_for_data);\n//print \"count(bits) = \".count($tbd->bits).\", cycs_to_steal = $cycs_to_steal\\n\";\n//print_r($tbd->bits);\n      $e = TBT_E_ZL_CHUNK;\n      // this \"zero-length chunk\" problem happens when\n      // the entire chunk is 1-cycles.\n      // So, we have the *opposite* of a \"cycs to steal\"\n      // situation here; this is a \"cycs to donate\" situation.\n      if (0 != $cycs_to_steal) {\n        print \"E: Impossible? Zero-length chunk, but nonzero cycs to steal from subsequent leader?!\\n\";\n        return TBT_E_BUG;\n      }\n      // OK, so actually we probably have some 1-cycles to donate.\n      // Sanity check that all bits are 1s. (Still don't know why this happens.)\n      for ($i=0; $i < count($tbd->bits); $i++) {\n        if ($tbd->bits[$i]->value != 1) {\n          print \"E: Checking empty chunk data: should be all 1s, but found a 0 in here!\\n\";\n          return TBT_E_BUG;\n        }\n      }\n      $cycs_to_steal = -count($tbd->bits) * 2;\n      print \"W: donating \".(count($tbd->bits) * 2).\n            \" 1-cycles from empty chunk (chunk was all 1s somehow)\\n\";\n    } else {\n      $chunkbuf .= $chunkbuf_local;\n    }\n    \n    $chunktype_used = $chunk_to_use_for_data; // out\n    \n    return $e;\n    \n  }\n  \n  \n  function build_uef_data_114 (TibetData $tbd,\n                               int $baud, // 0.5\n                               string &$chunkbuf,\n                               int &$cycs_to_steal) : int {\n    $bits = $tbd->bits;\n    $nb = count($bits);\n    $chunkbuf=\"   WW\";\n    \n    for ($i=0, $total_cycs=0, $bitpos=0, $v=0, $cycs_to_add=0;\n         $i < $nb;\n         $i++) {\n         \n      $b = $bits[$i];\n      \n      $cycs_to_add = ($b->value == 1) ? 2 : 1;\n      \n      // 0.5\n      if ($baud == 300) {\n        $cycs_to_add *= 4;\n      }\n      \n      for ($n=0; $n < $cycs_to_add; $n++) {\n        $v <<= 1;\n        $v |= ($b->value == 1) ? 1 : 0;\n        $bitpos++;\n        $total_cycs++;\n        if ($bitpos == 8) {\n          // end of UEF byte; 8 cycles inserted\n          $chunkbuf .= chr($v);\n          $bitpos = 0;\n        }\n      }\n\n    }\n    \n    if ($bitpos != 0) {\n      // rem bits\n      $v <<= (8 - $bitpos);\n      $chunkbuf .= chr($v);\n    }\n    \n    // rewrite total cycs in chunk header\n    $chunkbuf[0] = chr($total_cycs         & 0xff);\n    $chunkbuf[1] = chr(($total_cycs >> 8 ) & 0xff);\n    $chunkbuf[2] = chr(($total_cycs >> 16) & 0xff);\n    \n    return TBT_E_OK;\n    \n  }\n  \n  function build_uef_data_100 (TibetData $tbd,\n                               string &$chunkbuf,\n                               int &$cycs_to_steal) : int { // cycs will be double this\n                               \n    $bits = $tbd->bits;\n    $nb = count($bits);\n    \n    $s = \"\";\n    $bitnum = -1; // expecting start bit\n    $late_start_bit = 0;\n    $bits_to_steal = 0;\n    \n    for ($i=0; $i < $nb; $i++) {\n      $b = $bits[$i];\n      if ($bitnum == -1) {\n        if ($b->value != 0) {\n          if ( ! $late_start_bit ) {\n            print \"W: build_uef_data_100: line $b->linenum, span #$b->span_ix, bit $i: Late start bit\\n\";\n          }\n          $late_start_bit = 1; // latch, to avoid error message spam\n          continue;\n        }\n        $late_start_bit = 0; // unlatch\n        $bitnum++; // bitnum = 0\n        $v = 0;    // byte value\n      } else if (($bitnum >= 0) && ($bitnum <= 7)) {\n        $v >>= 1;\n        $v |= (($bits[$i]->value) << 7) & 0x80;\n        $bitnum++;\n      } else { // bitnum = 8\n        // byte finished\n        $s .= chr($v);\n        // expect stop bit\n        if ($bits[$i]->value != 1) {\n          print \"W: build_uef_data_100: line $b->linenum, span #$b->span_ix, bit $i: Bad stop bit\\n\";\n        }\n        $bitnum = -1; // go back to expecting start bit\n      }\n    }\n    \n    if ($bitnum != -1) {\n      // byte unfinished\n      // polish it off by stealing 1-bits from subsequent leader tone\n      $rem = (8 - $bitnum);\n//print \"rem = $rem\\n\";\n      for ($i=0; $i < $rem; $i++) {\n        $v >>= 1;\n        $v |= 0x80;\n      }\n      $s .= chr($v); // store final byte\n      $bits_to_steal += $rem + 1; // +1 for stop bit\n    }\n\n    $chunkbuf = $s;\n    \n    $cycs_to_steal = $bits_to_steal * 2;\n    \n    return TBT_E_OK;\n    \n  }\n  \n  \n  \n  function build_uef_data_104 (TibetData $tbd,\n                               string &$chunkbuf,\n                               int &$cycs_to_steal) : int {\n\n    /*\n      The first byte holds the number of data bits per packet,\n      not counting start/stop/parity bits.\n\n      The second byte holds the ascii code for 'N', 'E' or 'O',\n      which specifies that parity is not present, even or odd.\n\n      The third byte holds information concerning stop bits.\n      If it is a positive number then it is a count of stop bits.\n      If it is a negative number then it is a negatived count of\n      stop bits to which an extra short wave should be added.\n    */\n    \n    $frame7 = ($tbd->framing->framelen == 7) ? 1 : 0;\n    $stops1 = ($tbd->framing->stops == 1)    ? 1 : 0;\n    $parity = ($tbd->framing->parity != \"N\") ? 1 : 0;\n\n//print_r($tbd->framing->stops); print \"\\n\";\n//print \"stops = $tbd->framing->stops \\n\";\n    \n    $s = chr($tbd->framing->framelen).\n         $tbd->framing->parity.\n         chr($tbd->framing->stops);\n         \n    $bits = $tbd->bits;\n    $nb = count($bits);\n    $wordlen = $tbd->framing->framelen;\n    $framelen =   $wordlen\n                + (($tbd->framing->parity == \"N\") ? 0 : 1)\n                + $tbd->framing->stops;\n    $late_start_bit = 0;\n    $bitnum = -1;\n    $bits_to_steal = 0;\n    \n    // 7E1/7O1: 0xxxxxxxP1\n    // 8N1:     0xxxxxxxx1\n    // 7E2/7O2: 0xxxxxxxP11\n    // 8N2:     0xxxxxxxx11\n    // 8E1/8O1: 0xxxxxxxxP1\n    \n    for ($i=0; $i < $nb; $i++) {\n    \n      $b = $bits[$i];\n      \n      if ($bitnum == -1) {\n        if ($b->value != 0) {\n          if ( ! $late_start_bit ) {\n            print \"W: build_uef_data_104: line $b->linenum, span #$b->span_ix, bit $i: Late start bit\\n\";\n          }\n          $late_start_bit = 1; // latch, to avoid error message spam\n          continue;\n        }\n        $late_start_bit = 0; // unlatch\n        //$bitnum++; // bitnum = 0\n        $v = 0;    // byte value\n      } else if (($bitnum >= 0) && ($bitnum <= ($wordlen - 1))) {\n//die();\n        $v >>= 1;\n        $v |= (($bits[$i]->value) << 7) & 0x80;\n        //$bitnum++;\n      } else if ($bitnum == $wordlen) {\n        // byte finished\n        if ($wordlen == 7) {\n          // extra shift needed for 7-bit word\n          $v >>= 1;\n          $v &= 0x7f;\n        }\n        $s .= chr($v);\n        //$bitnum++;\n      }\n      \n//print \"?\\n\"; die();\n\n//print \"bitnum=$bitnum\\n\";\n\n//print \"parity=$parity , frame7=$frame7 \\n\";\n      \n      if ($bitnum == 7) {\n        if ($parity && $frame7) {\n          // 7E1, 7O1, 7E2, 7O2\n          // parity bit\n          if ( ! check_parity ($v, $bits[$i]->value, $tbd->framing->parity) ) {\n            print \"W: build_uef_data_104: line $b->linenum, span #$b->span_ix, bit $i: Bad parity bit\\n\";\n          }\n        }\n      } else if ($bitnum == 8) {\n        if ($parity && ! $frame7) {\n          // 8E1, 8O1\n          // parity bit\n          if ( ! check_parity ($v, $bits[$i]->value, $tbd->framing->parity) ) {\n            print \"W: build_uef_data_104: line $b->linenum, span #$b->span_ix, bit $i: Bad parity bit\\n\";\n          }\n        } else {\n          // 7E1, 7O1, 8N1, 7E2, 7O2, 8N2\n          // first stop bit\n          if ($bits[$i]->value != 1) {\n            print \"W: build_uef_data_104: line $b->linenum, span #$b->span_ix, bit $i: Bad stop bit\\n\";\n          }\n          // if 7E1, 7O1, 8N1, byte is now over\n          if ($frame7 && $parity) {\n            // 7E1, 7O1\n            $bitnum = -2;\n          } else if (! $frame7 && ! $parity && $stops1) {\n            // 8N1\n            $bitnum = -2;\n          }\n        }\n      } else if ($bitnum == 9) {\n        // 7E2, 7O2, 8N2, 8E1, 8O1\n        // second stop bit\n        if ($bits[$i]->value != 1) {\n          print \"W: build_uef_data_104: line $b->linenum, span #$b->span_ix, bit $i: Bad stop bit\\n\";\n        }\n        $bitnum = -2;\n      }\n      \n      $bitnum++;\n      \n    } // next bit\n    \n    \n    if ($bitnum != -1) {\n      // byte unfinished\n      // polish it off by stealing 1-bits from subsequent leader tone\n      $rem = ($wordlen - $bitnum);\n//print \"rem = $rem\\n\";\n      for ($i=0; $i < $rem; $i++) {\n        $v >>= 1;\n        $v |= 0x80;\n      }\n      if ($wordlen == 7) {\n        // extra shift needed for 7-bit word\n        $v >>= 1;\n        $v &= 0x7f;\n      }\n      $s .= chr($v); // store final byte\n      $bits_to_steal += $rem + $parity + ($stops1 ? 1 : 2);\n    }\n    \n    $chunkbuf = $s;\n    $cycs_to_steal = $bits_to_steal * 2; // out\n    \n    return TBT_E_OK;\n    \n  }\n  \n  \n  function build_uef_data_102 (TibetData $tbd,\n                               string &$chunkbuf,\n                               int &$cycs_to_steal) : int {\n                               //int $chunk_102_interpretation) : int {\n\n    $bits = $tbd->bits;\n    $nb = count($bits);\n    \n    // regregex's argument for how this should be implemented was compelling:\n    \n    // https://stardot.org.uk/forums/viewtopic.php?f=4&t=26822\n    \n    // ---\n    // Chunk &0102 is a raw representation of data bits stored on\n    // cassette. Unlike chunk &0100 there are no implicit start/stop\n    // bits.\n    // The first byte of this chunk is used to calculate chunk length\n    // at the bit level. Only the first\n    // (chunk length [1] * 8) - (value of first byte)\n    // bits are used in this chunk.\n    // ---\n    \n    // Let's assume there are 15 bits of data in the chunk. We need\n    // two bytes of data to hold 15 bits, with one bit spare. Hence the\n    // chunk is going to look like this (bits):\n    \n    // ZZZZZZZZ YYYYYYYY xYYYYYYY\n    // Interpretation B ($chunk_102_interpretation = 1):\n    // If \"chunk length\" refers to all three bytes of the chunk, then\n    // we need:\n    \n    // (3 * 8) - Z = 15\n    // 24 - 15 = Z\n    // Z = 9\n    \n    // When reading a chunk &102 (which we obviously don't do here), it\n    // should be possible to auto-detect which interpretation was used\n    // by examining that first byte; if it's < 8 then interpretation A\n    // was used; if it's >= 8 then B was used. This isn't watertight\n    // because it is possible to encode a pathological chunk &102 that\n    // has, say, three unused bytes at the end, all of which are\n    // \"switched off\" by that first byte (Z=24 or Z=32), but hey ho.\n    \n    $rem      = $nb % 8;\n    \n    if ($rem > 0) {\n      $first_byte = 8 - $rem;\n    } else {\n      $first_byte = 0;\n    }\n    \n    //if ($chunk_102_interpretation == 1) {\n    $first_byte += 8;\n    //}\n    \n    $chunkbuf .= chr($first_byte);\n    \n    for ($i=0, $bitnum=0, $b=0; $i < $nb; $i++, $bitnum++) {\n      $b >>= 1;\n      $b |= ($bits[$i]->value ? 0x80 : 0);\n      if ($bitnum == 7) {\n        $chunkbuf .= chr($b);\n        $bitnum = -1;\n        $b = 0;\n      }\n    }\n    \n    // we may have some bits not yet sent.\n    // we'll use 1-bits as filler, so that in case the decoder doesn't\n    // respect the first byte and carries on sending bits right up to\n    // the end of the chunk, they will be leader bits, which is most\n    // likely to work.\n    if ($bitnum != 0) {\n      for (; $bitnum < 8; $bitnum++) {\n        $b >>= 1;\n        $b |= 0x80;\n      }\n      $chunkbuf .= chr($b);\n    }\n    \n    // we can have an arbitrary number of bits, so we don't need to \n    // steal filler bits from subsequent leader to complete bytes,\n    // as we do for the other data chunk types.\n    $cycs_to_steal = 0;\n    \n    return TBT_E_OK;\n    \n  }\n  \n  \n  /*\n  function my_hexdump (array $mem, bool $include_offset)  {\n    $s=\"\";\n    //$start_of_line = 1;\n    if (!isset($mem) || (count($mem)==0)) { return; }\n    $l=count($mem);\n    if (defined(\"HEXDUMP_MAX\") && $l>HEXDUMP_MAX) {\n      $l=HEXDUMP_MAX;\n    }\n    $sbuf=\"\";\n    for ($i=0;$i<$l;$i++) {\n      if (!($i%16)) {\n        if ($include_offset) {\n          $s.=sprintf (\"%02x  \", $i);\n        } else {\n          $s.=\"    \";\n        }\n      }\n      $s.=sprintf (\"%02x \", $z=ord($mem[$i]));\n      if (!ctype_print($w=($mem[$i]))||$z>127||$w===\"\\r\"||$w===\"\\n\") {\n        $sbuf.=\".\";\n      } else {\n        $sbuf.=$w;\n      }\n      if ($i%16 == 15) { // append text bit yet?\n        $s .= \" \".$sbuf.\"\\n\";\n        $sbuf=\"\";\n        $start_of_line = 1;\n      }\n    }\n    // ending\n    // append any remaining text bit\n    if ($i%16!=0) {\n      for ($i=(16-$i%16);$i;$i--) {\n        // pad up to start of text bit\n        $s.= \"   \";\n      }\n      $s.= \" \".$sbuf.\"\\n\";\n    }\n    return $s;\n  }\n  */\n  \n  \n  function check_parity (int $word, int $parity_bit, string $parity_mode) : bool {\n    $num_ones = 0;\n    // include bit 7 even if in 7-bit mode, it'll be zero in 7-bit mode so it doesn't matter\n    for ($i=0; $i < 8; $i++) {\n      $num_ones += ($word & 1);\n      $word >>= 1;\n    }\n    $num_ones += ($parity_bit ? 1 : 0);\n    return ($parity_mode == \"E\") XOR ($num_ones & 1);\n  }\n  \n\n  \n  function frexp ( $f, &$exponent) {\n    $exponent = ( floor(log($f, 2)) + 1   );\n    return ( $f * pow(2, -$exponent) );\n  }\n  \n  function uef_float (float $f) : string {\n    \n    $a = array();\n    \n    $a[3] = 0;\n\n    // sign bit\n    if ($f < 0) {\n      $f = -$f;\n      $a[3] = 0x80;\n    }\n\n    // decode mantissa and exponent\n    $mantissa = (float) frexp ($f, $exponent);\n    $exponent += 126;\n\n    // store mantissa\n    $im = (int) ($mantissa * (1 << 24)); // hmm. was cast to u32_t. problem?\n    $a[0] = $im&0xff;\n    $a[1] = ($im >> 8)&0xff;\n    $a[2] = ($im >> 16)&0x7f;\n\n    // store exponent\n    $a[3] |= $exponent >> 1;\n    $a[2] |= ($exponent&1) << 7;\n    \n    $buf = \"\";\n    $buf .= chr($a[0]);\n    $buf .= chr($a[1]);\n    $buf .= chr($a[2]);\n    $buf .= chr($a[3]);\n    \n    return $buf;\n\n  }\n\n  \n  function wrap_chunk (int $type, string $in, string &$msg) : string {\n    $out = \"\";\n    $len = strlen($in);\n    $out .= le16($type);\n    $out .= le32($len);\n    $out .= $in;\n    //printf(\"Chunk: 0x%04x, payload len 0x%x\\n\", $type, $len);\n    //~ $msg .= sprintf(\"[_&%03x_len_&%x_] \", $type, $len);\n    $msg .= sprintf(\"0x%03x-0x%04x \", $type, $len);\n    return $out;\n  }\n  \n  function le16 (int $i) : string {\n    $s = \"\";\n    $s .= chr($i & 0xff);\n    $s .= chr(($i >> 8) & 0xff);\n    return $s;\n  }\n  \n  function le32 (int $i) : string {\n    $s = \"\";\n    $s .= chr($i & 0xff);\n    $s .= chr(($i >> 8)  & 0xff);\n    $s .= chr(($i >> 16) & 0xff);\n    $s .= chr(($i >> 24) & 0xff);\n    return $s;\n  }\n  \n  function le24 (int $i) : string {\n    $s = \"\";\n    $s .= chr($i & 0xff);\n    $s .= chr(($i >> 8)  & 0xff);\n    $s .= chr(($i >> 16) & 0xff);\n    return $s;\n  }\n  \n\n  \n  function process_line (int $ln,\n                         string $line,\n                         int &$state,\n                         int &$span_ix,\n                         bool $insert_timestamps,\n                         ParsedTibet &$tbt) : int {\n                         \n    // FIXME: doesn't quite meet TIBET specifications\n    // more checking needed ...\n  \n    // eliminate comments\n    $line_tmp = explode(\"#\", $line);\n    $line = $line_tmp[0];\n  \n    // split by space\n    $words_tmp = explode(\" \", $line);\n    $words = array();\n    \n    // remove any blank words\n    foreach ($words_tmp as $tmp=>$w) {\n      $w = trim($w);\n      if (strlen($w) > 0) {\n        $words[] = $w;\n      }\n    }\n    \n    $wc = count($words);\n    \n    // skip empty lines\n    if ($wc == 0) {\n      return TBT_E_OK;\n    }\n    \n    $e = TBT_E_OK;\n    \n    $w0 = $words[0];\n    \n    // the default state at the start of a parse is STATE_VERSION ...\n    if (STATE_VERSION == $state) {\n      // version line must be the first non-comment, non-blank\n      // line in the file.\n      // any subsequent version lines will simply be ignored.\n      // (this is deliberate and makes concatenating files easy)\n      $e = parse_version ($words, $ln, $tbt->version, $line);\n      $state = STATE_IDLE;\n    } else if (STATE_IDLE == $state) {\n      // this is a whitelist; we could ignore unknown keywords\n      // instead, but we'll leave it like this for now\n      if ($w0 == \"tibet\") {\n        // duplicate version line; just check it for validity\n        $dummy = \"\";\n        $e = parse_version ($words, $ln, $dummy, $line);\n        if ($dummy != $tbt->version) {\n          print \"E: line $ln, span $span_ix: Mismatched duplicate version: $line\\n\";\n          return TBT_E_PARSE_DUP_VERSION;\n        }\n        // TIBET 0.4: reset framing and baud hints for file concatenation\n        $df = new DataFraming; // constructor defaults to 8N1\n        $df->linenum = $ln;\n        $df->span_ix = $span_ix;\n        $tbt->spans[] = $df; // token rather than span\n        $br = new BaudRate; // constructor defaults to 1200\n        $br->linenum = $ln;\n        $br->span_ix = $span_ix;\n        $tbt->spans[] = $br; // token rather than span\n      } else if ($w0 == \"silence\") {\n        if ($wc != 2) {\n          print \"E: line $ln, span $span_ix: Bad silence line: $line\\n\";\n          return TBT_E_PARSE_SILENCE;\n        }\n        $silence = new TibetSilence;\n        $silence->linenum = $ln;\n        $f = 0.0;\n        $e = parse_float ($words[1], $f); // f populated\n        if (TBT_E_OK != $e) { return $e; }\n        $silence->secs = $f; //(float) $words[1];\n        $silence->span_ix = $span_ix;\n        $span_ix++;\n        if (($silence->secs <= 0.0) || ($silence->secs > 1000000.0)) {\n          print \"E: line $ln, span $span_ix: Illegal silence length: $words[1]\\n\";\n          return TBT_E_BAD_SILENCE;\n        }\n        $tbt->spans[] = $silence;\n      } else if ($w0 == \"leader\") {\n        if ($wc != 2) {\n          print \"E: line $ln: Bad leader line: $line\\n\";\n          return TBT_E_PARSE_LEADER;\n        }\n        $leader = new TibetLeader;\n        $leader->linenum = $ln;\n        $num_cycs = 0;\n        $e = parse_int($words[1], $num_cycs); // $num_cycs populated\n        if (TBT_E_OK != $e) {\n          print \"E: line $ln, span $span_ix: Non-integer leader cycles count: $words[1]\\n\";\n          return $e;\n        }\n        $leader->cycles  = $num_cycs; //(int) $words[1];\n        $leader->span_ix = $span_ix;\n        $span_ix++;\n        if (($leader->cycles < 1) || ($leader->cycles > 30000000)) {\n          print \"E: line $ln, span $span_ix: Illegal leader length: $words[1]\\n\";\n          return TBT_E_BAD_LEADER;\n        }\n        $tbt->spans[] = $leader;\n      } else if (($w0 == \"squawk\") || ($w0 == \"data\")) {\n        if ($wc != 1) {\n          print \"E: line $ln, span $span_ix: Illegal $w0 line: $line\\n\";\n          return TBT_E_PARSE_DATA;\n        }\n        $data = new TibetData;\n        $data->linenum = $ln;\n        $data->span_ix = $span_ix;\n        $data->squawk = ($w0 == \"squawk\");\n        $span_ix++;\n        $state = STATE_CYCLES;\n        $tbt->spans[] = $data;\n      } else if ($w0 == \"/phase\") {\n        // don't care; it's partially a function of playback,\n        // so I disagree that it should be regarded\n      } else if ($w0 == \"/speed\") {\n        // don't care; again, it's a function of playback,\n        // not of the source\n      } else if ($w0 == \"/time\") {\n        if ($insert_timestamps) {\n          $timehint = new TimeHint;\n          $timestamp = 0.0;\n          $e = parse_float($words[1], $timestamp); // timestamp populated\n          if (TBT_E_OK != $e) {\n            print \"E: line $ln, span $span_ix: Illegal /time hint: $line\\n\";\n            return $e;\n          }\n          $timehint->timestamp = $timestamp; //(float) $words[1];\n          $timehint->linenum = $ln;\n          $timehint->span_ix = $span_ix;\n          $tbt->spans[] = $timehint; // token rather than span\n        }\n      } else if ($w0 == \"/framing\") {\n        // quadbike doesn't export this, as it can't detect framing,\n        // but it could be added by manually editing a TIBET file.\n        // UEF chunk 104 needs to know about non-standard framings, and\n        // if they e.g. change in the middle of a block, we stand no\n        // chance of detecting them automatically, so\n        $df = new DataFraming;\n        $df->linenum = $ln;\n        $df->span_ix = $span_ix;\n        $e = parse_framing ($words[1], $df); // df populated\n        if (TBT_E_OK != $e) { return $e; }\n        $tbt->spans[] = $df; // token rather than span\n      } else if ($w0 == \"/baud\") {\n        // again, not exported by QB\n        $br = new BaudRate;\n        $br->linenum = $ln;\n        $br->span_ix = $span_ix;\n        $e = parse_baudrate ($words[1], $br); // br populated\n        if (TBT_E_OK != $e) { return $e; }\n        $tbt->spans[] = $br; // token rather than span\n      } else {\n        print \"E: line $ln, span $span_ix: Unrecognised: $line\\n\";\n        return TBT_E_PARSE_BAD_LINE;\n      }\n    } else if (STATE_CYCLES == $state) {\n      if ($w0 == \"end\") {\n        $state = STATE_IDLE;\n      } else {\n        $len = strlen($words[0]);\n        for ($i=0; $i < $len; $i++) {\n          $span_ix = count($tbt->spans) - 1;\n          $span = $tbt->spans[$span_ix]; // TibetData\n          if ($words[0][$i] == \"-\") {\n            $cyc = new TibetCycle;\n            $cyc->value = 0;\n            $cyc->linenum = $ln; //$span->linenum;\n            $cyc->span_ix = $span->span_ix;\n            $span->cycles[] = $cyc;\n          } else if ($words[0][$i] == \".\") {\n            $cyc = new TibetCycle;\n            $cyc->value = 1;\n            $cyc->linenum = $ln; //$span->linenum;\n            $cyc->span_ix = $span->span_ix;\n            $span->cycles[] = $cyc;\n          } else if ($words[0][$i] == \"P\") {\n            // P cannot be turned into a bit, so decoders just skip it.\n          } else {\n            print \"E: line $ln, span $span_ix: Bad cycle line: $line\\n\";\n            return TBT_E_PARSE_CYCLES;\n          }\n          $tbt->spans[$span_ix] = $span; // replace the modified value\n        }\n      }\n    }\n    \n    if (TBT_E_OK != $e) { return $e; }\n    \n//print \"\\n\";\n    return TBT_E_OK;\n    \n  }\n  \n  \n  function parse_float (string $w, float &$f) : int {\n    $len = strlen($w);\n    $dp_count=0;\n    if ($len > 50) {\n      return TBT_E_BAD_FLOAT;\n    }\n    for ($i=0; $i < $len; $i++) {\n      $c = $w[$i];\n      if ($c == \".\") {\n        if ($dp_count != 0) { // only one decimal point allowed\n          return TBT_E_BAD_FLOAT;\n        } else if ($i == ($len - 1)) { // decimal point may not be the final character\n          return TBT_E_BAD_FLOAT;\n        }\n        $dp_count++;\n      } else if ( ! ctype_digit ($c) ) { // chars other than digits and decimal point are illegal\n        return TBT_E_BAD_FLOAT;\n      }\n    }\n    $f = (float) $w;\n    return TBT_E_OK;\n  }\n  \n  function parse_int (string $w, int &$i) : int {\n    $len = strlen($w);\n    if ($len > 19) {\n      return TBT_E_BAD_INT;\n    }\n    for ($j=0; $j < $len; $j++) {\n      $v = $w[$j];\n      if (!ctype_digit($v)) {\n        return TBT_E_BAD_INT;\n      }\n    }\n    $i = (int) $w;\n    return TBT_E_OK;\n  }\n    \n  \n  function parse_framing (string $w, DataFraming &$f) : int {\n    if (strlen($w) != 3) { return FALSE; }\n    if (($w[0] != \"7\") && ($w[0] != \"8\")) { return FALSE; }\n    if (($w[1] != \"N\") && ($w[1] != \"O\") && ($w[1] != \"E\")) { return FALSE; }\n    if (($w[2] != \"1\") && ($w[2] != \"2\")) { return FALSE; }\n    $framelen = 0;\n    $e = parse_int ($w[0], $framelen); // framelen populated\n    if (TBT_E_OK != $e) { return $e; }\n    $f->framelen = $framelen;\n    $f->parity = $w[1];\n    $num_stops = 0;\n    $e = parse_int ($w[2], $num_stops); // num_stops populated\n    if (TBT_E_OK != $e) { return $e; }\n    $f->stops = $num_stops;\n    return TBT_E_OK;\n  }\n  \n  function parse_baudrate (string $w, BaudRate &$r) : int {\n    $i = 0;\n    $e = parse_int ($w, $i); // i populated\n    if (TBT_E_OK != $e) { return $e; }\n    $r->rate = $i;\n    return TBT_E_OK;\n  }\n  \n  \n  function parse_version (array $words, int $ln, string &$tbt_version, string $line) : int {\n    $wc = count($words);\n    if ($words[0] != \"tibet\") {\n      print \"E: Version line not found: $line\\n\";\n      return TBT_E_PARSE_VERSION;\n    }\n    if ($wc != 2) {\n      print \"E: line $ln: Bad version line: $line\\n\";\n      return TBT_E_PARSE_VERSION;\n    }\n    // 0.8: switched to major/minor version paradigm\n    $tbt_version = $words[1];\n    $v = explode(\".\", $tbt_version);\n    if (count($v) != 2) {\n      print \"E: line $ln: Bad version: $tbt_version\\n\";\n      return TBT_E_BAD_VERSION;\n    }\n    //if (TIBET_VERSION_STG != $tbt_version) {\n    if ($v[0] != TIBET_MAJOR_VERSION) {\n      print \"E: line $ln: Incompatible TIBET version: $tbt_version\\n\";\n      return TBT_E_INCOMPATIBLE;\n    }\n    return TBT_E_OK;\n  }\n  \n  \n  function tbt_process (string $ip, bool $insert_timestamps, ParsedTibet &$tbt) : int {\n    $state = STATE_VERSION;\n    $lines = explode (\"\\n\", $ip);\n    $span_ix = 0;\n    print count($lines).\" lines.\\n\";\n    foreach ($lines as $ln=>$v) {\n      $ln++; // linenum; 1-indexed\n      $e = process_line ($ln, $v, $state, $span_ix, $insert_timestamps, $tbt); // state, tbt, span_ix modified\n      if (TBT_E_OK != $e) { return $e; }\n    }\n    if ((STATE_IDLE != $state) && (STATE_DATA != $state)) {\n      print \"W: Finished in unexpected state $state\\n\";\n    }\n    print \"TIBET version: $tbt->version\\n\";\n    return TBT_E_OK;\n  }\n  \n  \n  function usage(string $argv0) {\n    print \"Usage:\\n\\n\";\n    print \"  php -f $argv0 [options] <input TIBET file> <output UEF file>\\n\\n\";\n    print \"where [options] may be:\\n\\n\";\n    //print \"    +f activates automatic framing detection\\n\";\n    //print \"      (overrides all framing lines in input)\\n\\n\";\n    print \"  +t       use \\\"/time\\\" hints in TIBET file to insert &120 label chunks into UEF\\n\";\n    print \"           (currently breaks beebjit)\\n\\n\";\n    print \"  +102     use chunk &102 for data\\n\";\n    //print \"  +102b                            (interpretation B)\\n\";\n    print \"  +104     use chunk &104 for data\\n\";\n    print \"  +114     use chunk &114 for data\\n\\n\";\n    print \"  +112     use chunk &112 instead of &116 for silence\\n\\n\";\n    print \"  +no-117  omit baud rate chunk &117 (Elkulator compatibility)\\n\\n\";\n    print \"  +nz      do not compress output UEF file\\n\";\n    print \"\\n\";\n  }\n  \n?>\n"
  },
  {
    "path": "3-assembled-output/README.md",
    "content": "# Assembled output for the BBC Micro cassette version of Elite\n\nThis folder contains the output binaries from the build process for the BBC Micro cassette version of Elite.\n\nIt also contains [compile.txt](compile.txt), which contains the output from the assembly process. This is very useful when debugging the build process.\n\n---\n\nRight on, Commanders!\n\n_Mark Moxon_"
  },
  {
    "path": "3-assembled-output/README.txt",
    "content": "\n\r---------------------------------------\n\rAcornsoft Elite\n\r\n\rVersion: BBC Micro cassette\n\rVariant: Stairway to Hell cassette\n\rProduct: Acornsoft SBG38\n\r\n\rSee www.bbcelite.com for details\n\r---------------------------------------\n\r"
  },
  {
    "path": "3-assembled-output/compile.txt",
    "content": ".ZP\n     0000\n.RAND\n     0000\n.TRTB%\n     0004\n.T1\n     0006\n.SC\n     0007\n.SCH\n     0008\n.XX16\n     0009\n.P\n     001B\n.XX0\n     001E\n.INF\n     0020\n.V\n     0022\n.XX\n     0024\n.YY\n     0026\n.SUNX\n     0028\n.BETA\n     002A\n.BET1\n     002B\n.XC\n     002C\n.YC\n     002D\n.QQ22\n     002E\n.ECMA\n     0030\n.XX15\n     0031\n.X1\n     0031\n.Y1\n     0032\n.X2\n     0033\n.Y2\n     0034\n     0035\n.XX12\n     0037\n.K\n     003D\n.KL\n     0041\n.KY1\n     0042\n.KY2\n     0043\n.KY3\n     0044\n.KY4\n     0045\n.KY5\n     0046\n.KY6\n     0047\n.KY7\n     0048\n.KY12\n     0049\n.KY13\n     004A\n.KY14\n     004B\n.KY15\n     004C\n.KY16\n     004D\n.KY17\n     004E\n.KY18\n     004F\n.KY19\n     0050\n.LAS\n     0051\n.MSTG\n     0052\n.XX1\n     0053\n.INWK\n     0053\n.XX19\n     0074\n.LSP\n     0077\n.QQ15\n     0078\n.K5\n     007E\n.XX18\n     007E\n.QQ17\n     007E\n.QQ19\n     007F\n.K6\n     0082\n.ALP1\n     0087\n.ALP2\n     0088\n.BET2\n     008A\n.DELTA\n     008C\n.DELT4\n     008D\n.U\n     008F\n.Q\n     0090\n.R\n     0091\n.S\n     0092\n.XSAV\n     0093\n.YSAV\n     0094\n.XX17\n     0095\n.QQ11\n     0096\n.ZZ\n     0097\n.XX13\n     0098\n.MCNT\n     0099\n.DL\n     009A\n.TYPE\n     009B\n.JSTX\n     009C\n.JSTY\n     009D\n.ALPHA\n     009E\n.QQ12\n     009F\n.TGT\n     00A0\n.SWAP\n     00A1\n.COL\n     00A2\n.FLAG\n     00A3\n.CNT\n     00A4\n.CNT2\n     00A5\n.STP\n     00A6\n.XX4\n     00A7\n.XX20\n     00A8\n.XX14\n     00A9\n.RAT\n     00AA\n.RAT2\n     00AB\n.K2\n     00AC\n.T\n     00D1\n.K3\n     00D2\n.XX2\n     00D2\n.K4\n     00E0\nZP workspace from &0 to &E1 inclusive\n.XX3\n     0100\n.T%\n     0300\n.TP\n     0300\n.QQ0\n     0301\n.QQ1\n     0302\n.QQ21\n     0303\n.CASH\n     0309\n.QQ14\n     030D\n.COK\n     030E\n.GCNT\n     030F\n.LASER\n     0310\n     0314\n.CRGO\n     0316\n.QQ20\n     0317\n.ECM\n     0328\n.BST\n     0329\n.BOMB\n     032A\n.ENGY\n     032B\n.DKCMP\n     032C\n.GHYP\n     032D\n.ESCP\n     032E\n     032F\n.NOMSL\n     0333\n.FIST\n     0334\n.AVL\n     0335\n.QQ26\n     0346\n.TALLY\n     0347\n.SVC\n     0349\n     034A\n.SX\n     034C\n.SXL\n     035F\nT% workspace from &300 to &371 inclusive\n.QQ18\nMacro RTOK:\n     0400   4C\nEnd macro RTOK\nMacro RTOK:\n     0401   32\nEnd macro RTOK\nMacro CONT:\n     0402   24\nEnd macro CONT\n     0403   00\nMacro CHAR:\n     0404   03\nEnd macro CHAR\nMacro CHAR:\n     0405   60\nEnd macro CHAR\nMacro CHAR:\n     0406   6B\nEnd macro CHAR\nMacro TWOK:\n     0407   A9\nEnd macro TWOK\nMacro CHAR:\n     0408   77\nEnd macro CHAR\n     0409   00\nMacro CHAR:\n     040A   64\nEnd macro CHAR\nMacro CHAR:\n     040B   6C\nEnd macro CHAR\nMacro TWOK:\n     040C   B5\nEnd macro TWOK\nMacro CHAR:\n     040D   71\nEnd macro CHAR\nMacro CHAR:\n     040E   6D\nEnd macro CHAR\nMacro CHAR:\n     040F   6E\nEnd macro CHAR\nMacro TWOK:\n     0410   B1\nEnd macro TWOK\nMacro CHAR:\n     0411   77\nEnd macro CHAR\n     0412   00\nMacro CHAR:\n     0413   67\nEnd macro CHAR\nMacro TWOK:\n     0414   B2\nEnd macro TWOK\nMacro CHAR:\n     0415   62\nEnd macro CHAR\nMacro RTOK:\n     0416   32\nEnd macro RTOK\nMacro CONT:\n     0417   20\nEnd macro CONT\n     0418   00\nMacro TWOK:\n     0419   AF\nEnd macro TWOK\nMacro TWOK:\n     041A   B5\nEnd macro TWOK\nMacro CHAR:\n     041B   6D\nEnd macro CHAR\nMacro CHAR:\n     041C   77\nEnd macro CHAR\nMacro TWOK:\n     041D   BA\nEnd macro TWOK\nMacro CHAR:\n     041E   7A\nEnd macro CHAR\nMacro CONT:\n     041F   2E\nEnd macro CONT\n     0420   00\nMacro CHAR:\n     0421   70\nEnd macro CHAR\nMacro CHAR:\n     0422   7A\nEnd macro CHAR\nMacro CHAR:\n     0423   70\nEnd macro CHAR\nMacro TWOK:\n     0424   BF\nEnd macro TWOK\nMacro CHAR:\n     0425   6E\nEnd macro CHAR\n     0426   00\nMacro CHAR:\n     0427   73\nEnd macro CHAR\nMacro TWOK:\n     0428   BD\nEnd macro TWOK\nMacro TWOK:\n     0429   A6\nEnd macro TWOK\n     042A   00\nMacro CONT:\n     042B   21\nEnd macro CONT\nMacro CHAR:\n     042C   03\nEnd macro CHAR\nMacro TWOK:\n     042D   A8\nEnd macro TWOK\nMacro CHAR:\n     042E   71\nEnd macro CHAR\nMacro CHAR:\n     042F   68\nEnd macro CHAR\nMacro CHAR:\n     0430   66\nEnd macro CHAR\nMacro CHAR:\n     0431   77\nEnd macro CHAR\nMacro CHAR:\n     0432   03\nEnd macro CHAR\nMacro RTOK:\n     0433   85\nEnd macro RTOK\nMacro CHAR:\n     0434   70\nEnd macro CHAR\n     0435   00\nMacro TWOK:\n     0436   AF\nEnd macro TWOK\nMacro CHAR:\n     0437   67\nEnd macro CHAR\nMacro TWOK:\n     0438   AB\nEnd macro TWOK\nMacro CHAR:\n     0439   77\nEnd macro CHAR\nMacro TWOK:\n     043A   BD\nEnd macro TWOK\nMacro TWOK:\n     043B   A3\nEnd macro TWOK\n     043C   00\nMacro CHAR:\n     043D   62\nEnd macro CHAR\nMacro CHAR:\n     043E   64\nEnd macro CHAR\nMacro TWOK:\n     043F   BD\nEnd macro TWOK\nMacro CHAR:\n     0440   60\nEnd macro CHAR\nMacro CHAR:\n     0441   76\nEnd macro CHAR\nMacro CHAR:\n     0442   6F\nEnd macro CHAR\nMacro CHAR:\n     0443   77\nEnd macro CHAR\nMacro CHAR:\n     0444   76\nEnd macro CHAR\nMacro TWOK:\n     0445   B7\nEnd macro TWOK\nMacro CHAR:\n     0446   6F\nEnd macro CHAR\n     0447   00\nMacro TWOK:\n     0448   BD\nEnd macro TWOK\nMacro CHAR:\n     0449   60\nEnd macro CHAR\nMacro CHAR:\n     044A   6B\nEnd macro CHAR\nMacro CHAR:\n     044B   03\nEnd macro CHAR\n     044C   00\nMacro CHAR:\n     044D   62\nEnd macro CHAR\nMacro TWOK:\n     044E   B5\nEnd macro TWOK\nMacro TWOK:\n     044F   B7\nEnd macro TWOK\nMacro TWOK:\n     0450   A0\nEnd macro TWOK\nMacro CHAR:\n     0451   03\nEnd macro CHAR\n     0452   00\nMacro CHAR:\n     0453   73\nEnd macro CHAR\nMacro CHAR:\n     0454   6C\nEnd macro CHAR\nMacro TWOK:\n     0455   BA\nEnd macro TWOK\nMacro CHAR:\n     0456   03\nEnd macro CHAR\n     0457   00\nMacro TWOK:\n     0458   A8\nEnd macro TWOK\nMacro TWOK:\n     0459   AF\nEnd macro TWOK\nMacro CHAR:\n     045A   6F\nEnd macro CHAR\nMacro CHAR:\n     045B   7A\nEnd macro CHAR\nMacro CHAR:\n     045C   03\nEnd macro CHAR\n     045D   00\nMacro CHAR:\n     045E   76\nEnd macro CHAR\nMacro CHAR:\n     045F   6D\nEnd macro CHAR\nMacro CHAR:\n     0460   6A\nEnd macro CHAR\nMacro CHAR:\n     0461   77\nEnd macro CHAR\n     0462   00\nMacro CHAR:\n     0463   75\nEnd macro CHAR\nMacro CHAR:\n     0464   6A\nEnd macro CHAR\nMacro CHAR:\n     0465   66\nEnd macro CHAR\nMacro CHAR:\n     0466   74\nEnd macro CHAR\nMacro CHAR:\n     0467   03\nEnd macro CHAR\n     0468   00\nMacro TWOK:\n     0469   B9\nEnd macro TWOK\nMacro TWOK:\n     046A   B8\nEnd macro TWOK\nMacro TWOK:\n     046B   B4\nEnd macro TWOK\nMacro CHAR:\n     046C   77\nEnd macro CHAR\nMacro CHAR:\n     046D   7A\nEnd macro CHAR\n     046E   00\nMacro TWOK:\n     046F   B8\nEnd macro TWOK\nMacro TWOK:\n     0470   A9\nEnd macro TWOK\nMacro CHAR:\n     0471   60\nEnd macro CHAR\nMacro CHAR:\n     0472   6B\nEnd macro CHAR\nMacro CHAR:\n     0473   7A\nEnd macro CHAR\n     0474   00\nMacro CHAR:\n     0475   65\nEnd macro CHAR\nMacro CHAR:\n     0476   66\nEnd macro CHAR\nMacro CHAR:\n     0477   76\nEnd macro CHAR\nMacro CHAR:\n     0478   67\nEnd macro CHAR\nMacro TWOK:\n     0479   A3\nEnd macro TWOK\n     047A   00\nMacro CHAR:\n     047B   6E\nEnd macro CHAR\nMacro CHAR:\n     047C   76\nEnd macro CHAR\nMacro CHAR:\n     047D   6F\nEnd macro CHAR\nMacro TWOK:\n     047E   B4\nEnd macro TWOK\nMacro CHAR:\n     047F   0E\nEnd macro CHAR\nMacro RTOK:\n     0480   81\nEnd macro RTOK\n     0481   00\nMacro TWOK:\n     0482   AE\nEnd macro TWOK\nMacro CHAR:\n     0483   60\nEnd macro CHAR\nMacro CHAR:\n     0484   77\nEnd macro CHAR\nMacro TWOK:\n     0485   B2\nEnd macro TWOK\nMacro TWOK:\n     0486   BA\nEnd macro TWOK\nMacro RTOK:\n     0487   9A\nEnd macro RTOK\n     0488   00\nMacro RTOK:\n     0489   D8\nEnd macro RTOK\nMacro CHAR:\n     048A   6E\nEnd macro CHAR\nMacro CHAR:\n     048B   76\nEnd macro CHAR\nMacro CHAR:\n     048C   6D\nEnd macro CHAR\nMacro TWOK:\n     048D   BE\nEnd macro TWOK\nMacro CHAR:\n     048E   77\nEnd macro CHAR\n     048F   00\nMacro CHAR:\n     0490   60\nEnd macro CHAR\nMacro TWOK:\n     0491   BC\nEnd macro TWOK\nMacro CHAR:\n     0492   65\nEnd macro CHAR\nMacro TWOK:\n     0493   BB\nEnd macro TWOK\nMacro TWOK:\n     0494   B3\nEnd macro TWOK\nMacro CHAR:\n     0495   62\nEnd macro CHAR\nMacro CHAR:\n     0496   60\nEnd macro CHAR\nMacro CHAR:\n     0497   7A\nEnd macro CHAR\n     0498   00\nMacro CHAR:\n     0499   67\nEnd macro CHAR\nMacro CHAR:\n     049A   66\nEnd macro CHAR\nMacro CHAR:\n     049B   6E\nEnd macro CHAR\nMacro CHAR:\n     049C   6C\nEnd macro CHAR\nMacro CHAR:\n     049D   60\nEnd macro CHAR\nMacro TWOK:\n     049E   B7\nEnd macro TWOK\nMacro CHAR:\n     049F   60\nEnd macro CHAR\nMacro CHAR:\n     04A0   7A\nEnd macro CHAR\n     04A1   00\nMacro CHAR:\n     04A2   60\nEnd macro CHAR\nMacro TWOK:\n     04A3   BA\nEnd macro TWOK\nMacro CHAR:\n     04A4   73\nEnd macro CHAR\nMacro TWOK:\n     04A5   BA\nEnd macro TWOK\nMacro TWOK:\n     04A6   B2\nEnd macro TWOK\nMacro CHAR:\n     04A7   66\nEnd macro CHAR\nMacro CHAR:\n     04A8   03\nEnd macro CHAR\nMacro RTOK:\n     04A9   E8\nEnd macro RTOK\nMacro TWOK:\n     04AA   B2\nEnd macro TWOK\nMacro CHAR:\n     04AB   66\nEnd macro CHAR\n     04AC   00\nMacro CHAR:\n     04AD   70\nEnd macro CHAR\nMacro CHAR:\n     04AE   6B\nEnd macro CHAR\nMacro CHAR:\n     04AF   6A\nEnd macro CHAR\nMacro CHAR:\n     04B0   73\nEnd macro CHAR\n     04B1   00\nMacro CHAR:\n     04B2   73\nEnd macro CHAR\nMacro CHAR:\n     04B3   71\nEnd macro CHAR\nMacro CHAR:\n     04B4   6C\nEnd macro CHAR\nMacro CHAR:\n     04B5   67\nEnd macro CHAR\nMacro CHAR:\n     04B6   76\nEnd macro CHAR\nMacro CHAR:\n     04B7   60\nEnd macro CHAR\nMacro CHAR:\n     04B8   77\nEnd macro CHAR\n     04B9   00\nMacro CHAR:\n     04BA   03\nEnd macro CHAR\nMacro TWOK:\n     04BB   B6\nEnd macro TWOK\nMacro CHAR:\n     04BC   70\nEnd macro CHAR\nMacro TWOK:\n     04BD   B3\nEnd macro TWOK\n     04BE   00\nMacro CHAR:\n     04BF   6B\nEnd macro CHAR\nMacro CHAR:\n     04C0   76\nEnd macro CHAR\nMacro CHAR:\n     04C1   6E\nEnd macro CHAR\nMacro TWOK:\n     04C2   B8\nEnd macro TWOK\nMacro CHAR:\n     04C3   03\nEnd macro CHAR\nMacro CHAR:\n     04C4   60\nEnd macro CHAR\nMacro CHAR:\n     04C5   6C\nEnd macro CHAR\nMacro CHAR:\n     04C6   6F\nEnd macro CHAR\nMacro TWOK:\n     04C7   BC\nEnd macro TWOK\nMacro CHAR:\n     04C8   6A\nEnd macro CHAR\nMacro TWOK:\n     04C9   A3\nEnd macro TWOK\n     04CA   00\nMacro CHAR:\n     04CB   6B\nEnd macro CHAR\nMacro CHAR:\n     04CC   7A\nEnd macro CHAR\nMacro CHAR:\n     04CD   73\nEnd macro CHAR\nMacro TWOK:\n     04CE   B3\nEnd macro TWOK\nMacro CHAR:\n     04CF   70\nEnd macro CHAR\nMacro CHAR:\n     04D0   73\nEnd macro CHAR\nMacro CHAR:\n     04D1   62\nEnd macro CHAR\nMacro TWOK:\n     04D2   A6\nEnd macro TWOK\nMacro CHAR:\n     04D3   03\nEnd macro CHAR\n     04D4   00\nMacro CHAR:\n     04D5   70\nEnd macro CHAR\nMacro CHAR:\n     04D6   6B\nEnd macro CHAR\nMacro TWOK:\n     04D7   BA\nEnd macro TWOK\nMacro CHAR:\n     04D8   77\nEnd macro CHAR\nMacro CHAR:\n     04D9   03\nEnd macro CHAR\nMacro RTOK:\n     04DA   E9\nEnd macro RTOK\nMacro RTOK:\n     04DB   82\nEnd macro RTOK\n     04DC   00\nMacro TWOK:\n     04DD   AE\nEnd macro TWOK\nMacro RTOK:\n     04DE   E8\nEnd macro RTOK\nMacro TWOK:\n     04DF   B8\nEnd macro TWOK\nMacro TWOK:\n     04E0   A6\nEnd macro TWOK\n     04E1   00\nMacro CHAR:\n     04E2   73\nEnd macro CHAR\nMacro CHAR:\n     04E3   6C\nEnd macro CHAR\nMacro CHAR:\n     04E4   73\nEnd macro CHAR\nMacro CHAR:\n     04E5   76\nEnd macro CHAR\nMacro CHAR:\n     04E6   6F\nEnd macro CHAR\nMacro TWOK:\n     04E7   B2\nEnd macro TWOK\nMacro CHAR:\n     04E8   6A\nEnd macro CHAR\nMacro TWOK:\n     04E9   BC\nEnd macro TWOK\n     04EA   00\nMacro CHAR:\n     04EB   64\nEnd macro CHAR\nMacro CHAR:\n     04EC   71\nEnd macro CHAR\nMacro CHAR:\n     04ED   6C\nEnd macro CHAR\nMacro CHAR:\n     04EE   70\nEnd macro CHAR\nMacro CHAR:\n     04EF   70\nEnd macro CHAR\nMacro CHAR:\n     04F0   03\nEnd macro CHAR\nMacro RTOK:\n     04F1   99\nEnd macro RTOK\nMacro CHAR:\n     04F2   6A\nEnd macro CHAR\nMacro CHAR:\n     04F3   75\nEnd macro CHAR\nMacro CHAR:\n     04F4   6A\nEnd macro CHAR\nMacro CHAR:\n     04F5   77\nEnd macro CHAR\nMacro CHAR:\n     04F6   7A\nEnd macro CHAR\n     04F7   00\nMacro CHAR:\n     04F8   66\nEnd macro CHAR\nMacro CHAR:\n     04F9   60\nEnd macro CHAR\nMacro TWOK:\n     04FA   BC\nEnd macro TWOK\nMacro CHAR:\n     04FB   6C\nEnd macro CHAR\nMacro CHAR:\n     04FC   6E\nEnd macro CHAR\nMacro CHAR:\n     04FD   7A\nEnd macro CHAR\n     04FE   00\nMacro CHAR:\n     04FF   03\nEnd macro CHAR\nMacro CHAR:\n     0500   6F\nEnd macro CHAR\nMacro CHAR:\n     0501   6A\nEnd macro CHAR\nMacro CHAR:\n     0502   64\nEnd macro CHAR\nMacro CHAR:\n     0503   6B\nEnd macro CHAR\nMacro CHAR:\n     0504   77\nEnd macro CHAR\nMacro CHAR:\n     0505   03\nEnd macro CHAR\nMacro CHAR:\n     0506   7A\nEnd macro CHAR\nMacro CHAR:\n     0507   66\nEnd macro CHAR\nMacro TWOK:\n     0508   A9\nEnd macro TWOK\nMacro CHAR:\n     0509   70\nEnd macro CHAR\n     050A   00\nMacro TWOK:\n     050B   BF\nEnd macro TWOK\nMacro CHAR:\n     050C   60\nEnd macro CHAR\nMacro CHAR:\n     050D   6B\nEnd macro CHAR\nMacro CHAR:\n     050E   0D\nEnd macro CHAR\nMacro TWOK:\n     050F   A2\nEnd macro TWOK\nMacro TWOK:\n     0510   B5\nEnd macro TWOK\nMacro CHAR:\n     0511   6F\nEnd macro CHAR\n     0512   00\nMacro CHAR:\n     0513   60\nEnd macro CHAR\nMacro CHAR:\n     0514   62\nEnd macro CHAR\nMacro CHAR:\n     0515   70\nEnd macro CHAR\nMacro CHAR:\n     0516   6B\nEnd macro CHAR\n     0517   00\nMacro CHAR:\n     0518   03\nEnd macro CHAR\nMacro TWOK:\n     0519   A5\nEnd macro TWOK\nMacro RTOK:\n     051A   55\nEnd macro RTOK\nMacro CHAR:\n     051B   6A\nEnd macro CHAR\nMacro TWOK:\n     051C   BC\nEnd macro TWOK\n     051D   00\nMacro RTOK:\n     051E   59\nEnd macro RTOK\nMacro RTOK:\n     051F   82\nEnd macro RTOK\nMacro CONT:\n     0520   22\nEnd macro CONT\n     0521   00\nMacro CHAR:\n     0522   77\nEnd macro CHAR\nMacro TWOK:\n     0523   A9\nEnd macro TWOK\nMacro TWOK:\n     0524   A0\nEnd macro TWOK\nMacro CHAR:\n     0525   77\nEnd macro CHAR\nMacro CHAR:\n     0526   03\nEnd macro CHAR\nMacro CHAR:\n     0527   6F\nEnd macro CHAR\nMacro CHAR:\n     0528   6C\nEnd macro CHAR\nMacro RTOK:\n     0529   E8\nEnd macro RTOK\n     052A   00\nMacro RTOK:\n     052B   49\nEnd macro RTOK\nMacro CHAR:\n     052C   03\nEnd macro CHAR\nMacro CHAR:\n     052D   69\nEnd macro CHAR\nMacro CHAR:\n     052E   62\nEnd macro CHAR\nMacro CHAR:\n     052F   6E\nEnd macro CHAR\nMacro CHAR:\n     0530   6E\nEnd macro CHAR\nMacro TWOK:\n     0531   BB\nEnd macro TWOK\n     0532   00\nMacro CHAR:\n     0533   71\nEnd macro CHAR\nMacro TWOK:\n     0534   B8\nEnd macro TWOK\nMacro TWOK:\n     0535   A0\nEnd macro TWOK\n     0536   00\nMacro CHAR:\n     0537   70\nEnd macro CHAR\nMacro CHAR:\n     0538   77\nEnd macro CHAR\n     0539   00\nMacro RTOK:\n     053A   93\nEnd macro RTOK\nMacro CHAR:\n     053B   03\nEnd macro CHAR\nMacro CHAR:\n     053C   6C\nEnd macro CHAR\nMacro CHAR:\n     053D   65\nEnd macro CHAR\nMacro CHAR:\n     053E   03\nEnd macro CHAR\n     053F   00\nMacro CHAR:\n     0540   70\nEnd macro CHAR\nMacro CHAR:\n     0541   66\nEnd macro CHAR\nMacro RTOK:\n     0542   55\nEnd macro RTOK\n     0543   00\nMacro CHAR:\n     0544   03\nEnd macro CHAR\nMacro CHAR:\n     0545   60\nEnd macro CHAR\nMacro TWOK:\n     0546   A9\nEnd macro TWOK\nMacro CHAR:\n     0547   64\nEnd macro CHAR\nMacro CHAR:\n     0548   6C\nEnd macro CHAR\nMacro CONT:\n     0549   25\nEnd macro CONT\n     054A   00\nMacro CHAR:\n     054B   66\nEnd macro CHAR\nMacro TWOK:\n     054C   B9\nEnd macro TWOK\nMacro CHAR:\n     054D   6A\nEnd macro CHAR\nMacro CHAR:\n     054E   73\nEnd macro CHAR\n     054F   00\nMacro CHAR:\n     0550   65\nEnd macro CHAR\nMacro CHAR:\n     0551   6C\nEnd macro CHAR\nMacro CHAR:\n     0552   6C\nEnd macro CHAR\nMacro CHAR:\n     0553   67\nEnd macro CHAR\n     0554   00\nMacro TWOK:\n     0555   BF\nEnd macro TWOK\nMacro CHAR:\n     0556   7B\nEnd macro CHAR\nMacro TWOK:\n     0557   B4\nEnd macro TWOK\nMacro CHAR:\n     0558   6F\nEnd macro CHAR\nMacro TWOK:\n     0559   AA\nEnd macro TWOK\n     055A   00\nMacro TWOK:\n     055B   B7\nEnd macro TWOK\nMacro TWOK:\n     055C   AE\nEnd macro TWOK\nMacro CHAR:\n     055D   6C\nEnd macro CHAR\nMacro CHAR:\n     055E   62\nEnd macro CHAR\nMacro CHAR:\n     055F   60\nEnd macro CHAR\nMacro TWOK:\n     0560   B4\nEnd macro TWOK\nMacro TWOK:\n     0561   B5\nEnd macro TWOK\nMacro CHAR:\n     0562   70\nEnd macro CHAR\n     0563   00\nMacro CHAR:\n     0564   70\nEnd macro CHAR\nMacro TWOK:\n     0565   B6\nEnd macro TWOK\nMacro TWOK:\n     0566   B5\nEnd macro TWOK\nMacro CHAR:\n     0567   70\nEnd macro CHAR\n     0568   00\nMacro CHAR:\n     0569   6F\nEnd macro CHAR\nMacro CHAR:\n     056A   6A\nEnd macro CHAR\nMacro TWOK:\n     056B   B9\nEnd macro TWOK\nMacro TWOK:\n     056C   BA\nEnd macro TWOK\nMacro CHAR:\n     056D   0C\nEnd macro CHAR\nMacro CHAR:\n     056E   74\nEnd macro CHAR\nMacro TWOK:\n     056F   AF\nEnd macro TWOK\nMacro TWOK:\n     0570   AA\nEnd macro TWOK\n     0571   00\nMacro CHAR:\n     0572   6F\nEnd macro CHAR\nMacro CHAR:\n     0573   76\nEnd macro CHAR\nMacro CHAR:\n     0574   7B\nEnd macro CHAR\nMacro CHAR:\n     0575   76\nEnd macro CHAR\nMacro TWOK:\n     0576   BD\nEnd macro TWOK\nMacro TWOK:\n     0577   AA\nEnd macro TWOK\n     0578   00\nMacro CHAR:\n     0579   6D\nEnd macro CHAR\nMacro TWOK:\n     057A   A9\nEnd macro TWOK\nMacro CHAR:\n     057B   60\nEnd macro CHAR\nMacro CHAR:\n     057C   6C\nEnd macro CHAR\nMacro TWOK:\n     057D   B4\nEnd macro TWOK\nMacro CHAR:\n     057E   60\nEnd macro CHAR\nMacro CHAR:\n     057F   70\nEnd macro CHAR\n     0580   00\nMacro RTOK:\n     0581   D8\nEnd macro RTOK\nMacro CHAR:\n     0582   73\nEnd macro CHAR\nMacro CHAR:\n     0583   76\nEnd macro CHAR\nMacro CHAR:\n     0584   77\nEnd macro CHAR\nMacro TWOK:\n     0585   B3\nEnd macro TWOK\nMacro CHAR:\n     0586   70\nEnd macro CHAR\n     0587   00\nMacro TWOK:\n     0588   A8\nEnd macro TWOK\nMacro CHAR:\n     0589   60\nEnd macro CHAR\nMacro CHAR:\n     058A   6B\nEnd macro CHAR\nMacro TWOK:\n     058B   AF\nEnd macro TWOK\nMacro TWOK:\n     058C   B3\nEnd macro TWOK\nMacro CHAR:\n     058D   7A\nEnd macro CHAR\n     058E   00\nMacro RTOK:\n     058F   56\nEnd macro RTOK\nMacro CHAR:\n     0590   6C\nEnd macro CHAR\nMacro CHAR:\n     0591   7A\nEnd macro CHAR\nMacro CHAR:\n     0592   70\nEnd macro CHAR\n     0593   00\nMacro CHAR:\n     0594   65\nEnd macro CHAR\nMacro CHAR:\n     0595   6A\nEnd macro CHAR\nMacro TWOK:\n     0596   AD\nEnd macro TWOK\nMacro TWOK:\n     0597   A9\nEnd macro TWOK\nMacro CHAR:\n     0598   6E\nEnd macro CHAR\nMacro CHAR:\n     0599   70\nEnd macro CHAR\n     059A   00\nMacro CHAR:\n     059B   65\nEnd macro CHAR\nMacro CHAR:\n     059C   76\nEnd macro CHAR\nMacro CHAR:\n     059D   71\nEnd macro CHAR\nMacro CHAR:\n     059E   70\nEnd macro CHAR\n     059F   00\nMacro CHAR:\n     05A0   6E\nEnd macro CHAR\nMacro TWOK:\n     05A1   AF\nEnd macro TWOK\nMacro TWOK:\n     05A2   B3\nEnd macro TWOK\nMacro TWOK:\n     05A3   A3\nEnd macro TWOK\nMacro CHAR:\n     05A4   70\nEnd macro CHAR\n     05A5   00\nMacro CHAR:\n     05A6   64\nEnd macro CHAR\nMacro CHAR:\n     05A7   6C\nEnd macro CHAR\nMacro CHAR:\n     05A8   6F\nEnd macro CHAR\nMacro CHAR:\n     05A9   67\nEnd macro CHAR\n     05AA   00\nMacro CHAR:\n     05AB   73\nEnd macro CHAR\nMacro CHAR:\n     05AC   6F\nEnd macro CHAR\nMacro TWOK:\n     05AD   B2\nEnd macro TWOK\nMacro TWOK:\n     05AE   AF\nEnd macro TWOK\nMacro CHAR:\n     05AF   76\nEnd macro CHAR\nMacro CHAR:\n     05B0   6E\nEnd macro CHAR\n     05B1   00\nMacro TWOK:\n     05B2   A0\nEnd macro TWOK\nMacro CHAR:\n     05B3   6E\nEnd macro CHAR\nMacro CHAR:\n     05B4   0E\nEnd macro CHAR\nMacro RTOK:\n     05B5   E8\nEnd macro RTOK\nMacro TWOK:\n     05B6   BC\nEnd macro TWOK\nMacro TWOK:\n     05B7   AA\nEnd macro TWOK\n     05B8   00\nMacro TWOK:\n     05B9   A3\nEnd macro TWOK\nMacro CHAR:\n     05BA   6A\nEnd macro CHAR\nMacro TWOK:\n     05BB   B1\nEnd macro TWOK\nMacro CHAR:\n     05BC   03\nEnd macro CHAR\nMacro RTOK:\n     05BD   5C\nEnd macro RTOK\nMacro CHAR:\n     05BE   70\nEnd macro CHAR\n     05BF   00\nMacro CHAR:\n     05C0   0B\nEnd macro CHAR\nMacro CHAR:\n     05C1   7A\nEnd macro CHAR\nMacro CHAR:\n     05C2   0C\nEnd macro CHAR\nMacro CHAR:\n     05C3   6D\nEnd macro CHAR\nMacro CHAR:\n     05C4   0A\nEnd macro CHAR\nMacro CHAR:\n     05C5   1C\nEnd macro CHAR\n     05C6   00\nMacro CHAR:\n     05C7   03\nEnd macro CHAR\nMacro CHAR:\n     05C8   60\nEnd macro CHAR\nMacro CHAR:\n     05C9   71\nEnd macro CHAR\n     05CA   00\nMacro CHAR:\n     05CB   6F\nEnd macro CHAR\nMacro TWOK:\n     05CC   A9\nEnd macro TWOK\nMacro TWOK:\n     05CD   A0\nEnd macro TWOK\n     05CE   00\nMacro CHAR:\n     05CF   65\nEnd macro CHAR\nMacro CHAR:\n     05D0   6A\nEnd macro CHAR\nMacro TWOK:\n     05D1   B3\nEnd macro TWOK\nMacro TWOK:\n     05D2   A6\nEnd macro TWOK\n     05D3   00\nMacro CHAR:\n     05D4   70\nEnd macro CHAR\nMacro TWOK:\n     05D5   A8\nEnd macro TWOK\nMacro RTOK:\n     05D6   55\nEnd macro RTOK\n     05D7   00\nMacro CHAR:\n     05D8   64\nEnd macro CHAR\nMacro TWOK:\n     05D9   AD\nEnd macro TWOK\nMacro TWOK:\n     05DA   B1\nEnd macro TWOK\n     05DB   00\nMacro CHAR:\n     05DC   71\nEnd macro CHAR\nMacro TWOK:\n     05DD   BB\nEnd macro TWOK\n     05DE   00\nMacro CHAR:\n     05DF   7A\nEnd macro CHAR\nMacro CHAR:\n     05E0   66\nEnd macro CHAR\nMacro RTOK:\n     05E1   55\nEnd macro RTOK\nMacro CHAR:\n     05E2   6C\nEnd macro CHAR\nMacro CHAR:\n     05E3   74\nEnd macro CHAR\n     05E4   00\nMacro CHAR:\n     05E5   61\nEnd macro CHAR\nMacro CHAR:\n     05E6   6F\nEnd macro CHAR\nMacro CHAR:\n     05E7   76\nEnd macro CHAR\nMacro CHAR:\n     05E8   66\nEnd macro CHAR\n     05E9   00\nMacro CHAR:\n     05EA   61\nEnd macro CHAR\nMacro TWOK:\n     05EB   B6\nEnd macro TWOK\nMacro CHAR:\n     05EC   60\nEnd macro CHAR\nMacro CHAR:\n     05ED   68\nEnd macro CHAR\n     05EE   00\nMacro RTOK:\n     05EF   35\nEnd macro RTOK\n     05F0   00\nMacro CHAR:\n     05F1   70\nEnd macro CHAR\nMacro CHAR:\n     05F2   6F\nEnd macro CHAR\nMacro CHAR:\n     05F3   6A\nEnd macro CHAR\nMacro CHAR:\n     05F4   6E\nEnd macro CHAR\nMacro CHAR:\n     05F5   7A\nEnd macro CHAR\n     05F6   00\nMacro CHAR:\n     05F7   61\nEnd macro CHAR\nMacro CHAR:\n     05F8   76\nEnd macro CHAR\nMacro CHAR:\n     05F9   64\nEnd macro CHAR\nMacro CHAR:\n     05FA   0E\nEnd macro CHAR\nMacro CHAR:\n     05FB   66\nEnd macro CHAR\nMacro CHAR:\n     05FC   7A\nEnd macro CHAR\nMacro TWOK:\n     05FD   BB\nEnd macro TWOK\n     05FE   00\nMacro CHAR:\n     05FF   6B\nEnd macro CHAR\nMacro TWOK:\n     0600   BA\nEnd macro TWOK\nMacro CHAR:\n     0601   6D\nEnd macro CHAR\nMacro TWOK:\n     0602   BB\nEnd macro TWOK\n     0603   00\nMacro CHAR:\n     0604   61\nEnd macro CHAR\nMacro TWOK:\n     0605   BC\nEnd macro TWOK\nMacro CHAR:\n     0606   7A\nEnd macro CHAR\n     0607   00\nMacro CHAR:\n     0608   65\nEnd macro CHAR\nMacro TWOK:\n     0609   B2\nEnd macro TWOK\n     060A   00\nMacro CHAR:\n     060B   65\nEnd macro CHAR\nMacro CHAR:\n     060C   76\nEnd macro CHAR\nMacro CHAR:\n     060D   71\nEnd macro CHAR\nMacro CHAR:\n     060E   71\nEnd macro CHAR\nMacro CHAR:\n     060F   7A\nEnd macro CHAR\n     0610   00\nMacro CHAR:\n     0611   71\nEnd macro CHAR\nMacro CHAR:\n     0612   6C\nEnd macro CHAR\nMacro CHAR:\n     0613   67\nEnd macro CHAR\nMacro TWOK:\n     0614   B1\nEnd macro TWOK\nMacro CHAR:\n     0615   77\nEnd macro CHAR\n     0616   00\nMacro CHAR:\n     0617   65\nEnd macro CHAR\nMacro CHAR:\n     0618   71\nEnd macro CHAR\nMacro CHAR:\n     0619   6C\nEnd macro CHAR\nMacro CHAR:\n     061A   64\nEnd macro CHAR\n     061B   00\nMacro CHAR:\n     061C   6F\nEnd macro CHAR\nMacro CHAR:\n     061D   6A\nEnd macro CHAR\nMacro TWOK:\n     061E   A7\nEnd macro TWOK\nMacro CHAR:\n     061F   71\nEnd macro CHAR\nMacro CHAR:\n     0620   67\nEnd macro CHAR\n     0621   00\nMacro CHAR:\n     0622   6F\nEnd macro CHAR\nMacro CHAR:\n     0623   6C\nEnd macro CHAR\nMacro CHAR:\n     0624   61\nEnd macro CHAR\nMacro RTOK:\n     0625   E8\nEnd macro RTOK\nMacro TWOK:\n     0626   B3\nEnd macro TWOK\n     0627   00\nMacro TWOK:\n     0628   A5\nEnd macro TWOK\nMacro CHAR:\n     0629   71\nEnd macro CHAR\nMacro CHAR:\n     062A   67\nEnd macro CHAR\n     062B   00\nMacro CHAR:\n     062C   6B\nEnd macro CHAR\nMacro CHAR:\n     062D   76\nEnd macro CHAR\nMacro CHAR:\n     062E   6E\nEnd macro CHAR\nMacro TWOK:\n     062F   B8\nEnd macro TWOK\nMacro CHAR:\n     0630   6C\nEnd macro CHAR\nMacro CHAR:\n     0631   6A\nEnd macro CHAR\nMacro CHAR:\n     0632   67\nEnd macro CHAR\n     0633   00\nMacro CHAR:\n     0634   65\nEnd macro CHAR\nMacro CHAR:\n     0635   66\nEnd macro CHAR\nMacro CHAR:\n     0636   6F\nEnd macro CHAR\nMacro TWOK:\n     0637   AF\nEnd macro TWOK\nMacro CHAR:\n     0638   66\nEnd macro CHAR\n     0639   00\nMacro TWOK:\n     063A   AF\nEnd macro TWOK\nMacro CHAR:\n     063B   70\nEnd macro CHAR\nMacro CHAR:\n     063C   66\nEnd macro CHAR\nMacro CHAR:\n     063D   60\nEnd macro CHAR\nMacro CHAR:\n     063E   77\nEnd macro CHAR\n     063F   00\nMacro RTOK:\n     0640   88\nEnd macro RTOK\nMacro TWOK:\n     0641   B7\nEnd macro TWOK\nMacro TWOK:\n     0642   AE\nEnd macro TWOK\nMacro TWOK:\n     0643   AB\nEnd macro TWOK\n     0644   00\nMacro CHAR:\n     0645   60\nEnd macro CHAR\nMacro CHAR:\n     0646   6C\nEnd macro CHAR\nMacro CHAR:\n     0647   6E\nEnd macro CHAR\n     0648   00\nMacro RTOK:\n     0649   D8\nEnd macro RTOK\nMacro CHAR:\n     064A   6E\nEnd macro CHAR\nMacro TWOK:\n     064B   B8\nEnd macro TWOK\nMacro CHAR:\n     064C   67\nEnd macro CHAR\nMacro TWOK:\n     064D   B3\nEnd macro TWOK\n     064E   00\nMacro CHAR:\n     064F   03\nEnd macro CHAR\nMacro CHAR:\n     0650   67\nEnd macro CHAR\nMacro TWOK:\n     0651   AA\nEnd macro TWOK\nMacro CHAR:\n     0652   77\nEnd macro CHAR\nMacro CHAR:\n     0653   71\nEnd macro CHAR\nMacro CHAR:\n     0654   6C\nEnd macro CHAR\nMacro CHAR:\n     0655   7A\nEnd macro CHAR\nMacro TWOK:\n     0656   BB\nEnd macro TWOK\n     0657   00\nMacro CHAR:\n     0658   61\nEnd macro CHAR\nMacro CHAR:\n     0659   7A\nEnd macro CHAR\nMacro CHAR:\n     065A   03\nEnd macro CHAR\nMacro CHAR:\n     065B   67\nEnd macro CHAR\nMacro CHAR:\n     065C   0D\nEnd macro CHAR\nMacro CHAR:\n     065D   61\nEnd macro CHAR\nMacro TWOK:\n     065E   B7\nEnd macro TWOK\nMacro TWOK:\n     065F   B0\nEnd macro TWOK\nMacro CHAR:\n     0660   6D\nEnd macro CHAR\nMacro CHAR:\n     0661   03\nEnd macro CHAR\nMacro CHAR:\n     0662   05\nEnd macro CHAR\nMacro CHAR:\n     0663   03\nEnd macro CHAR\nMacro CHAR:\n     0664   6A\nEnd macro CHAR\nMacro CHAR:\n     0665   0D\nEnd macro CHAR\nMacro TWOK:\n     0666   B0\nEnd macro TWOK\nMacro RTOK:\n     0667   55\nEnd macro RTOK\n     0668   00\nMacro RTOK:\n     0669   8D\nEnd macro RTOK\nMacro CHAR:\n     066A   03\nEnd macro CHAR\nMacro CHAR:\n     066B   03\nEnd macro CHAR\nMacro RTOK:\n     066C   93\nEnd macro RTOK\nMacro CONT:\n     066D   2E\nEnd macro CONT\nMacro CHAR:\n     066E   03\nEnd macro CHAR\nMacro RTOK:\n     066F   99\nEnd macro RTOK\nMacro CHAR:\n     0670   03\nEnd macro CHAR\nMacro CHAR:\n     0671   03\nEnd macro CHAR\nMacro CHAR:\n     0672   03\nEnd macro CHAR\nMacro RTOK:\n     0673   8D\nEnd macro RTOK\nMacro CHAR:\n     0674   03\nEnd macro CHAR\nMacro RTOK:\n     0675   85\nEnd macro RTOK\nMacro CHAR:\n     0676   03\nEnd macro CHAR\nMacro CHAR:\n     0677   65\nEnd macro CHAR\nMacro TWOK:\n     0678   BA\nEnd macro TWOK\nMacro CHAR:\n     0679   03\nEnd macro CHAR\nMacro CHAR:\n     067A   70\nEnd macro CHAR\nMacro CHAR:\n     067B   62\nEnd macro CHAR\nMacro TWOK:\n     067C   A2\nEnd macro TWOK\nMacro CONT:\n     067D   2E\nEnd macro CONT\nMacro CONT:\n     067E   29\nEnd macro CONT\n     067F   00\nMacro CHAR:\n     0680   65\nEnd macro CHAR\nMacro CHAR:\n     0681   71\nEnd macro CHAR\nMacro TWOK:\n     0682   BC\nEnd macro TWOK\nMacro CHAR:\n     0683   77\nEnd macro CHAR\n     0684   00\nMacro TWOK:\n     0685   AD\nEnd macro TWOK\nMacro TWOK:\n     0686   A9\nEnd macro TWOK\n     0687   00\nMacro TWOK:\n     0688   A2\nEnd macro TWOK\nMacro CHAR:\n     0689   65\nEnd macro CHAR\nMacro CHAR:\n     068A   77\nEnd macro CHAR\n     068B   00\nMacro TWOK:\n     068C   BD\nEnd macro TWOK\nMacro CHAR:\n     068D   64\nEnd macro CHAR\nMacro CHAR:\n     068E   6B\nEnd macro CHAR\nMacro CHAR:\n     068F   77\nEnd macro CHAR\n     0690   00\nMacro RTOK:\n     0691   5A\nEnd macro RTOK\nMacro CHAR:\n     0692   6F\nEnd macro CHAR\nMacro CHAR:\n     0693   6C\nEnd macro CHAR\nMacro CHAR:\n     0694   74\nEnd macro CHAR\nMacro CONT:\n     0695   24\nEnd macro CONT\n     0696   00\nMacro RTOK:\n     0697   40\nEnd macro RTOK\nMacro RTOK:\n     0698   32\nEnd macro RTOK\nMacro RTOK:\n     0699   DF\nEnd macro RTOK\nMacro CHAR:\n     069A   02\nEnd macro CHAR\n     069B   00\nMacro CHAR:\n     069C   66\nEnd macro CHAR\nMacro CHAR:\n     069D   7B\nEnd macro CHAR\nMacro CHAR:\n     069E   77\nEnd macro CHAR\nMacro TWOK:\n     069F   B7\nEnd macro TWOK\nMacro CHAR:\n     06A0   03\nEnd macro CHAR\n     06A1   00\nMacro CHAR:\n     06A2   73\nEnd macro CHAR\nMacro CHAR:\n     06A3   76\nEnd macro CHAR\nMacro CHAR:\n     06A4   6F\nEnd macro CHAR\nMacro CHAR:\n     06A5   70\nEnd macro CHAR\nMacro CHAR:\n     06A6   66\nEnd macro CHAR\nMacro RTOK:\n     06A7   98\nEnd macro RTOK\n     06A8   00\nMacro TWOK:\n     06A9   B0\nEnd macro TWOK\nMacro CHAR:\n     06AA   62\nEnd macro CHAR\nMacro CHAR:\n     06AB   6E\nEnd macro CHAR\nMacro RTOK:\n     06AC   98\nEnd macro RTOK\n     06AD   00\nMacro CHAR:\n     06AE   65\nEnd macro CHAR\nMacro CHAR:\n     06AF   76\nEnd macro CHAR\nMacro CHAR:\n     06B0   66\nEnd macro CHAR\nMacro CHAR:\n     06B1   6F\nEnd macro CHAR\n     06B2   00\nMacro CHAR:\n     06B3   6E\nEnd macro CHAR\nMacro TWOK:\n     06B4   BE\nEnd macro TWOK\nMacro CHAR:\n     06B5   70\nEnd macro CHAR\nMacro CHAR:\n     06B6   6A\nEnd macro CHAR\nMacro TWOK:\n     06B7   A2\nEnd macro TWOK\n     06B8   00\nMacro RTOK:\n     06B9   C0\nEnd macro RTOK\nMacro RTOK:\n     06BA   ED\nEnd macro RTOK\nMacro CHAR:\n     06BB   03\nEnd macro CHAR\nMacro CHAR:\n     06BC   61\nEnd macro CHAR\nMacro CHAR:\n     06BD   62\nEnd macro CHAR\nMacro CHAR:\n     06BE   7A\nEnd macro CHAR\n     06BF   00\nMacro CHAR:\n     06C0   66\nEnd macro CHAR\nMacro CHAR:\n     06C1   0D\nEnd macro CHAR\nMacro CHAR:\n     06C2   60\nEnd macro CHAR\nMacro CHAR:\n     06C3   0D\nEnd macro CHAR\nMacro CHAR:\n     06C4   6E\nEnd macro CHAR\nMacro CHAR:\n     06C5   0D\nEnd macro CHAR\nMacro RTOK:\n     06C6   86\nEnd macro RTOK\n     06C7   00\nMacro RTOK:\n     06C8   45\nEnd macro RTOK\nMacro RTOK:\n     06C9   44\nEnd macro RTOK\nMacro CHAR:\n     06CA   70\nEnd macro CHAR\n     06CB   00\nMacro RTOK:\n     06CC   45\nEnd macro RTOK\nMacro RTOK:\n     06CD   4B\nEnd macro RTOK\nMacro CHAR:\n     06CE   70\nEnd macro CHAR\n     06CF   00\nMacro RTOK:\n     06D0   4A\nEnd macro RTOK\nMacro CHAR:\n     06D1   03\nEnd macro CHAR\nMacro CHAR:\n     06D2   70\nEnd macro CHAR\nMacro CHAR:\n     06D3   60\nEnd macro CHAR\nMacro CHAR:\n     06D4   6C\nEnd macro CHAR\nMacro CHAR:\n     06D5   6C\nEnd macro CHAR\nMacro CHAR:\n     06D6   73\nEnd macro CHAR\nMacro CHAR:\n     06D7   70\nEnd macro CHAR\n     06D8   00\nMacro TWOK:\n     06D9   AA\nEnd macro TWOK\nMacro CHAR:\n     06DA   60\nEnd macro CHAR\nMacro CHAR:\n     06DB   62\nEnd macro CHAR\nMacro CHAR:\n     06DC   73\nEnd macro CHAR\nMacro CHAR:\n     06DD   66\nEnd macro CHAR\nMacro CHAR:\n     06DE   03\nEnd macro CHAR\nMacro CHAR:\n     06DF   73\nEnd macro CHAR\nMacro CHAR:\n     06E0   6C\nEnd macro CHAR\nMacro CHAR:\n     06E1   67\nEnd macro CHAR\n     06E2   00\nMacro RTOK:\n     06E3   5A\nEnd macro RTOK\nMacro CHAR:\n     06E4   61\nEnd macro CHAR\nMacro CHAR:\n     06E5   6C\nEnd macro CHAR\nMacro CHAR:\n     06E6   6E\nEnd macro CHAR\nMacro CHAR:\n     06E7   61\nEnd macro CHAR\n     06E8   00\nMacro RTOK:\n     06E9   5A\nEnd macro RTOK\nMacro RTOK:\n     06EA   8D\nEnd macro RTOK\n     06EB   00\nMacro RTOK:\n     06EC   5F\nEnd macro RTOK\nMacro TWOK:\n     06ED   AF\nEnd macro TWOK\nMacro CHAR:\n     06EE   64\nEnd macro CHAR\nMacro CHAR:\n     06EF   03\nEnd macro CHAR\nMacro RTOK:\n     06F0   F4\nEnd macro RTOK\n     06F1   00\nMacro RTOK:\n     06F2   59\nEnd macro RTOK\nMacro CHAR:\n     06F3   03\nEnd macro CHAR\nMacro RTOK:\n     06F4   9E\nEnd macro RTOK\n     06F5   00\nMacro CHAR:\n     06F6   62\nEnd macro CHAR\nMacro RTOK:\n     06F7   55\nEnd macro RTOK\n     06F8   00\nMacro CHAR:\n     06F9   6F\nEnd macro CHAR\nMacro CHAR:\n     06FA   6F\nEnd macro CHAR\n     06FB   00\nMacro RTOK:\n     06FC   E6\nEnd macro RTOK\nMacro CHAR:\n     06FD   19\nEnd macro CHAR\nMacro CONT:\n     06FE   23\nEnd macro CONT\n     06FF   00\nMacro TWOK:\n     0700   AF\nEnd macro TWOK\nMacro RTOK:\n     0701   D8\nEnd macro RTOK\nMacro TWOK:\n     0702   AF\nEnd macro TWOK\nMacro CHAR:\n     0703   64\nEnd macro CHAR\nMacro CHAR:\n     0704   03\nEnd macro CHAR\nMacro RTOK:\n     0705   49\nEnd macro RTOK\n     0706   00\nMacro TWOK:\n     0707   B1\nEnd macro TWOK\nMacro TWOK:\n     0708   B3\nEnd macro TWOK\nMacro CHAR:\n     0709   64\nEnd macro CHAR\nMacro CHAR:\n     070A   7A\nEnd macro CHAR\nMacro CHAR:\n     070B   03\nEnd macro CHAR\n     070C   00\nMacro CHAR:\n     070D   64\nEnd macro CHAR\nMacro CHAR:\n     070E   62\nEnd macro CHAR\nMacro TWOK:\n     070F   B6\nEnd macro TWOK\nMacro CHAR:\n     0710   60\nEnd macro CHAR\nMacro TWOK:\n     0711   B4\nEnd macro TWOK\nMacro CHAR:\n     0712   60\nEnd macro CHAR\n     0713   00\nMacro CONT:\n     0714   2E\nEnd macro CONT\nMacro RTOK:\n     0715   DF\nEnd macro RTOK\nMacro CHAR:\n     0716   04\nEnd macro CHAR\nMacro CHAR:\n     0717   70\nEnd macro CHAR\nMacro CHAR:\n     0718   03\nEnd macro CHAR\nMacro CHAR:\n     0719   6D\nEnd macro CHAR\nMacro CHAR:\n     071A   62\nEnd macro CHAR\nMacro CHAR:\n     071B   6E\nEnd macro CHAR\nMacro CHAR:\n     071C   66\nEnd macro CHAR\nMacro CHAR:\n     071D   1C\nEnd macro CHAR\nMacro CHAR:\n     071E   03\nEnd macro CHAR\n     071F   00\nMacro CHAR:\n     0720   67\nEnd macro CHAR\nMacro CHAR:\n     0721   6C\nEnd macro CHAR\nMacro CHAR:\n     0722   60\nEnd macro CHAR\nMacro CHAR:\n     0723   68\nEnd macro CHAR\n     0724   00\nMacro CONT:\n     0725   26\nEnd macro CONT\nMacro TWOK:\n     0726   A2\nEnd macro TWOK\nMacro CHAR:\n     0727   64\nEnd macro CHAR\nMacro TWOK:\n     0728   A3\nEnd macro TWOK\nMacro CHAR:\n     0729   03\nEnd macro CHAR\nMacro RTOK:\n     072A   E8\nEnd macro RTOK\nMacro TWOK:\n     072B   B2\nEnd macro TWOK\nMacro TWOK:\n     072C   AB\nEnd macro TWOK\nMacro CHAR:\n     072D   19\nEnd macro CHAR\n     072E   00\nMacro RTOK:\n     072F   DF\nEnd macro RTOK\nMacro CHAR:\n     0730   03\nEnd macro CHAR\nMacro CONT:\n     0731   27\nEnd macro CONT\nMacro CONT:\n     0732   2E\nEnd macro CONT\nMacro CONT:\n     0733   2E\nEnd macro CONT\nMacro CONT:\n     0734   2E\nEnd macro CONT\nMacro CONT:\n     0735   25\nEnd macro CONT\nMacro RTOK:\n     0736   3C\nEnd macro RTOK\nMacro CHAR:\n     0737   03\nEnd macro CHAR\nMacro RTOK:\n     0738   86\nEnd macro RTOK\nMacro CONT:\n     0739   2A\nEnd macro CONT\nMacro CONT:\n     073A   21\nEnd macro CONT\nMacro CONT:\n     073B   2E\nEnd macro CONT\nMacro RTOK:\n     073C   9E\nEnd macro RTOK\nMacro RTOK:\n     073D   86\nEnd macro RTOK\nMacro CONT:\n     073E   2A\nEnd macro CONT\nMacro CONT:\n     073F   20\nEnd macro CONT\nMacro CONT:\n     0740   2E\nEnd macro CONT\nMacro CHAR:\n     0741   60\nEnd macro CHAR\nMacro TWOK:\n     0742   BC\nEnd macro TWOK\nMacro TWOK:\n     0743   AE\nEnd macro TWOK\nMacro TWOK:\n     0744   B4\nEnd macro TWOK\nMacro TWOK:\n     0745   BC\nEnd macro TWOK\nMacro CONT:\n     0746   2A\nEnd macro CONT\n     0747   00\nMacro CHAR:\n     0748   6A\nEnd macro CHAR\nMacro TWOK:\n     0749   BF\nEnd macro TWOK\nMacro CHAR:\n     074A   6E\nEnd macro CHAR\n     074B   00\nMacro CHAR:\n     074C   03\nEnd macro CHAR\nMacro CHAR:\n     074D   03\nEnd macro CHAR\nMacro CHAR:\n     074E   6F\nEnd macro CHAR\nMacro CHAR:\n     074F   6C\nEnd macro CHAR\nMacro CHAR:\n     0750   62\nEnd macro CHAR\nMacro CHAR:\n     0751   67\nEnd macro CHAR\nMacro CHAR:\n     0752   03\nEnd macro CHAR\nMacro CHAR:\n     0753   6D\nEnd macro CHAR\nMacro CHAR:\n     0754   66\nEnd macro CHAR\nMacro CHAR:\n     0755   74\nEnd macro CHAR\nMacro CHAR:\n     0756   03\nEnd macro CHAR\nMacro RTOK:\n     0757   DF\nEnd macro RTOK\nMacro CHAR:\n     0758   03\nEnd macro CHAR\nMacro RTOK:\n     0759   C2\nEnd macro RTOK\nMacro CONT:\n     075A   2E\nEnd macro CONT\nMacro CONT:\n     075B   2E\nEnd macro CONT\n     075C   00\nMacro CONT:\n     075D   25\nEnd macro CONT\nMacro RTOK:\n     075E   5F\nEnd macro RTOK\nMacro TWOK:\n     075F   BB\nEnd macro TWOK\n     0760   00\nMacro TWOK:\n     0761   B7\nEnd macro TWOK\nMacro TWOK:\n     0762   B4\nEnd macro TWOK\nMacro CHAR:\n     0763   6D\nEnd macro CHAR\nMacro CHAR:\n     0764   64\nEnd macro CHAR\nMacro CHAR:\n     0765   19\nEnd macro CHAR\n     0766   00\nMacro CHAR:\n     0767   03\nEnd macro CHAR\nMacro TWOK:\n     0768   BC\nEnd macro TWOK\nMacro CHAR:\n     0769   03\nEnd macro CHAR\n     076A   00\nMacro CONT:\n     076B   2E\nEnd macro CONT\nMacro CONT:\n     076C   2B\nEnd macro CONT\nMacro RTOK:\n     076D   EC\nEnd macro RTOK\nMacro CHAR:\n     076E   6E\nEnd macro CHAR\nMacro TWOK:\n     076F   B1\nEnd macro TWOK\nMacro CHAR:\n     0770   77\nEnd macro CHAR\nMacro CHAR:\n     0771   19\nEnd macro CHAR\nMacro CONT:\n     0772   25\nEnd macro CONT\n     0773   00\nMacro CHAR:\n     0774   60\nEnd macro CHAR\nMacro TWOK:\n     0775   A2\nEnd macro TWOK\nMacro TWOK:\n     0776   B8\nEnd macro TWOK\n     0777   00\nMacro CHAR:\n     0778   6C\nEnd macro CHAR\nMacro CHAR:\n     0779   65\nEnd macro CHAR\nMacro CHAR:\n     077A   65\nEnd macro CHAR\nMacro TWOK:\n     077B   B1\nEnd macro TWOK\nMacro CHAR:\n     077C   67\nEnd macro CHAR\nMacro TWOK:\n     077D   B3\nEnd macro TWOK\n     077E   00\nMacro CHAR:\n     077F   65\nEnd macro CHAR\nMacro CHAR:\n     0780   76\nEnd macro CHAR\nMacro CHAR:\n     0781   64\nEnd macro CHAR\nMacro CHAR:\n     0782   6A\nEnd macro CHAR\nMacro TWOK:\n     0783   B4\nEnd macro TWOK\nMacro TWOK:\n     0784   B5\nEnd macro TWOK\n     0785   00\nMacro CHAR:\n     0786   6B\nEnd macro CHAR\nMacro TWOK:\n     0787   A9\nEnd macro TWOK\nMacro CHAR:\n     0788   6E\nEnd macro CHAR\nMacro TWOK:\n     0789   A2\nEnd macro TWOK\nMacro CHAR:\n     078A   70\nEnd macro CHAR\nMacro CHAR:\n     078B   70\nEnd macro CHAR\n     078C   00\nMacro CHAR:\n     078D   6E\nEnd macro CHAR\nMacro CHAR:\n     078E   6C\nEnd macro CHAR\nMacro RTOK:\n     078F   E8\nEnd macro RTOK\nMacro CHAR:\n     0790   6F\nEnd macro CHAR\nMacro CHAR:\n     0791   7A\nEnd macro CHAR\nMacro CHAR:\n     0792   03\nEnd macro CHAR\nMacro RTOK:\n     0793   35\nEnd macro RTOK\n     0794   00\nMacro RTOK:\n     0795   8F\nEnd macro RTOK\n     0796   00\nMacro RTOK:\n     0797   88\nEnd macro RTOK\n     0798   00\nMacro CHAR:\n     0799   62\nEnd macro CHAR\nMacro CHAR:\n     079A   61\nEnd macro CHAR\nMacro CHAR:\n     079B   6C\nEnd macro CHAR\nMacro TWOK:\n     079C   B5\nEnd macro TWOK\nMacro CHAR:\n     079D   03\nEnd macro CHAR\nMacro RTOK:\n     079E   88\nEnd macro RTOK\n     079F   00\nMacro RTOK:\n     07A0   D8\nEnd macro RTOK\nMacro CHAR:\n     07A1   73\nEnd macro CHAR\nMacro CHAR:\n     07A2   66\nEnd macro CHAR\nMacro CHAR:\n     07A3   77\nEnd macro CHAR\nMacro TWOK:\n     07A4   B1\nEnd macro TWOK\nMacro CHAR:\n     07A5   77\nEnd macro CHAR\n     07A6   00\nMacro CHAR:\n     07A7   67\nEnd macro CHAR\nMacro TWOK:\n     07A8   B8\nEnd macro TWOK\nMacro TWOK:\n     07A9   A0\nEnd macro TWOK\nMacro CHAR:\n     07AA   71\nEnd macro CHAR\nMacro CHAR:\n     07AB   6C\nEnd macro CHAR\nMacro TWOK:\n     07AC   AB\nEnd macro TWOK\n     07AD   00\nMacro CHAR:\n     07AE   67\nEnd macro CHAR\nMacro CHAR:\n     07AF   66\nEnd macro CHAR\nMacro CHAR:\n     07B0   62\nEnd macro CHAR\nMacro CHAR:\n     07B1   67\nEnd macro CHAR\nMacro CHAR:\n     07B2   6F\nEnd macro CHAR\nMacro CHAR:\n     07B3   7A\nEnd macro CHAR\n     07B4   00\nMacro CHAR:\n     07B5   0E\nEnd macro CHAR\nMacro CHAR:\n     07B6   0E\nEnd macro CHAR\nMacro CHAR:\n     07B7   0E\nEnd macro CHAR\nMacro CHAR:\n     07B8   0E\nEnd macro CHAR\nMacro CHAR:\n     07B9   03\nEnd macro CHAR\nMacro CHAR:\n     07BA   66\nEnd macro CHAR\nMacro CHAR:\n     07BB   03\nEnd macro CHAR\nMacro CHAR:\n     07BC   6F\nEnd macro CHAR\nMacro CHAR:\n     07BD   03\nEnd macro CHAR\nMacro CHAR:\n     07BE   6A\nEnd macro CHAR\nMacro CHAR:\n     07BF   03\nEnd macro CHAR\nMacro CHAR:\n     07C0   77\nEnd macro CHAR\nMacro CHAR:\n     07C1   03\nEnd macro CHAR\nMacro CHAR:\n     07C2   66\nEnd macro CHAR\nMacro CHAR:\n     07C3   03\nEnd macro CHAR\nMacro CHAR:\n     07C4   0E\nEnd macro CHAR\nMacro CHAR:\n     07C5   0E\nEnd macro CHAR\nMacro CHAR:\n     07C6   0E\nEnd macro CHAR\nMacro CHAR:\n     07C7   0E\nEnd macro CHAR\n     07C8   00\nMacro CHAR:\n     07C9   73\nEnd macro CHAR\nMacro TWOK:\n     07CA   AD\nEnd macro TWOK\nMacro CHAR:\n     07CB   70\nEnd macro CHAR\nMacro TWOK:\n     07CC   B1\nEnd macro TWOK\nMacro CHAR:\n     07CD   77\nEnd macro CHAR\n     07CE   00\nMacro CONT:\n     07CF   2B\nEnd macro CONT\nMacro CHAR:\n     07D0   64\nEnd macro CHAR\nMacro CHAR:\n     07D1   62\nEnd macro CHAR\nMacro CHAR:\n     07D2   6E\nEnd macro CHAR\nMacro CHAR:\n     07D3   66\nEnd macro CHAR\nMacro CHAR:\n     07D4   03\nEnd macro CHAR\nMacro CHAR:\n     07D5   6C\nEnd macro CHAR\nMacro TWOK:\n     07D6   B5\nEnd macro TWOK\nMacro CHAR:\n     07D7   71\nEnd macro CHAR\n     07D8   00\nMacro CHAR:\n     07D9   73\nEnd macro CHAR\nMacro CHAR:\n     07DA   71\nEnd macro CHAR\nMacro TWOK:\n     07DB   AA\nEnd macro TWOK\nMacro CHAR:\n     07DC   70\nEnd macro CHAR\nMacro CHAR:\n     07DD   03\nEnd macro CHAR\nMacro CHAR:\n     07DE   65\nEnd macro CHAR\nMacro CHAR:\n     07DF   6A\nEnd macro CHAR\nMacro TWOK:\n     07E0   AD\nEnd macro TWOK\nMacro CHAR:\n     07E1   03\nEnd macro CHAR\nMacro TWOK:\n     07E2   BA\nEnd macro TWOK\nMacro CHAR:\n     07E3   03\nEnd macro CHAR\nMacro CHAR:\n     07E4   70\nEnd macro CHAR\nMacro CHAR:\n     07E5   73\nEnd macro CHAR\nMacro CHAR:\n     07E6   62\nEnd macro CHAR\nMacro TWOK:\n     07E7   A6\nEnd macro TWOK\nMacro CHAR:\n     07E8   0F\nEnd macro CHAR\nMacro RTOK:\n     07E9   DF\nEnd macro RTOK\nMacro CHAR:\n     07EA   0D\nEnd macro CHAR\nMacro CONT:\n     07EB   2E\nEnd macro CONT\nMacro CONT:\n     07EC   2E\nEnd macro CONT\n     07ED   00\nMacro CHAR:\n     07EE   0B\nEnd macro CHAR\nMacro CHAR:\n     07EF   60\nEnd macro CHAR\nMacro CHAR:\n     07F0   0A\nEnd macro CHAR\nMacro CHAR:\n     07F1   03\nEnd macro CHAR\nMacro CHAR:\n     07F2   62\nEnd macro CHAR\nMacro CHAR:\n     07F3   60\nEnd macro CHAR\nMacro TWOK:\n     07F4   BA\nEnd macro TWOK\nMacro CHAR:\n     07F5   6D\nEnd macro CHAR\nMacro TWOK:\n     07F6   A4\nEnd macro TWOK\nMacro CHAR:\n     07F7   65\nEnd macro CHAR\nMacro CHAR:\n     07F8   77\nEnd macro CHAR\nMacro CHAR:\n     07F9   03\nEnd macro CHAR\nMacro CHAR:\n     07FA   12\nEnd macro CHAR\nMacro CHAR:\n     07FB   1A\nEnd macro CHAR\nMacro CHAR:\n     07FC   1B\nEnd macro CHAR\nMacro CHAR:\n     07FD   17\nEnd macro CHAR\n     07FE   00\nWORDS9\nAssembled at &400 \nEnds at &7FF \nCode size is &3FF \nExecute at &1100 \nReload at &1100 \nS.WORDS9 &400  &7FF  &1100  &1100 \nSaving file '3-assembled-output/WORDS9.bin'\n.K%\n     0900\nK% workspace from &900 to &AAF inclusive\n.WP\n     0D40\n.FRIN\n     0D40\n.CABTMP\n     0D4D\n.MANY\n     0D4D\n.SSPR\n     0D55\n.ECMP\n     0D5B\n.MJ\n     0D5C\n.LAS2\n     0D5D\n.MSAR\n     0D5E\n.VIEW\n     0D5F\n.LASCT\n     0D60\n.GNTMP\n     0D61\n.HFX\n     0D62\n.EV\n     0D63\n.DLY\n     0D64\n.de\n     0D65\n.LSX\n     0D66\n.LSO\n     0D66\n.LSX2\n     0E26\n.LSY2\n     0E74\n.SY\n     0EC2\n.SYL\n     0ED5\n.SZ\n     0EE8\n.SZL\n     0EFB\n.XSAV2\n     0F0E\n.YSAV2\n     0F0F\n.MCH\n     0F10\n.FSH\n     0F11\n.ASH\n     0F12\n.ENERGY\n     0F13\n.LASX\n     0F14\n.LASY\n     0F15\n.COMX\n     0F16\n.COMY\n     0F17\n.QQ24\n     0F18\n.QQ25\n     0F19\n.QQ28\n     0F1A\n.QQ29\n     0F1B\n.gov\n     0F1C\n.tek\n     0F1D\n.SLSP\n     0F1E\n.XX24\n     0F20\n.ALTIT\n     0F21\n.QQ2\n     0F22\n.QQ3\n     0F28\n.QQ4\n     0F29\n.QQ5\n     0F2A\n.QQ6\n     0F2B\n.QQ7\n     0F2D\n.QQ8\n     0F2F\n.QQ9\n     0F31\n.QQ10\n     0F32\n.NOSTM\n     0F33\nWP workspace from &D40 to &F33 inclusive\n.S%\n     0F40   F5 46\n     0F42   81 1F\n     0F44   A6 21\n     0F46   F8 46\n.COMC\n     0F48\n.DNOIZ\n     0F49\n.DAMP\n     0F4A\n.DJD\n     0F4B\n.PATG\n     0F4C\n.FLH\n     0F4D\n.JSTGY\n     0F4E\n.JSTE\n     0F4F\n.JSTK\n     0F50\nS% workspace from &F40 to &F50 inclusive\n.M%\n     0F51   AD 00 09   LDA &0900\n     0F54   85 00      STA &00\n     0F56   A6 9C      LDX &9C\n     0F58   20 5F 29   JSR &295F\n     0F5B   20 5F 29   JSR &295F\n     0F5E   8A         TXA\n     0F5F   49 80      EOR #&80\n     0F61   A8         TAY\n     0F62   29 80      AND #&80\n     0F64   85 88      STA &88\n     0F66   86 9C      STX &9C\n     0F68   49 80      EOR #&80\n     0F6A   85 89      STA &89\n     0F6C   98         TYA\n     0F6D   10 05      BPL &0F74\n     0F6F   49 FF      EOR #&FF\n     0F71   18         CLC\n     0F72   69 01      ADC #&01\n     0F74   4A         LSR A\n     0F75   4A         LSR A\n     0F76   C9 08      CMP #&08\n     0F78   B0 02      BCS &0F7C\n     0F7A   4A         LSR A\n     0F7B   18         CLC\n     0F7C   85 87      STA &87\n     0F7E   05 88      ORA &88\n     0F80   85 9E      STA &9E\n     0F82   A6 9D      LDX &9D\n     0F84   20 5F 29   JSR &295F\n     0F87   8A         TXA\n     0F88   49 80      EOR #&80\n     0F8A   A8         TAY\n     0F8B   29 80      AND #&80\n     0F8D   86 9D      STX &9D\n     0F8F   85 8B      STA &8B\n     0F91   49 80      EOR #&80\n     0F93   85 8A      STA &8A\n     0F95   98         TYA\n     0F96   10 02      BPL &0F9A\n     0F98   49 FF      EOR #&FF\n     0F9A   69 04      ADC #&04\n     0F9C   4A         LSR A\n     0F9D   4A         LSR A\n     0F9E   4A         LSR A\n     0F9F   4A         LSR A\n     0FA0   C9 03      CMP #&03\n     0FA2   B0 01      BCS &0FA5\n     0FA4   4A         LSR A\n     0FA5   85 2B      STA &2B\n     0FA7   05 8A      ORA &8A\n     0FA9   85 2A      STA &2A\n     0FAB   A5 43      LDA &43\n     0FAD   F0 08      BEQ &0FB7\n     0FAF   A5 8C      LDA &8C\n     0FB1   C9 28      CMP #&28\n     0FB3   B0 02      BCS &0FB7\n     0FB5   E6 8C      INC &8C\n.MA17\n     0FB7   A5 42      LDA &42\n     0FB9   F0 06      BEQ &0FC1\n     0FBB   C6 8C      DEC &8C\n     0FBD   D0 02      BNE &0FC1\n     0FBF   E6 8C      INC &8C\n.MA4\n     0FC1   A5 4C      LDA &4C\n     0FC3   2D 33 03   AND &0333\n     0FC6   F0 0F      BEQ &0FD7\n     0FC8   A0 EE      LDY #&EE\n     0FCA   20 07 3D   JSR &3D07\n     0FCD   A9 28      LDA #&28\n     0FCF   20 CD 49   JSR &49CD\n.MA31\n     0FD2   A9 00      LDA #&00\n     0FD4   8D 5E 0D   STA &0D5E\n.MA20\n     0FD7   A5 52      LDA &52\n     0FD9   10 11      BPL &0FEC\n     0FDB   A5 4B      LDA &4B\n     0FDD   F0 0D      BEQ &0FEC\n     0FDF   AE 33 03   LDX &0333\n     0FE2   F0 08      BEQ &0FEC\n     0FE4   8D 5E 0D   STA &0D5E\n     0FE7   A0 E0      LDY #&E0\n     0FE9   20 41 3D   JSR &3D41\n.MA25\n     0FEC   A5 4D      LDA &4D\n     0FEE   F0 07      BEQ &0FF7\n     0FF0   A5 52      LDA &52\n     0FF2   30 2C      BMI &1020\n     0FF4   20 8C 24   JSR &248C\n.MA24\n     0FF7   A5 49      LDA &49\n     0FF9   F0 03      BEQ &0FFE\n     0FFB   0E 2A 03   ASL &032A\n.MA76\n     0FFE   A5 4A      LDA &4A\n     1000   2D 2E 03   AND &032E\n     1003   F0 03      BEQ &1008\n     1005   4C D7 21   JMP &21D7\n     1008   A5 4F      LDA &4F\n     100A   F0 03      BEQ &100F\n     100C   20 FD 29   JSR &29FD\n     100F   A5 4E      LDA &4E\n     1011   2D 28 03   AND &0328\n     1014   F0 0A      BEQ &1020\n     1016   A5 30      LDA &30\n     1018   D0 06      BNE &1020\n     101A   CE 5B 0D   DEC &0D5B\n     101D   20 15 3D   JSR &3D15\n.MA64\n     1020   A5 50      LDA &50\n     1022   2D 2C 03   AND &032C\n     1025   2D 55 0D   AND &0D55\n     1028   F0 08      BEQ &1032\n     102A   AD 44 09   LDA &0944\n     102D   30 03      BMI &1032\n     102F   4C 43 11   JMP &1143\n.MA68\n     1032   A9 00      LDA #&00\n     1034   85 51      STA &51\n     1036   85 8D      STA &8D\n     1038   A5 8C      LDA &8C\n     103A   4A         LSR A\n     103B   66 8D      ROR &8D\n     103D   4A         LSR A\n     103E   66 8D      ROR &8D\n     1040   85 8E      STA &8E\n     1042   AD 60 0D   LDA &0D60\n     1045   D0 2D      BNE &1074\n     1047   A5 48      LDA &48\n     1049   F0 29      BEQ &1074\n     104B   AD 61 0D   LDA &0D61\n     104E   C9 F2      CMP #&F2\n     1050   B0 22      BCS &1074\n     1052   AE 5F 0D   LDX &0D5F\n     1055   BD 10 03   LDA &0310,X\n     1058   F0 1A      BEQ &1074\n     105A   48         PHA\n     105B   29 7F      AND #&7F\n     105D   85 51      STA &51\n     105F   8D 5D 0D   STA &0D5D\n     1062   A9 00      LDA #&00\n     1064   20 CD 49   JSR &49CD\n     1067   20 5B 2A   JSR &2A5B\n     106A   68         PLA\n     106B   10 02      BPL &106F\n     106D   A9 00      LDA #&00\n.ma1\n     106F   29 FA      AND #&FA\n     1071   8D 60 0D   STA &0D60\n.MA3\n     1074   A2 00      LDX #&00\n.MAL1\n     1076   86 93      STX &93\n     1078   BD 40 0D   LDA &0D40,X\n     107B   D0 03      BNE &1080\n     107D   4C 29 12   JMP &1229\n     1080   85 9B      STA &9B\n     1082   20 4F 3C   JSR &3C4F\n     1085   A0 23      LDY #&23\n.MAL2\n     1087   B1 20      LDA (&20),Y\n     1089   99 53 00   STA &0053,Y\n     108C   88         DEY\n     108D   10 F8      BPL &1087\n     108F   A5 9B      LDA &9B\n     1091   30 24      BMI &10B7\n     1093   0A         ASL A\n     1094   A8         TAY\n     1095   B9 38 56   LDA &5638,Y\n     1098   85 1E      STA &1E\n     109A   B9 39 56   LDA &5639,Y\n     109D   85 1F      STA &1F\n     109F   AD 2A 03   LDA &032A\n     10A2   10 13      BPL &10B7\n     10A4   C0 10      CPY #&10\n     10A6   F0 0F      BEQ &10B7\n     10A8   A5 72      LDA &72\n     10AA   29 20      AND #&20\n     10AC   D0 09      BNE &10B7\n     10AE   A5 72      LDA &72\n     10B0   09 80      ORA #&80\n     10B2   85 72      STA &72\n     10B4   20 A5 49   JSR &49A5\n.MA21\n     10B7   20 A9 13   JSR &13A9\n     10BA   A0 23      LDY #&23\n.MAL3\n     10BC   B9 53 00   LDA &0053,Y\n     10BF   91 20      STA (&20),Y\n     10C1   88         DEY\n     10C2   10 F8      BPL &10BC\n     10C4   A5 72      LDA &72\n     10C6   29 A0      AND #&A0\n     10C8   20 78 46   JSR &4678\n     10CB   D0 55      BNE &1122\n     10CD   A5 53      LDA &53\n     10CF   05 56      ORA &56\n     10D1   05 59      ORA &59\n     10D3   30 4D      BMI &1122\n     10D5   A6 9B      LDX &9B\n     10D7   30 49      BMI &1122\n     10D9   E0 08      CPX #&08\n     10DB   F0 48      BEQ &1125\n     10DD   29 C0      AND #&C0\n     10DF   D0 41      BNE &1122\n     10E1   E0 09      CPX #&09\n     10E3   F0 3D      BEQ &1122\n     10E5   E0 0B      CPX #&0B\n     10E7   B0 03      BCS &10EC\n     10E9   4C 6D 11   JMP &116D\n     10EC   AD 29 03   LDA &0329\n     10EF   25 58      AND &58\n     10F1   10 7A      BPL &116D\n     10F3   A9 03      LDA #&03\n     10F5   E0 0C      CPX #&0C\n     10F7   90 06      BCC &10FF\n     10F9   D0 09      BNE &1104\n     10FB   A9 10      LDA #&10\n     10FD   D0 05      BNE &1104\n.oily\n     10FF   20 57 44   JSR &4457\n     1102   29 07      AND #&07\n.slvy2\n     1104   8D 1B 0F   STA &0F1B\n     1107   A9 01      LDA #&01\n     1109   20 C8 2C   JSR &2CC8\n     110C   A0 4E      LDY #&4E\n     110E   B0 4B      BCS &115B\n     1110   AC 1B 0F   LDY &0F1B\n     1113   79 17 03   ADC &0317,Y\n     1116   99 17 03   STA &0317,Y\n     1119   98         TYA\n     111A   69 D0      ADC #&D0\n     111C   20 29 4B   JSR &4B29\n     111F   4C 5E 11   JMP &115E\n.MA65\n     1122   4C 7C 11   JMP &117C\n.ISDK\n     1125   AD 44 09   LDA &0944\n     1128   30 28      BMI &1152\n     112A   A5 61      LDA &61\n     112C   C9 D6      CMP #&D6\n     112E   90 22      BCC &1152\n     1130   20 7D 3B   JSR &3B7D\n     1133   A5 33      LDA &33\n     1135   30 1B      BMI &1152\n     1137   C9 59      CMP #&59\n     1139   90 17      BCC &1152\n     113B   A5 63      LDA &63\n     113D   29 7F      AND #&7F\n     113F   C9 50      CMP #&50\n     1141   90 0F      BCC &1152\n.GOIN\n     1143   A9 00      LDA #&00\n     1145   85 2F      STA &2F\n     1147   A9 08      LDA #&08\n     1149   20 76 25   JSR &2576\n     114C   20 A7 43   JSR &43A7\n     114F   4C 4D 47   JMP &474D\n.MA62\n     1152   A5 8C      LDA &8C\n     1154   C9 05      CMP #&05\n     1156   90 0D      BCC &1165\n     1158   4C 7F 46   JMP &467F\n.MA59\n     115B   20 8C 49   JSR &498C\n.MA60\n     115E   06 72      ASL &72\n     1160   38         SEC\n     1161   66 72      ROR &72\n.MA61\n     1163   D0 17      BNE &117C\n.MA67\n     1165   A9 01      LDA #&01\n     1167   85 8C      STA &8C\n     1169   A9 05      LDA #&05\n     116B   D0 09      BNE &1176\n.MA58\n     116D   06 72      ASL &72\n     116F   38         SEC\n     1170   66 72      ROR &72\n     1172   A5 76      LDA &76\n     1174   38         SEC\n     1175   6A         ROR A\n.MA63\n     1176   20 01 3C   JSR &3C01\n     1179   20 8C 49   JSR &498C\n.MA26\n     117C   A5 96      LDA &96\n     117E   D0 5A      BNE &11DA\n     1180   20 AF 2A   JSR &2AAF\n     1183   20 27 24   JSR &2427\n     1186   90 4F      BCC &11D7\n     1188   AD 5E 0D   LDA &0D5E\n     118B   F0 0A      BEQ &1197\n     118D   20 CB 49   JSR &49CB\n     1190   A6 93      LDX &93\n     1192   A0 0E      LDY #&0E\n     1194   20 09 3D   JSR &3D09\n.MA47\n     1197   A5 51      LDA &51\n     1199   F0 3C      BEQ &11D7\n     119B   A2 0F      LDX #&0F\n     119D   20 B4 49   JSR &49B4\n     11A0   A5 76      LDA &76\n     11A2   38         SEC\n     11A3   E5 51      SBC &51\n     11A5   B0 29      BCS &11D0\n     11A7   A5 9B      LDA &9B\n     11A9   C9 08      CMP #&08\n     11AB   F0 25      BEQ &11D2\n     11AD   A5 72      LDA &72\n     11AF   09 80      ORA #&80\n     11B1   85 72      STA &72\n     11B3   B0 22      BCS &11D7\n     11B5   20 57 44   JSR &4457\n     11B8   10 13      BPL &11CD\n     11BA   A0 00      LDY #&00\n     11BC   31 1E      AND (&1E),Y\n     11BE   85 A4      STA &A4\n.um\n     11C0   F0 0B      BEQ &11CD\n     11C2   A2 0B      LDX #&0B\n     11C4   A9 00      LDA #&00\n     11C6   20 E0 24   JSR &24E0\n     11C9   C6 A4      DEC &A4\n     11CB   10 F3      BPL &11C0\n.oh\n     11CD   20 A5 49   JSR &49A5\n.MA14\n     11D0   85 76      STA &76\n     11D2   A5 9B      LDA &9B\n     11D4   20 AB 24   JSR &24AB\n.MA8\n     11D7   20 2F 4E   JSR &4E2F\n.MA15\n     11DA   A0 23      LDY #&23\n     11DC   A5 76      LDA &76\n     11DE   91 20      STA (&20),Y\n     11E0   A5 72      LDA &72\n     11E2   10 30      BPL &1214\n     11E4   29 20      AND #&20\n     11E6   F0 2C      BEQ &1214\n     11E8   A5 9B      LDA &9B\n     11EA   C9 02      CMP #&02\n     11EC   D0 08      BNE &11F6\n     11EE   AD 34 03   LDA &0334\n     11F1   09 40      ORA #&40\n     11F3   8D 34 03   STA &0334\n.q2\n     11F6   AD 64 0D   LDA &0D64\n     11F9   0D 5C 0D   ORA &0D5C\n     11FC   D0 13      BNE &1211\n     11FE   A0 0A      LDY #&0A\n     1200   B1 1E      LDA (&1E),Y\n     1202   F0 0D      BEQ &1211\n     1204   AA         TAX\n     1205   C8         INY\n     1206   B1 1E      LDA (&1E),Y\n     1208   A8         TAY\n     1209   20 18 36   JSR &3618\n     120C   A9 00      LDA #&00\n     120E   20 29 4B   JSR &4B29\n.KS1S\n     1211   4C 81 42   JMP &4281\n.NBOUN\n.MAC1\n     1214   A5 9B      LDA &9B\n     1216   30 05      BMI &121D\n     1218   20 6B 46   JSR &466B\n     121B   90 F4      BCC &1211\n.MA27\n     121D   A0 1F      LDY #&1F\n     121F   A5 72      LDA &72\n     1221   91 20      STA (&20),Y\n     1223   A6 93      LDX &93\n     1225   E8         INX\n     1226   4C 76 10   JMP &1076\n.MA18\n     1229   AD 2A 03   LDA &032A\n     122C   10 0B      BPL &1239\n     122E   0E 2A 03   ASL &032A\n     1231   20 BF 2C   JSR &2CBF\n     1234   A9 30      LDA #&30\n     1236   8D 21 FE   STA &FE21\n.MA77\n     1239   A5 99      LDA &99\n     123B   29 07      AND #&07\n     123D   D0 71      BNE &12B0\n     123F   AE 13 0F   LDX &0F13\n     1242   10 12      BPL &1256\n     1244   AE 12 0F   LDX &0F12\n     1247   20 43 3B   JSR &3B43\n     124A   8E 12 0F   STX &0F12\n     124D   AE 11 0F   LDX &0F11\n     1250   20 43 3B   JSR &3B43\n     1253   8E 11 0F   STX &0F11\n.b\n     1256   38         SEC\n     1257   AD 2B 03   LDA &032B\n     125A   6D 13 0F   ADC &0F13\n     125D   B0 03      BCS &1262\n     125F   8D 13 0F   STA &0F13\n     1262   AD 5C 0D   LDA &0D5C\n     1265   D0 46      BNE &12AD\n     1267   A5 99      LDA &99\n     1269   29 1F      AND #&1F\n     126B   D0 4C      BNE &12B9\n     126D   AD 55 0D   LDA &0D55\n     1270   D0 3B      BNE &12AD\n     1272   A8         TAY\n     1273   20 7C 13   JSR &137C\n     1276   D0 35      BNE &12AD\n     1278   A2 1C      LDX #&1C\n.MAL4\n     127A   BD 00 09   LDA &0900,X\n     127D   95 53      STA &53,X\n     127F   CA         DEX\n     1280   10 F8      BPL &127A\n     1282   E8         INX\n     1283   A0 09      LDY #&09\n     1285   20 59 13   JSR &1359\n     1288   D0 23      BNE &12AD\n     128A   A2 03      LDX #&03\n     128C   A0 0B      LDY #&0B\n     128E   20 59 13   JSR &1359\n     1291   D0 1A      BNE &12AD\n     1293   A2 06      LDX #&06\n     1295   A0 0D      LDY #&0D\n     1297   20 59 13   JSR &1359\n     129A   D0 11      BNE &12AD\n     129C   A9 C0      LDA #&C0\n     129E   20 6D 46   JSR &466D\n     12A1   90 0A      BCC &12AD\n     12A3   A5 96      LDA &96\n     12A5   D0 03      BNE &12AA\n     12A7   20 36 41   JSR &4136\n     12AA   20 5D 3C   JSR &3C5D\n.MA23S\n     12AD   4C 29 13   JMP &1329\n.MA22\n     12B0   AD 5C 0D   LDA &0D5C\n     12B3   D0 74      BNE &1329\n     12B5   A5 99      LDA &99\n     12B7   29 1F      AND #&1F\n.MA93\n     12B9   C9 0A      CMP #&0A\n     12BB   D0 2E      BNE &12EB\n     12BD   A9 32      LDA #&32\n     12BF   CD 13 0F   CMP &0F13\n     12C2   90 04      BCC &12C8\n     12C4   0A         ASL A\n     12C5   20 29 4B   JSR &4B29\n     12C8   A0 FF      LDY #&FF\n     12CA   8C 21 0F   STY &0F21\n     12CD   C8         INY\n     12CE   20 7A 13   JSR &137A\n     12D1   D0 56      BNE &1329\n     12D3   20 88 13   JSR &1388\n     12D6   B0 51      BCS &1329\n     12D8   E9 24      SBC #&24\n     12DA   90 0C      BCC &12E8\n     12DC   85 91      STA &91\n     12DE   20 5B 4D   JSR &4D5B\n     12E1   A5 90      LDA &90\n     12E3   8D 21 0F   STA &0F21\n     12E6   D0 41      BNE &1329\n.MA28\n     12E8   4C 7F 46   JMP &467F\n.MA29\n     12EB   C9 14      CMP #&14\n     12ED   D0 3A      BNE &1329\n     12EF   A9 1E      LDA #&1E\n     12F1   8D 4D 0D   STA &0D4D\n     12F4   AD 55 0D   LDA &0D55\n     12F7   D0 30      BNE &1329\n     12F9   A0 24      LDY #&24\n     12FB   20 7C 13   JSR &137C\n     12FE   D0 29      BNE &1329\n     1300   20 88 13   JSR &1388\n     1303   49 FF      EOR #&FF\n     1305   69 1E      ADC #&1E\n     1307   8D 4D 0D   STA &0D4D\n     130A   B0 DC      BCS &12E8\n     130C   C9 E0      CMP #&E0\n     130E   90 19      BCC &1329\n     1310   AD 29 03   LDA &0329\n     1313   F0 14      BEQ &1329\n     1315   A5 8E      LDA &8E\n     1317   4A         LSR A\n     1318   6D 0D 03   ADC &030D\n     131B   C9 46      CMP #&46\n     131D   90 02      BCC &1321\n     131F   A9 46      LDA #&46\n     1321   8D 0D 03   STA &030D\n     1324   A9 A0      LDA #&A0\n     1326   20 29 4B   JSR &4B29\n.MA23\n     1329   AD 5D 0D   LDA &0D5D\n     132C   F0 0F      BEQ &133D\n     132E   AD 60 0D   LDA &0D60\n     1331   C9 08      CMP #&08\n     1333   B0 08      BCS &133D\n     1335   20 7A 2A   JSR &2A7A\n     1338   A9 00      LDA #&00\n     133A   8D 5D 0D   STA &0D5D\n.MA16\n     133D   AD 5B 0D   LDA &0D5B\n     1340   F0 05      BEQ &1347\n     1342   20 46 3B   JSR &3B46\n     1345   F0 08      BEQ &134F\n.MA69\n     1347   A5 30      LDA &30\n     1349   F0 07      BEQ &1352\n     134B   C6 30      DEC &30\n     134D   D0 03      BNE &1352\n.MA70\n     134F   20 7E 49   JSR &497E\n.MA66\n     1352   A5 96      LDA &96\n     1354   D0 23      BNE &1379\n     1356   4C D2 1B   JMP &1BD2\n.MAS1\n     1359   B9 53 00   LDA &0053,Y\n     135C   0A         ASL A\n     135D   85 3E      STA &3E\n     135F   B9 54 00   LDA &0054,Y\n     1362   2A         ROL A\n     1363   85 3F      STA &3F\n     1365   A9 00      LDA #&00\n     1367   6A         ROR A\n     1368   85 40      STA &40\n     136A   20 AA 15   JSR &15AA\n     136D   95 55      STA &55,X\n     136F   A4 3E      LDY &3E\n     1371   94 53      STY &53,X\n     1373   A4 3F      LDY &3F\n     1375   94 54      STY &54,X\n     1377   29 7F      AND #&7F\n.MA9\n     1379   60         RTS\n.m\n     137A   A9 00      LDA #&00\n.MAS2\n     137C   19 02 09   ORA &0902,Y\n     137F   19 05 09   ORA &0905,Y\n     1382   19 08 09   ORA &0908,Y\n     1385   29 7F      AND #&7F\n     1387   60         RTS\n.MAS3\n     1388   B9 01 09   LDA &0901,Y\n     138B   20 6F 27   JSR &276F\n     138E   85 91      STA &91\n     1390   B9 04 09   LDA &0904,Y\n     1393   20 6F 27   JSR &276F\n     1396   65 91      ADC &91\n     1398   B0 0C      BCS &13A6\n     139A   85 91      STA &91\n     139C   B9 07 09   LDA &0907,Y\n     139F   20 6F 27   JSR &276F\n     13A2   65 91      ADC &91\n     13A4   90 02      BCC &13A8\n.MA30\n     13A6   A9 FF      LDA #&FF\n     13A8   60         RTS\n.MVEIT\n     13A9   A5 72      LDA &72\n     13AB   29 A0      AND #&A0\n     13AD   D0 25      BNE &13D4\n     13AF   A5 99      LDA &99\n     13B1   45 93      EOR &93\n     13B3   29 0F      AND #&0F\n     13B5   D0 03      BNE &13BA\n     13B7   20 1C 4C   JSR &4C1C\n.MV3\n     13BA   A6 9B      LDX &9B\n     13BC   10 03      BPL &13C1\n     13BE   4C 2E 17   JMP &172E\n     13C1   A5 73      LDA &73\n     13C3   10 0F      BPL &13D4\n     13C5   E0 09      CPX #&09\n     13C7   F0 08      BEQ &13D1\n     13C9   A5 99      LDA &99\n     13CB   45 93      EOR &93\n     13CD   29 07      AND #&07\n     13CF   D0 03      BNE &13D4\n.MV26\n     13D1   20 9F 22   JSR &229F\n.MV30\n     13D4   20 20 2C   JSR &2C20\n     13D7   A5 6E      LDA &6E\n     13D9   0A         ASL A\n     13DA   0A         ASL A\n     13DB   85 90      STA &90\n     13DD   A5 5D      LDA &5D\n     13DF   29 7F      AND #&7F\n     13E1   20 A9 27   JSR &27A9\n     13E4   85 91      STA &91\n     13E6   A5 5D      LDA &5D\n     13E8   A2 00      LDX #&00\n     13EA   20 53 15   JSR &1553\n     13ED   A5 5F      LDA &5F\n     13EF   29 7F      AND #&7F\n     13F1   20 A9 27   JSR &27A9\n     13F4   85 91      STA &91\n     13F6   A5 5F      LDA &5F\n     13F8   A2 03      LDX #&03\n     13FA   20 53 15   JSR &1553\n     13FD   A5 61      LDA &61\n     13FF   29 7F      AND #&7F\n     1401   20 A9 27   JSR &27A9\n     1404   85 91      STA &91\n     1406   A5 61      LDA &61\n     1408   A2 06      LDX #&06\n     140A   20 53 15   JSR &1553\n     140D   A5 6E      LDA &6E\n     140F   18         CLC\n     1410   65 6F      ADC &6F\n     1412   10 02      BPL &1416\n     1414   A9 00      LDA #&00\n     1416   A0 0F      LDY #&0F\n     1418   D1 1E      CMP (&1E),Y\n     141A   90 02      BCC &141E\n     141C   B1 1E      LDA (&1E),Y\n     141E   85 6E      STA &6E\n     1420   A9 00      LDA #&00\n     1422   85 6F      STA &6F\n     1424   A6 87      LDX &87\n     1426   A5 53      LDA &53\n     1428   49 FF      EOR #&FF\n     142A   85 1B      STA &1B\n     142C   A5 54      LDA &54\n     142E   20 D9 27   JSR &27D9\n     1431   85 1D      STA &1D\n     1433   A5 89      LDA &89\n     1435   45 55      EOR &55\n     1437   A2 03      LDX #&03\n     1439   20 F9 16   JSR &16F9\n     143C   85 AF      STA &AF\n     143E   A5 1C      LDA &1C\n     1440   85 AD      STA &AD\n     1442   49 FF      EOR #&FF\n     1444   85 1B      STA &1B\n     1446   A5 1D      LDA &1D\n     1448   85 AE      STA &AE\n     144A   A6 2B      LDX &2B\n     144C   20 D9 27   JSR &27D9\n     144F   85 1D      STA &1D\n     1451   A5 AF      LDA &AF\n     1453   45 8A      EOR &8A\n     1455   A2 06      LDX #&06\n     1457   20 F9 16   JSR &16F9\n     145A   85 5B      STA &5B\n     145C   A5 1C      LDA &1C\n     145E   85 59      STA &59\n     1460   49 FF      EOR #&FF\n     1462   85 1B      STA &1B\n     1464   A5 1D      LDA &1D\n     1466   85 5A      STA &5A\n     1468   20 DB 27   JSR &27DB\n     146B   85 1D      STA &1D\n     146D   A5 AF      LDA &AF\n     146F   85 58      STA &58\n     1471   45 8A      EOR &8A\n     1473   45 5B      EOR &5B\n     1475   10 0F      BPL &1486\n     1477   A5 1C      LDA &1C\n     1479   65 AD      ADC &AD\n     147B   85 56      STA &56\n     147D   A5 1D      LDA &1D\n     147F   65 AE      ADC &AE\n     1481   85 57      STA &57\n     1483   4C A6 14   JMP &14A6\n.MV43\n     1486   A5 AD      LDA &AD\n     1488   E5 1C      SBC &1C\n     148A   85 56      STA &56\n     148C   A5 AE      LDA &AE\n     148E   E5 1D      SBC &1D\n     1490   85 57      STA &57\n     1492   B0 12      BCS &14A6\n     1494   A9 01      LDA #&01\n     1496   E5 56      SBC &56\n     1498   85 56      STA &56\n     149A   A9 00      LDA #&00\n     149C   E5 57      SBC &57\n     149E   85 57      STA &57\n     14A0   A5 58      LDA &58\n     14A2   49 80      EOR #&80\n     14A4   85 58      STA &58\n.MV44\n     14A6   A6 87      LDX &87\n     14A8   A5 56      LDA &56\n     14AA   49 FF      EOR #&FF\n     14AC   85 1B      STA &1B\n     14AE   A5 57      LDA &57\n     14B0   20 D9 27   JSR &27D9\n     14B3   85 1D      STA &1D\n     14B5   A5 88      LDA &88\n     14B7   45 58      EOR &58\n     14B9   A2 00      LDX #&00\n     14BB   20 F9 16   JSR &16F9\n     14BE   85 55      STA &55\n     14C0   A5 1D      LDA &1D\n     14C2   85 54      STA &54\n     14C4   A5 1C      LDA &1C\n     14C6   85 53      STA &53\n.MV45\n     14C8   A5 8C      LDA &8C\n     14CA   85 91      STA &91\n     14CC   A9 80      LDA #&80\n     14CE   A2 06      LDX #&06\n     14D0   20 55 15   JSR &1555\n     14D3   A5 9B      LDA &9B\n     14D5   29 81      AND #&81\n     14D7   C9 81      CMP #&81\n     14D9   D0 01      BNE &14DC\n     14DB   60         RTS\n     14DC   A0 09      LDY #&09\n     14DE   20 06 16   JSR &1606\n     14E1   A0 0F      LDY #&0F\n     14E3   20 06 16   JSR &1606\n     14E6   A0 15      LDY #&15\n     14E8   20 06 16   JSR &1606\n     14EB   A5 71      LDA &71\n     14ED   29 80      AND #&80\n     14EF   85 AB      STA &AB\n     14F1   A5 71      LDA &71\n     14F3   29 7F      AND #&7F\n     14F5   F0 1D      BEQ &1514\n     14F7   C9 7F      CMP #&7F\n     14F9   E9 00      SBC #&00\n     14FB   05 AB      ORA &AB\n     14FD   85 71      STA &71\n     14FF   A2 0F      LDX #&0F\n     1501   A0 09      LDY #&09\n     1503   20 6D 16   JSR &166D\n     1506   A2 11      LDX #&11\n     1508   A0 0B      LDY #&0B\n     150A   20 6D 16   JSR &166D\n     150D   A2 13      LDX #&13\n     150F   A0 0D      LDY #&0D\n     1511   20 6D 16   JSR &166D\n.MV8\n     1514   A5 70      LDA &70\n     1516   29 80      AND #&80\n     1518   85 AB      STA &AB\n     151A   A5 70      LDA &70\n     151C   29 7F      AND #&7F\n     151E   F0 1D      BEQ &153D\n     1520   C9 7F      CMP #&7F\n     1522   E9 00      SBC #&00\n     1524   05 AB      ORA &AB\n     1526   85 70      STA &70\n     1528   A2 0F      LDX #&0F\n     152A   A0 15      LDY #&15\n     152C   20 6D 16   JSR &166D\n     152F   A2 11      LDX #&11\n     1531   A0 17      LDY #&17\n     1533   20 6D 16   JSR &166D\n     1536   A2 13      LDX #&13\n     1538   A0 19      LDY #&19\n     153A   20 6D 16   JSR &166D\n.MV5\n     153D   A5 72      LDA &72\n     153F   29 A0      AND #&A0\n     1541   D0 09      BNE &154C\n     1543   A5 72      LDA &72\n     1545   09 10      ORA #&10\n     1547   85 72      STA &72\n     1549   4C 20 2C   JMP &2C20\n.MVD1\n     154C   A5 72      LDA &72\n     154E   29 EF      AND #&EF\n     1550   85 72      STA &72\n     1552   60         RTS\n     1553   29 80      AND #&80\n.MVT1\n     1555   0A         ASL A\n     1556   85 92      STA &92\n     1558   A9 00      LDA #&00\n     155A   6A         ROR A\n     155B   85 D1      STA &D1\n     155D   46 92      LSR &92\n     155F   55 55      EOR &55,X\n     1561   30 15      BMI &1578\n     1563   A5 91      LDA &91\n     1565   75 53      ADC &53,X\n     1567   95 53      STA &53,X\n     1569   A5 92      LDA &92\n     156B   75 54      ADC &54,X\n     156D   95 54      STA &54,X\n     156F   B5 55      LDA &55,X\n     1571   69 00      ADC #&00\n     1573   05 D1      ORA &D1\n     1575   95 55      STA &55,X\n     1577   60         RTS\n.MV10\n     1578   B5 53      LDA &53,X\n     157A   38         SEC\n     157B   E5 91      SBC &91\n     157D   95 53      STA &53,X\n     157F   B5 54      LDA &54,X\n     1581   E5 92      SBC &92\n     1583   95 54      STA &54,X\n     1585   B5 55      LDA &55,X\n     1587   29 7F      AND #&7F\n     1589   E9 00      SBC #&00\n     158B   09 80      ORA #&80\n     158D   45 D1      EOR &D1\n     158F   95 55      STA &55,X\n     1591   B0 16      BCS &15A9\n     1593   A9 01      LDA #&01\n     1595   F5 53      SBC &53,X\n     1597   95 53      STA &53,X\n     1599   A9 00      LDA #&00\n     159B   F5 54      SBC &54,X\n     159D   95 54      STA &54,X\n     159F   A9 00      LDA #&00\n     15A1   F5 55      SBC &55,X\n     15A3   29 7F      AND #&7F\n     15A5   05 D1      ORA &D1\n     15A7   95 55      STA &55,X\n.MV11\n     15A9   60         RTS\n.MVT3\n     15AA   A5 40      LDA &40\n     15AC   85 92      STA &92\n     15AE   29 80      AND #&80\n     15B0   85 D1      STA &D1\n     15B2   55 55      EOR &55,X\n     15B4   30 18      BMI &15CE\n     15B6   A5 3E      LDA &3E\n     15B8   18         CLC\n     15B9   75 53      ADC &53,X\n     15BB   85 3E      STA &3E\n     15BD   A5 3F      LDA &3F\n     15BF   75 54      ADC &54,X\n     15C1   85 3F      STA &3F\n     15C3   A5 40      LDA &40\n     15C5   75 55      ADC &55,X\n     15C7   29 7F      AND #&7F\n     15C9   05 D1      ORA &D1\n     15CB   85 40      STA &40\n     15CD   60         RTS\n.MV13\n     15CE   A5 92      LDA &92\n     15D0   29 7F      AND #&7F\n     15D2   85 92      STA &92\n     15D4   B5 53      LDA &53,X\n     15D6   38         SEC\n     15D7   E5 3E      SBC &3E\n     15D9   85 3E      STA &3E\n     15DB   B5 54      LDA &54,X\n     15DD   E5 3F      SBC &3F\n     15DF   85 3F      STA &3F\n     15E1   B5 55      LDA &55,X\n     15E3   29 7F      AND #&7F\n     15E5   E5 92      SBC &92\n     15E7   09 80      ORA #&80\n     15E9   45 D1      EOR &D1\n     15EB   85 40      STA &40\n     15ED   B0 16      BCS &1605\n     15EF   A9 01      LDA #&01\n     15F1   E5 3E      SBC &3E\n     15F3   85 3E      STA &3E\n     15F5   A9 00      LDA #&00\n     15F7   E5 3F      SBC &3F\n     15F9   85 3F      STA &3F\n     15FB   A9 00      LDA #&00\n     15FD   E5 40      SBC &40\n     15FF   29 7F      AND #&7F\n     1601   05 D1      ORA &D1\n     1603   85 40      STA &40\n.MV14\n     1605   60         RTS\n.MVS4\n     1606   A5 9E      LDA &9E\n     1608   85 90      STA &90\n     160A   B6 55      LDX &55,Y\n     160C   86 91      STX &91\n     160E   B6 56      LDX &56,Y\n     1610   86 92      STX &92\n     1612   B6 53      LDX &53,Y\n     1614   86 1B      STX &1B\n     1616   B9 54 00   LDA &0054,Y\n     1619   49 80      EOR #&80\n     161B   20 5C 28   JSR &285C\n     161E   99 56 00   STA &0056,Y\n     1621   96 55      STX &55,Y\n     1623   86 1B      STX &1B\n     1625   B6 53      LDX &53,Y\n     1627   86 91      STX &91\n     1629   B6 54      LDX &54,Y\n     162B   86 92      STX &92\n     162D   B9 56 00   LDA &0056,Y\n     1630   20 5C 28   JSR &285C\n     1633   99 54 00   STA &0054,Y\n     1636   96 53      STX &53,Y\n     1638   86 1B      STX &1B\n     163A   A5 2A      LDA &2A\n     163C   85 90      STA &90\n     163E   B6 55      LDX &55,Y\n     1640   86 91      STX &91\n     1642   B6 56      LDX &56,Y\n     1644   86 92      STX &92\n     1646   B6 57      LDX &57,Y\n     1648   86 1B      STX &1B\n     164A   B9 58 00   LDA &0058,Y\n     164D   49 80      EOR #&80\n     164F   20 5C 28   JSR &285C\n     1652   99 56 00   STA &0056,Y\n     1655   96 55      STX &55,Y\n     1657   86 1B      STX &1B\n     1659   B6 57      LDX &57,Y\n     165B   86 91      STX &91\n     165D   B6 58      LDX &58,Y\n     165F   86 92      STX &92\n     1661   B9 56 00   LDA &0056,Y\n     1664   20 5C 28   JSR &285C\n     1667   99 58 00   STA &0058,Y\n     166A   96 57      STX &57,Y\n     166C   60         RTS\n.MVS5\n     166D   B5 54      LDA &54,X\n     166F   29 7F      AND #&7F\n     1671   4A         LSR A\n     1672   85 D1      STA &D1\n     1674   B5 53      LDA &53,X\n     1676   38         SEC\n     1677   E5 D1      SBC &D1\n     1679   85 91      STA &91\n     167B   B5 54      LDA &54,X\n     167D   E9 00      SBC #&00\n     167F   85 92      STA &92\n     1681   B9 53 00   LDA &0053,Y\n     1684   85 1B      STA &1B\n     1686   B9 54 00   LDA &0054,Y\n     1689   29 80      AND #&80\n     168B   85 D1      STA &D1\n     168D   B9 54 00   LDA &0054,Y\n     1690   29 7F      AND #&7F\n     1692   4A         LSR A\n     1693   66 1B      ROR &1B\n     1695   4A         LSR A\n     1696   66 1B      ROR &1B\n     1698   4A         LSR A\n     1699   66 1B      ROR &1B\n     169B   4A         LSR A\n     169C   66 1B      ROR &1B\n     169E   05 D1      ORA &D1\n     16A0   45 AB      EOR &AB\n     16A2   86 90      STX &90\n     16A4   20 5F 28   JSR &285F\n     16A7   85 3E      STA &3E\n     16A9   86 3D      STX &3D\n     16AB   A6 90      LDX &90\n     16AD   B9 54 00   LDA &0054,Y\n     16B0   29 7F      AND #&7F\n     16B2   4A         LSR A\n     16B3   85 D1      STA &D1\n     16B5   B9 53 00   LDA &0053,Y\n     16B8   38         SEC\n     16B9   E5 D1      SBC &D1\n     16BB   85 91      STA &91\n     16BD   B9 54 00   LDA &0054,Y\n     16C0   E9 00      SBC #&00\n     16C2   85 92      STA &92\n     16C4   B5 53      LDA &53,X\n     16C6   85 1B      STA &1B\n     16C8   B5 54      LDA &54,X\n     16CA   29 80      AND #&80\n     16CC   85 D1      STA &D1\n     16CE   B5 54      LDA &54,X\n     16D0   29 7F      AND #&7F\n     16D2   4A         LSR A\n     16D3   66 1B      ROR &1B\n     16D5   4A         LSR A\n     16D6   66 1B      ROR &1B\n     16D8   4A         LSR A\n     16D9   66 1B      ROR &1B\n     16DB   4A         LSR A\n     16DC   66 1B      ROR &1B\n     16DE   05 D1      ORA &D1\n     16E0   49 80      EOR #&80\n     16E2   45 AB      EOR &AB\n     16E4   86 90      STX &90\n     16E6   20 5F 28   JSR &285F\n     16E9   99 54 00   STA &0054,Y\n     16EC   96 53      STX &53,Y\n     16EE   A6 90      LDX &90\n     16F0   A5 3D      LDA &3D\n     16F2   95 53      STA &53,X\n     16F4   A5 3E      LDA &3E\n     16F6   95 54      STA &54,X\n     16F8   60         RTS\n.MVT6\n     16F9   A8         TAY\n     16FA   55 55      EOR &55,X\n     16FC   30 0F      BMI &170D\n     16FE   A5 1C      LDA &1C\n     1700   18         CLC\n     1701   75 53      ADC &53,X\n     1703   85 1C      STA &1C\n     1705   A5 1D      LDA &1D\n     1707   75 54      ADC &54,X\n     1709   85 1D      STA &1D\n     170B   98         TYA\n     170C   60         RTS\n.MV50\n     170D   B5 53      LDA &53,X\n     170F   38         SEC\n     1710   E5 1C      SBC &1C\n     1712   85 1C      STA &1C\n     1714   B5 54      LDA &54,X\n     1716   E5 1D      SBC &1D\n     1718   85 1D      STA &1D\n     171A   90 04      BCC &1720\n     171C   98         TYA\n     171D   49 80      EOR #&80\n     171F   60         RTS\n.MV51\n     1720   A9 01      LDA #&01\n     1722   E5 1C      SBC &1C\n     1724   85 1C      STA &1C\n     1726   A9 00      LDA #&00\n     1728   E5 1D      SBC &1D\n     172A   85 1D      STA &1D\n     172C   98         TYA\n     172D   60         RTS\n.MV40\n     172E   A5 9E      LDA &9E\n     1730   49 80      EOR #&80\n     1732   85 90      STA &90\n     1734   A5 53      LDA &53\n     1736   85 1B      STA &1B\n     1738   A5 54      LDA &54\n     173A   85 1C      STA &1C\n     173C   A5 55      LDA &55\n     173E   20 E4 26   JSR &26E4\n     1741   A2 03      LDX #&03\n     1743   20 AA 15   JSR &15AA\n     1746   A5 3E      LDA &3E\n     1748   85 AD      STA &AD\n     174A   85 1B      STA &1B\n     174C   A5 3F      LDA &3F\n     174E   85 AE      STA &AE\n     1750   85 1C      STA &1C\n     1752   A5 2A      LDA &2A\n     1754   85 90      STA &90\n     1756   A5 40      LDA &40\n     1758   85 AF      STA &AF\n     175A   20 E4 26   JSR &26E4\n     175D   A2 06      LDX #&06\n     175F   20 AA 15   JSR &15AA\n     1762   A5 3E      LDA &3E\n     1764   85 1B      STA &1B\n     1766   85 59      STA &59\n     1768   A5 3F      LDA &3F\n     176A   85 1C      STA &1C\n     176C   85 5A      STA &5A\n     176E   A5 40      LDA &40\n     1770   85 5B      STA &5B\n     1772   49 80      EOR #&80\n     1774   20 E4 26   JSR &26E4\n     1777   A5 40      LDA &40\n     1779   29 80      AND #&80\n     177B   85 D1      STA &D1\n     177D   45 AF      EOR &AF\n     177F   30 17      BMI &1798\n     1781   A5 3D      LDA &3D\n     1783   65 AC      ADC &AC\n     1785   A5 3E      LDA &3E\n     1787   65 AD      ADC &AD\n     1789   85 56      STA &56\n     178B   A5 3F      LDA &3F\n     178D   65 AE      ADC &AE\n     178F   85 57      STA &57\n     1791   A5 40      LDA &40\n     1793   65 AF      ADC &AF\n     1795   4C CB 17   JMP &17CB\n.MV1\n     1798   A5 3D      LDA &3D\n     179A   38         SEC\n     179B   E5 AC      SBC &AC\n     179D   A5 3E      LDA &3E\n     179F   E5 AD      SBC &AD\n     17A1   85 56      STA &56\n     17A3   A5 3F      LDA &3F\n     17A5   E5 AE      SBC &AE\n     17A7   85 57      STA &57\n     17A9   A5 AF      LDA &AF\n     17AB   29 7F      AND #&7F\n     17AD   85 1B      STA &1B\n     17AF   A5 40      LDA &40\n     17B1   29 7F      AND #&7F\n     17B3   E5 1B      SBC &1B\n     17B5   85 1B      STA &1B\n     17B7   B0 12      BCS &17CB\n     17B9   A9 01      LDA #&01\n     17BB   E5 56      SBC &56\n     17BD   85 56      STA &56\n     17BF   A9 00      LDA #&00\n     17C1   E5 57      SBC &57\n     17C3   85 57      STA &57\n     17C5   A9 00      LDA #&00\n     17C7   E5 1B      SBC &1B\n     17C9   09 80      ORA #&80\n.MV2\n     17CB   45 D1      EOR &D1\n     17CD   85 58      STA &58\n     17CF   A5 9E      LDA &9E\n     17D1   85 90      STA &90\n     17D3   A5 56      LDA &56\n     17D5   85 1B      STA &1B\n     17D7   A5 57      LDA &57\n     17D9   85 1C      STA &1C\n     17DB   A5 58      LDA &58\n     17DD   20 E4 26   JSR &26E4\n     17E0   A2 00      LDX #&00\n     17E2   20 AA 15   JSR &15AA\n     17E5   A5 3E      LDA &3E\n     17E7   85 53      STA &53\n     17E9   A5 3F      LDA &3F\n     17EB   85 54      STA &54\n     17ED   A5 40      LDA &40\n     17EF   85 55      STA &55\n     17F1   4C C8 14   JMP &14C8\nELITE A\nAssembled at &F40 \nEnds at &17F4 \nCode size is &8B4 \nExecute at &1128 \nReload at &1128 \nS.ELTA &F40  &17F4  &1128  &1128 \nSaving file '3-assembled-output/ELTA.bin'\n.NA%\n     17F4   4A 41 4D ...\n     17FB   0D\n     17FC   00\n     17FD   14\n     17FE   AD\n     17FF   4A 5A\n     1801   48 02\n     1803   53 B7\n     1805   00 00 03 E8\n     1809   46\n     180A   00\n     180B   00\n     180C   0F\n     180D   00\n     180E   00\n     180F   00\n     1810   00 00\n     1812   16\n     1813   00\n     1814   00\n     1815   00\n     1816   00\n     1817   00\n     1818   00\n     1819   00\n     181A   00\n     181B   00\n     181C   00\n     181D   00\n     181E   00\n     181F   00\n     1820   00\n     1821   00\n     1822   00\n     1823   00\n     1824   00\n     1825   00\n     1826   00\n     1827   00\n     1828   00\n     1829   00\n     182A   00\n     182B   00 00 00 00\n     182F   03\n     1830   00\n     1831   10\n     1832   0F\n     1833   11\n     1834   00\n     1835   03\n     1836   1C\n     1837   0E\n     1838   00\n     1839   00\n     183A   0A\n     183B   00\n     183C   11\n     183D   3A\n     183E   07\n     183F   09\n     1840   08\n     1841   00\n     1842   00\n     1843   00 00\n     1845   80\n.CHK2\n     1846   AA\n.CHK\n     1847   03\n.UNIV\n     1848   00 09\n     184A   24 09\n     184C   48 09\n     184E   6C 09\n     1850   90 09\n     1852   B4 09\n     1854   D8 09\n     1856   FC 09\n     1858   20 0A\n     185A   44 0A\n     185C   68 0A\n     185E   8C 0A\n     1860   B0 0A\n.TWOS\n     1862   80\n     1863   40\n     1864   20\n     1865   10\n     1866   08\n     1867   04\n     1868   02\n     1869   01\n.TWOS2\n     186A   C0\n     186B   60\n     186C   30\n     186D   18\n     186E   0C\n     186F   06\n     1870   03\n     1871   03\n.CTWOS\n     1872   88\n     1873   44\n     1874   22\n     1875   11\n     1876   88\n.LL30\n     1877\n.LOIN\n     1877   84 94      STY &94\n     1879   A9 80      LDA #&80\n     187B   85 92      STA &92\n     187D   0A         ASL A\n     187E   85 A1      STA &A1\n     1880   A5 33      LDA &33\n     1882   E5 31      SBC &31\n     1884   B0 05      BCS &188B\n     1886   49 FF      EOR #&FF\n     1888   69 01      ADC #&01\n     188A   38         SEC\n.LI1\n     188B   85 1B      STA &1B\n     188D   A5 34      LDA &34\n     188F   E5 32      SBC &32\n     1891   B0 04      BCS &1897\n     1893   49 FF      EOR #&FF\n     1895   69 01      ADC #&01\n.LI2\n     1897   85 90      STA &90\n     1899   C5 1B      CMP &1B\n     189B   90 03      BCC &18A0\n     189D   4C 4A 19   JMP &194A\n.STPX\n     18A0   A6 31      LDX &31\n     18A2   E4 33      CPX &33\n     18A4   90 11      BCC &18B7\n     18A6   C6 A1      DEC &A1\n     18A8   A5 33      LDA &33\n     18AA   85 31      STA &31\n     18AC   86 33      STX &33\n     18AE   AA         TAX\n     18AF   A5 34      LDA &34\n     18B1   A4 32      LDY &32\n     18B3   85 32      STA &32\n     18B5   84 34      STY &34\n.LI3\n     18B7   A5 32      LDA &32\n     18B9   4A         LSR A\n     18BA   4A         LSR A\n     18BB   4A         LSR A\n     18BC   09 60      ORA #&60\n     18BE   85 08      STA &08\n     18C0   A5 32      LDA &32\n     18C2   29 07      AND #&07\n     18C4   A8         TAY\n     18C5   8A         TXA\n     18C6   29 F8      AND #&F8\n     18C8   85 07      STA &07\n     18CA   8A         TXA\n     18CB   29 07      AND #&07\n     18CD   AA         TAX\n     18CE   BD 62 18   LDA &1862,X\n     18D1   85 91      STA &91\n     18D3   A5 90      LDA &90\n     18D5   A2 FE      LDX #&FE\n     18D7   86 90      STX &90\n.LIL1\n     18D9   0A         ASL A\n     18DA   B0 04      BCS &18E0\n     18DC   C5 1B      CMP &1B\n     18DE   90 03      BCC &18E3\n.LI4\n     18E0   E5 1B      SBC &1B\n     18E2   38         SEC\n.LI5\n     18E3   26 90      ROL &90\n     18E5   B0 F2      BCS &18D9\n     18E7   A6 1B      LDX &1B\n     18E9   E8         INX\n     18EA   A5 34      LDA &34\n     18EC   E5 32      SBC &32\n     18EE   B0 2C      BCS &191C\n     18F0   A5 A1      LDA &A1\n     18F2   D0 07      BNE &18FB\n     18F4   CA         DEX\n.LIL2\n     18F5   A5 91      LDA &91\n     18F7   51 07      EOR (&07),Y\n     18F9   91 07      STA (&07),Y\n.LI6\n     18FB   46 91      LSR &91\n     18FD   90 08      BCC &1907\n     18FF   66 91      ROR &91\n     1901   A5 07      LDA &07\n     1903   69 08      ADC #&08\n     1905   85 07      STA &07\n.LI7\n     1907   A5 92      LDA &92\n     1909   65 90      ADC &90\n     190B   85 92      STA &92\n     190D   90 07      BCC &1916\n     190F   88         DEY\n     1910   10 04      BPL &1916\n     1912   C6 08      DEC &08\n     1914   A0 07      LDY #&07\n.LIC2\n     1916   CA         DEX\n     1917   D0 DC      BNE &18F5\n     1919   A4 94      LDY &94\n     191B   60         RTS\n.DOWN\n     191C   A5 A1      LDA &A1\n     191E   F0 07      BEQ &1927\n     1920   CA         DEX\n.LIL3\n     1921   A5 91      LDA &91\n     1923   51 07      EOR (&07),Y\n     1925   91 07      STA (&07),Y\n.LI9\n     1927   46 91      LSR &91\n     1929   90 08      BCC &1933\n     192B   66 91      ROR &91\n     192D   A5 07      LDA &07\n     192F   69 08      ADC #&08\n     1931   85 07      STA &07\n.LI10\n     1933   A5 92      LDA &92\n     1935   65 90      ADC &90\n     1937   85 92      STA &92\n     1939   90 09      BCC &1944\n     193B   C8         INY\n     193C   C0 08      CPY #&08\n     193E   D0 04      BNE &1944\n     1940   E6 08      INC &08\n     1942   A0 00      LDY #&00\n.LIC3\n     1944   CA         DEX\n     1945   D0 DA      BNE &1921\n     1947   A4 94      LDY &94\n     1949   60         RTS\n.STPY\n     194A   A4 32      LDY &32\n     194C   98         TYA\n     194D   A6 31      LDX &31\n     194F   C4 34      CPY &34\n     1951   B0 10      BCS &1963\n     1953   C6 A1      DEC &A1\n     1955   A5 33      LDA &33\n     1957   85 31      STA &31\n     1959   86 33      STX &33\n     195B   AA         TAX\n     195C   A5 34      LDA &34\n     195E   85 32      STA &32\n     1960   84 34      STY &34\n     1962   A8         TAY\n.LI15\n     1963   4A         LSR A\n     1964   4A         LSR A\n     1965   4A         LSR A\n     1966   09 60      ORA #&60\n     1968   85 08      STA &08\n     196A   8A         TXA\n     196B   29 F8      AND #&F8\n     196D   85 07      STA &07\n     196F   8A         TXA\n     1970   29 07      AND #&07\n     1972   AA         TAX\n     1973   BD 62 18   LDA &1862,X\n     1976   85 91      STA &91\n     1978   A5 32      LDA &32\n     197A   29 07      AND #&07\n     197C   A8         TAY\n     197D   A5 1B      LDA &1B\n     197F   A2 01      LDX #&01\n     1981   86 1B      STX &1B\n.LIL4\n     1983   0A         ASL A\n     1984   B0 04      BCS &198A\n     1986   C5 90      CMP &90\n     1988   90 03      BCC &198D\n.LI13\n     198A   E5 90      SBC &90\n     198C   38         SEC\n.LI14\n     198D   26 1B      ROL &1B\n     198F   90 F2      BCC &1983\n     1991   A6 90      LDX &90\n     1993   E8         INX\n     1994   A5 33      LDA &33\n     1996   E5 31      SBC &31\n     1998   90 2D      BCC &19C7\n     199A   18         CLC\n     199B   A5 A1      LDA &A1\n     199D   F0 07      BEQ &19A6\n     199F   CA         DEX\n.LIL5\n     19A0   A5 91      LDA &91\n     19A2   51 07      EOR (&07),Y\n     19A4   91 07      STA (&07),Y\n.LI17\n     19A6   88         DEY\n     19A7   10 04      BPL &19AD\n     19A9   C6 08      DEC &08\n     19AB   A0 07      LDY #&07\n.LI16\n     19AD   A5 92      LDA &92\n     19AF   65 1B      ADC &1B\n     19B1   85 92      STA &92\n     19B3   90 0C      BCC &19C1\n     19B5   46 91      LSR &91\n     19B7   90 08      BCC &19C1\n     19B9   66 91      ROR &91\n     19BB   A5 07      LDA &07\n     19BD   69 08      ADC #&08\n     19BF   85 07      STA &07\n.LIC5\n     19C1   CA         DEX\n     19C2   D0 DC      BNE &19A0\n     19C4   A4 94      LDY &94\n     19C6   60         RTS\n.LFT\n     19C7   A5 A1      LDA &A1\n     19C9   F0 07      BEQ &19D2\n     19CB   CA         DEX\n.LIL6\n     19CC   A5 91      LDA &91\n     19CE   51 07      EOR (&07),Y\n     19D0   91 07      STA (&07),Y\n.LI18\n     19D2   88         DEY\n     19D3   10 04      BPL &19D9\n     19D5   C6 08      DEC &08\n     19D7   A0 07      LDY #&07\n.LI19\n     19D9   A5 92      LDA &92\n     19DB   65 1B      ADC &1B\n     19DD   85 92      STA &92\n     19DF   90 0D      BCC &19EE\n     19E1   06 91      ASL &91\n     19E3   90 09      BCC &19EE\n     19E5   26 91      ROL &91\n     19E7   A5 07      LDA &07\n     19E9   E9 07      SBC #&07\n     19EB   85 07      STA &07\n     19ED   18         CLC\n.LIC6\n     19EE   CA         DEX\n     19EF   D0 DB      BNE &19CC\n     19F1   A4 94      LDY &94\n.HL6\n     19F3   60         RTS\n.NLIN3\n     19F4   20 B6 38   JSR &38B6\n.NLIN4\n     19F7   A9 13      LDA #&13\n     19F9   D0 04      BNE &19FF\n.NLIN\n     19FB   A9 17      LDA #&17\n     19FD   E6 2D      INC &2D\n.NLIN2\n     19FF   85 32      STA &32\n     1A01   A2 02      LDX #&02\n     1A03   86 31      STX &31\n     1A05   A2 FE      LDX #&FE\n     1A07   86 33      STX &33\n     1A09   D0 0A      BNE &1A15\n.HLOIN2\n     1A0B   20 55 41   JSR &4155\n     1A0E   84 32      STY &32\n     1A10   A9 00      LDA #&00\n     1A12   99 66 0D   STA &0D66,Y\n.HLOIN\n     1A15   84 94      STY &94\n     1A17   A6 31      LDX &31\n     1A19   E4 33      CPX &33\n     1A1B   F0 D6      BEQ &19F3\n     1A1D   90 07      BCC &1A26\n     1A1F   A5 33      LDA &33\n     1A21   85 31      STA &31\n     1A23   86 33      STX &33\n     1A25   AA         TAX\n.HL5\n     1A26   C6 33      DEC &33\n     1A28   A5 32      LDA &32\n     1A2A   4A         LSR A\n     1A2B   4A         LSR A\n     1A2C   4A         LSR A\n     1A2D   09 60      ORA #&60\n     1A2F   85 08      STA &08\n     1A31   A5 32      LDA &32\n     1A33   29 07      AND #&07\n     1A35   85 07      STA &07\n     1A37   8A         TXA\n     1A38   29 F8      AND #&F8\n     1A3A   A8         TAY\n.HL1\n     1A3B   8A         TXA\n     1A3C   29 F8      AND #&F8\n     1A3E   85 D1      STA &D1\n     1A40   A5 33      LDA &33\n     1A42   29 F8      AND #&F8\n     1A44   38         SEC\n     1A45   E5 D1      SBC &D1\n     1A47   F0 37      BEQ &1A80\n     1A49   4A         LSR A\n     1A4A   4A         LSR A\n     1A4B   4A         LSR A\n     1A4C   85 91      STA &91\n     1A4E   A5 31      LDA &31\n     1A50   29 07      AND #&07\n     1A52   AA         TAX\n     1A53   BD A2 1A   LDA &1AA2,X\n     1A56   51 07      EOR (&07),Y\n     1A58   91 07      STA (&07),Y\n     1A5A   98         TYA\n     1A5B   69 08      ADC #&08\n     1A5D   A8         TAY\n     1A5E   A6 91      LDX &91\n     1A60   CA         DEX\n     1A61   F0 0E      BEQ &1A71\n     1A63   18         CLC\n.HLL1\n     1A64   A9 FF      LDA #&FF\n     1A66   51 07      EOR (&07),Y\n     1A68   91 07      STA (&07),Y\n     1A6A   98         TYA\n     1A6B   69 08      ADC #&08\n     1A6D   A8         TAY\n     1A6E   CA         DEX\n     1A6F   D0 F3      BNE &1A64\n.HL3\n     1A71   A5 33      LDA &33\n     1A73   29 07      AND #&07\n     1A75   AA         TAX\n     1A76   BD 9B 1A   LDA &1A9B,X\n     1A79   51 07      EOR (&07),Y\n     1A7B   91 07      STA (&07),Y\n     1A7D   A4 94      LDY &94\n     1A7F   60         RTS\n.HL2\n     1A80   A5 31      LDA &31\n     1A82   29 07      AND #&07\n     1A84   AA         TAX\n     1A85   BD A2 1A   LDA &1AA2,X\n     1A88   85 D1      STA &D1\n     1A8A   A5 33      LDA &33\n     1A8C   29 07      AND #&07\n     1A8E   AA         TAX\n     1A8F   BD 9B 1A   LDA &1A9B,X\n     1A92   25 D1      AND &D1\n     1A94   51 07      EOR (&07),Y\n     1A96   91 07      STA (&07),Y\n     1A98   A4 94      LDY &94\n     1A9A   60         RTS\n.TWFL\n     1A9B   80\n     1A9C   C0\n     1A9D   E0\n     1A9E   F0\n     1A9F   F8\n     1AA0   FC\n     1AA1   FE\n.TWFR\n     1AA2   FF\n     1AA3   7F\n     1AA4   3F\n     1AA5   1F\n     1AA6   0F\n     1AA7   07\n     1AA8   03\n     1AA9   01\n.PX3\n     1AAA   BD 62 18   LDA &1862,X\n     1AAD   51 07      EOR (&07),Y\n     1AAF   91 07      STA (&07),Y\n     1AB1   A4 06      LDY &06\n     1AB3   60         RTS\n.PIX1\n     1AB4   20 5F 28   JSR &285F\n     1AB7   85 27      STA &27\n     1AB9   8A         TXA\n     1ABA   99 D5 0E   STA &0ED5,Y\n.PIXEL2\n     1ABD   A5 31      LDA &31\n     1ABF   10 05      BPL &1AC6\n     1AC1   49 7F      EOR #&7F\n     1AC3   18         CLC\n     1AC4   69 01      ADC #&01\n.PX1\n     1AC6   49 80      EOR #&80\n     1AC8   AA         TAX\n     1AC9   A5 32      LDA &32\n     1ACB   29 7F      AND #&7F\n     1ACD   C9 60      CMP #&60\n     1ACF   B0 46      BCS &1B17\n     1AD1   A5 32      LDA &32\n     1AD3   10 04      BPL &1AD9\n     1AD5   49 7F      EOR #&7F\n     1AD7   69 01      ADC #&01\n.PX2\n     1AD9   85 D1      STA &D1\n     1ADB   A9 61      LDA #&61\n     1ADD   E5 D1      SBC &D1\n.PIXEL\n     1ADF   84 06      STY &06\n     1AE1   A8         TAY\n     1AE2   4A         LSR A\n     1AE3   4A         LSR A\n     1AE4   4A         LSR A\n     1AE5   09 60      ORA #&60\n     1AE7   85 08      STA &08\n     1AE9   8A         TXA\n     1AEA   29 F8      AND #&F8\n     1AEC   85 07      STA &07\n     1AEE   98         TYA\n     1AEF   29 07      AND #&07\n     1AF1   A8         TAY\n     1AF2   8A         TXA\n     1AF3   29 07      AND #&07\n     1AF5   AA         TAX\n     1AF6   A5 97      LDA &97\n     1AF8   C9 90      CMP #&90\n     1AFA   B0 AE      BCS &1AAA\n     1AFC   BD 6A 18   LDA &186A,X\n     1AFF   51 07      EOR (&07),Y\n     1B01   91 07      STA (&07),Y\n     1B03   A5 97      LDA &97\n     1B05   C9 50      CMP #&50\n     1B07   B0 0C      BCS &1B15\n     1B09   88         DEY\n     1B0A   10 02      BPL &1B0E\n     1B0C   A0 01      LDY #&01\n.PX14\n     1B0E   BD 6A 18   LDA &186A,X\n     1B11   51 07      EOR (&07),Y\n     1B13   91 07      STA (&07),Y\n.PX13\n     1B15   A4 06      LDY &06\n.PX4\n     1B17   60         RTS\n.BLINE\n     1B18   8A         TXA\n     1B19   65 E0      ADC &E0\n     1B1B   85 84      STA &84\n     1B1D   A5 E1      LDA &E1\n     1B1F   65 D1      ADC &D1\n     1B21   85 85      STA &85\n     1B23   A5 A3      LDA &A3\n     1B25   F0 12      BEQ &1B39\n     1B27   E6 A3      INC &A3\n.BL5\n     1B29   A4 77      LDY &77\n     1B2B   A9 FF      LDA #&FF\n     1B2D   D9 73 0E   CMP &0E73,Y\n     1B30   F0 68      BEQ &1B9A\n     1B32   99 74 0E   STA &0E74,Y\n     1B35   E6 77      INC &77\n     1B37   D0 61      BNE &1B9A\n.BL1\n     1B39   A5 7E      LDA &7E\n     1B3B   85 31      STA &31\n     1B3D   A5 7F      LDA &7F\n     1B3F   85 32      STA &32\n     1B41   A5 80      LDA &80\n     1B43   85 33      STA &33\n     1B45   A5 81      LDA &81\n     1B47   85 34      STA &34\n     1B49   A5 82      LDA &82\n     1B4B   85 35      STA &35\n     1B4D   A5 83      LDA &83\n     1B4F   85 36      STA &36\n     1B51   A5 84      LDA &84\n     1B53   85 37      STA &37\n     1B55   A5 85      LDA &85\n     1B57   85 38      STA &38\n     1B59   20 13 55   JSR &5513\n     1B5C   B0 CB      BCS &1B29\n     1B5E   A5 A1      LDA &A1\n     1B60   F0 10      BEQ &1B72\n     1B62   A5 31      LDA &31\n     1B64   A4 33      LDY &33\n     1B66   85 33      STA &33\n     1B68   84 31      STY &31\n     1B6A   A5 32      LDA &32\n     1B6C   A4 34      LDY &34\n     1B6E   85 34      STA &34\n     1B70   84 32      STY &32\n.BL9\n     1B72   A4 77      LDY &77\n     1B74   B9 73 0E   LDA &0E73,Y\n     1B77   C9 FF      CMP #&FF\n     1B79   D0 0B      BNE &1B86\n     1B7B   A5 31      LDA &31\n     1B7D   99 26 0E   STA &0E26,Y\n     1B80   A5 32      LDA &32\n     1B82   99 74 0E   STA &0E74,Y\n     1B85   C8         INY\n.BL8\n     1B86   A5 33      LDA &33\n     1B88   99 26 0E   STA &0E26,Y\n     1B8B   A5 34      LDA &34\n     1B8D   99 74 0E   STA &0E74,Y\n     1B90   C8         INY\n     1B91   84 77      STY &77\n     1B93   20 77 18   JSR &1877\n     1B96   A5 98      LDA &98\n     1B98   D0 8F      BNE &1B29\n.BL7\n     1B9A   A5 82      LDA &82\n     1B9C   85 7E      STA &7E\n     1B9E   A5 83      LDA &83\n     1BA0   85 7F      STA &7F\n     1BA2   A5 84      LDA &84\n     1BA4   85 80      STA &80\n     1BA6   A5 85      LDA &85\n     1BA8   85 81      STA &81\n     1BAA   A5 A4      LDA &A4\n     1BAC   18         CLC\n     1BAD   65 A6      ADC &A6\n     1BAF   85 A4      STA &A4\n     1BB1   60         RTS\n.FLIP\n     1BB2   AC 33 0F   LDY &0F33\n.FLL1\n     1BB5   BE C2 0E   LDX &0EC2,Y\n     1BB8   B9 4C 03   LDA &034C,Y\n     1BBB   85 32      STA &32\n     1BBD   99 C2 0E   STA &0EC2,Y\n     1BC0   8A         TXA\n     1BC1   85 31      STA &31\n     1BC3   99 4C 03   STA &034C,Y\n     1BC6   B9 E8 0E   LDA &0EE8,Y\n     1BC9   85 97      STA &97\n     1BCB   20 BD 1A   JSR &1ABD\n     1BCE   88         DEY\n     1BCF   D0 E4      BNE &1BB5\n     1BD1   60         RTS\n.STARS\n     1BD2   AE 5F 0D   LDX &0D5F\n     1BD5   F0 09      BEQ &1BE0\n     1BD7   CA         DEX\n     1BD8   D0 03      BNE &1BDD\n     1BDA   4C CD 1C   JMP &1CCD\n.ST11\n     1BDD   4C BB 25   JMP &25BB\n.STARS1\n     1BE0   AC 33 0F   LDY &0F33\n.STL1\n     1BE3   20 BE 28   JSR &28BE\n     1BE6   A5 91      LDA &91\n     1BE8   46 1B      LSR &1B\n     1BEA   6A         ROR A\n     1BEB   46 1B      LSR &1B\n     1BED   6A         ROR A\n     1BEE   09 01      ORA #&01\n     1BF0   85 90      STA &90\n     1BF2   B9 FB 0E   LDA &0EFB,Y\n     1BF5   E5 8D      SBC &8D\n     1BF7   99 FB 0E   STA &0EFB,Y\n     1BFA   B9 E8 0E   LDA &0EE8,Y\n     1BFD   85 97      STA &97\n     1BFF   E5 8E      SBC &8E\n     1C01   99 E8 0E   STA &0EE8,Y\n     1C04   20 79 27   JSR &2779\n     1C07   85 27      STA &27\n     1C09   A5 1B      LDA &1B\n     1C0B   79 D5 0E   ADC &0ED5,Y\n     1C0E   85 26      STA &26\n     1C10   85 91      STA &91\n     1C12   A5 32      LDA &32\n     1C14   65 27      ADC &27\n     1C16   85 27      STA &27\n     1C18   85 92      STA &92\n     1C1A   B9 4C 03   LDA &034C,Y\n     1C1D   85 31      STA &31\n     1C1F   20 7E 27   JSR &277E\n     1C22   85 25      STA &25\n     1C24   A5 1B      LDA &1B\n     1C26   79 5F 03   ADC &035F,Y\n     1C29   85 24      STA &24\n     1C2B   A5 31      LDA &31\n     1C2D   65 25      ADC &25\n     1C2F   85 25      STA &25\n     1C31   45 89      EOR &89\n     1C33   20 28 27   JSR &2728\n     1C36   20 5F 28   JSR &285F\n     1C39   85 27      STA &27\n     1C3B   86 26      STX &26\n     1C3D   45 88      EOR &88\n     1C3F   20 20 27   JSR &2720\n     1C42   20 5F 28   JSR &285F\n     1C45   85 25      STA &25\n     1C47   86 24      STX &24\n     1C49   A6 2B      LDX &2B\n     1C4B   A5 27      LDA &27\n     1C4D   45 8B      EOR &8B\n     1C4F   20 2A 27   JSR &272A\n     1C52   85 90      STA &90\n     1C54   20 00 28   JSR &2800\n     1C57   06 1B      ASL &1B\n     1C59   2A         ROL A\n     1C5A   85 D1      STA &D1\n     1C5C   A9 00      LDA #&00\n     1C5E   6A         ROR A\n     1C5F   05 D1      ORA &D1\n     1C61   20 5F 28   JSR &285F\n     1C64   85 25      STA &25\n     1C66   8A         TXA\n     1C67   99 5F 03   STA &035F,Y\n     1C6A   A5 26      LDA &26\n     1C6C   85 91      STA &91\n     1C6E   A5 27      LDA &27\n     1C70   85 92      STA &92\n     1C72   A9 00      LDA #&00\n     1C74   85 1B      STA &1B\n     1C76   A5 2A      LDA &2A\n     1C78   49 80      EOR #&80\n     1C7A   20 B4 1A   JSR &1AB4\n     1C7D   A5 25      LDA &25\n     1C7F   85 31      STA &31\n     1C81   99 4C 03   STA &034C,Y\n     1C84   29 7F      AND #&7F\n     1C86   C9 78      CMP #&78\n     1C88   B0 20      BCS &1CAA\n     1C8A   A5 27      LDA &27\n     1C8C   99 C2 0E   STA &0EC2,Y\n     1C8F   85 32      STA &32\n     1C91   29 7F      AND #&7F\n     1C93   C9 78      CMP #&78\n     1C95   B0 13      BCS &1CAA\n     1C97   B9 E8 0E   LDA &0EE8,Y\n     1C9A   C9 10      CMP #&10\n     1C9C   90 0C      BCC &1CAA\n     1C9E   85 97      STA &97\n.STC1\n     1CA0   20 BD 1A   JSR &1ABD\n     1CA3   88         DEY\n     1CA4   F0 03      BEQ &1CA9\n     1CA6   4C E3 1B   JMP &1BE3\n     1CA9   60         RTS\n.KILL1\n     1CAA   20 57 44   JSR &4457\n     1CAD   09 04      ORA #&04\n     1CAF   85 32      STA &32\n     1CB1   99 C2 0E   STA &0EC2,Y\n     1CB4   20 57 44   JSR &4457\n     1CB7   09 08      ORA #&08\n     1CB9   85 31      STA &31\n     1CBB   99 4C 03   STA &034C,Y\n     1CBE   20 57 44   JSR &4457\n     1CC1   09 90      ORA #&90\n     1CC3   99 E8 0E   STA &0EE8,Y\n     1CC6   85 97      STA &97\n     1CC8   A5 32      LDA &32\n     1CCA   4C A0 1C   JMP &1CA0\n.STARS6\n     1CCD   AC 33 0F   LDY &0F33\n.STL6\n     1CD0   20 BE 28   JSR &28BE\n     1CD3   A5 91      LDA &91\n     1CD5   46 1B      LSR &1B\n     1CD7   6A         ROR A\n     1CD8   46 1B      LSR &1B\n     1CDA   6A         ROR A\n     1CDB   09 01      ORA #&01\n     1CDD   85 90      STA &90\n     1CDF   B9 4C 03   LDA &034C,Y\n     1CE2   85 31      STA &31\n     1CE4   20 7E 27   JSR &277E\n     1CE7   85 25      STA &25\n     1CE9   B9 5F 03   LDA &035F,Y\n     1CEC   E5 1B      SBC &1B\n     1CEE   85 24      STA &24\n     1CF0   A5 31      LDA &31\n     1CF2   E5 25      SBC &25\n     1CF4   85 25      STA &25\n     1CF6   20 79 27   JSR &2779\n     1CF9   85 27      STA &27\n     1CFB   B9 D5 0E   LDA &0ED5,Y\n     1CFE   E5 1B      SBC &1B\n     1D00   85 26      STA &26\n     1D02   85 91      STA &91\n     1D04   A5 32      LDA &32\n     1D06   E5 27      SBC &27\n     1D08   85 27      STA &27\n     1D0A   85 92      STA &92\n     1D0C   B9 FB 0E   LDA &0EFB,Y\n     1D0F   65 8D      ADC &8D\n     1D11   99 FB 0E   STA &0EFB,Y\n     1D14   B9 E8 0E   LDA &0EE8,Y\n     1D17   85 97      STA &97\n     1D19   65 8E      ADC &8E\n     1D1B   99 E8 0E   STA &0EE8,Y\n     1D1E   A5 25      LDA &25\n     1D20   45 88      EOR &88\n     1D22   20 28 27   JSR &2728\n     1D25   20 5F 28   JSR &285F\n     1D28   85 27      STA &27\n     1D2A   86 26      STX &26\n     1D2C   45 89      EOR &89\n     1D2E   20 20 27   JSR &2720\n     1D31   20 5F 28   JSR &285F\n     1D34   85 25      STA &25\n     1D36   86 24      STX &24\n     1D38   A5 27      LDA &27\n     1D3A   45 8B      EOR &8B\n     1D3C   A6 2B      LDX &2B\n     1D3E   20 2A 27   JSR &272A\n     1D41   85 90      STA &90\n     1D43   A5 25      LDA &25\n     1D45   85 92      STA &92\n     1D47   49 80      EOR #&80\n     1D49   20 04 28   JSR &2804\n     1D4C   06 1B      ASL &1B\n     1D4E   2A         ROL A\n     1D4F   85 D1      STA &D1\n     1D51   A9 00      LDA #&00\n     1D53   6A         ROR A\n     1D54   05 D1      ORA &D1\n     1D56   20 5F 28   JSR &285F\n     1D59   85 25      STA &25\n     1D5B   8A         TXA\n     1D5C   99 5F 03   STA &035F,Y\n     1D5F   A5 26      LDA &26\n     1D61   85 91      STA &91\n     1D63   A5 27      LDA &27\n     1D65   85 92      STA &92\n     1D67   A9 00      LDA #&00\n     1D69   85 1B      STA &1B\n     1D6B   A5 2A      LDA &2A\n     1D6D   20 B4 1A   JSR &1AB4\n     1D70   A5 25      LDA &25\n     1D72   85 31      STA &31\n     1D74   99 4C 03   STA &034C,Y\n     1D77   A5 27      LDA &27\n     1D79   99 C2 0E   STA &0EC2,Y\n     1D7C   85 32      STA &32\n     1D7E   29 7F      AND #&7F\n     1D80   C9 6E      CMP #&6E\n     1D82   B0 13      BCS &1D97\n     1D84   B9 E8 0E   LDA &0EE8,Y\n     1D87   C9 A0      CMP #&A0\n     1D89   B0 0C      BCS &1D97\n     1D8B   85 97      STA &97\n.STC6\n     1D8D   20 BD 1A   JSR &1ABD\n     1D90   88         DEY\n     1D91   F0 03      BEQ &1D96\n     1D93   4C D0 1C   JMP &1CD0\n.ST3\n     1D96   60         RTS\n.KILL6\n     1D97   20 57 44   JSR &4457\n     1D9A   29 7F      AND #&7F\n     1D9C   69 0A      ADC #&0A\n     1D9E   99 E8 0E   STA &0EE8,Y\n     1DA1   85 97      STA &97\n     1DA3   4A         LSR A\n     1DA4   B0 14      BCS &1DBA\n     1DA6   4A         LSR A\n     1DA7   A9 FC      LDA #&FC\n     1DA9   6A         ROR A\n     1DAA   85 31      STA &31\n     1DAC   99 4C 03   STA &034C,Y\n     1DAF   20 57 44   JSR &4457\n     1DB2   85 32      STA &32\n     1DB4   99 C2 0E   STA &0EC2,Y\n     1DB7   4C 8D 1D   JMP &1D8D\n.ST4\n     1DBA   20 57 44   JSR &4457\n     1DBD   85 31      STA &31\n     1DBF   99 4C 03   STA &034C,Y\n     1DC2   4A         LSR A\n     1DC3   A9 E6      LDA #&E6\n     1DC5   6A         ROR A\n     1DC6   85 32      STA &32\n     1DC8   99 C2 0E   STA &0EC2,Y\n     1DCB   D0 C0      BNE &1D8D\n.PRXS\n     1DCD   01 00\n     1DCF   2C 01\n     1DD1   A0 0F\n     1DD3   70 17\n     1DD5   A0 0F\n     1DD7   10 27\n     1DD9   82 14\n     1DDB   10 27\n     1DDD   28 23\n     1DDF   98 3A\n     1DE1   10 27\n     1DE3   50 C3\n.st4\n     1DE5   A2 09      LDX #&09\n     1DE7   C9 19      CMP #&19\n     1DE9   B0 5F      BCS &1E4A\n     1DEB   CA         DEX\n     1DEC   C9 0A      CMP #&0A\n     1DEE   B0 5A      BCS &1E4A\n     1DF0   CA         DEX\n     1DF1   C9 02      CMP #&02\n     1DF3   B0 55      BCS &1E4A\n     1DF5   CA         DEX\n     1DF6   D0 52      BNE &1E4A\n.STATUS\n     1DF8   A9 08      LDA #&08\n     1DFA   20 7B 2B   JSR &2B7B\n     1DFD   20 A4 32   JSR &32A4\n     1E00   A9 07      LDA #&07\n     1E02   85 2C      STA &2C\n     1E04   A9 7E      LDA #&7E\n     1E06   20 F4 19   JSR &19F4\n     1E09   A9 0F      LDA #&0F\n     1E0B   A4 9F      LDY &9F\n     1E0D   D0 11      BNE &1E20\n     1E0F   A9 E6      LDA #&E6\n     1E11   AC 57 0D   LDY &0D57\n     1E14   BE 42 0D   LDX &0D42,Y\n     1E17   F0 07      BEQ &1E20\n     1E19   AC 13 0F   LDY &0F13\n     1E1C   C0 80      CPY #&80\n     1E1E   69 01      ADC #&01\n.st6\n     1E20   20 AB 38   JSR &38AB\n     1E23   A9 7D      LDA #&7D\n     1E25   20 44 2D   JSR &2D44\n     1E28   A9 13      LDA #&13\n     1E2A   AC 34 03   LDY &0334\n     1E2D   F0 04      BEQ &1E33\n     1E2F   C0 32      CPY #&32\n     1E31   69 01      ADC #&01\n.st5\n     1E33   20 AB 38   JSR &38AB\n     1E36   A9 10      LDA #&10\n     1E38   20 44 2D   JSR &2D44\n     1E3B   AD 48 03   LDA &0348\n     1E3E   D0 A5      BNE &1DE5\n     1E40   AA         TAX\n     1E41   AD 47 03   LDA &0347\n     1E44   4A         LSR A\n     1E45   4A         LSR A\n.st5L\n     1E46   E8         INX\n     1E47   4A         LSR A\n     1E48   D0 FC      BNE &1E46\n.st3\n     1E4A   8A         TXA\n     1E4B   18         CLC\n     1E4C   69 15      ADC #&15\n     1E4E   20 AB 38   JSR &38AB\n     1E51   A9 12      LDA #&12\n     1E53   20 B1 1E   JSR &1EB1\n     1E56   AD 16 03   LDA &0316\n     1E59   C9 1A      CMP #&1A\n     1E5B   90 05      BCC &1E62\n     1E5D   A9 6B      LDA #&6B\n     1E5F   20 B1 1E   JSR &1EB1\n     1E62   AD 29 03   LDA &0329\n     1E65   F0 05      BEQ &1E6C\n     1E67   A9 6F      LDA #&6F\n     1E69   20 B1 1E   JSR &1EB1\n     1E6C   AD 28 03   LDA &0328\n     1E6F   F0 05      BEQ &1E76\n     1E71   A9 6C      LDA #&6C\n     1E73   20 B1 1E   JSR &1EB1\n     1E76   A9 71      LDA #&71\n     1E78   85 A7      STA &A7\n.stqv\n     1E7A   A8         TAY\n     1E7B   BE B9 02   LDX &02B9,Y\n     1E7E   F0 03      BEQ &1E83\n     1E80   20 B1 1E   JSR &1EB1\n     1E83   E6 A7      INC &A7\n     1E85   A5 A7      LDA &A7\n     1E87   C9 75      CMP #&75\n     1E89   90 EF      BCC &1E7A\n     1E8B   A2 00      LDX #&00\n.st\n     1E8D   86 A4      STX &A4\n     1E8F   BC 10 03   LDY &0310,X\n     1E92   F0 15      BEQ &1EA9\n     1E94   8A         TXA\n     1E95   18         CLC\n     1E96   69 60      ADC #&60\n     1E98   20 44 2D   JSR &2D44\n     1E9B   A9 67      LDA #&67\n     1E9D   A6 A4      LDX &A4\n     1E9F   BC 10 03   LDY &0310,X\n     1EA2   10 02      BPL &1EA6\n     1EA4   A9 68      LDA #&68\n     1EA6   20 B1 1E   JSR &1EB1\n.st1\n     1EA9   A6 A4      LDX &A4\n     1EAB   E8         INX\n     1EAC   E0 04      CPX #&04\n     1EAE   90 DD      BCC &1E8D\n     1EB0   60         RTS\n.plf2\n     1EB1   20 AB 38   JSR &38AB\n     1EB4   A2 06      LDX #&06\n     1EB6   86 2C      STX &2C\n     1EB8   60         RTS\n.TENS\n     1EB9   48 76 E8 00\n.pr2\n     1EBD   A9 03      LDA #&03\n     1EBF   A0 00      LDY #&00\n.TT11\n     1EC1   85 8F      STA &8F\n     1EC3   A9 00      LDA #&00\n     1EC5   85 3D      STA &3D\n     1EC7   85 3E      STA &3E\n     1EC9   84 3F      STY &3F\n     1ECB   86 40      STX &40\n.BPRNT\n     1ECD   A2 0B      LDX #&0B\n     1ECF   86 D1      STX &D1\n     1ED1   08         PHP\n     1ED2   90 04      BCC &1ED8\n     1ED4   C6 D1      DEC &D1\n     1ED6   C6 8F      DEC &8F\n.TT30\n     1ED8   A9 0B      LDA #&0B\n     1EDA   38         SEC\n     1EDB   85 95      STA &95\n     1EDD   E5 8F      SBC &8F\n     1EDF   85 8F      STA &8F\n     1EE1   E6 8F      INC &8F\n     1EE3   A0 00      LDY #&00\n     1EE5   84 92      STY &92\n     1EE7   4C 29 1F   JMP &1F29\n.TT35\n     1EEA   06 40      ASL &40\n     1EEC   26 3F      ROL &3F\n     1EEE   26 3E      ROL &3E\n     1EF0   26 3D      ROL &3D\n     1EF2   26 92      ROL &92\n     1EF4   A2 03      LDX #&03\n.tt35\n     1EF6   B5 3D      LDA &3D,X\n     1EF8   95 31      STA &31,X\n     1EFA   CA         DEX\n     1EFB   10 F9      BPL &1EF6\n     1EFD   A5 92      LDA &92\n     1EFF   85 35      STA &35\n     1F01   06 40      ASL &40\n     1F03   26 3F      ROL &3F\n     1F05   26 3E      ROL &3E\n     1F07   26 3D      ROL &3D\n     1F09   26 92      ROL &92\n     1F0B   06 40      ASL &40\n     1F0D   26 3F      ROL &3F\n     1F0F   26 3E      ROL &3E\n     1F11   26 3D      ROL &3D\n     1F13   26 92      ROL &92\n     1F15   18         CLC\n     1F16   A2 03      LDX #&03\n.tt36\n     1F18   B5 3D      LDA &3D,X\n     1F1A   75 31      ADC &31,X\n     1F1C   95 3D      STA &3D,X\n     1F1E   CA         DEX\n     1F1F   10 F7      BPL &1F18\n     1F21   A5 35      LDA &35\n     1F23   65 92      ADC &92\n     1F25   85 92      STA &92\n     1F27   A0 00      LDY #&00\n.TT36\n     1F29   A2 03      LDX #&03\n     1F2B   38         SEC\n.tt37\n     1F2C   B5 3D      LDA &3D,X\n     1F2E   FD B9 1E   SBC &1EB9,X\n     1F31   95 31      STA &31,X\n     1F33   CA         DEX\n     1F34   10 F6      BPL &1F2C\n     1F36   A5 92      LDA &92\n     1F38   E9 17      SBC #&17\n     1F3A   85 35      STA &35\n     1F3C   90 11      BCC &1F4F\n     1F3E   A2 03      LDX #&03\n.tt38\n     1F40   B5 31      LDA &31,X\n     1F42   95 3D      STA &3D,X\n     1F44   CA         DEX\n     1F45   10 F9      BPL &1F40\n     1F47   A5 35      LDA &35\n     1F49   85 92      STA &92\n     1F4B   C8         INY\n     1F4C   4C 29 1F   JMP &1F29\n.TT37\n     1F4F   98         TYA\n     1F50   D0 0C      BNE &1F5E\n     1F52   A5 D1      LDA &D1\n     1F54   F0 08      BEQ &1F5E\n     1F56   C6 8F      DEC &8F\n     1F58   10 0E      BPL &1F68\n     1F5A   A9 20      LDA #&20\n     1F5C   D0 07      BNE &1F65\n.TT32\n     1F5E   A0 00      LDY #&00\n     1F60   84 D1      STY &D1\n     1F62   18         CLC\n     1F63   69 30      ADC #&30\n.tt34\n     1F65   20 81 1F   JSR &1F81\n.TT34\n     1F68   C6 D1      DEC &D1\n     1F6A   10 02      BPL &1F6E\n     1F6C   E6 D1      INC &D1\n     1F6E   C6 95      DEC &95\n     1F70   30 68      BMI &1FDA\n     1F72   D0 08      BNE &1F7C\n     1F74   28         PLP\n     1F75   90 05      BCC &1F7C\n     1F77   A9 2E      LDA #&2E\n     1F79   20 81 1F   JSR &1F81\n     1F7C   4C EA 1E   JMP &1EEA\n.BELL\n     1F7F   A9 07      LDA #&07\n.TT26\n     1F81   85 D2      STA &D2\n     1F83   8C 0F 0F   STY &0F0F\n     1F86   8E 0E 0F   STX &0F0E\n     1F89   A4 7E      LDY &7E\n     1F8B   C0 FF      CPY #&FF\n     1F8D   F0 59      BEQ &1FE8\n     1F8F   C9 07      CMP #&07\n     1F91   F0 5F      BEQ &1FF2\n     1F93   C9 20      CMP #&20\n     1F95   B0 0C      BCS &1FA3\n     1F97   C9 0A      CMP #&0A\n     1F99   F0 04      BEQ &1F9F\n     1F9B   A2 01      LDX #&01\n     1F9D   86 2C      STX &2C\n.RRX1\n     1F9F   E6 2D      INC &2D\n     1FA1   D0 45      BNE &1FE8\n.RR1\n     1FA3   A8         TAY\n     1FA4   A2 BF      LDX #&BF\n     1FA6   0A         ASL A\n     1FA7   0A         ASL A\n     1FA8   90 02      BCC &1FAC\n     1FAA   A2 C1      LDX #&C1\n     1FAC   0A         ASL A\n     1FAD   90 01      BCC &1FB0\n     1FAF   E8         INX\n     1FB0   85 1C      STA &1C\n     1FB2   86 1D      STX &1D\n     1FB4   A5 2C      LDA &2C\n     1FB6   0A         ASL A\n     1FB7   0A         ASL A\n     1FB8   0A         ASL A\n     1FB9   85 07      STA &07\n     1FBB   A5 2D      LDA &2D\n     1FBD   C0 7F      CPY #&7F\n     1FBF   D0 0C      BNE &1FCD\n     1FC1   C6 2C      DEC &2C\n     1FC3   69 5E      ADC #&5E\n     1FC5   AA         TAX\n     1FC6   A0 F8      LDY #&F8\n     1FC8   20 31 48   JSR &4831\n     1FCB   F0 1B      BEQ &1FE8\n.RR2\n     1FCD   E6 2C      INC &2C\n     1FCF   C9 18      CMP #&18\n     1FD1   90 06      BCC &1FD9\n     1FD3   20 7D 2B   JSR &2B7D\n     1FD6   4C E8 1F   JMP &1FE8\n.RR3\n     1FD9   09 60      ORA #&60\n.RREN\n     1FDB   85 08      STA &08\n     1FDD   A0 07      LDY #&07\n.RRL1\n     1FDF   B1 1C      LDA (&1C),Y\n     1FE1   51 07      EOR (&07),Y\n     1FE3   91 07      STA (&07),Y\n     1FE5   88         DEY\n     1FE6   10 F7      BPL &1FDF\n.RR4\n     1FE8   AC 0F 0F   LDY &0F0F\n     1FEB   AE 0E 0F   LDX &0F0E\n     1FEE   A5 D2      LDA &D2\n     1FF0   18         CLC\n.rT9\n     1FF1   60         RTS\n.R5\n     1FF2   20 CB 49   JSR &49CB\n     1FF5   4C E8 1F   JMP &1FE8\n.DIALS\n     1FF8   A9 D0      LDA #&D0\n     1FFA   85 07      STA &07\n     1FFC   A9 78      LDA #&78\n     1FFE   85 08      STA &08\n     2000   20 BC 20   JSR &20BC\n     2003   86 3E      STX &3E\n     2005   85 3D      STA &3D\n     2007   A9 0E      LDA #&0E\n     2009   85 06      STA &06\n     200B   A5 8C      LDA &8C\n     200D   20 CF 20   JSR &20CF\n     2010   A9 00      LDA #&00\n     2012   85 91      STA &91\n     2014   85 1B      STA &1B\n     2016   A9 08      LDA #&08\n     2018   85 92      STA &92\n     201A   A5 87      LDA &87\n     201C   4A         LSR A\n     201D   4A         LSR A\n     201E   05 88      ORA &88\n     2020   49 80      EOR #&80\n     2022   20 5F 28   JSR &285F\n     2025   20 23 21   JSR &2123\n     2028   A5 2A      LDA &2A\n     202A   A6 2B      LDX &2B\n     202C   F0 02      BEQ &2030\n     202E   E9 01      SBC #&01\n     2030   20 5F 28   JSR &285F\n     2033   20 23 21   JSR &2123\n     2036   A5 99      LDA &99\n     2038   29 03      AND #&03\n     203A   D0 B5      BNE &1FF1\n     203C   A0 00      LDY #&00\n     203E   20 BC 20   JSR &20BC\n     2041   86 3D      STX &3D\n     2043   85 3E      STA &3E\n     2045   A2 03      LDX #&03\n     2047   86 06      STX &06\n.DLL23\n     2049   94 37      STY &37,X\n     204B   CA         DEX\n     204C   10 FB      BPL &2049\n     204E   A2 03      LDX #&03\n     2050   AD 13 0F   LDA &0F13\n     2053   4A         LSR A\n     2054   4A         LSR A\n     2055   85 90      STA &90\n.DLL24\n     2057   38         SEC\n     2058   E9 10      SBC #&10\n     205A   90 0D      BCC &2069\n     205C   85 90      STA &90\n     205E   A9 10      LDA #&10\n     2060   95 37      STA &37,X\n     2062   A5 90      LDA &90\n     2064   CA         DEX\n     2065   10 F0      BPL &2057\n     2067   30 04      BMI &206D\n.DLL26\n     2069   A5 90      LDA &90\n     206B   95 37      STA &37,X\n.DLL9\n     206D   B9 37 00   LDA &0037,Y\n     2070   84 1B      STY &1B\n     2072   20 D0 20   JSR &20D0\n     2075   A4 1B      LDY &1B\n     2077   C8         INY\n     2078   C0 04      CPY #&04\n     207A   D0 F1      BNE &206D\n     207C   A9 78      LDA #&78\n     207E   85 08      STA &08\n     2080   A9 10      LDA #&10\n     2082   85 07      STA &07\n     2084   AD 11 0F   LDA &0F11\n     2087   20 CC 20   JSR &20CC\n     208A   AD 12 0F   LDA &0F12\n     208D   20 CC 20   JSR &20CC\n     2090   AD 0D 03   LDA &030D\n     2093   20 CE 20   JSR &20CE\n     2096   20 BC 20   JSR &20BC\n     2099   86 3E      STX &3E\n     209B   85 3D      STA &3D\n     209D   A2 0B      LDX #&0B\n     209F   86 06      STX &06\n     20A1   AD 4D 0D   LDA &0D4D\n     20A4   20 CC 20   JSR &20CC\n     20A7   AD 61 0D   LDA &0D61\n     20AA   20 CC 20   JSR &20CC\n     20AD   A9 F0      LDA #&F0\n     20AF   85 06      STA &06\n     20B1   85 3E      STA &3E\n     20B3   AD 21 0F   LDA &0F21\n     20B6   20 CC 20   JSR &20CC\n     20B9   4C 51 3B   JMP &3B51\n.PZW\n     20BC   A2 F0      LDX #&F0\n     20BE   A5 99      LDA &99\n     20C0   29 08      AND #&08\n     20C2   2D 4D 0F   AND &0F4D\n     20C5   F0 02      BEQ &20C9\n     20C7   8A         TXA\n     20C8   2C\n     20C9   A9 0F      LDA #&0F\n     20CB   60         RTS\n.DILX\n     20CC   4A         LSR A\n     20CD   4A         LSR A\n     20CE   4A         LSR A\n     20CF   4A         LSR A\n.DIL\n     20D0   85 90      STA &90\n     20D2   A2 FF      LDX #&FF\n     20D4   86 91      STX &91\n     20D6   C5 06      CMP &06\n     20D8   B0 04      BCS &20DE\n     20DA   A5 3E      LDA &3E\n     20DC   D0 02      BNE &20E0\n.DL30\n     20DE   A5 3D      LDA &3D\n.DL31\n     20E0   85 A2      STA &A2\n     20E2   A0 02      LDY #&02\n     20E4   A2 03      LDX #&03\n.DL1\n     20E6   A5 90      LDA &90\n     20E8   C9 04      CMP #&04\n     20EA   90 1A      BCC &2106\n     20EC   E9 04      SBC #&04\n     20EE   85 90      STA &90\n     20F0   A5 91      LDA &91\n.DL5\n     20F2   25 A2      AND &A2\n     20F4   91 07      STA (&07),Y\n     20F6   C8         INY\n     20F7   91 07      STA (&07),Y\n     20F9   C8         INY\n     20FA   91 07      STA (&07),Y\n     20FC   98         TYA\n     20FD   18         CLC\n     20FE   69 06      ADC #&06\n     2100   A8         TAY\n     2101   CA         DEX\n     2102   30 1C      BMI &2120\n     2104   10 E0      BPL &20E6\n.DL2\n     2106   49 03      EOR #&03\n     2108   85 90      STA &90\n     210A   A5 91      LDA &91\n.DL3\n     210C   0A         ASL A\n     210D   29 EF      AND #&EF\n     210F   C6 90      DEC &90\n     2111   10 F9      BPL &210C\n     2113   48         PHA\n     2114   A9 00      LDA #&00\n     2116   85 91      STA &91\n     2118   A9 63      LDA #&63\n     211A   85 90      STA &90\n     211C   68         PLA\n     211D   4C F2 20   JMP &20F2\n.DL6\n     2120   E6 08      INC &08\n.DL9\n     2122   60         RTS\n.DIL2\n     2123   A0 01      LDY #&01\n     2125   85 90      STA &90\n.DLL10\n     2127   38         SEC\n     2128   A5 90      LDA &90\n     212A   E9 04      SBC #&04\n     212C   B0 0D      BCS &213B\n     212E   A9 FF      LDA #&FF\n     2130   A6 90      LDX &90\n     2132   85 90      STA &90\n     2134   BD 72 18   LDA &1872,X\n     2137   29 F0      AND #&F0\n     2139   D0 04      BNE &213F\n.DLL11\n     213B   85 90      STA &90\n     213D   A9 00      LDA #&00\n.DLL12\n     213F   91 07      STA (&07),Y\n     2141   C8         INY\n     2142   91 07      STA (&07),Y\n     2144   C8         INY\n     2145   91 07      STA (&07),Y\n     2147   C8         INY\n     2148   91 07      STA (&07),Y\n     214A   98         TYA\n     214B   18         CLC\n     214C   69 05      ADC #&05\n     214E   A8         TAY\n     214F   C0 1E      CPY #&1E\n     2151   90 D4      BCC &2127\n     2153   E6 08      INC &08\n     2155   60         RTS\n.TVT1\n     2156   D4\n     2157   C4\n     2158   94\n     2159   84\n     215A   F5\n     215B   E5\n     215C   B5\n     215D   A5\n     215E   76\n     215F   66\n     2160   36\n     2161   26\n     2162   E1\n     2163   F1\n     2164   B1\n     2165   A1\n     2166   F0\n     2167   E0\n     2168   B0\n     2169   A0\n     216A   D0\n     216B   C0\n     216C   90\n     216D   80\n     216E   77\n     216F   67\n     2170   37\n     2171   27\n.LINSCN\n     2172   A9 1E      LDA #&1E\n     2174   85 9A      STA &9A\n     2176   8D 44 FE   STA &FE44\n     2179   A9 39      LDA #&39\n     217B   8D 45 FE   STA &FE45\n     217E   AD 62 0D   LDA &0D62\n     2181   D0 47      BNE &21CA\n     2183   A9 08      LDA #&08\n     2185   8D 20 FE   STA &FE20\n.VNT3\n     2188   B9 66 21   LDA &2166,Y\n     218B   8D 21 FE   STA &FE21\n     218E   88         DEY\n     218F   10 F7      BPL &2188\n     2191   AD 60 0D   LDA &0D60\n     2194   F0 03      BEQ &2199\n     2196   CE 60 0D   DEC &0D60\n     2199   AD FD 7F   LDA &7FFD\n     219C   D0 27      BNE &21C5\n     219E   68         PLA\n     219F   A8         TAY\n     21A0   AD 41 FE   LDA &FE41\n     21A3   A5 FC      LDA &FC\n     21A5   40         RTI\n.IRQ1\n     21A6   98         TYA\n     21A7   48         PHA\n     21A8   A0 0B      LDY #&0B\n     21AA   A9 02      LDA #&02\n     21AC   2C 4D FE   BIT &FE4D\n     21AF   D0 C1      BNE &2172\n     21B1   50 12      BVC &21C5\n     21B3   0A         ASL A\n     21B4   8D 20 FE   STA &FE20\n     21B7   AD 2E 03   LDA &032E\n     21BA   D0 0E      BNE &21CA\n     21BC   B9 56 21   LDA &2156,Y\n     21BF   8D 21 FE   STA &FE21\n     21C2   88         DEY\n     21C3   10 F7      BPL &21BC\n.jvec\n     21C5   68         PLA\n     21C6   A8         TAY\n     21C7   6C FE 7F   JMP (&7FFE)\n.VNT1\n     21CA   A0 07      LDY #&07\n     21CC   B9 5E 21   LDA &215E,Y\n     21CF   8D 21 FE   STA &FE21\n     21D2   88         DEY\n     21D3   10 F7      BPL &21CC\n     21D5   30 EE      BMI &21C5\n.ESCAPE\n     21D7   AD 5C 0D   LDA &0D5C\n     21DA   48         PHA\n     21DB   20 B1 43   JSR &43B1\n     21DE   A2 07      LDX #&07\n     21E0   86 9B      STX &9B\n     21E2   20 66 24   JSR &2466\n     21E5   A9 08      LDA #&08\n     21E7   85 6E      STA &6E\n     21E9   A9 C2      LDA #&C2\n     21EB   85 71      STA &71\n     21ED   4A         LSR A\n     21EE   85 73      STA &73\n.ESL1\n     21F0   20 A9 13   JSR &13A9\n     21F3   20 2F 4E   JSR &4E2F\n     21F6   C6 73      DEC &73\n     21F8   D0 F6      BNE &21F0\n     21FA   20 20 2C   JSR &2C20\n     21FD   20 9B 43   JSR &439B\n     2200   68         PLA\n     2201   F0 03      BEQ &2206\n     2203   4C 7F 46   JMP &467F\n     2206   A2 10      LDX #&10\n.ESL2\n     2208   9D 17 03   STA &0317,X\n     220B   CA         DEX\n     220C   10 FA      BPL &2208\n     220E   8D 34 03   STA &0334\n     2211   8D 2E 03   STA &032E\n     2214   A9 46      LDA #&46\n     2216   8D 0D 03   STA &030D\n     2219   4C 4D 47   JMP &474D\nELITE B\nAssembled at &17F4 \nEnds at &221C \nCode size is &A28 \nExecute at &1128 \nReload at &19DC \nS.ELTB &17F4  &221C  &1128  &19DC \nSaving file '3-assembled-output/ELTB.bin'\n.TA34\n     221C   A9 00      LDA #&00\n     221E   20 78 46   JSR &4678\n     2221   F0 03      BEQ &2226\n     2223   4C F3 22   JMP &22F3\n     2226   20 88 22   JSR &2288\n     2229   20 8C 49   JSR &498C\n     222C   A9 FA      LDA #&FA\n     222E   4C 01 3C   JMP &3C01\n.TA18\n     2231   A5 30      LDA &30\n     2233   D0 43      BNE &2278\n     2235   A5 73      LDA &73\n     2237   0A         ASL A\n     2238   30 E2      BMI &221C\n     223A   4A         LSR A\n     223B   AA         TAX\n     223C   BD 48 18   LDA &1848,X\n     223F   85 22      STA &22\n     2241   BD 49 18   LDA &1849,X\n     2244   85 23      STA &23\n     2246   A0 02      LDY #&02\n     2248   20 03 24   JSR &2403\n     224B   A0 05      LDY #&05\n     224D   20 03 24   JSR &2403\n     2250   A0 08      LDY #&08\n     2252   20 03 24   JSR &2403\n     2255   A5 D4      LDA &D4\n     2257   05 D7      ORA &D7\n     2259   05 DA      ORA &DA\n     225B   29 7F      AND #&7F\n     225D   05 D3      ORA &D3\n     225F   05 D6      ORA &D6\n     2261   05 D9      ORA &D9\n     2263   D0 29      BNE &228E\n     2265   A5 73      LDA &73\n     2267   C9 82      CMP #&82\n     2269   F0 0D      BEQ &2278\n     226B   A0 1F      LDY #&1F\n     226D   B1 22      LDA (&22),Y\n     226F   2C 96 22   BIT &2296\n     2272   D0 04      BNE &2278\n     2274   09 80      ORA #&80\n     2276   91 22      STA (&22),Y\n.TA35\n     2278   A5 53      LDA &53\n     227A   05 56      ORA &56\n     227C   05 59      ORA &59\n     227E   D0 05      BNE &2285\n     2280   A9 50      LDA #&50\n     2282   20 01 3C   JSR &3C01\n.TA87\n     2285   20 A5 49   JSR &49A5\n     2288   06 72      ASL &72\n     228A   38         SEC\n     228B   66 72      ROR &72\n.TA1\n     228D   60         RTS\n.TA64\n     228E   20 57 44   JSR &4457\n     2291   C9 10      CMP #&10\n     2293   B0 67      BCS &22FC\n.M32\n     2295   A0 20      LDY #&20\n     2297   B1 22      LDA (&22),Y\n     2299   4A         LSR A\n     229A   90 60      BCC &22FC\n     229C   4C 15 3D   JMP &3D15\n.TACTICS\n     229F   E0 09      CPX #&09\n     22A1   F0 8E      BEQ &2231\n     22A3   E0 0D      CPX #&0D\n     22A5   D0 06      BNE &22AD\n     22A7   20 DE 48   JSR &48DE\n     22AA   4C C2 23   JMP &23C2\n     22AD   E0 08      CPX #&08\n     22AF   D0 15      BNE &22C6\n     22B1   20 57 44   JSR &4457\n     22B4   C9 8C      CMP #&8C\n     22B6   90 1D      BCC &22D5\n     22B8   AD 4F 0D   LDA &0D4F\n     22BB   C9 04      CMP #&04\n     22BD   B0 16      BCS &22D5\n     22BF   A2 02      LDX #&02\n     22C1   A9 F1      LDA #&F1\n     22C3   4C E0 24   JMP &24E0\n.TA13\n     22C6   E0 0C      CPX #&0C\n     22C8   D0 0C      BNE &22D6\n     22CA   AD 53 0D   LDA &0D53\n     22CD   D0 07      BNE &22D6\n     22CF   46 73      LSR &73\n     22D1   06 73      ASL &73\n     22D3   46 6E      LSR &6E\n     22D5   60         RTS\n.TA14\n     22D6   E0 07      CPX #&07\n     22D8   B0 0F      BCS &22E9\n     22DA   E0 02      CPX #&02\n     22DC   F0 0B      BEQ &22E9\n     22DE   AD 55 0D   LDA &0D55\n     22E1   F0 06      BEQ &22E9\n     22E3   A5 73      LDA &73\n     22E5   29 81      AND #&81\n     22E7   85 73      STA &73\n.TA62\n     22E9   A0 0E      LDY #&0E\n     22EB   A5 76      LDA &76\n     22ED   D1 1E      CMP (&1E),Y\n     22EF   B0 02      BCS &22F3\n     22F1   E6 76      INC &76\n.TA21\n     22F3   A2 08      LDX #&08\n.TAL1\n     22F5   B5 53      LDA &53,X\n     22F7   95 D2      STA &D2,X\n     22F9   CA         DEX\n     22FA   10 F9      BPL &22F5\n.TA19\n     22FC   20 ED 48   JSR &48ED\n     22FF   A0 0A      LDY #&0A\n     2301   20 40 28   JSR &2840\n     2304   85 A4      STA &A4\n     2306   A5 9B      LDA &9B\n     2308   C9 09      CMP #&09\n     230A   D0 03      BNE &230F\n     230C   4C AA 23   JMP &23AA\n     230F   20 57 44   JSR &4457\n     2312   C9 FA      CMP #&FA\n     2314   90 07      BCC &231D\n     2316   20 57 44   JSR &4457\n     2319   09 68      ORA #&68\n     231B   85 70      STA &70\n.TA7\n     231D   A0 0E      LDY #&0E\n     231F   B1 1E      LDA (&1E),Y\n     2321   4A         LSR A\n     2322   C5 76      CMP &76\n     2324   90 41      BCC &2367\n     2326   4A         LSR A\n     2327   4A         LSR A\n     2328   C5 76      CMP &76\n     232A   90 14      BCC &2340\n     232C   20 57 44   JSR &4457\n     232F   C9 E6      CMP #&E6\n     2331   90 0D      BCC &2340\n     2333   A5 9B      LDA &9B\n     2335   C9 06      CMP #&06\n     2337   F0 07      BEQ &2340\n     2339   A9 00      LDA #&00\n     233B   85 73      STA &73\n     233D   4C DC 24   JMP &24DC\n.ta3\n     2340   A5 72      LDA &72\n     2342   29 07      AND #&07\n     2344   F0 21      BEQ &2367\n     2346   85 D1      STA &D1\n     2348   20 57 44   JSR &4457\n     234B   29 1F      AND #&1F\n     234D   C5 D1      CMP &D1\n     234F   B0 16      BCS &2367\n     2351   A5 30      LDA &30\n     2353   D0 12      BNE &2367\n     2355   C6 72      DEC &72\n     2357   A5 9B      LDA &9B\n     2359   C9 06      CMP #&06\n     235B   D0 07      BNE &2364\n     235D   A2 0C      LDX #&0C\n     235F   A5 73      LDA &73\n     2361   4C E0 24   JMP &24E0\n.TA16\n     2364   4C 95 49   JMP &4995\n.TA3\n     2367   A9 00      LDA #&00\n     2369   20 78 46   JSR &4678\n     236C   29 E0      AND #&E0\n     236E   D0 23      BNE &2393\n     2370   A6 A4      LDX &A4\n     2372   E0 A0      CPX #&A0\n     2374   90 1D      BCC &2393\n     2376   A5 72      LDA &72\n     2378   09 40      ORA #&40\n     237A   85 72      STA &72\n     237C   E0 A3      CPX #&A3\n     237E   90 13      BCC &2393\n.HIT\n     2380   A0 13      LDY #&13\n     2382   B1 1E      LDA (&1E),Y\n     2384   4A         LSR A\n     2385   20 01 3C   JSR &3C01\n     2388   C6 6F      DEC &6F\n     238A   A5 30      LDA &30\n     238C   D0 74      BNE &2402\n     238E   A9 08      LDA #&08\n     2390   4C CD 49   JMP &49CD\n.TA4\n     2393   A5 5A      LDA &5A\n     2395   C9 03      CMP #&03\n     2397   B0 08      BCS &23A1\n     2399   A5 54      LDA &54\n     239B   05 57      ORA &57\n     239D   29 FE      AND #&FE\n     239F   F0 21      BEQ &23C2\n.TA5\n     23A1   20 57 44   JSR &4457\n     23A4   09 80      ORA #&80\n     23A6   C5 73      CMP &73\n     23A8   B0 18      BCS &23C2\n.TA20\n     23AA   A5 31      LDA &31\n     23AC   49 80      EOR #&80\n     23AE   85 31      STA &31\n     23B0   A5 32      LDA &32\n     23B2   49 80      EOR #&80\n     23B4   85 32      STA &32\n     23B6   A5 33      LDA &33\n     23B8   49 80      EOR #&80\n     23BA   85 33      STA &33\n     23BC   A5 A4      LDA &A4\n     23BE   49 80      EOR #&80\n     23C0   85 A4      STA &A4\n.TA15\n     23C2   A0 10      LDY #&10\n     23C4   20 40 28   JSR &2840\n     23C7   49 80      EOR #&80\n     23C9   29 80      AND #&80\n     23CB   09 03      ORA #&03\n     23CD   85 71      STA &71\n     23CF   A5 70      LDA &70\n     23D1   29 7F      AND #&7F\n     23D3   C9 10      CMP #&10\n     23D5   B0 0D      BCS &23E4\n     23D7   A0 16      LDY #&16\n     23D9   20 40 28   JSR &2840\n     23DC   45 71      EOR &71\n     23DE   29 80      AND #&80\n     23E0   49 85      EOR #&85\n     23E2   85 70      STA &70\n.TA6\n     23E4   A5 A4      LDA &A4\n     23E6   30 09      BMI &23F1\n     23E8   C9 16      CMP #&16\n     23EA   90 05      BCC &23F1\n     23EC   A9 03      LDA #&03\n     23EE   85 6F      STA &6F\n     23F0   60         RTS\n.TA9\n     23F1   29 7F      AND #&7F\n     23F3   C9 12      CMP #&12\n     23F5   90 0B      BCC &2402\n     23F7   A9 FF      LDA #&FF\n     23F9   A6 9B      LDX &9B\n     23FB   E0 09      CPX #&09\n     23FD   D0 01      BNE &2400\n     23FF   0A         ASL A\n     2400   85 6F      STA &6F\n.TA10\n     2402   60         RTS\n.TAS1\n     2403   B1 22      LDA (&22),Y\n     2405   49 80      EOR #&80\n     2407   85 40      STA &40\n     2409   88         DEY\n     240A   B1 22      LDA (&22),Y\n     240C   85 3F      STA &3F\n     240E   88         DEY\n     240F   B1 22      LDA (&22),Y\n     2411   85 3E      STA &3E\n     2413   84 8F      STY &8F\n     2415   A6 8F      LDX &8F\n     2417   20 AA 15   JSR &15AA\n     241A   A4 8F      LDY &8F\n     241C   95 D4      STA &D4,X\n     241E   A5 3F      LDA &3F\n     2420   95 D3      STA &D3,X\n     2422   A5 3E      LDA &3E\n     2424   95 D2      STA &D2,X\n     2426   60         RTS\n.HITCH\n     2427   18         CLC\n     2428   A5 5B      LDA &5B\n     242A   D0 39      BNE &2465\n     242C   A5 9B      LDA &9B\n     242E   30 35      BMI &2465\n     2430   A5 72      LDA &72\n     2432   29 20      AND #&20\n     2434   05 54      ORA &54\n     2436   05 57      ORA &57\n     2438   D0 2B      BNE &2465\n     243A   A5 53      LDA &53\n     243C   20 6F 27   JSR &276F\n     243F   85 92      STA &92\n     2441   A5 1B      LDA &1B\n     2443   85 91      STA &91\n     2445   A5 56      LDA &56\n     2447   20 6F 27   JSR &276F\n     244A   AA         TAX\n     244B   A5 1B      LDA &1B\n     244D   65 91      ADC &91\n     244F   85 91      STA &91\n     2451   8A         TXA\n     2452   65 92      ADC &92\n     2454   B0 7F      BCS &24D5\n     2456   85 92      STA &92\n     2458   A0 02      LDY #&02\n     245A   B1 1E      LDA (&1E),Y\n     245C   C5 92      CMP &92\n     245E   D0 05      BNE &2465\n     2460   88         DEY\n     2461   B1 1E      LDA (&1E),Y\n     2463   C5 91      CMP &91\n.HI1\n     2465   60         RTS\n.FRS1\n     2466   20 F9 43   JSR &43F9\n     2469   A9 1C      LDA #&1C\n     246B   85 56      STA &56\n     246D   4A         LSR A\n     246E   85 59      STA &59\n     2470   A9 80      LDA #&80\n     2472   85 58      STA &58\n     2474   A5 52      LDA &52\n     2476   0A         ASL A\n     2477   09 80      ORA #&80\n     2479   85 73      STA &73\n.fq1\n     247B   A9 60      LDA #&60\n     247D   85 61      STA &61\n     247F   09 80      ORA #&80\n     2481   85 69      STA &69\n     2483   A5 8C      LDA &8C\n     2485   2A         ROL A\n     2486   85 6E      STA &6E\n     2488   8A         TXA\n     2489   4C 82 3C   JMP &3C82\n.FRMIS\n     248C   A2 09      LDX #&09\n     248E   20 66 24   JSR &2466\n     2491   90 44      BCC &24D7\n     2493   A6 52      LDX &52\n     2495   20 4F 3C   JSR &3C4F\n     2498   BD 40 0D   LDA &0D40,X\n     249B   20 AB 24   JSR &24AB\n     249E   A0 00      LDY #&00\n     24A0   20 07 3D   JSR &3D07\n     24A3   CE 33 03   DEC &0333\n     24A6   A9 30      LDA #&30\n     24A8   4C CD 49   JMP &49CD\n.ANGRY\n     24AB   C9 08      CMP #&08\n     24AD   F0 1F      BEQ &24CE\n     24AF   B0 B4      BCS &2465\n     24B1   C9 07      CMP #&07\n     24B3   D0 03      BNE &24B8\n     24B5   20 CE 24   JSR &24CE\n     24B8   A0 20      LDY #&20\n     24BA   B1 20      LDA (&20),Y\n     24BC   F0 A7      BEQ &2465\n     24BE   09 80      ORA #&80\n     24C0   91 20      STA (&20),Y\n     24C2   A0 1C      LDY #&1C\n     24C4   A9 02      LDA #&02\n     24C6   91 20      STA (&20),Y\n     24C8   0A         ASL A\n     24C9   A0 1E      LDY #&1E\n     24CB   91 20      STA (&20),Y\n     24CD   60         RTS\n.AN2\n     24CE   0E 44 09   ASL &0944\n     24D1   38         SEC\n     24D2   6E 44 09   ROR &0944\n     24D5   18         CLC\n     24D6   60         RTS\n.FR1\n     24D7   A9 C9      LDA #&C9\n     24D9   4C 29 4B   JMP &4B29\n.SESCP\n     24DC   A2 0D      LDX #&0D\n     24DE   A9 FE      LDA #&FE\n.SFS1\n     24E0   85 06      STA &06\n     24E2   A5 1E      LDA &1E\n     24E4   48         PHA\n     24E5   A5 1F      LDA &1F\n     24E7   48         PHA\n     24E8   A5 20      LDA &20\n     24EA   48         PHA\n     24EB   A5 21      LDA &21\n     24ED   48         PHA\n     24EE   A0 23      LDY #&23\n.FRL2\n     24F0   B9 53 00   LDA &0053,Y\n     24F3   99 00 01   STA &0100,Y\n     24F6   B1 20      LDA (&20),Y\n     24F8   99 53 00   STA &0053,Y\n     24FB   88         DEY\n     24FC   10 F2      BPL &24F0\n     24FE   A5 9B      LDA &9B\n     2500   C9 08      CMP #&08\n     2502   D0 1D      BNE &2521\n     2504   8A         TXA\n     2505   48         PHA\n     2506   A9 20      LDA #&20\n     2508   85 6E      STA &6E\n     250A   A2 00      LDX #&00\n     250C   A5 5D      LDA &5D\n     250E   20 5A 25   JSR &255A\n     2511   A2 03      LDX #&03\n     2513   A5 5F      LDA &5F\n     2515   20 5A 25   JSR &255A\n     2518   A2 06      LDX #&06\n     251A   A5 61      LDA &61\n     251C   20 5A 25   JSR &255A\n     251F   68         PLA\n     2520   AA         TAX\n.rx\n     2521   A5 06      LDA &06\n     2523   85 73      STA &73\n     2525   46 70      LSR &70\n     2527   06 70      ASL &70\n     2529   8A         TXA\n     252A   C9 0B      CMP #&0B\n     252C   D0 12      BNE &2540\n     252E   20 57 44   JSR &4457\n     2531   0A         ASL A\n     2532   85 71      STA &71\n     2534   8A         TXA\n     2535   29 0F      AND #&0F\n     2537   85 6E      STA &6E\n     2539   A9 FF      LDA #&FF\n     253B   6A         ROR A\n     253C   85 70      STA &70\n     253E   A9 0B      LDA #&0B\n.NOIL\n     2540   20 82 3C   JSR &3C82\n     2543   68         PLA\n     2544   85 21      STA &21\n     2546   68         PLA\n     2547   85 20      STA &20\n     2549   A2 23      LDX #&23\n.FRL3\n     254B   BD 00 01   LDA &0100,X\n     254E   95 53      STA &53,X\n     2550   CA         DEX\n     2551   10 F8      BPL &254B\n     2553   68         PLA\n     2554   85 1F      STA &1F\n     2556   68         PLA\n     2557   85 1E      STA &1E\n     2559   60         RTS\n.SFS2\n     255A   0A         ASL A\n     255B   85 91      STA &91\n     255D   A9 00      LDA #&00\n     255F   6A         ROR A\n     2560   4C 55 15   JMP &1555\n.LL164\n     2563   A9 38      LDA #&38\n     2565   20 CD 49   JSR &49CD\n     2568   A9 01      LDA #&01\n     256A   8D 62 0D   STA &0D62\n     256D   A9 04      LDA #&04\n     256F   20 7D 25   JSR &257D\n     2572   CE 62 0D   DEC &0D62\n     2575   60         RTS\n.LAUN\n     2576   A9 30      LDA #&30\n     2578   20 CD 49   JSR &49CD\n     257B   A9 08      LDA #&08\n.HFS2\n     257D   85 A6      STA &A6\n     257F   20 7D 2B   JSR &2B7D\n     2582   20 85 25   JSR &2585\n.HFS1\n     2585   A9 80      LDA #&80\n     2587   85 D2      STA &D2\n     2589   A2 60      LDX #&60\n     258B   86 E0      STX &E0\n     258D   0A         ASL A\n     258E   85 A7      STA &A7\n     2590   85 D3      STA &D3\n     2592   85 E1      STA &E1\n.HFL5\n     2594   20 A0 25   JSR &25A0\n     2597   E6 A7      INC &A7\n     2599   A6 A7      LDX &A7\n     259B   E0 08      CPX #&08\n     259D   D0 F5      BNE &2594\n     259F   60         RTS\n.HFL1\n     25A0   A5 A7      LDA &A7\n     25A2   29 07      AND #&07\n     25A4   18         CLC\n     25A5   69 08      ADC #&08\n     25A7   85 3D      STA &3D\n.HFL2\n     25A9   A9 01      LDA #&01\n     25AB   85 77      STA &77\n     25AD   20 96 40   JSR &4096\n     25B0   06 3D      ASL &3D\n     25B2   B0 06      BCS &25BA\n     25B4   A5 3D      LDA &3D\n     25B6   C9 A0      CMP #&A0\n     25B8   90 EF      BCC &25A9\n.HF8\n     25BA   60         RTS\n.STARS2\n     25BB   A9 00      LDA #&00\n     25BD   E0 02      CPX #&02\n     25BF   6A         ROR A\n     25C0   85 AA      STA &AA\n     25C2   49 80      EOR #&80\n     25C4   85 AB      STA &AB\n     25C6   20 6F 26   JSR &266F\n     25C9   AC 33 0F   LDY &0F33\n.STL2\n     25CC   B9 E8 0E   LDA &0EE8,Y\n     25CF   85 97      STA &97\n     25D1   4A         LSR A\n     25D2   4A         LSR A\n     25D3   4A         LSR A\n     25D4   20 C1 28   JSR &28C1\n     25D7   A5 1B      LDA &1B\n     25D9   45 AB      EOR &AB\n     25DB   85 92      STA &92\n     25DD   B9 5F 03   LDA &035F,Y\n     25E0   85 1B      STA &1B\n     25E2   B9 4C 03   LDA &034C,Y\n     25E5   85 31      STA &31\n     25E7   20 5F 28   JSR &285F\n     25EA   85 92      STA &92\n     25EC   86 91      STX &91\n     25EE   B9 C2 0E   LDA &0EC2,Y\n     25F1   85 32      STA &32\n     25F3   45 8A      EOR &8A\n     25F5   A6 2B      LDX &2B\n     25F7   20 2A 27   JSR &272A\n     25FA   20 5F 28   JSR &285F\n     25FD   86 24      STX &24\n     25FF   85 25      STA &25\n     2601   BE D5 0E   LDX &0ED5,Y\n     2604   86 91      STX &91\n     2606   A6 32      LDX &32\n     2608   86 92      STX &92\n     260A   A6 2B      LDX &2B\n     260C   45 8B      EOR &8B\n     260E   20 2A 27   JSR &272A\n     2611   20 5F 28   JSR &285F\n     2614   86 26      STX &26\n     2616   85 27      STA &27\n     2618   A6 87      LDX &87\n     261A   45 88      EOR &88\n     261C   20 2A 27   JSR &272A\n     261F   85 90      STA &90\n     2621   A5 24      LDA &24\n     2623   85 91      STA &91\n     2625   A5 25      LDA &25\n     2627   85 92      STA &92\n     2629   49 80      EOR #&80\n     262B   20 5C 28   JSR &285C\n     262E   85 25      STA &25\n     2630   8A         TXA\n     2631   99 5F 03   STA &035F,Y\n     2634   A5 26      LDA &26\n     2636   85 91      STA &91\n     2638   A5 27      LDA &27\n     263A   85 92      STA &92\n     263C   20 5C 28   JSR &285C\n     263F   85 92      STA &92\n     2641   86 91      STX &91\n     2643   A9 00      LDA #&00\n     2645   85 1B      STA &1B\n     2647   A5 9E      LDA &9E\n     2649   20 B4 1A   JSR &1AB4\n     264C   A5 25      LDA &25\n     264E   99 4C 03   STA &034C,Y\n     2651   85 31      STA &31\n     2653   29 7F      AND #&7F\n     2655   C9 74      CMP #&74\n     2657   B0 31      BCS &268A\n     2659   A5 27      LDA &27\n     265B   99 C2 0E   STA &0EC2,Y\n     265E   85 32      STA &32\n     2660   29 7F      AND #&7F\n     2662   C9 74      CMP #&74\n     2664   B0 37      BCS &269D\n.STC2\n     2666   20 BD 1A   JSR &1ABD\n     2669   88         DEY\n     266A   F0 03      BEQ &266F\n     266C   4C CC 25   JMP &25CC\n.ST2\n     266F   A5 9E      LDA &9E\n     2671   45 AA      EOR &AA\n     2673   85 9E      STA &9E\n     2675   A5 88      LDA &88\n     2677   45 AA      EOR &AA\n     2679   85 88      STA &88\n     267B   49 80      EOR #&80\n     267D   85 89      STA &89\n     267F   A5 8A      LDA &8A\n     2681   45 AA      EOR &AA\n     2683   85 8A      STA &8A\n     2685   49 80      EOR #&80\n     2687   85 8B      STA &8B\n     2689   60         RTS\n.KILL2\n     268A   20 57 44   JSR &4457\n     268D   85 32      STA &32\n     268F   99 C2 0E   STA &0EC2,Y\n     2692   A9 73      LDA #&73\n     2694   05 AA      ORA &AA\n     2696   85 31      STA &31\n     2698   99 4C 03   STA &034C,Y\n     269B   D0 11      BNE &26AE\n.ST5\n     269D   20 57 44   JSR &4457\n     26A0   85 31      STA &31\n     26A2   99 4C 03   STA &034C,Y\n     26A5   A9 6E      LDA #&6E\n     26A7   05 89      ORA &89\n     26A9   85 32      STA &32\n     26AB   99 C2 0E   STA &0EC2,Y\n.STF1\n     26AE   20 57 44   JSR &4457\n     26B1   09 08      ORA #&08\n     26B3   85 97      STA &97\n     26B5   99 E8 0E   STA &0EE8,Y\n     26B8   D0 AC      BNE &2666\n.SNE\n     26BA   00\n     26BB   19\n     26BC   32\n     26BD   4A\n     26BE   62\n     26BF   79\n     26C0   8E\n     26C1   A2\n     26C2   B5\n     26C3   C6\n     26C4   D5\n     26C5   E2\n     26C6   ED\n     26C7   F5\n     26C8   FB\n     26C9   FF\n     26CA   FF\n     26CB   FF\n     26CC   FB\n     26CD   F5\n     26CE   ED\n     26CF   E2\n     26D0   D5\n     26D1   C6\n     26D2   B5\n     26D3   A2\n     26D4   8E\n     26D5   79\n     26D6   62\n     26D7   4A\n     26D8   32\n     26D9   19\n.MU5\n     26DA   85 3D      STA &3D\n     26DC   85 3E      STA &3E\n     26DE   85 3F      STA &3F\n     26E0   85 40      STA &40\n     26E2   18         CLC\n     26E3   60         RTS\n.MULT3\n     26E4   85 91      STA &91\n     26E6   29 7F      AND #&7F\n     26E8   85 3F      STA &3F\n     26EA   A5 90      LDA &90\n     26EC   29 7F      AND #&7F\n     26EE   F0 EA      BEQ &26DA\n     26F0   38         SEC\n     26F1   E9 01      SBC #&01\n     26F3   85 D1      STA &D1\n     26F5   A5 1C      LDA &1C\n     26F7   46 3F      LSR &3F\n     26F9   6A         ROR A\n     26FA   85 3E      STA &3E\n     26FC   A5 1B      LDA &1B\n     26FE   6A         ROR A\n     26FF   85 3D      STA &3D\n     2701   A9 00      LDA #&00\n     2703   A2 18      LDX #&18\n.MUL2\n     2705   90 02      BCC &2709\n     2707   65 D1      ADC &D1\n     2709   6A         ROR A\n     270A   66 3F      ROR &3F\n     270C   66 3E      ROR &3E\n     270E   66 3D      ROR &3D\n     2710   CA         DEX\n     2711   D0 F2      BNE &2705\n     2713   85 D1      STA &D1\n     2715   A5 91      LDA &91\n     2717   45 90      EOR &90\n     2719   29 80      AND #&80\n     271B   05 D1      ORA &D1\n     271D   85 40      STA &40\n     271F   60         RTS\n.MLS2\n     2720   A6 24      LDX &24\n     2722   86 91      STX &91\n     2724   A6 25      LDX &25\n     2726   86 92      STX &92\n.MLS1\n     2728   A6 87      LDX &87\n     272A   86 1B      STX &1B\n.MULTS\n     272C   AA         TAX\n     272D   29 80      AND #&80\n     272F   85 D1      STA &D1\n     2731   8A         TXA\n     2732   29 7F      AND #&7F\n     2734   F0 64      BEQ &279A\n     2736   AA         TAX\n     2737   CA         DEX\n     2738   86 06      STX &06\n     273A   A9 00      LDA #&00\n     273C   46 1B      LSR &1B\n     273E   90 02      BCC &2742\n     2740   65 06      ADC &06\n     2742   6A         ROR A\n     2743   66 1B      ROR &1B\n     2745   90 02      BCC &2749\n     2747   65 06      ADC &06\n     2749   6A         ROR A\n     274A   66 1B      ROR &1B\n     274C   90 02      BCC &2750\n     274E   65 06      ADC &06\n     2750   6A         ROR A\n     2751   66 1B      ROR &1B\n     2753   90 02      BCC &2757\n     2755   65 06      ADC &06\n     2757   6A         ROR A\n     2758   66 1B      ROR &1B\n     275A   90 02      BCC &275E\n     275C   65 06      ADC &06\n     275E   6A         ROR A\n     275F   66 1B      ROR &1B\n     2761   4A         LSR A\n     2762   66 1B      ROR &1B\n     2764   4A         LSR A\n     2765   66 1B      ROR &1B\n     2767   4A         LSR A\n     2768   66 1B      ROR &1B\n     276A   05 D1      ORA &D1\n     276C   60         RTS\n.SQUA\n     276D   29 7F      AND #&7F\n.SQUA2\n     276F   85 1B      STA &1B\n     2771   AA         TAX\n     2772   D0 12      BNE &2786\n.MU1\n     2774   18         CLC\n     2775   86 1B      STX &1B\n     2777   8A         TXA\n     2778   60         RTS\n.MLU1\n     2779   B9 C2 0E   LDA &0EC2,Y\n     277C   85 32      STA &32\n.MLU2\n     277E   29 7F      AND #&7F\n     2780   85 1B      STA &1B\n.MULTU\n     2782   A6 90      LDX &90\n     2784   F0 EE      BEQ &2774\n.MU11\n     2786   CA         DEX\n     2787   86 D1      STX &D1\n     2789   A9 00      LDA #&00\n     278B   A2 08      LDX #&08\n     278D   46 1B      LSR &1B\n.MUL6\n     278F   90 02      BCC &2793\n     2791   65 D1      ADC &D1\n     2793   6A         ROR A\n     2794   66 1B      ROR &1B\n     2796   CA         DEX\n     2797   D0 F6      BNE &278F\n     2799   60         RTS\n.MU6\n     279A   85 1C      STA &1C\n     279C   85 1B      STA &1B\n     279E   60         RTS\n.FMLTU2\n     279F   29 1F      AND #&1F\n     27A1   AA         TAX\n     27A2   BD BA 26   LDA &26BA,X\n     27A5   85 90      STA &90\n     27A7   A5 3D      LDA &3D\n.FMLTU\n     27A9   49 FF      EOR #&FF\n     27AB   38         SEC\n     27AC   6A         ROR A\n     27AD   85 1B      STA &1B\n     27AF   A9 00      LDA #&00\n.MUL3\n     27B1   B0 08      BCS &27BB\n     27B3   65 90      ADC &90\n     27B5   6A         ROR A\n     27B6   46 1B      LSR &1B\n     27B8   D0 F7      BNE &27B1\n     27BA   60         RTS\n.MU7\n     27BB   4A         LSR A\n     27BC   46 1B      LSR &1B\n     27BE   D0 F1      BNE &27B1\n     27C0   60         RTS\n     27C1   A6 90      LDX &90\n     27C3   F0 AF      BEQ &2774\n     27C5   CA         DEX\n     27C6   86 D1      STX &D1\n     27C8   A9 00      LDA #&00\n     27CA   A2 08      LDX #&08\n     27CC   46 1B      LSR &1B\n.MUL6K\n     27CE   90 02      BCC &27D2\n     27D0   65 D1      ADC &D1\n     27D2   6A         ROR A\n     27D3   66 1B      ROR &1B\n     27D5   CA         DEX\n     27D6   D0 F6      BNE &27CE\n     27D8   60         RTS\n     27D9   86 90      STX &90\n.MLTU2\n     27DB   49 FF      EOR #&FF\n     27DD   4A         LSR A\n     27DE   85 1C      STA &1C\n     27E0   A9 00      LDA #&00\n     27E2   A2 10      LDX #&10\n     27E4   66 1B      ROR &1B\n.MUL7\n     27E6   B0 0B      BCS &27F3\n     27E8   65 90      ADC &90\n     27EA   6A         ROR A\n     27EB   66 1C      ROR &1C\n     27ED   66 1B      ROR &1B\n     27EF   CA         DEX\n     27F0   D0 F4      BNE &27E6\n     27F2   60         RTS\n.MU21\n     27F3   4A         LSR A\n     27F4   66 1C      ROR &1C\n     27F6   66 1B      ROR &1B\n     27F8   CA         DEX\n     27F9   D0 EB      BNE &27E6\n     27FB   60         RTS\n.MUT3\n     27FC   A6 87      LDX &87\n     27FE   86 1B      STX &1B\n.MUT2\n     2800   A6 25      LDX &25\n     2802   86 92      STX &92\n.MUT1\n     2804   A6 24      LDX &24\n     2806   86 91      STX &91\n.MULT1\n     2808   AA         TAX\n     2809   29 7F      AND #&7F\n     280B   4A         LSR A\n     280C   85 1B      STA &1B\n     280E   8A         TXA\n     280F   45 90      EOR &90\n     2811   29 80      AND #&80\n     2813   85 D1      STA &D1\n     2815   A5 90      LDA &90\n     2817   29 7F      AND #&7F\n     2819   F0 18      BEQ &2833\n     281B   AA         TAX\n     281C   CA         DEX\n     281D   86 06      STX &06\n     281F   A9 00      LDA #&00\n     2821   A2 07      LDX #&07\n.MUL4\n     2823   90 02      BCC &2827\n     2825   65 06      ADC &06\n     2827   6A         ROR A\n     2828   66 1B      ROR &1B\n     282A   CA         DEX\n     282B   D0 F6      BNE &2823\n     282D   4A         LSR A\n     282E   66 1B      ROR &1B\n     2830   05 D1      ORA &D1\n     2832   60         RTS\n.mu10\n     2833   85 1B      STA &1B\n     2835   60         RTS\n.MULT12\n     2836   20 08 28   JSR &2808\n     2839   85 92      STA &92\n     283B   A5 1B      LDA &1B\n     283D   85 91      STA &91\n     283F   60         RTS\n.TAS3\n     2840   B6 53      LDX &53,Y\n     2842   86 90      STX &90\n     2844   A5 31      LDA &31\n     2846   20 36 28   JSR &2836\n     2849   B6 55      LDX &55,Y\n     284B   86 90      STX &90\n     284D   A5 32      LDA &32\n     284F   20 5C 28   JSR &285C\n     2852   85 92      STA &92\n     2854   86 91      STX &91\n     2856   B6 57      LDX &57,Y\n     2858   86 90      STX &90\n     285A   A5 33      LDA &33\n.MAD\n     285C   20 08 28   JSR &2808\n.ADD\n     285F   85 06      STA &06\n     2861   29 80      AND #&80\n     2863   85 D1      STA &D1\n     2865   45 92      EOR &92\n     2867   30 0D      BMI &2876\n     2869   A5 91      LDA &91\n     286B   18         CLC\n     286C   65 1B      ADC &1B\n     286E   AA         TAX\n     286F   A5 92      LDA &92\n     2871   65 06      ADC &06\n     2873   05 D1      ORA &D1\n     2875   60         RTS\n.MU8\n     2876   A5 92      LDA &92\n     2878   29 7F      AND #&7F\n     287A   85 8F      STA &8F\n     287C   A5 1B      LDA &1B\n     287E   38         SEC\n     287F   E5 91      SBC &91\n     2881   AA         TAX\n     2882   A5 06      LDA &06\n     2884   29 7F      AND #&7F\n     2886   E5 8F      SBC &8F\n     2888   B0 0E      BCS &2898\n     288A   85 8F      STA &8F\n     288C   8A         TXA\n     288D   49 FF      EOR #&FF\n     288F   69 01      ADC #&01\n     2891   AA         TAX\n     2892   A9 00      LDA #&00\n     2894   E5 8F      SBC &8F\n     2896   09 80      ORA #&80\n.MU9\n     2898   45 D1      EOR &D1\n     289A   60         RTS\n.TIS1\n     289B   86 90      STX &90\n     289D   49 80      EOR #&80\n     289F   20 5C 28   JSR &285C\n.DVID96\n     28A2   AA         TAX\n     28A3   29 80      AND #&80\n     28A5   85 D1      STA &D1\n     28A7   8A         TXA\n     28A8   29 7F      AND #&7F\n     28AA   A2 FE      LDX #&FE\n     28AC   86 06      STX &06\n.DVL3\n     28AE   0A         ASL A\n     28AF   C9 60      CMP #&60\n     28B1   90 02      BCC &28B5\n     28B3   E9 60      SBC #&60\n.DV4\n     28B5   26 06      ROL &06\n     28B7   B0 F5      BCS &28AE\n     28B9   A5 06      LDA &06\n     28BB   05 D1      ORA &D1\n     28BD   60         RTS\n.DV42\n     28BE   B9 E8 0E   LDA &0EE8,Y\n.DV41\n     28C1   85 90      STA &90\n     28C3   A5 8C      LDA &8C\n.DVID4\n     28C5   A2 08      LDX #&08\n     28C7   0A         ASL A\n     28C8   85 1B      STA &1B\n     28CA   A9 00      LDA #&00\n.DVL4\n     28CC   2A         ROL A\n     28CD   B0 04      BCS &28D3\n     28CF   C5 90      CMP &90\n     28D1   90 03      BCC &28D6\n.DV8\n     28D3   E5 90      SBC &90\n     28D5   38         SEC\n.DV5\n     28D6   26 1B      ROL &1B\n     28D8   CA         DEX\n     28D9   D0 F1      BNE &28CC\n     28DB   4C 96 4D   JMP &4D96\n.DVID3B2\n     28DE   85 1D      STA &1D\n     28E0   A5 59      LDA &59\n     28E2   85 90      STA &90\n     28E4   A5 5A      LDA &5A\n     28E6   85 91      STA &91\n     28E8   A5 5B      LDA &5B\n     28EA   85 92      STA &92\n.DVID3B\n     28EC   A5 1B      LDA &1B\n     28EE   09 01      ORA #&01\n     28F0   85 1B      STA &1B\n     28F2   A5 1D      LDA &1D\n     28F4   45 92      EOR &92\n     28F6   29 80      AND #&80\n     28F8   85 D1      STA &D1\n     28FA   A0 00      LDY #&00\n     28FC   A5 1D      LDA &1D\n     28FE   29 7F      AND #&7F\n.DVL9\n     2900   C9 40      CMP #&40\n     2902   B0 08      BCS &290C\n     2904   06 1B      ASL &1B\n     2906   26 1C      ROL &1C\n     2908   2A         ROL A\n     2909   C8         INY\n     290A   D0 F4      BNE &2900\n.DV14\n     290C   85 1D      STA &1D\n     290E   A5 92      LDA &92\n     2910   29 7F      AND #&7F\n     2912   30 08      BMI &291C\n.DVL6\n     2914   88         DEY\n     2915   06 90      ASL &90\n     2917   26 91      ROL &91\n     2919   2A         ROL A\n     291A   10 F8      BPL &2914\n.DV9\n     291C   85 90      STA &90\n     291E   A9 FE      LDA #&FE\n     2920   85 91      STA &91\n     2922   A5 1D      LDA &1D\n     2924   20 9A 4D   JSR &4D9A\n     2927   A9 00      LDA #&00\n     2929   85 3E      STA &3E\n     292B   85 3F      STA &3F\n     292D   85 40      STA &40\n     292F   98         TYA\n     2930   10 1E      BPL &2950\n     2932   A5 91      LDA &91\n.DVL8\n     2934   0A         ASL A\n     2935   26 3E      ROL &3E\n     2937   26 3F      ROL &3F\n     2939   26 40      ROL &40\n     293B   C8         INY\n     293C   D0 F6      BNE &2934\n     293E   85 3D      STA &3D\n     2940   A5 40      LDA &40\n     2942   05 D1      ORA &D1\n     2944   85 40      STA &40\n     2946   60         RTS\n.DV13\n     2947   A5 91      LDA &91\n     2949   85 3D      STA &3D\n     294B   A5 D1      LDA &D1\n     294D   85 40      STA &40\n     294F   60         RTS\n.DV12\n     2950   F0 F5      BEQ &2947\n     2952   A5 91      LDA &91\n.DVL10\n     2954   4A         LSR A\n     2955   88         DEY\n     2956   D0 FC      BNE &2954\n     2958   85 3D      STA &3D\n     295A   A5 D1      LDA &D1\n     295C   85 40      STA &40\n     295E   60         RTS\n.cntr\n     295F   AD 4A 0F   LDA &0F4A\n     2962   D0 0C      BNE &2970\n     2964   8A         TXA\n     2965   10 03      BPL &296A\n     2967   CA         DEX\n     2968   30 06      BMI &2970\n.BUMP\n     296A   E8         INX\n     296B   D0 03      BNE &2970\n.REDU\n     296D   CA         DEX\n     296E   F0 FA      BEQ &296A\n.RE1\n     2970   60         RTS\n.BUMP2\n     2971   85 D1      STA &D1\n     2973   8A         TXA\n     2974   18         CLC\n     2975   65 D1      ADC &D1\n     2977   AA         TAX\n     2978   90 02      BCC &297C\n     297A   A2 FF      LDX #&FF\n.RE2\n     297C   10 10      BPL &298E\n     297E   A5 D1      LDA &D1\n     2980   60         RTS\n.REDU2\n     2981   85 D1      STA &D1\n     2983   8A         TXA\n     2984   38         SEC\n     2985   E5 D1      SBC &D1\n     2987   AA         TAX\n     2988   B0 02      BCS &298C\n     298A   A2 01      LDX #&01\n.RE3\n     298C   10 F0      BPL &297E\n     298E   AD 4B 0F   LDA &0F4B\n     2991   D0 EB      BNE &297E\n     2993   A2 80      LDX #&80\n     2995   30 E7      BMI &297E\n.ARCTAN\n     2997   A5 1B      LDA &1B\n     2999   45 90      EOR &90\n     299B   85 06      STA &06\n     299D   A5 90      LDA &90\n     299F   F0 25      BEQ &29C6\n     29A1   0A         ASL A\n     29A2   85 90      STA &90\n     29A4   A5 1B      LDA &1B\n     29A6   0A         ASL A\n     29A7   C5 90      CMP &90\n     29A9   B0 09      BCS &29B4\n     29AB   20 D0 29   JSR &29D0\n     29AE   38         SEC\n.AR4\n     29AF   A6 06      LDX &06\n     29B1   30 16      BMI &29C9\n     29B3   60         RTS\n.AR1\n     29B4   A6 90      LDX &90\n     29B6   85 90      STA &90\n     29B8   86 1B      STX &1B\n     29BA   8A         TXA\n     29BB   20 D0 29   JSR &29D0\n     29BE   85 D1      STA &D1\n     29C0   A9 40      LDA #&40\n     29C2   E5 D1      SBC &D1\n     29C4   B0 E9      BCS &29AF\n.AR2\n     29C6   A9 3F      LDA #&3F\n     29C8   60         RTS\n.AR3\n     29C9   85 D1      STA &D1\n     29CB   A9 80      LDA #&80\n     29CD   E5 D1      SBC &D1\n     29CF   60         RTS\n.ARS1\n     29D0   20 92 4D   JSR &4D92\n     29D3   A5 91      LDA &91\n     29D5   4A         LSR A\n     29D6   4A         LSR A\n     29D7   4A         LSR A\n     29D8   AA         TAX\n     29D9   BD DD 29   LDA &29DD,X\n     29DC   60         RTS\n.ACT\n     29DD   00\n     29DE   01\n     29DF   03\n     29E0   04\n     29E1   05\n     29E2   06\n     29E3   08\n     29E4   09\n     29E5   0A\n     29E6   0B\n     29E7   0C\n     29E8   0D\n     29E9   0F\n     29EA   10\n     29EB   11\n     29EC   12\n     29ED   13\n     29EE   14\n     29EF   15\n     29F0   16\n     29F1   17\n     29F2   18\n     29F3   19\n     29F4   19\n     29F5   1A\n     29F6   1B\n     29F7   1C\n     29F8   1D\n     29F9   1D\n     29FA   1E\n     29FB   1F\n     29FC   1F\n.WARP\n     29FD   AD 57 0D   LDA &0D57\n     2A00   18         CLC\n     2A01   6D 5A 0D   ADC &0D5A\n     2A04   6D 58 0D   ADC &0D58\n     2A07   AA         TAX\n     2A08   BD 42 0D   LDA &0D42,X\n     2A0B   0D 55 0D   ORA &0D55\n     2A0E   0D 5C 0D   ORA &0D5C\n     2A11   D0 43      BNE &2A56\n     2A13   AC 08 09   LDY &0908\n     2A16   30 07      BMI &2A1F\n     2A18   A8         TAY\n     2A19   20 7C 13   JSR &137C\n     2A1C   4A         LSR A\n     2A1D   F0 37      BEQ &2A56\n.WA3\n     2A1F   AC 2C 09   LDY &092C\n     2A22   30 08      BMI &2A2C\n     2A24   A0 24      LDY #&24\n     2A26   20 7A 13   JSR &137A\n     2A29   4A         LSR A\n     2A2A   F0 2A      BEQ &2A56\n.WA2\n     2A2C   A9 81      LDA #&81\n     2A2E   85 92      STA &92\n     2A30   85 91      STA &91\n     2A32   85 1B      STA &1B\n     2A34   AD 08 09   LDA &0908\n     2A37   20 5F 28   JSR &285F\n     2A3A   8D 08 09   STA &0908\n     2A3D   AD 2C 09   LDA &092C\n     2A40   20 5F 28   JSR &285F\n     2A43   8D 2C 09   STA &092C\n     2A46   A9 01      LDA #&01\n     2A48   85 96      STA &96\n     2A4A   85 99      STA &99\n     2A4C   4A         LSR A\n     2A4D   8D 63 0D   STA &0D63\n     2A50   AE 5F 0D   LDX &0D5F\n     2A53   4C 44 2B   JMP &2B44\n.WA1\n     2A56   A9 28      LDA #&28\n     2A58   4C CD 49   JMP &49CD\n.LASLI\n     2A5B   20 57 44   JSR &4457\n     2A5E   29 07      AND #&07\n     2A60   69 5C      ADC #&5C\n     2A62   8D 15 0F   STA &0F15\n     2A65   20 57 44   JSR &4457\n     2A68   29 07      AND #&07\n     2A6A   69 7C      ADC #&7C\n     2A6C   8D 14 0F   STA &0F14\n     2A6F   AD 61 0D   LDA &0D61\n     2A72   69 08      ADC #&08\n     2A74   8D 61 0D   STA &0D61\n     2A77   20 46 3B   JSR &3B46\n.LASLI2\n     2A7A   A5 96      LDA &96\n     2A7C   D0 36      BNE &2AB4\n     2A7E   A9 20      LDA #&20\n     2A80   A0 E0      LDY #&E0\n     2A82   20 89 2A   JSR &2A89\n     2A85   A9 30      LDA #&30\n     2A87   A0 D0      LDY #&D0\n.las\n     2A89   85 33      STA &33\n     2A8B   AD 14 0F   LDA &0F14\n     2A8E   85 31      STA &31\n     2A90   AD 15 0F   LDA &0F15\n     2A93   85 32      STA &32\n     2A95   A9 BF      LDA #&BF\n     2A97   85 34      STA &34\n     2A99   20 77 18   JSR &1877\n     2A9C   AD 14 0F   LDA &0F14\n     2A9F   85 31      STA &31\n     2AA1   AD 15 0F   LDA &0F15\n     2AA4   85 32      STA &32\n     2AA6   84 33      STY &33\n     2AA8   A9 BF      LDA #&BF\n     2AAA   85 34      STA &34\n     2AAC   4C 77 18   JMP &1877\n.PLUT\n     2AAF   AE 5F 0D   LDX &0D5F\n     2AB2   D0 01      BNE &2AB5\n     2AB4   60         RTS\n.PU1\n     2AB5   CA         DEX\n     2AB6   D0 31      BNE &2AE9\n     2AB8   A5 55      LDA &55\n     2ABA   49 80      EOR #&80\n     2ABC   85 55      STA &55\n     2ABE   A5 5B      LDA &5B\n     2AC0   49 80      EOR #&80\n     2AC2   85 5B      STA &5B\n     2AC4   A5 5D      LDA &5D\n     2AC6   49 80      EOR #&80\n     2AC8   85 5D      STA &5D\n     2ACA   A5 61      LDA &61\n     2ACC   49 80      EOR #&80\n     2ACE   85 61      STA &61\n     2AD0   A5 63      LDA &63\n     2AD2   49 80      EOR #&80\n     2AD4   85 63      STA &63\n     2AD6   A5 67      LDA &67\n     2AD8   49 80      EOR #&80\n     2ADA   85 67      STA &67\n     2ADC   A5 69      LDA &69\n     2ADE   49 80      EOR #&80\n     2AE0   85 69      STA &69\n     2AE2   A5 6D      LDA &6D\n     2AE4   49 80      EOR #&80\n     2AE6   85 6D      STA &6D\n     2AE8   60         RTS\n.PU2\n     2AE9   A9 00      LDA #&00\n     2AEB   E0 02      CPX #&02\n     2AED   6A         ROR A\n     2AEE   85 AB      STA &AB\n     2AF0   49 80      EOR #&80\n     2AF2   85 AA      STA &AA\n     2AF4   A5 53      LDA &53\n     2AF6   A6 59      LDX &59\n     2AF8   85 59      STA &59\n     2AFA   86 53      STX &53\n     2AFC   A5 54      LDA &54\n     2AFE   A6 5A      LDX &5A\n     2B00   85 5A      STA &5A\n     2B02   86 54      STX &54\n     2B04   A5 55      LDA &55\n     2B06   45 AA      EOR &AA\n     2B08   AA         TAX\n     2B09   A5 5B      LDA &5B\n     2B0B   45 AB      EOR &AB\n     2B0D   85 55      STA &55\n     2B0F   86 5B      STX &5B\n     2B11   A0 09      LDY #&09\n     2B13   20 1D 2B   JSR &2B1D\n     2B16   A0 0F      LDY #&0F\n     2B18   20 1D 2B   JSR &2B1D\n     2B1B   A0 15      LDY #&15\n.PUS1\n     2B1D   B9 53 00   LDA &0053,Y\n     2B20   B6 57      LDX &57,Y\n     2B22   99 57 00   STA &0057,Y\n     2B25   96 53      STX &53,Y\n     2B27   B9 54 00   LDA &0054,Y\n     2B2A   45 AA      EOR &AA\n     2B2C   AA         TAX\n     2B2D   B9 58 00   LDA &0058,Y\n     2B30   45 AB      EOR &AB\n     2B32   99 54 00   STA &0054,Y\n     2B35   96 58      STX &58,Y\n.LO2\n     2B37   60         RTS\n.LQ\n     2B38   8E 5F 0D   STX &0D5F\n     2B3B   20 7B 2B   JSR &2B7B\n     2B3E   20 5B 2B   JSR &2B5B\n     2B41   4C CE 3A   JMP &3ACE\n.LOOK1\n     2B44   A9 00      LDA #&00\n     2B46   A4 96      LDY &96\n     2B48   D0 EE      BNE &2B38\n     2B4A   EC 5F 0D   CPX &0D5F\n     2B4D   F0 E8      BEQ &2B37\n     2B4F   8E 5F 0D   STX &0D5F\n     2B52   20 7B 2B   JSR &2B7B\n     2B55   20 B2 1B   JSR &1BB2\n     2B58   20 F5 3A   JSR &3AF5\n.SIGHT\n     2B5B   AC 5F 0D   LDY &0D5F\n     2B5E   B9 10 03   LDA &0310,Y\n     2B61   F0 D4      BEQ &2B37\n     2B63   A9 80      LDA #&80\n     2B65   85 7F      STA &7F\n     2B67   A9 48      LDA #&48\n     2B69   85 80      STA &80\n     2B6B   A9 14      LDA #&14\n     2B6D   85 81      STA &81\n     2B6F   20 0B 2F   JSR &2F0B\n     2B72   A9 0A      LDA #&0A\n     2B74   85 81      STA &81\n     2B76   4C 0B 2F   JMP &2F0B\n     2B79   A9 01      LDA #&01\n.TT66\n     2B7B   85 96      STA &96\n.TTX66\n     2B7D   A9 80      LDA #&80\n     2B7F   85 7E      STA &7E\n     2B81   0A         ASL A\n     2B82   8D 5D 0D   STA &0D5D\n     2B85   8D 64 0D   STA &0D64\n     2B88   8D 65 0D   STA &0D65\n     2B8B   A2 60      LDX #&60\n.BOL1\n     2B8D   20 2D 48   JSR &482D\n     2B90   E8         INX\n     2B91   E0 78      CPX #&78\n     2B93   D0 F8      BNE &2B8D\n     2B95   A6 2F      LDX &2F\n     2B97   F0 03      BEQ &2B9C\n     2B99   20 E0 33   JSR &33E0\n.BOX\n     2B9C   A0 01      LDY #&01\n     2B9E   84 2D      STY &2D\n     2BA0   A5 96      LDA &96\n     2BA2   D0 14      BNE &2BB8\n     2BA4   A0 0B      LDY #&0B\n     2BA6   84 2C      STY &2C\n     2BA8   AD 5F 0D   LDA &0D5F\n     2BAB   09 60      ORA #&60\n     2BAD   20 B6 38   JSR &38B6\n     2BB0   20 70 34   JSR &3470\n     2BB3   A9 AF      LDA #&AF\n     2BB5   20 B6 38   JSR &38B6\n.tt66\n     2BB8   A2 00      LDX #&00\n     2BBA   86 31      STX &31\n     2BBC   86 32      STX &32\n     2BBE   86 7E      STX &7E\n     2BC0   CA         DEX\n     2BC1   86 33      STX &33\n     2BC3   20 15 1A   JSR &1A15\n     2BC6   A9 02      LDA #&02\n     2BC8   85 31      STA &31\n     2BCA   85 33      STA &33\n     2BCC   20 CF 2B   JSR &2BCF\n.BOS2\n     2BCF   20 D2 2B   JSR &2BD2\n.BOS1\n     2BD2   A9 00      LDA #&00\n     2BD4   85 32      STA &32\n     2BD6   A9 BF      LDA #&BF\n     2BD8   85 34      STA &34\n     2BDA   C6 31      DEC &31\n     2BDC   C6 33      DEC &33\n     2BDE   4C 77 18   JMP &1877\n     2BE1   A0 02      LDY #&02\n     2BE3   2C\n.DEL8\n     2BE4   A0 08      LDY #&08\n.DELAY\n     2BE6   20 BF 2C   JSR &2CBF\n     2BE9   88         DEY\n     2BEA   D0 FA      BNE &2BE6\n     2BEC   60         RTS\n.hm\n     2BED   20 94 31   JSR &3194\n     2BF0   20 A4 32   JSR &32A4\n     2BF3   20 94 31   JSR &3194\n     2BF6   A5 96      LDA &96\n     2BF8   F0 25      BEQ &2C1F\n.CLYNS\n     2BFA   A9 14      LDA #&14\n     2BFC   85 2D      STA &2D\n     2BFE   A9 75      LDA #&75\n     2C00   85 08      STA &08\n     2C02   A9 07      LDA #&07\n     2C04   85 07      STA &07\n     2C06   20 37 2D   JSR &2D37\n     2C09   A9 00      LDA #&00\n     2C0B   20 18 2C   JSR &2C18\n     2C0E   E6 08      INC &08\n     2C10   20 18 2C   JSR &2C18\n     2C13   E6 08      INC &08\n     2C15   C8         INY\n     2C16   84 2C      STY &2C\n.LYN\n     2C18   A0 E9      LDY #&E9\n.EE2\n     2C1A   91 07      STA (&07),Y\n     2C1C   88         DEY\n     2C1D   D0 FB      BNE &2C1A\n.SC5\n     2C1F   60         RTS\n.SCAN\n     2C20   A5 72      LDA &72\n     2C22   29 10      AND #&10\n     2C24   F0 F9      BEQ &2C1F\n     2C26   A5 9B      LDA &9B\n     2C28   30 F5      BMI &2C1F\n     2C2A   A2 FF      LDX #&FF\n     2C2C   C9 09      CMP #&09\n     2C2E   D0 02      BNE &2C32\n     2C30   A2 F0      LDX #&F0\n     2C32   86 A2      STX &A2\n     2C34   A5 54      LDA &54\n     2C36   05 57      ORA &57\n     2C38   05 5A      ORA &5A\n     2C3A   29 C0      AND #&C0\n     2C3C   D0 E1      BNE &2C1F\n     2C3E   A5 54      LDA &54\n     2C40   18         CLC\n     2C41   A6 55      LDX &55\n     2C43   10 04      BPL &2C49\n     2C45   49 FF      EOR #&FF\n     2C47   69 01      ADC #&01\n.SC2\n     2C49   69 7B      ADC #&7B\n     2C4B   85 31      STA &31\n     2C4D   A5 5A      LDA &5A\n     2C4F   4A         LSR A\n     2C50   4A         LSR A\n     2C51   18         CLC\n     2C52   A6 5B      LDX &5B\n     2C54   10 03      BPL &2C59\n     2C56   49 FF      EOR #&FF\n     2C58   38         SEC\n.SC3\n     2C59   69 23      ADC #&23\n     2C5B   49 FF      EOR #&FF\n     2C5D   85 07      STA &07\n     2C5F   A5 57      LDA &57\n     2C61   4A         LSR A\n     2C62   18         CLC\n     2C63   A6 58      LDX &58\n     2C65   30 03      BMI &2C6A\n     2C67   49 FF      EOR #&FF\n     2C69   38         SEC\n.SCD6\n     2C6A   65 07      ADC &07\n     2C6C   10 0A      BPL &2C78\n     2C6E   C9 C2      CMP #&C2\n     2C70   B0 02      BCS &2C74\n     2C72   A9 C2      LDA #&C2\n     2C74   C9 F7      CMP #&F7\n     2C76   90 02      BCC &2C7A\n.ld246\n     2C78   A9 F6      LDA #&F6\n     2C7A   85 32      STA &32\n     2C7C   38         SEC\n     2C7D   E5 07      SBC &07\n     2C7F   08         PHP\n.SC48\n     2C80   48         PHA\n     2C81   20 C4 3B   JSR &3BC4\n     2C84   BD 73 18   LDA &1873,X\n     2C87   25 A2      AND &A2\n     2C89   85 31      STA &31\n     2C8B   68         PLA\n     2C8C   28         PLP\n     2C8D   AA         TAX\n     2C8E   F0 12      BEQ &2CA2\n     2C90   90 11      BCC &2CA3\n.VLL1\n     2C92   88         DEY\n     2C93   10 04      BPL &2C99\n     2C95   A0 07      LDY #&07\n     2C97   C6 08      DEC &08\n.VL1\n     2C99   A5 31      LDA &31\n     2C9B   51 07      EOR (&07),Y\n     2C9D   91 07      STA (&07),Y\n     2C9F   CA         DEX\n     2CA0   D0 F0      BNE &2C92\n.RTS\n     2CA2   60         RTS\n     2CA3   C8         INY\n     2CA4   C0 08      CPY #&08\n     2CA6   D0 04      BNE &2CAC\n     2CA8   A0 00      LDY #&00\n     2CAA   E6 08      INC &08\n.VLL2\n     2CAC   C8         INY\n     2CAD   C0 08      CPY #&08\n     2CAF   D0 04      BNE &2CB5\n     2CB1   A0 00      LDY #&00\n     2CB3   E6 08      INC &08\n.VL2\n     2CB5   A5 31      LDA &31\n     2CB7   51 07      EOR (&07),Y\n     2CB9   91 07      STA (&07),Y\n     2CBB   E8         INX\n     2CBC   D0 EE      BNE &2CAC\n     2CBE   60         RTS\n.WSCAN\n     2CBF   A9 00      LDA #&00\n     2CC1   85 9A      STA &9A\n     2CC3   A5 9A      LDA &9A\n     2CC5   F0 FC      BEQ &2CC3\n     2CC7   60         RTS\nELITE C\nAssembled at &221C \nEnds at &2CC8 \nCode size is &AAC \nExecute at &1128 \nReload at &2404 \nS.ELTC &221C  &2CC8  &1128  &2404 \nSaving file '3-assembled-output/ELTC.bin'\n.tnpr\n     2CC8   48         PHA\n     2CC9   A2 0C      LDX #&0C\n     2CCB   EC 1B 0F   CPX &0F1B\n     2CCE   90 0B      BCC &2CDB\n.Tml\n     2CD0   7D 17 03   ADC &0317,X\n     2CD3   CA         DEX\n     2CD4   10 FA      BPL &2CD0\n     2CD6   CD 16 03   CMP &0316\n     2CD9   68         PLA\n     2CDA   60         RTS\n.kg\n     2CDB   AC 1B 0F   LDY &0F1B\n     2CDE   79 17 03   ADC &0317,Y\n     2CE1   C9 C8      CMP #&C8\n     2CE3   68         PLA\n     2CE4   60         RTS\n.TT20\n     2CE5   20 E8 2C   JSR &2CE8\n     2CE8   20 EB 2C   JSR &2CEB\n.TT54\n     2CEB   A5 78      LDA &78\n     2CED   18         CLC\n     2CEE   65 7A      ADC &7A\n     2CF0   AA         TAX\n     2CF1   A5 79      LDA &79\n     2CF3   65 7B      ADC &7B\n     2CF5   A8         TAY\n     2CF6   A5 7A      LDA &7A\n     2CF8   85 78      STA &78\n     2CFA   A5 7B      LDA &7B\n     2CFC   85 79      STA &79\n     2CFE   A5 7D      LDA &7D\n     2D00   85 7B      STA &7B\n     2D02   A5 7C      LDA &7C\n     2D04   85 7A      STA &7A\n     2D06   18         CLC\n     2D07   8A         TXA\n     2D08   65 7A      ADC &7A\n     2D0A   85 7C      STA &7C\n     2D0C   98         TYA\n     2D0D   65 7B      ADC &7B\n     2D0F   85 7D      STA &7D\n     2D11   60         RTS\n.TT146\n     2D12   AD 2F 0F   LDA &0F2F\n     2D15   0D 30 0F   ORA &0F30\n     2D18   D0 03      BNE &2D1D\n     2D1A   E6 2D      INC &2D\n     2D1C   60         RTS\n.TT63\n     2D1D   A9 BF      LDA #&BF\n     2D1F   20 B1 38   JSR &38B1\n     2D22   AE 2F 0F   LDX &0F2F\n     2D25   AC 30 0F   LDY &0F30\n     2D28   38         SEC\n     2D29   20 E8 33   JSR &33E8\n     2D2C   A9 C3      LDA #&C3\n.TT60\n     2D2E   20 B6 38   JSR &38B6\n.TTX69\n     2D31   E6 2D      INC &2D\n.TT69\n     2D33   A9 80      LDA #&80\n     2D35   85 7E      STA &7E\n.TT67\n     2D37   A9 0D      LDA #&0D\n     2D39   4C B6 38   JMP &38B6\n.TT70\n     2D3C   A9 AD      LDA #&AD\n     2D3E   20 B6 38   JSR &38B6\n     2D41   4C 7E 2D   JMP &2D7E\n.spc\n     2D44   20 B6 38   JSR &38B6\n     2D47   4C 70 34   JMP &3470\n.TT25\n     2D4A   20 79 2B   JSR &2B79\n     2D4D   A9 09      LDA #&09\n     2D4F   85 2C      STA &2C\n     2D51   A9 A3      LDA #&A3\n     2D53   20 B6 38   JSR &38B6\n     2D56   20 FB 19   JSR &19FB\n     2D59   20 31 2D   JSR &2D31\n     2D5C   E6 2D      INC &2D\n     2D5E   20 12 2D   JSR &2D12\n     2D61   A9 C2      LDA #&C2\n     2D63   20 B1 38   JSR &38B1\n     2D66   AD 28 0F   LDA &0F28\n     2D69   18         CLC\n     2D6A   69 01      ADC #&01\n     2D6C   4A         LSR A\n     2D6D   C9 02      CMP #&02\n     2D6F   F0 CB      BEQ &2D3C\n     2D71   AD 28 0F   LDA &0F28\n     2D74   90 03      BCC &2D79\n     2D76   E9 05      SBC #&05\n     2D78   18         CLC\n.TT71\n     2D79   69 AA      ADC #&AA\n     2D7B   20 B6 38   JSR &38B6\n.TT72\n     2D7E   AD 28 0F   LDA &0F28\n     2D81   4A         LSR A\n     2D82   4A         LSR A\n     2D83   18         CLC\n     2D84   69 A8      ADC #&A8\n     2D86   20 2E 2D   JSR &2D2E\n     2D89   A9 A2      LDA #&A2\n     2D8B   20 B1 38   JSR &38B1\n     2D8E   AD 29 0F   LDA &0F29\n     2D91   18         CLC\n     2D92   69 B1      ADC #&B1\n     2D94   20 2E 2D   JSR &2D2E\n     2D97   A9 C4      LDA #&C4\n     2D99   20 B1 38   JSR &38B1\n     2D9C   AE 2A 0F   LDX &0F2A\n     2D9F   E8         INX\n     2DA0   18         CLC\n     2DA1   20 BD 1E   JSR &1EBD\n     2DA4   20 31 2D   JSR &2D31\n     2DA7   A9 C0      LDA #&C0\n     2DA9   20 B1 38   JSR &38B1\n     2DAC   38         SEC\n     2DAD   AE 2B 0F   LDX &0F2B\n     2DB0   20 BD 1E   JSR &1EBD\n     2DB3   A9 C6      LDA #&C6\n     2DB5   20 2E 2D   JSR &2D2E\n     2DB8   A9 28      LDA #&28\n     2DBA   20 B6 38   JSR &38B6\n     2DBD   A5 7C      LDA &7C\n     2DBF   30 08      BMI &2DC9\n     2DC1   A9 BC      LDA #&BC\n     2DC3   20 B6 38   JSR &38B6\n     2DC6   4C 05 2E   JMP &2E05\n.TT75\n     2DC9   A5 7D      LDA &7D\n     2DCB   4A         LSR A\n     2DCC   4A         LSR A\n     2DCD   48         PHA\n     2DCE   29 07      AND #&07\n     2DD0   C9 03      CMP #&03\n     2DD2   B0 05      BCS &2DD9\n     2DD4   69 E3      ADC #&E3\n     2DD6   20 44 2D   JSR &2D44\n.TT205\n     2DD9   68         PLA\n     2DDA   4A         LSR A\n     2DDB   4A         LSR A\n     2DDC   4A         LSR A\n     2DDD   C9 06      CMP #&06\n     2DDF   B0 05      BCS &2DE6\n     2DE1   69 E6      ADC #&E6\n     2DE3   20 44 2D   JSR &2D44\n.TT206\n     2DE6   A5 7B      LDA &7B\n     2DE8   45 79      EOR &79\n     2DEA   29 07      AND #&07\n     2DEC   85 7F      STA &7F\n     2DEE   C9 06      CMP #&06\n     2DF0   B0 05      BCS &2DF7\n     2DF2   69 EC      ADC #&EC\n     2DF4   20 44 2D   JSR &2D44\n.TT207\n     2DF7   A5 7D      LDA &7D\n     2DF9   29 03      AND #&03\n     2DFB   18         CLC\n     2DFC   65 7F      ADC &7F\n     2DFE   29 07      AND #&07\n     2E00   69 F2      ADC #&F2\n     2E02   20 B6 38   JSR &38B6\n.TT76\n     2E05   A9 53      LDA #&53\n     2E07   20 B6 38   JSR &38B6\n     2E0A   A9 29      LDA #&29\n     2E0C   20 2E 2D   JSR &2D2E\n     2E0F   A9 C1      LDA #&C1\n     2E11   20 B1 38   JSR &38B1\n     2E14   AE 2D 0F   LDX &0F2D\n     2E17   AC 2E 0F   LDY &0F2E\n     2E1A   20 E7 33   JSR &33E7\n     2E1D   20 70 34   JSR &3470\n     2E20   A9 00      LDA #&00\n     2E22   85 7E      STA &7E\n     2E24   A9 4D      LDA #&4D\n     2E26   20 B6 38   JSR &38B6\n     2E29   A9 E2      LDA #&E2\n     2E2B   20 2E 2D   JSR &2D2E\n     2E2E   A9 FA      LDA #&FA\n     2E30   20 B1 38   JSR &38B1\n     2E33   A5 7D      LDA &7D\n     2E35   A6 7B      LDX &7B\n     2E37   29 0F      AND #&0F\n     2E39   18         CLC\n     2E3A   69 0B      ADC #&0B\n     2E3C   A8         TAY\n     2E3D   20 E8 33   JSR &33E8\n     2E40   20 70 34   JSR &3470\n     2E43   A9 6B      LDA #&6B\n     2E45   20 81 1F   JSR &1F81\n     2E48   A9 6D      LDA #&6D\n     2E4A   4C 81 1F   JMP &1F81\n.TT24\n     2E4D   A5 79      LDA &79\n     2E4F   29 07      AND #&07\n     2E51   8D 28 0F   STA &0F28\n     2E54   A5 7A      LDA &7A\n     2E56   4A         LSR A\n     2E57   4A         LSR A\n     2E58   4A         LSR A\n     2E59   29 07      AND #&07\n     2E5B   8D 29 0F   STA &0F29\n     2E5E   4A         LSR A\n     2E5F   D0 08      BNE &2E69\n     2E61   AD 28 0F   LDA &0F28\n     2E64   09 02      ORA #&02\n     2E66   8D 28 0F   STA &0F28\n.TT77\n     2E69   AD 28 0F   LDA &0F28\n     2E6C   49 07      EOR #&07\n     2E6E   18         CLC\n     2E6F   8D 2A 0F   STA &0F2A\n     2E72   A5 7B      LDA &7B\n     2E74   29 03      AND #&03\n     2E76   6D 2A 0F   ADC &0F2A\n     2E79   8D 2A 0F   STA &0F2A\n     2E7C   AD 29 0F   LDA &0F29\n     2E7F   4A         LSR A\n     2E80   6D 2A 0F   ADC &0F2A\n     2E83   8D 2A 0F   STA &0F2A\n     2E86   0A         ASL A\n     2E87   0A         ASL A\n     2E88   6D 28 0F   ADC &0F28\n     2E8B   6D 29 0F   ADC &0F29\n     2E8E   69 01      ADC #&01\n     2E90   8D 2B 0F   STA &0F2B\n     2E93   AD 28 0F   LDA &0F28\n     2E96   49 07      EOR #&07\n     2E98   69 03      ADC #&03\n     2E9A   85 1B      STA &1B\n     2E9C   AD 29 0F   LDA &0F29\n     2E9F   69 04      ADC #&04\n     2EA1   85 90      STA &90\n     2EA3   20 82 27   JSR &2782\n     2EA6   AD 2B 0F   LDA &0F2B\n     2EA9   85 90      STA &90\n     2EAB   20 82 27   JSR &2782\n     2EAE   06 1B      ASL &1B\n     2EB0   2A         ROL A\n     2EB1   06 1B      ASL &1B\n     2EB3   2A         ROL A\n     2EB4   06 1B      ASL &1B\n     2EB6   2A         ROL A\n     2EB7   8D 2E 0F   STA &0F2E\n     2EBA   A5 1B      LDA &1B\n     2EBC   8D 2D 0F   STA &0F2D\n     2EBF   60         RTS\n.TT22\n     2EC0   A9 40      LDA #&40\n     2EC2   20 7B 2B   JSR &2B7B\n     2EC5   A9 07      LDA #&07\n     2EC7   85 2C      STA &2C\n     2EC9   20 99 32   JSR &3299\n     2ECC   A9 C7      LDA #&C7\n     2ECE   20 B6 38   JSR &38B6\n     2ED1   20 FB 19   JSR &19FB\n     2ED4   A9 98      LDA #&98\n     2ED6   20 FF 19   JSR &19FF\n     2ED9   20 76 2F   JSR &2F76\n     2EDC   A2 00      LDX #&00\n.TT83\n     2EDE   86 93      STX &93\n     2EE0   A6 7B      LDX &7B\n     2EE2   A4 7C      LDY &7C\n     2EE4   98         TYA\n     2EE5   09 50      ORA #&50\n     2EE7   85 97      STA &97\n     2EE9   A5 79      LDA &79\n     2EEB   4A         LSR A\n     2EEC   18         CLC\n     2EED   69 18      ADC #&18\n     2EEF   85 32      STA &32\n     2EF1   20 DF 1A   JSR &1ADF\n     2EF4   20 E5 2C   JSR &2CE5\n     2EF7   A6 93      LDX &93\n     2EF9   E8         INX\n     2EFA   D0 E2      BNE &2EDE\n     2EFC   AD 31 0F   LDA &0F31\n     2EFF   85 7F      STA &7F\n     2F01   AD 32 0F   LDA &0F32\n     2F04   4A         LSR A\n     2F05   85 80      STA &80\n     2F07   A9 04      LDA #&04\n     2F09   85 81      STA &81\n.TT15\n     2F0B   A9 18      LDA #&18\n     2F0D   A6 96      LDX &96\n     2F0F   10 02      BPL &2F13\n     2F11   A9 00      LDA #&00\n     2F13   85 84      STA &84\n     2F15   A5 7F      LDA &7F\n     2F17   38         SEC\n     2F18   E5 81      SBC &81\n     2F1A   B0 02      BCS &2F1E\n     2F1C   A9 00      LDA #&00\n.TT84\n     2F1E   85 31      STA &31\n     2F20   A5 7F      LDA &7F\n     2F22   18         CLC\n     2F23   65 81      ADC &81\n     2F25   90 02      BCC &2F29\n     2F27   A9 FF      LDA #&FF\n     2F29   85 33      STA &33\n     2F2B   A5 80      LDA &80\n     2F2D   18         CLC\n     2F2E   65 84      ADC &84\n     2F30   85 32      STA &32\n     2F32   20 15 1A   JSR &1A15\n     2F35   A5 80      LDA &80\n     2F37   38         SEC\n     2F38   E5 81      SBC &81\n     2F3A   B0 02      BCS &2F3E\n     2F3C   A9 00      LDA #&00\n.TT86\n     2F3E   18         CLC\n     2F3F   65 84      ADC &84\n     2F41   85 32      STA &32\n     2F43   A5 80      LDA &80\n     2F45   18         CLC\n     2F46   65 81      ADC &81\n     2F48   65 84      ADC &84\n     2F4A   C9 98      CMP #&98\n     2F4C   90 06      BCC &2F54\n     2F4E   A6 96      LDX &96\n     2F50   30 02      BMI &2F54\n     2F52   A9 97      LDA #&97\n.TT87\n     2F54   85 34      STA &34\n     2F56   A5 7F      LDA &7F\n     2F58   85 31      STA &31\n     2F5A   85 33      STA &33\n     2F5C   4C 77 18   JMP &1877\n.TT126\n     2F5F   A9 68      LDA #&68\n     2F61   85 7F      STA &7F\n     2F63   A9 5A      LDA #&5A\n     2F65   85 80      STA &80\n     2F67   A9 10      LDA #&10\n     2F69   85 81      STA &81\n     2F6B   20 0B 2F   JSR &2F0B\n     2F6E   AD 0D 03   LDA &030D\n     2F71   85 3D      STA &3D\n     2F73   4C 9A 2F   JMP &2F9A\n.TT14\n     2F76   A5 96      LDA &96\n     2F78   30 E5      BMI &2F5F\n     2F7A   AD 0D 03   LDA &030D\n     2F7D   4A         LSR A\n     2F7E   4A         LSR A\n     2F7F   85 3D      STA &3D\n     2F81   AD 01 03   LDA &0301\n     2F84   85 7F      STA &7F\n     2F86   AD 02 03   LDA &0302\n     2F89   4A         LSR A\n     2F8A   85 80      STA &80\n     2F8C   A9 07      LDA #&07\n     2F8E   85 81      STA &81\n     2F90   20 0B 2F   JSR &2F0B\n     2F93   A5 80      LDA &80\n     2F95   18         CLC\n     2F96   69 18      ADC #&18\n     2F98   85 80      STA &80\n.TT128\n     2F9A   A5 7F      LDA &7F\n     2F9C   85 D2      STA &D2\n     2F9E   A5 80      LDA &80\n     2FA0   85 E0      STA &E0\n     2FA2   A2 00      LDX #&00\n     2FA4   86 E1      STX &E1\n     2FA6   86 D3      STX &D3\n     2FA8   E8         INX\n     2FA9   86 77      STX &77\n     2FAB   A2 02      LDX #&02\n     2FAD   86 A6      STX &A6\n     2FAF   20 96 40   JSR &4096\n     2FB2   60         RTS\n.TT219\n     2FB3   20 79 2B   JSR &2B79\n     2FB6   20 86 34   JSR &3486\n     2FB9   A9 80      LDA #&80\n     2FBB   85 7E      STA &7E\n     2FBD   A9 00      LDA #&00\n     2FBF   8D 1B 0F   STA &0F1B\n.TT220\n     2FC2   20 F7 33   JSR &33F7\n     2FC5   AD 19 0F   LDA &0F19\n     2FC8   D0 0F      BNE &2FD9\n     2FCA   4C 3B 30   JMP &303B\n.TQ4\n     2FCD   A0 B0      LDY #&B0\n.Tc\n     2FCF   20 70 34   JSR &3470\n     2FD2   98         TYA\n     2FD3   20 EF 33   JSR &33EF\n.TTX224\n     2FD6   20 B7 37   JSR &37B7\n.TT224\n     2FD9   20 FA 2B   JSR &2BFA\n     2FDC   A9 CC      LDA #&CC\n     2FDE   20 B6 38   JSR &38B6\n     2FE1   AD 1B 0F   LDA &0F1B\n     2FE4   18         CLC\n     2FE5   69 D0      ADC #&D0\n     2FE7   20 B6 38   JSR &38B6\n     2FEA   A9 2F      LDA #&2F\n     2FEC   20 B6 38   JSR &38B6\n     2FEF   20 63 34   JSR &3463\n     2FF2   A9 3F      LDA #&3F\n     2FF4   20 B6 38   JSR &38B6\n     2FF7   20 37 2D   JSR &2D37\n     2FFA   A2 00      LDX #&00\n     2FFC   86 91      STX &91\n     2FFE   A2 0C      LDX #&0C\n     3000   86 06      STX &06\n     3002   20 59 30   JSR &3059\n     3005   B0 C6      BCS &2FCD\n     3007   85 1B      STA &1B\n     3009   20 C8 2C   JSR &2CC8\n     300C   A0 CE      LDY #&CE\n     300E   B0 BF      BCS &2FCF\n     3010   AD 18 0F   LDA &0F18\n     3013   85 90      STA &90\n     3015   20 39 36   JSR &3639\n     3018   20 F1 35   JSR &35F1\n     301B   A0 C5      LDY #&C5\n     301D   90 B0      BCC &2FCF\n     301F   AC 1B 0F   LDY &0F1B\n     3022   A5 91      LDA &91\n     3024   48         PHA\n     3025   18         CLC\n     3026   79 17 03   ADC &0317,Y\n     3029   99 17 03   STA &0317,Y\n     302C   B9 35 03   LDA &0335,Y\n     302F   38         SEC\n     3030   E5 91      SBC &91\n     3032   99 35 03   STA &0335,Y\n     3035   68         PLA\n     3036   F0 03      BEQ &303B\n     3038   20 AF 37   JSR &37AF\n.TT222\n     303B   AD 1B 0F   LDA &0F1B\n     303E   18         CLC\n     303F   69 05      ADC #&05\n     3041   85 2D      STA &2D\n     3043   A9 00      LDA #&00\n     3045   85 2C      STA &2C\n     3047   EE 1B 0F   INC &0F1B\n     304A   AD 1B 0F   LDA &0F1B\n     304D   C9 11      CMP #&11\n     304F   B0 03      BCS &3054\n     3051   4C C2 2F   JMP &2FC2\n.BAY2\n     3054   A9 77      LDA #&77\n     3056   4C 83 45   JMP &4583\n.gnum\n     3059   A2 00      LDX #&00\n     305B   86 91      STX &91\n     305D   A2 0C      LDX #&0C\n     305F   86 06      STX &06\n.TT223\n     3061   20 02 4B   JSR &4B02\n     3064   85 90      STA &90\n     3066   38         SEC\n     3067   E9 30      SBC #&30\n     3069   90 27      BCC &3092\n     306B   C9 0A      CMP #&0A\n     306D   B0 E5      BCS &3054\n     306F   85 92      STA &92\n     3071   A5 91      LDA &91\n     3073   C9 1A      CMP #&1A\n     3075   B0 1B      BCS &3092\n     3077   0A         ASL A\n     3078   85 D1      STA &D1\n     307A   0A         ASL A\n     307B   0A         ASL A\n     307C   65 D1      ADC &D1\n     307E   65 92      ADC &92\n     3080   85 91      STA &91\n     3082   CD 19 0F   CMP &0F19\n     3085   F0 02      BEQ &3089\n     3087   B0 09      BCS &3092\n.TT226\n     3089   A5 90      LDA &90\n     308B   20 81 1F   JSR &1F81\n     308E   C6 06      DEC &06\n     3090   D0 CF      BNE &3061\n.OUT\n     3092   A5 91      LDA &91\n     3094   60         RTS\n.TT208\n     3095   A9 04      LDA #&04\n     3097   20 7B 2B   JSR &2B7B\n     309A   A9 04      LDA #&04\n     309C   85 2D      STA &2D\n     309E   85 2C      STA &2C\n     30A0   A9 CD      LDA #&CD\n     30A2   20 B6 38   JSR &38B6\n     30A5   A9 CE      LDA #&CE\n     30A7   20 B1 38   JSR &38B1\n.TT210\n     30AA   A0 00      LDY #&00\n.TT211\n     30AC   8C 1B 0F   STY &0F1B\n     30AF   BE 17 03   LDX &0317,Y\n     30B2   F0 58      BEQ &310C\n     30B4   98         TYA\n     30B5   0A         ASL A\n     30B6   0A         ASL A\n     30B7   A8         TAY\n     30B8   B9 BD 4B   LDA &4BBD,Y\n     30BB   85 80      STA &80\n     30BD   8A         TXA\n     30BE   48         PHA\n     30BF   20 33 2D   JSR &2D33\n     30C2   18         CLC\n     30C3   AD 1B 0F   LDA &0F1B\n     30C6   69 D0      ADC #&D0\n     30C8   20 B6 38   JSR &38B6\n     30CB   A9 0E      LDA #&0E\n     30CD   85 2C      STA &2C\n     30CF   68         PLA\n     30D0   AA         TAX\n     30D1   18         CLC\n     30D2   20 BD 1E   JSR &1EBD\n     30D5   20 63 34   JSR &3463\n     30D8   A5 96      LDA &96\n     30DA   C9 04      CMP #&04\n     30DC   D0 2E      BNE &310C\n     30DE   A9 CD      LDA #&CD\n     30E0   20 47 31   JSR &3147\n     30E3   90 27      BCC &310C\n     30E5   AD 1B 0F   LDA &0F1B\n     30E8   A2 FF      LDX #&FF\n     30EA   86 7E      STX &7E\n     30EC   20 F7 33   JSR &33F7\n     30EF   AC 1B 0F   LDY &0F1B\n     30F2   B9 17 03   LDA &0317,Y\n     30F5   85 1B      STA &1B\n     30F7   AD 18 0F   LDA &0F18\n     30FA   85 90      STA &90\n     30FC   20 39 36   JSR &3639\n     30FF   20 18 36   JSR &3618\n     3102   A9 00      LDA #&00\n     3104   AC 1B 0F   LDY &0F1B\n     3107   99 17 03   STA &0317,Y\n     310A   85 7E      STA &7E\n.TT212\n     310C   AC 1B 0F   LDY &0F1B\n     310F   C8         INY\n     3110   C0 11      CPY #&11\n     3112   B0 03      BCS &3117\n     3114   4C AC 30   JMP &30AC\n     3117   A5 96      LDA &96\n     3119   C9 04      CMP #&04\n     311B   D0 06      BNE &3123\n     311D   20 B7 37   JSR &37B7\n     3120   4C 54 30   JMP &3054\n     3123   60         RTS\n.TT213\n     3124   A9 08      LDA #&08\n     3126   20 7B 2B   JSR &2B7B\n     3129   A9 0B      LDA #&0B\n     312B   85 2C      STA &2C\n     312D   A9 A4      LDA #&A4\n     312F   20 2E 2D   JSR &2D2E\n     3132   20 F7 19   JSR &19F7\n     3135   20 82 38   JSR &3882\n     3138   AD 16 03   LDA &0316\n     313B   C9 1A      CMP #&1A\n     313D   90 05      BCC &3144\n     313F   A9 6B      LDA #&6B\n     3141   20 B6 38   JSR &38B6\n     3144   4C AA 30   JMP &30AA\n.TT214\n     3147   48         PHA\n     3148   20 70 34   JSR &3470\n     314B   68         PLA\n.TT221\n     314C   20 B6 38   JSR &38B6\n     314F   A9 E1      LDA #&E1\n     3151   20 B6 38   JSR &38B6\n     3154   20 02 4B   JSR &4B02\n     3157   09 20      ORA #&20\n     3159   C9 79      CMP #&79\n     315B   F0 05      BEQ &3162\n     315D   A9 6E      LDA #&6E\n     315F   4C 81 1F   JMP &1F81\n.TT218\n     3162   20 81 1F   JSR &1F81\n     3165   38         SEC\n     3166   60         RTS\n.TT16\n     3167   8A         TXA\n     3168   48         PHA\n     3169   88         DEY\n     316A   98         TYA\n     316B   49 FF      EOR #&FF\n     316D   48         PHA\n     316E   20 BF 2C   JSR &2CBF\n     3171   20 94 31   JSR &3194\n     3174   68         PLA\n     3175   85 82      STA &82\n     3177   AD 32 0F   LDA &0F32\n     317A   20 AC 31   JSR &31AC\n     317D   A5 83      LDA &83\n     317F   8D 32 0F   STA &0F32\n     3182   85 80      STA &80\n     3184   68         PLA\n     3185   85 82      STA &82\n     3187   AD 31 0F   LDA &0F31\n     318A   20 AC 31   JSR &31AC\n     318D   A5 83      LDA &83\n     318F   8D 31 0F   STA &0F31\n     3192   85 7F      STA &7F\n.TT103\n     3194   A5 96      LDA &96\n     3196   F0 24      BEQ &31BC\n     3198   30 23      BMI &31BD\n     319A   AD 31 0F   LDA &0F31\n     319D   85 7F      STA &7F\n     319F   AD 32 0F   LDA &0F32\n     31A2   4A         LSR A\n     31A3   85 80      STA &80\n     31A5   A9 04      LDA #&04\n     31A7   85 81      STA &81\n     31A9   4C 0B 2F   JMP &2F0B\n.TT123\n     31AC   85 83      STA &83\n     31AE   18         CLC\n     31AF   65 82      ADC &82\n     31B1   A6 82      LDX &82\n     31B3   30 03      BMI &31B8\n     31B5   90 03      BCC &31BA\n     31B7   60         RTS\n.TT124\n     31B8   90 02      BCC &31BC\n.TT125\n     31BA   85 83      STA &83\n.TT180\n     31BC   60         RTS\n.TT105\n     31BD   AD 31 0F   LDA &0F31\n     31C0   38         SEC\n     31C1   ED 01 03   SBC &0301\n     31C4   C9 26      CMP #&26\n     31C6   90 04      BCC &31CC\n     31C8   C9 E6      CMP #&E6\n     31CA   90 F0      BCC &31BC\n.TT179\n     31CC   0A         ASL A\n     31CD   0A         ASL A\n     31CE   18         CLC\n     31CF   69 68      ADC #&68\n     31D1   85 7F      STA &7F\n     31D3   AD 32 0F   LDA &0F32\n     31D6   38         SEC\n     31D7   ED 02 03   SBC &0302\n     31DA   C9 26      CMP #&26\n     31DC   90 04      BCC &31E2\n     31DE   C9 DC      CMP #&DC\n     31E0   90 DA      BCC &31BC\n     31E2   0A         ASL A\n     31E3   18         CLC\n     31E4   69 5A      ADC #&5A\n     31E6   85 80      STA &80\n     31E8   A9 08      LDA #&08\n     31EA   85 81      STA &81\n     31EC   4C 0B 2F   JMP &2F0B\n.TT23\n     31EF   A9 80      LDA #&80\n     31F1   20 7B 2B   JSR &2B7B\n     31F4   A9 07      LDA #&07\n     31F6   85 2C      STA &2C\n     31F8   A9 BE      LDA #&BE\n     31FA   20 F4 19   JSR &19F4\n     31FD   20 76 2F   JSR &2F76\n     3200   20 94 31   JSR &3194\n     3203   20 99 32   JSR &3299\n     3206   A9 00      LDA #&00\n     3208   85 A8      STA &A8\n     320A   A2 18      LDX #&18\n.EE3\n     320C   95 53      STA &53,X\n     320E   CA         DEX\n     320F   10 FB      BPL &320C\n.TT182\n     3211   A5 7B      LDA &7B\n     3213   38         SEC\n     3214   ED 01 03   SBC &0301\n     3217   B0 04      BCS &321D\n     3219   49 FF      EOR #&FF\n     321B   69 01      ADC #&01\n.TT184\n     321D   C9 14      CMP #&14\n     321F   B0 6E      BCS &328F\n     3221   A5 79      LDA &79\n     3223   38         SEC\n     3224   ED 02 03   SBC &0302\n     3227   B0 04      BCS &322D\n     3229   49 FF      EOR #&FF\n     322B   69 01      ADC #&01\n.TT186\n     322D   C9 26      CMP #&26\n     322F   B0 5E      BCS &328F\n     3231   A5 7B      LDA &7B\n     3233   38         SEC\n     3234   ED 01 03   SBC &0301\n     3237   0A         ASL A\n     3238   0A         ASL A\n     3239   69 68      ADC #&68\n     323B   85 37      STA &37\n     323D   4A         LSR A\n     323E   4A         LSR A\n     323F   4A         LSR A\n     3240   85 2C      STA &2C\n     3242   E6 2C      INC &2C\n     3244   A5 79      LDA &79\n     3246   38         SEC\n     3247   ED 02 03   SBC &0302\n     324A   0A         ASL A\n     324B   69 5A      ADC #&5A\n     324D   85 E0      STA &E0\n     324F   4A         LSR A\n     3250   4A         LSR A\n     3251   4A         LSR A\n     3252   A8         TAY\n     3253   B6 53      LDX &53,Y\n     3255   F0 0B      BEQ &3262\n     3257   C8         INY\n     3258   B6 53      LDX &53,Y\n     325A   F0 06      BEQ &3262\n     325C   88         DEY\n     325D   88         DEY\n     325E   B6 53      LDX &53,Y\n     3260   D0 10      BNE &3272\n.EE4\n     3262   84 2D      STY &2D\n     3264   C0 03      CPY #&03\n     3266   90 27      BCC &328F\n     3268   CA         DEX\n     3269   96 53      STX &53,Y\n     326B   A9 80      LDA #&80\n     326D   85 7E      STA &7E\n     326F   20 21 38   JSR &3821\n.ee1\n     3272   A9 00      LDA #&00\n     3274   85 D3      STA &D3\n     3276   85 E1      STA &E1\n     3278   85 3E      STA &3E\n     327A   A5 37      LDA &37\n     327C   85 D2      STA &D2\n     327E   A5 7D      LDA &7D\n     3280   29 01      AND #&01\n     3282   69 02      ADC #&02\n     3284   85 3D      STA &3D\n     3286   20 27 3B   JSR &3B27\n     3289   20 5A 3F   JSR &3F5A\n     328C   20 27 3B   JSR &3B27\n.TT187\n     328F   20 E5 2C   JSR &2CE5\n     3292   E6 A8      INC &A8\n     3294   F0 0D      BEQ &32A3\n     3296   4C 11 32   JMP &3211\n.TT81\n     3299   A2 05      LDX #&05\n     329B   BD 03 03   LDA &0303,X\n     329E   95 78      STA &78,X\n     32A0   CA         DEX\n     32A1   10 F8      BPL &329B\n     32A3   60         RTS\n.TT111\n     32A4   20 99 32   JSR &3299\n     32A7   A0 7F      LDY #&7F\n     32A9   84 D1      STY &D1\n     32AB   A9 00      LDA #&00\n     32AD   85 8F      STA &8F\n.TT130\n     32AF   A5 7B      LDA &7B\n     32B1   38         SEC\n     32B2   ED 31 0F   SBC &0F31\n     32B5   B0 04      BCS &32BB\n     32B7   49 FF      EOR #&FF\n     32B9   69 01      ADC #&01\n.TT132\n     32BB   4A         LSR A\n     32BC   85 92      STA &92\n     32BE   A5 79      LDA &79\n     32C0   38         SEC\n     32C1   ED 32 0F   SBC &0F32\n     32C4   B0 04      BCS &32CA\n     32C6   49 FF      EOR #&FF\n     32C8   69 01      ADC #&01\n.TT134\n     32CA   4A         LSR A\n     32CB   18         CLC\n     32CC   65 92      ADC &92\n     32CE   C5 D1      CMP &D1\n     32D0   B0 0B      BCS &32DD\n     32D2   85 D1      STA &D1\n     32D4   A2 05      LDX #&05\n.TT136\n     32D6   B5 78      LDA &78,X\n     32D8   95 7F      STA &7F,X\n     32DA   CA         DEX\n     32DB   10 F9      BPL &32D6\n.TT135\n     32DD   20 E5 2C   JSR &2CE5\n     32E0   E6 8F      INC &8F\n     32E2   D0 CB      BNE &32AF\n     32E4   A2 05      LDX #&05\n.TT137\n     32E6   B5 7F      LDA &7F,X\n     32E8   95 78      STA &78,X\n     32EA   CA         DEX\n     32EB   10 F9      BPL &32E6\n     32ED   A5 79      LDA &79\n     32EF   8D 32 0F   STA &0F32\n     32F2   A5 7B      LDA &7B\n     32F4   8D 31 0F   STA &0F31\n     32F7   38         SEC\n     32F8   ED 01 03   SBC &0301\n     32FB   B0 04      BCS &3301\n     32FD   49 FF      EOR #&FF\n     32FF   69 01      ADC #&01\n.TT139\n     3301   20 6F 27   JSR &276F\n     3304   85 3E      STA &3E\n     3306   A5 1B      LDA &1B\n     3308   85 3D      STA &3D\n     330A   AD 32 0F   LDA &0F32\n     330D   38         SEC\n     330E   ED 02 03   SBC &0302\n     3311   B0 04      BCS &3317\n     3313   49 FF      EOR #&FF\n     3315   69 01      ADC #&01\n.TT141\n     3317   4A         LSR A\n     3318   20 6F 27   JSR &276F\n     331B   48         PHA\n     331C   A5 1B      LDA &1B\n     331E   18         CLC\n     331F   65 3D      ADC &3D\n     3321   85 90      STA &90\n     3323   68         PLA\n     3324   65 3E      ADC &3E\n     3326   85 91      STA &91\n     3328   20 5B 4D   JSR &4D5B\n     332B   A5 90      LDA &90\n     332D   0A         ASL A\n     332E   A2 00      LDX #&00\n     3330   8E 30 0F   STX &0F30\n     3333   2E 30 0F   ROL &0F30\n     3336   0A         ASL A\n     3337   2E 30 0F   ROL &0F30\n     333A   8D 2F 0F   STA &0F2F\n     333D   4C 4D 2E   JMP &2E4D\n.hy6\n     3340   20 FA 2B   JSR &2BFA\n     3343   A9 0F      LDA #&0F\n     3345   85 2C      STA &2C\n     3347   4C B6 38   JMP &38B6\n.hyp\n     334A   A5 9F      LDA &9F\n     334C   D0 F2      BNE &3340\n     334E   A5 2F      LDA &2F\n     3350   D0 67      BNE &33B9\n     3352   20 0F 4A   JSR &4A0F\n     3355   30 3B      BMI &3392\n     3357   20 ED 2B   JSR &2BED\n     335A   AD 2F 0F   LDA &0F2F\n     335D   0D 30 0F   ORA &0F30\n     3360   F0 57      BEQ &33B9\n     3362   A9 07      LDA #&07\n     3364   85 2C      STA &2C\n     3366   A9 17      LDA #&17\n     3368   85 2D      STA &2D\n     336A   A9 00      LDA #&00\n     336C   85 7E      STA &7E\n     336E   A9 BD      LDA #&BD\n     3370   20 B6 38   JSR &38B6\n     3373   AD 30 0F   LDA &0F30\n     3376   D0 75      BNE &33ED\n     3378   AD 0D 03   LDA &030D\n     337B   CD 2F 0F   CMP &0F2F\n     337E   90 6D      BCC &33ED\n     3380   A9 2D      LDA #&2D\n     3382   20 B6 38   JSR &38B6\n     3385   20 21 38   JSR &3821\n.wW\n     3388   A9 0F      LDA #&0F\n     338A   85 2F      STA &2F\n     338C   85 2E      STA &2E\n     338E   AA         TAX\n     338F   4C E0 33   JMP &33E0\n.Ghy\n     3392   AE 2D 03   LDX &032D\n     3395   F0 48      BEQ &33DF\n     3397   E8         INX\n     3398   8E 2D 03   STX &032D\n     339B   8E 34 03   STX &0334\n     339E   20 88 33   JSR &3388\n     33A1   A2 05      LDX #&05\n     33A3   EE 0F 03   INC &030F\n     33A6   AD 0F 03   LDA &030F\n     33A9   29 07      AND #&07\n     33AB   8D 0F 03   STA &030F\n.G1\n     33AE   BD 03 03   LDA &0303,X\n     33B1   0A         ASL A\n     33B2   3E 03 03   ROL &0303,X\n     33B5   CA         DEX\n     33B6   10 F6      BPL &33AE\n.zZ\n     33B8   A9 60      LDA #&60\n     33BA   8D 31 0F   STA &0F31\n     33BD   8D 32 0F   STA &0F32\n     33C0   20 BA 35   JSR &35BA\n     33C3   20 A4 32   JSR &32A4\n     33C6   A2 00      LDX #&00\n     33C8   8E 2F 0F   STX &0F2F\n     33CB   8E 30 0F   STX &0F30\n     33CE   A9 74      LDA #&74\n     33D0   20 29 4B   JSR &4B29\n.jmp\n     33D3   AD 31 0F   LDA &0F31\n     33D6   8D 01 03   STA &0301\n     33D9   AD 32 0F   LDA &0F32\n     33DC   8D 02 03   STA &0302\n.hy5\n     33DF   60         RTS\n.ee3\n     33E0   A0 01      LDY #&01\n     33E2   84 2D      STY &2D\n     33E4   88         DEY\n     33E5   84 2C      STY &2C\n.pr6\n     33E7   18         CLC\n.pr5\n     33E8   A9 05      LDA #&05\n     33EA   4C C1 1E   JMP &1EC1\n.TT147\n     33ED   A9 CA      LDA #&CA\n.prq\n     33EF   20 B6 38   JSR &38B6\n     33F2   A9 3F      LDA #&3F\n     33F4   4C B6 38   JMP &38B6\n.TT151\n     33F7   48         PHA\n     33F8   85 83      STA &83\n     33FA   0A         ASL A\n     33FB   0A         ASL A\n     33FC   85 7F      STA &7F\n     33FE   A9 01      LDA #&01\n     3400   85 2C      STA &2C\n     3402   68         PLA\n     3403   69 D0      ADC #&D0\n     3405   20 B6 38   JSR &38B6\n     3408   A9 0E      LDA #&0E\n     340A   85 2C      STA &2C\n     340C   A6 7F      LDX &7F\n     340E   BD BD 4B   LDA &4BBD,X\n     3411   85 80      STA &80\n     3413   AD 46 03   LDA &0346\n     3416   3D BF 4B   AND &4BBF,X\n     3419   18         CLC\n     341A   7D BC 4B   ADC &4BBC,X\n     341D   8D 18 0F   STA &0F18\n     3420   20 63 34   JSR &3463\n     3423   20 BC 34   JSR &34BC\n     3426   A5 80      LDA &80\n     3428   30 08      BMI &3432\n     342A   AD 18 0F   LDA &0F18\n     342D   65 82      ADC &82\n     342F   4C 38 34   JMP &3438\n.TT155\n     3432   AD 18 0F   LDA &0F18\n     3435   38         SEC\n     3436   E5 82      SBC &82\n.TT156\n     3438   8D 18 0F   STA &0F18\n     343B   85 1B      STA &1B\n     343D   A9 00      LDA #&00\n     343F   20 3C 36   JSR &363C\n     3442   38         SEC\n     3443   20 E8 33   JSR &33E8\n     3446   A4 83      LDY &83\n     3448   A9 05      LDA #&05\n     344A   BE 35 03   LDX &0335,Y\n     344D   8E 19 0F   STX &0F19\n     3450   18         CLC\n     3451   F0 06      BEQ &3459\n     3453   20 BF 1E   JSR &1EBF\n     3456   4C 63 34   JMP &3463\n.TT172\n     3459   A5 2C      LDA &2C\n     345B   69 04      ADC #&04\n     345D   85 2C      STA &2C\n     345F   A9 2D      LDA #&2D\n     3461   D0 0F      BNE &3472\n.TT152\n     3463   A5 80      LDA &80\n     3465   29 60      AND #&60\n     3467   F0 0C      BEQ &3475\n     3469   C9 20      CMP #&20\n     346B   F0 0F      BEQ &347C\n     346D   20 81 34   JSR &3481\n.TT162\n     3470   A9 20      LDA #&20\n     3472   4C B6 38   JMP &38B6\n.TT160\n     3475   A9 74      LDA #&74\n     3477   20 81 1F   JSR &1F81\n     347A   90 F4      BCC &3470\n.TT161\n     347C   A9 6B      LDA #&6B\n     347E   20 81 1F   JSR &1F81\n.TT16a\n     3481   A9 67      LDA #&67\n     3483   4C 81 1F   JMP &1F81\n.TT163\n     3486   A9 11      LDA #&11\n     3488   85 2C      STA &2C\n     348A   A9 FF      LDA #&FF\n     348C   D0 E4      BNE &3472\n.TT167\n     348E   A9 10      LDA #&10\n     3490   20 7B 2B   JSR &2B7B\n     3493   A9 05      LDA #&05\n     3495   85 2C      STA &2C\n     3497   A9 A7      LDA #&A7\n     3499   20 F4 19   JSR &19F4\n     349C   A9 03      LDA #&03\n     349E   85 2D      STA &2D\n     34A0   20 86 34   JSR &3486\n     34A3   A9 00      LDA #&00\n     34A5   8D 1B 0F   STA &0F1B\n.TT168\n     34A8   A2 80      LDX #&80\n     34AA   86 7E      STX &7E\n     34AC   20 F7 33   JSR &33F7\n     34AF   E6 2D      INC &2D\n     34B1   EE 1B 0F   INC &0F1B\n     34B4   AD 1B 0F   LDA &0F1B\n     34B7   C9 11      CMP #&11\n     34B9   90 ED      BCC &34A8\n     34BB   60         RTS\n.var\n     34BC   A5 80      LDA &80\n     34BE   29 1F      AND #&1F\n     34C0   AC 1A 0F   LDY &0F1A\n     34C3   85 81      STA &81\n     34C5   18         CLC\n     34C6   A9 00      LDA #&00\n     34C8   8D 45 03   STA &0345\n.TT153\n     34CB   88         DEY\n     34CC   30 05      BMI &34D3\n     34CE   65 81      ADC &81\n     34D0   4C CB 34   JMP &34CB\n.TT154\n     34D3   85 82      STA &82\n     34D5   60         RTS\n.hyp1\n     34D6   20 A4 32   JSR &32A4\n     34D9   20 D3 33   JSR &33D3\n     34DC   A2 05      LDX #&05\n.TT112\n     34DE   B5 78      LDA &78,X\n     34E0   9D 22 0F   STA &0F22,X\n     34E3   CA         DEX\n     34E4   10 F8      BPL &34DE\n     34E6   E8         INX\n     34E7   8E 63 0D   STX &0D63\n     34EA   AD 28 0F   LDA &0F28\n     34ED   8D 1A 0F   STA &0F1A\n     34F0   AD 2A 0F   LDA &0F2A\n     34F3   8D 1D 0F   STA &0F1D\n     34F6   AD 29 0F   LDA &0F29\n     34F9   8D 1C 0F   STA &0F1C\n     34FC   60         RTS\n.GVL\n     34FD   20 57 44   JSR &4457\n     3500   8D 46 03   STA &0346\n     3503   A2 00      LDX #&00\n     3505   86 A7      STX &A7\n.hy9\n     3507   BD BD 4B   LDA &4BBD,X\n     350A   85 80      STA &80\n     350C   20 BC 34   JSR &34BC\n     350F   BD BF 4B   LDA &4BBF,X\n     3512   2D 46 03   AND &0346\n     3515   18         CLC\n     3516   7D BE 4B   ADC &4BBE,X\n     3519   A4 80      LDY &80\n     351B   30 06      BMI &3523\n     351D   38         SEC\n     351E   E5 82      SBC &82\n     3520   4C 26 35   JMP &3526\n.TT157\n     3523   18         CLC\n     3524   65 82      ADC &82\n.TT158\n     3526   10 02      BPL &352A\n     3528   A9 00      LDA #&00\n.TT159\n     352A   A4 A7      LDY &A7\n     352C   29 3F      AND #&3F\n     352E   99 35 03   STA &0335,Y\n     3531   C8         INY\n     3532   98         TYA\n     3533   85 A7      STA &A7\n     3535   0A         ASL A\n     3536   0A         ASL A\n     3537   AA         TAX\n     3538   C9 3F      CMP #&3F\n     353A   90 CB      BCC &3507\n.hyR\n     353C   60         RTS\n.GTHG\n     353D   20 35 44   JSR &4435\n     3540   A9 FF      LDA #&FF\n     3542   85 73      STA &73\n     3544   A9 06      LDA #&06\n     3546   20 82 3C   JSR &3C82\n     3549   A9 0C      LDA #&0C\n     354B   4C 82 3C   JMP &3C82\n.ptg\n     354E   4E 0E 03   LSR &030E\n     3551   38         SEC\n     3552   2E 0E 03   ROL &030E\n.MJP\n     3555   20 79 2B   JSR &2B79\n     3558   20 63 25   JSR &2563\n     355B   20 B1 43   JSR &43B1\n     355E   8C 5C 0D   STY &0D5C\n.MJP1\n     3561   20 3D 35   JSR &353D\n     3564   A9 03      LDA #&03\n     3566   CD 53 0D   CMP &0D53\n     3569   B0 F6      BCS &3561\n     356B   8D 33 0F   STA &0F33\n     356E   A2 00      LDX #&00\n     3570   20 44 2B   JSR &2B44\n     3573   AD 02 03   LDA &0302\n     3576   49 1F      EOR #&1F\n     3578   8D 02 03   STA &0302\n     357B   60         RTS\n.TT18\n     357C   AD 0D 03   LDA &030D\n     357F   38         SEC\n     3580   ED 2F 0F   SBC &0F2F\n     3583   8D 0D 03   STA &030D\n     3586   A5 96      LDA &96\n     3588   D0 06      BNE &3590\n     358A   20 7B 2B   JSR &2B7B\n     358D   20 63 25   JSR &2563\n.ee5\n     3590   20 0F 4A   JSR &4A0F\n     3593   2D 4C 0F   AND &0F4C\n     3596   30 B6      BMI &354E\n     3598   20 57 44   JSR &4457\n     359B   C9 FD      CMP #&FD\n     359D   B0 B6      BCS &3555\n     359F   20 D9 34   JSR &34D9\n     35A2   20 FD 34   JSR &34FD\n     35A5   20 B1 43   JSR &43B1\n     35A8   20 9C 3A   JSR &3A9C\n     35AB   A5 96      LDA &96\n     35AD   29 3F      AND #&3F\n     35AF   D0 8B      BNE &353C\n     35B1   20 7D 2B   JSR &2B7D\n     35B4   A5 96      LDA &96\n     35B6   D0 31      BNE &35E9\n     35B8   E6 96      INC &96\n.TT110\n     35BA   A6 9F      LDX &9F\n     35BC   F0 24      BEQ &35E2\n     35BE   20 76 25   JSR &2576\n     35C1   20 B1 43   JSR &43B1\n     35C4   20 A4 32   JSR &32A4\n     35C7   E6 5B      INC &5B\n     35C9   20 89 3A   JSR &3A89\n     35CC   A9 80      LDA #&80\n     35CE   85 5B      STA &5B\n     35D0   E6 5A      INC &5A\n     35D2   20 5D 3C   JSR &3C5D\n     35D5   A9 0C      LDA #&0C\n     35D7   85 8C      STA &8C\n     35D9   20 5F 46   JSR &465F\n     35DC   0D 34 03   ORA &0334\n     35DF   8D 34 03   STA &0334\n.NLUNCH\n     35E2   A2 00      LDX #&00\n     35E4   86 9F      STX &9F\n     35E6   4C 44 2B   JMP &2B44\n.TT114\n     35E9   30 03      BMI &35EE\n     35EB   4C C0 2E   JMP &2EC0\n.TT115\n     35EE   4C EF 31   JMP &31EF\n.LCASH\n     35F1   86 06      STX &06\n     35F3   AD 0C 03   LDA &030C\n     35F6   38         SEC\n     35F7   E5 06      SBC &06\n     35F9   8D 0C 03   STA &030C\n     35FC   84 06      STY &06\n     35FE   AD 0B 03   LDA &030B\n     3601   E5 06      SBC &06\n     3603   8D 0B 03   STA &030B\n     3606   AD 0A 03   LDA &030A\n     3609   E9 00      SBC #&00\n     360B   8D 0A 03   STA &030A\n     360E   AD 09 03   LDA &0309\n     3611   E9 00      SBC #&00\n     3613   8D 09 03   STA &0309\n     3616   B0 20      BCS &3638\n.MCASH\n     3618   8A         TXA\n     3619   18         CLC\n     361A   6D 0C 03   ADC &030C\n     361D   8D 0C 03   STA &030C\n     3620   98         TYA\n     3621   6D 0B 03   ADC &030B\n     3624   8D 0B 03   STA &030B\n     3627   AD 0A 03   LDA &030A\n     362A   69 00      ADC #&00\n     362C   8D 0A 03   STA &030A\n     362F   AD 09 03   LDA &0309\n     3632   69 00      ADC #&00\n     3634   8D 09 03   STA &0309\n     3637   18         CLC\n.TT113\n     3638   60         RTS\n.GCASH\n     3639   20 82 27   JSR &2782\n.GC2\n     363C   06 1B      ASL &1B\n     363E   2A         ROL A\n     363F   06 1B      ASL &1B\n     3641   2A         ROL A\n     3642   A8         TAY\n     3643   A6 1B      LDX &1B\n     3645   60         RTS\n.bay\n     3646   4C 4D 47   JMP &474D\n.EQSHP\n     3649   20 F8 1F   JSR &1FF8\n     364C   A9 20      LDA #&20\n     364E   20 7B 2B   JSR &2B7B\n     3651   A9 0C      LDA #&0C\n     3653   85 2C      STA &2C\n     3655   A9 CF      LDA #&CF\n     3657   20 44 2D   JSR &2D44\n     365A   A9 B9      LDA #&B9\n     365C   20 F4 19   JSR &19F4\n     365F   A9 80      LDA #&80\n     3661   85 7E      STA &7E\n     3663   E6 2D      INC &2D\n     3665   AD 1D 0F   LDA &0F1D\n     3668   18         CLC\n     3669   69 03      ADC #&03\n     366B   C9 0C      CMP #&0C\n     366D   90 02      BCC &3671\n     366F   A9 0C      LDA #&0C\n     3671   85 90      STA &90\n     3673   8D 19 0F   STA &0F19\n     3676   E6 90      INC &90\n     3678   A9 46      LDA #&46\n     367A   38         SEC\n     367B   ED 0D 03   SBC &030D\n     367E   0A         ASL A\n     367F   8D CD 1D   STA &1DCD\n     3682   A2 01      LDX #&01\n.EQL1\n     3684   86 98      STX &98\n     3686   20 37 2D   JSR &2D37\n     3689   A6 98      LDX &98\n     368B   18         CLC\n     368C   20 BD 1E   JSR &1EBD\n     368F   20 70 34   JSR &3470\n     3692   A5 98      LDA &98\n     3694   18         CLC\n     3695   69 68      ADC #&68\n     3697   20 B6 38   JSR &38B6\n     369A   A5 98      LDA &98\n     369C   20 CF 37   JSR &37CF\n     369F   38         SEC\n     36A0   A9 19      LDA #&19\n     36A2   85 2C      STA &2C\n     36A4   A9 06      LDA #&06\n     36A6   20 C1 1E   JSR &1EC1\n     36A9   A6 98      LDX &98\n     36AB   E8         INX\n     36AC   E4 90      CPX &90\n     36AE   90 D4      BCC &3684\n     36B0   20 FA 2B   JSR &2BFA\n     36B3   A9 7F      LDA #&7F\n     36B5   20 EF 33   JSR &33EF\n     36B8   20 59 30   JSR &3059\n     36BB   F0 89      BEQ &3646\n     36BD   B0 87      BCS &3646\n     36BF   E9 00      SBC #&00\n     36C1   A2 02      LDX #&02\n     36C3   86 2C      STX &2C\n     36C5   E6 2D      INC &2D\n     36C7   48         PHA\n     36C8   20 BF 37   JSR &37BF\n     36CB   68         PLA\n     36CC   D0 07      BNE &36D5\n     36CE   85 99      STA &99\n     36D0   A2 46      LDX #&46\n     36D2   8E 0D 03   STX &030D\n.et0\n     36D5   C9 01      CMP #&01\n     36D7   D0 10      BNE &36E9\n     36D9   AE 33 03   LDX &0333\n     36DC   E8         INX\n     36DD   A0 75      LDY #&75\n     36DF   E0 05      CPX #&05\n     36E1   B0 68      BCS &374B\n     36E3   8E 33 03   STX &0333\n     36E6   20 0E 44   JSR &440E\n.et1\n     36E9   A0 6B      LDY #&6B\n     36EB   C9 02      CMP #&02\n     36ED   D0 0A      BNE &36F9\n     36EF   A2 25      LDX #&25\n     36F1   EC 16 03   CPX &0316\n     36F4   F0 55      BEQ &374B\n     36F6   8E 16 03   STX &0316\n.et2\n     36F9   C9 03      CMP #&03\n     36FB   D0 09      BNE &3706\n     36FD   C8         INY\n     36FE   AE 28 03   LDX &0328\n     3701   D0 48      BNE &374B\n     3703   CE 28 03   DEC &0328\n.et3\n     3706   C9 04      CMP #&04\n     3708   D0 15      BNE &371F\n     370A   20 DC 37   JSR &37DC\n     370D   A9 04      LDA #&04\n     370F   BC 10 03   LDY &0310,X\n     3712   F0 04      BEQ &3718\n.ed7\n     3714   A0 BB      LDY #&BB\n     3716   D0 33      BNE &374B\n.ed4\n     3718   A9 0F      LDA #&0F\n     371A   9D 10 03   STA &0310,X\n     371D   A9 04      LDA #&04\n.et4\n     371F   C9 05      CMP #&05\n     3721   D0 1D      BNE &3740\n     3723   20 DC 37   JSR &37DC\n     3726   86 06      STX &06\n     3728   A9 05      LDA #&05\n     372A   BC 10 03   LDY &0310,X\n     372D   F0 0A      BEQ &3739\n     372F   30 E3      BMI &3714\n     3731   A9 04      LDA #&04\n     3733   20 D2 37   JSR &37D2\n     3736   20 18 36   JSR &3618\n.ed5\n     3739   A9 8F      LDA #&8F\n     373B   A6 06      LDX &06\n     373D   9D 10 03   STA &0310,X\n.et5\n     3740   A0 6F      LDY #&6F\n     3742   C9 06      CMP #&06\n     3744   D0 20      BNE &3766\n     3746   AE 29 03   LDX &0329\n     3749   F0 18      BEQ &3763\n.pres\n     374B   84 3D      STY &3D\n     374D   20 D2 37   JSR &37D2\n     3750   20 18 36   JSR &3618\n     3753   A5 3D      LDA &3D\n     3755   20 44 2D   JSR &2D44\n     3758   A9 1F      LDA #&1F\n     375A   20 B6 38   JSR &38B6\n.err\n     375D   20 B7 37   JSR &37B7\n     3760   4C 4D 47   JMP &474D\n.ed9\n     3763   CE 29 03   DEC &0329\n.et6\n     3766   C8         INY\n     3767   C9 07      CMP #&07\n     3769   D0 08      BNE &3773\n     376B   AE 2E 03   LDX &032E\n     376E   D0 DB      BNE &374B\n     3770   CE 2E 03   DEC &032E\n.et7\n     3773   C8         INY\n     3774   C9 08      CMP #&08\n     3776   D0 0A      BNE &3782\n     3778   AE 2A 03   LDX &032A\n     377B   D0 CE      BNE &374B\n     377D   A2 7F      LDX #&7F\n     377F   8E 2A 03   STX &032A\n.et8\n     3782   C8         INY\n     3783   C9 09      CMP #&09\n     3785   D0 08      BNE &378F\n     3787   AE 2B 03   LDX &032B\n     378A   D0 BF      BNE &374B\n     378C   EE 2B 03   INC &032B\n.etA\n     378F   C8         INY\n     3790   C9 0A      CMP #&0A\n     3792   D0 08      BNE &379C\n     3794   AE 2C 03   LDX &032C\n     3797   D0 B2      BNE &374B\n     3799   CE 2C 03   DEC &032C\n.etB\n     379C   C8         INY\n     379D   C9 0B      CMP #&0B\n     379F   D0 08      BNE &37A9\n     37A1   AE 2D 03   LDX &032D\n     37A4   D0 A5      BNE &374B\n     37A6   CE 2D 03   DEC &032D\n.et9\n     37A9   20 AF 37   JSR &37AF\n     37AC   4C 49 36   JMP &3649\n.dn\n     37AF   20 70 34   JSR &3470\n     37B2   A9 77      LDA #&77\n     37B4   20 44 2D   JSR &2D44\n.dn2\n     37B7   20 CB 49   JSR &49CB\n     37BA   A0 32      LDY #&32\n     37BC   4C E6 2B   JMP &2BE6\n.eq\n     37BF   20 D2 37   JSR &37D2\n     37C2   20 F1 35   JSR &35F1\n     37C5   B0 14      BCS &37DB\n     37C7   A9 C5      LDA #&C5\n     37C9   20 EF 33   JSR &33EF\n     37CC   4C 5D 37   JMP &375D\n     37CF   38         SEC\n     37D0   E9 01      SBC #&01\n.prx\n     37D2   0A         ASL A\n     37D3   A8         TAY\n     37D4   BE CD 1D   LDX &1DCD,Y\n     37D7   B9 CE 1D   LDA &1DCE,Y\n     37DA   A8         TAY\n.c\n     37DB   60         RTS\n.qv\n     37DC   A0 10      LDY #&10\n     37DE   84 2D      STY &2D\n.qv1\n     37E0   A2 0C      LDX #&0C\n     37E2   86 2C      STX &2C\n     37E4   98         TYA\n     37E5   18         CLC\n     37E6   69 20      ADC #&20\n     37E8   20 44 2D   JSR &2D44\n     37EB   A5 2D      LDA &2D\n     37ED   18         CLC\n     37EE   69 50      ADC #&50\n     37F0   20 B6 38   JSR &38B6\n     37F3   E6 2D      INC &2D\n     37F5   A4 2D      LDY &2D\n     37F7   C0 14      CPY #&14\n     37F9   90 E5      BCC &37E0\n.qv3\n     37FB   20 FA 2B   JSR &2BFA\n.qv2\n     37FE   A9 AF      LDA #&AF\n     3800   20 EF 33   JSR &33EF\n     3803   20 02 4B   JSR &4B02\n     3806   38         SEC\n     3807   E9 30      SBC #&30\n     3809   C9 04      CMP #&04\n     380B   B0 EE      BCS &37FB\n     380D   AA         TAX\n     380E   60         RTS\nELITE D\nAssembled at &2CC8 \nEnds at &380F \nCode size is &B47 \nExecute at &1128 \nReload at &2EB0 \nS.ELTD &2CC8  &380F  &1128  &2EB0 \nSaving file '3-assembled-output/ELTD.bin'\n     380F   8C\n     3810   E7\n     3811   8D\n     3812   E6\n     3813   C1\n     3814   C8\n     3815   C8\n     3816   8B\n     3817   E6\n     3818   D6\n     3819   C5\n     381A   C6\n     381B   C1\n     381C   CA\n     381D   95\n     381E   9D\n     381F   9C\n     3820   90\n.cpl\n     3821   A2 05      LDX #&05\n.TT53\n     3823   B5 78      LDA &78,X\n     3825   95 7F      STA &7F,X\n     3827   CA         DEX\n     3828   10 F9      BPL &3823\n     382A   A0 03      LDY #&03\n     382C   24 78      BIT &78\n     382E   70 01      BVS &3831\n     3830   88         DEY\n     3831   84 D1      STY &D1\n.TT55\n     3833   A5 7D      LDA &7D\n     3835   29 1F      AND #&1F\n     3837   F0 05      BEQ &383E\n     3839   09 80      ORA #&80\n     383B   20 B6 38   JSR &38B6\n     383E   20 EB 2C   JSR &2CEB\n     3841   C6 D1      DEC &D1\n     3843   10 EE      BPL &3833\n     3845   A2 05      LDX #&05\n.TT56\n     3847   B5 7F      LDA &7F,X\n     3849   95 78      STA &78,X\n     384B   CA         DEX\n     384C   10 F9      BPL &3847\n     384E   60         RTS\n.cmn\n     384F   A0 00      LDY #&00\n.QUL4\n     3851   B9 F4 17   LDA &17F4,Y\n     3854   C9 0D      CMP #&0D\n     3856   F0 06      BEQ &385E\n     3858   20 81 1F   JSR &1F81\n     385B   C8         INY\n     385C   D0 F3      BNE &3851\n     385E   60         RTS\n.ypl\n     385F   AD 5C 0D   LDA &0D5C\n     3862   D0 EA      BNE &384E\n     3864   20 6A 38   JSR &386A\n     3867   20 21 38   JSR &3821\n.TT62\n     386A   A2 05      LDX #&05\n.TT78\n     386C   B5 78      LDA &78,X\n     386E   BC 22 0F   LDY &0F22,X\n     3871   9D 22 0F   STA &0F22,X\n     3874   94 78      STY &78,X\n     3876   CA         DEX\n     3877   10 F3      BPL &386C\n     3879   60         RTS\n.tal\n     387A   18         CLC\n     387B   AE 0F 03   LDX &030F\n     387E   E8         INX\n     387F   4C BD 1E   JMP &1EBD\n.fwl\n     3882   A9 69      LDA #&69\n     3884   20 B1 38   JSR &38B1\n     3887   AE 0D 03   LDX &030D\n     388A   38         SEC\n     388B   20 BD 1E   JSR &1EBD\n     388E   A9 C3      LDA #&C3\n     3890   20 AB 38   JSR &38AB\n.PCASH\n     3893   A9 77      LDA #&77\n     3895   D0 1F      BNE &38B6\n.csh\n     3897   A2 03      LDX #&03\n.pc1\n     3899   BD 09 03   LDA &0309,X\n     389C   95 3D      STA &3D,X\n     389E   CA         DEX\n     389F   10 F8      BPL &3899\n     38A1   A9 09      LDA #&09\n     38A3   85 8F      STA &8F\n     38A5   38         SEC\n     38A6   20 CD 1E   JSR &1ECD\n     38A9   A9 E2      LDA #&E2\n.plf\n     38AB   20 B6 38   JSR &38B6\n     38AE   4C 37 2D   JMP &2D37\n.TT68\n     38B1   20 B6 38   JSR &38B6\n.TT73\n     38B4   A9 3A      LDA #&3A\n.TT27\n     38B6   AA         TAX\n     38B7   F0 DE      BEQ &3897\n     38B9   30 74      BMI &392F\n     38BB   CA         DEX\n     38BC   F0 BC      BEQ &387A\n     38BE   CA         DEX\n     38BF   F0 9E      BEQ &385F\n     38C1   CA         DEX\n     38C2   D0 03      BNE &38C7\n     38C4   4C 21 38   JMP &3821\n     38C7   CA         DEX\n     38C8   F0 85      BEQ &384F\n     38CA   CA         DEX\n     38CB   F0 B5      BEQ &3882\n     38CD   CA         DEX\n     38CE   D0 05      BNE &38D5\n     38D0   A9 80      LDA #&80\n     38D2   85 7E      STA &7E\n     38D4   60         RTS\n     38D5   CA         DEX\n     38D6   CA         DEX\n     38D7   D0 03      BNE &38DC\n     38D9   86 7E      STX &7E\n     38DB   60         RTS\n     38DC   CA         DEX\n     38DD   F0 38      BEQ &3917\n     38DF   C9 60      CMP #&60\n     38E1   B0 66      BCS &3949\n     38E3   C9 0E      CMP #&0E\n     38E5   90 04      BCC &38EB\n     38E7   C9 20      CMP #&20\n     38E9   90 28      BCC &3913\n     38EB   A6 7E      LDX &7E\n     38ED   F0 3D      BEQ &392C\n     38EF   30 11      BMI &3902\n     38F1   24 7E      BIT &7E\n     38F3   70 30      BVS &3925\n.TT42\n     38F5   C9 41      CMP #&41\n     38F7   90 06      BCC &38FF\n     38F9   C9 5B      CMP #&5B\n     38FB   B0 02      BCS &38FF\n     38FD   69 20      ADC #&20\n.TT44\n     38FF   4C 81 1F   JMP &1F81\n.TT41\n     3902   24 7E      BIT &7E\n     3904   70 17      BVS &391D\n     3906   C9 41      CMP #&41\n     3908   90 22      BCC &392C\n     390A   48         PHA\n     390B   8A         TXA\n     390C   09 40      ORA #&40\n     390E   85 7E      STA &7E\n     3910   68         PLA\n     3911   D0 EC      BNE &38FF\n.qw\n     3913   69 72      ADC #&72\n     3915   D0 32      BNE &3949\n.crlf\n     3917   A9 15      LDA #&15\n     3919   85 2C      STA &2C\n     391B   D0 97      BNE &38B4\n.TT45\n     391D   E0 FF      CPX #&FF\n     391F   F0 63      BEQ &3984\n     3921   C9 41      CMP #&41\n     3923   B0 D0      BCS &38F5\n.TT46\n     3925   48         PHA\n     3926   8A         TXA\n     3927   29 BF      AND #&BF\n     3929   85 7E      STA &7E\n     392B   68         PLA\n.TT74\n     392C   4C 81 1F   JMP &1F81\n.TT43\n     392F   C9 A0      CMP #&A0\n     3931   B0 14      BCS &3947\n     3933   29 7F      AND #&7F\n     3935   0A         ASL A\n     3936   A8         TAY\n     3937   B9 7C 4B   LDA &4B7C,Y\n     393A   20 B6 38   JSR &38B6\n     393D   B9 7D 4B   LDA &4B7D,Y\n     3940   C9 3F      CMP #&3F\n     3942   F0 40      BEQ &3984\n     3944   4C B6 38   JMP &38B6\n.TT47\n     3947   E9 A0      SBC #&A0\n.ex\n     3949   AA         TAX\n     394A   A9 00      LDA #&00\n     394C   85 22      STA &22\n     394E   A9 04      LDA #&04\n     3950   85 23      STA &23\n     3952   A0 00      LDY #&00\n     3954   8A         TXA\n     3955   F0 13      BEQ &396A\n.TT51\n     3957   B1 22      LDA (&22),Y\n     3959   F0 07      BEQ &3962\n     395B   C8         INY\n     395C   D0 F9      BNE &3957\n     395E   E6 23      INC &23\n     3960   D0 F5      BNE &3957\n.TT49\n     3962   C8         INY\n     3963   D0 02      BNE &3967\n     3965   E6 23      INC &23\n.TT59\n     3967   CA         DEX\n     3968   D0 ED      BNE &3957\n.TT50\n     396A   98         TYA\n     396B   48         PHA\n     396C   A5 23      LDA &23\n     396E   48         PHA\n     396F   B1 22      LDA (&22),Y\n     3971   49 23      EOR #&23\n     3973   20 B6 38   JSR &38B6\n     3976   68         PLA\n     3977   85 23      STA &23\n     3979   68         PLA\n     397A   A8         TAY\n     397B   C8         INY\n     397C   D0 02      BNE &3980\n     397E   E6 23      INC &23\n     3980   B1 22      LDA (&22),Y\n     3982   D0 E6      BNE &396A\n.TT48\n     3984   60         RTS\n.EX2\n     3985   A5 72      LDA &72\n     3987   09 A0      ORA #&A0\n     3989   85 72      STA &72\n     398B   60         RTS\n.DOEXP\n     398C   A5 72      LDA &72\n     398E   29 40      AND #&40\n     3990   F0 03      BEQ &3995\n     3992   20 EF 39   JSR &39EF\n     3995   A5 59      LDA &59\n     3997   85 D1      STA &D1\n     3999   A5 5A      LDA &5A\n     399B   C9 20      CMP #&20\n     399D   90 04      BCC &39A3\n     399F   A9 FE      LDA #&FE\n     39A1   D0 08      BNE &39AB\n     39A3   06 D1      ASL &D1\n     39A5   2A         ROL A\n     39A6   06 D1      ASL &D1\n     39A8   2A         ROL A\n     39A9   38         SEC\n     39AA   2A         ROL A\n.yy\n     39AB   85 90      STA &90\n     39AD   A0 01      LDY #&01\n     39AF   B1 74      LDA (&74),Y\n     39B1   69 04      ADC #&04\n     39B3   B0 D0      BCS &3985\n     39B5   91 74      STA (&74),Y\n     39B7   20 C5 28   JSR &28C5\n     39BA   A5 1B      LDA &1B\n     39BC   C9 1C      CMP #&1C\n     39BE   90 04      BCC &39C4\n     39C0   A9 FE      LDA #&FE\n     39C2   D0 09      BNE &39CD\n     39C4   06 91      ASL &91\n     39C6   2A         ROL A\n     39C7   06 91      ASL &91\n     39C9   2A         ROL A\n     39CA   06 91      ASL &91\n     39CC   2A         ROL A\n.LABEL_1\n     39CD   88         DEY\n     39CE   91 74      STA (&74),Y\n     39D0   A5 72      LDA &72\n     39D2   29 BF      AND #&BF\n     39D4   85 72      STA &72\n     39D6   29 08      AND #&08\n     39D8   F0 AA      BEQ &3984\n     39DA   A0 02      LDY #&02\n     39DC   B1 74      LDA (&74),Y\n     39DE   A8         TAY\n.EXL1\n     39DF   B9 F9 00   LDA &00F9,Y\n     39E2   91 74      STA (&74),Y\n     39E4   88         DEY\n     39E5   C0 06      CPY #&06\n     39E7   D0 F6      BNE &39DF\n     39E9   A5 72      LDA &72\n     39EB   09 40      ORA #&40\n     39ED   85 72      STA &72\n.PTCLS\n     39EF   A0 00      LDY #&00\n     39F1   B1 74      LDA (&74),Y\n     39F3   85 90      STA &90\n     39F5   C8         INY\n     39F6   B1 74      LDA (&74),Y\n     39F8   10 02      BPL &39FC\n     39FA   49 FF      EOR #&FF\n     39FC   4A         LSR A\n     39FD   4A         LSR A\n     39FE   4A         LSR A\n     39FF   09 01      ORA #&01\n     3A01   85 8F      STA &8F\n     3A03   C8         INY\n     3A04   B1 74      LDA (&74),Y\n     3A06   85 A0      STA &A0\n     3A08   A5 01      LDA &01\n     3A0A   48         PHA\n     3A0B   A0 06      LDY #&06\n.EXL5\n     3A0D   A2 03      LDX #&03\n.EXL3\n     3A0F   C8         INY\n     3A10   B1 74      LDA (&74),Y\n     3A12   95 D2      STA &D2,X\n     3A14   CA         DEX\n     3A15   10 F8      BPL &3A0F\n     3A17   84 A4      STY &A4\n     3A19   A0 02      LDY #&02\n.EXL2\n     3A1B   C8         INY\n     3A1C   B1 74      LDA (&74),Y\n     3A1E   45 A4      EOR &A4\n     3A20   99 FD FF   STA &FFFD,Y\n     3A23   C0 06      CPY #&06\n     3A25   D0 F4      BNE &3A1B\n     3A27   A4 8F      LDY &8F\n.EXL4\n     3A29   20 56 44   JSR &4456\n     3A2C   85 97      STA &97\n     3A2E   A5 D3      LDA &D3\n     3A30   85 91      STA &91\n     3A32   A5 D2      LDA &D2\n     3A34   20 67 3A   JSR &3A67\n     3A37   D0 28      BNE &3A61\n     3A39   E0 BF      CPX #&BF\n     3A3B   B0 24      BCS &3A61\n     3A3D   86 32      STX &32\n     3A3F   A5 D5      LDA &D5\n     3A41   85 91      STA &91\n     3A43   A5 D4      LDA &D4\n     3A45   20 67 3A   JSR &3A67\n     3A48   D0 05      BNE &3A4F\n     3A4A   A5 32      LDA &32\n     3A4C   20 DF 1A   JSR &1ADF\n.EX4\n     3A4F   88         DEY\n     3A50   10 D7      BPL &3A29\n     3A52   A4 A4      LDY &A4\n     3A54   C4 A0      CPY &A0\n     3A56   90 B5      BCC &3A0D\n     3A58   68         PLA\n     3A59   85 01      STA &01\n     3A5B   AD 06 09   LDA &0906\n     3A5E   85 03      STA &03\n     3A60   60         RTS\n.EX11\n     3A61   20 56 44   JSR &4456\n     3A64   4C 4F 3A   JMP &3A4F\n.EXS1\n     3A67   85 92      STA &92\n     3A69   20 56 44   JSR &4456\n     3A6C   2A         ROL A\n     3A6D   B0 0B      BCS &3A7A\n     3A6F   20 A9 27   JSR &27A9\n     3A72   65 91      ADC &91\n     3A74   AA         TAX\n     3A75   A5 92      LDA &92\n     3A77   69 00      ADC #&00\n     3A79   60         RTS\n.EX5\n     3A7A   20 A9 27   JSR &27A9\n     3A7D   85 D1      STA &D1\n     3A7F   A5 91      LDA &91\n     3A81   E5 D1      SBC &D1\n     3A83   AA         TAX\n     3A84   A5 92      LDA &92\n     3A86   E9 00      SBC #&00\n     3A88   60         RTS\n.SOS1\n     3A89   20 0E 44   JSR &440E\n     3A8C   A9 7F      LDA #&7F\n     3A8E   85 70      STA &70\n     3A90   85 71      STA &71\n     3A92   AD 1D 0F   LDA &0F1D\n     3A95   29 02      AND #&02\n     3A97   09 80      ORA #&80\n     3A99   4C 82 3C   JMP &3C82\n.SOLAR\n     3A9C   4E 34 03   LSR &0334\n     3A9F   20 F9 43   JSR &43F9\n     3AA2   A5 79      LDA &79\n     3AA4   29 07      AND #&07\n     3AA6   69 06      ADC #&06\n     3AA8   4A         LSR A\n     3AA9   85 5B      STA &5B\n     3AAB   6A         ROR A\n     3AAC   85 55      STA &55\n     3AAE   85 58      STA &58\n     3AB0   20 89 3A   JSR &3A89\n     3AB3   A5 7B      LDA &7B\n     3AB5   29 07      AND #&07\n     3AB7   09 81      ORA #&81\n     3AB9   85 5B      STA &5B\n     3ABB   A5 7D      LDA &7D\n     3ABD   29 03      AND #&03\n     3ABF   85 55      STA &55\n     3AC1   85 54      STA &54\n     3AC3   A9 00      LDA #&00\n     3AC5   85 70      STA &70\n     3AC7   85 71      STA &71\n     3AC9   A9 81      LDA #&81\n     3ACB   20 82 3C   JSR &3C82\n.NWSTARS\n     3ACE   A5 96      LDA &96\n     3AD0   D0 23      BNE &3AF5\n.nWq\n     3AD2   AC 33 0F   LDY &0F33\n.SAL4\n     3AD5   20 57 44   JSR &4457\n     3AD8   09 08      ORA #&08\n     3ADA   99 E8 0E   STA &0EE8,Y\n     3ADD   85 97      STA &97\n     3ADF   20 57 44   JSR &4457\n     3AE2   99 4C 03   STA &034C,Y\n     3AE5   85 31      STA &31\n     3AE7   20 57 44   JSR &4457\n     3AEA   99 C2 0E   STA &0EC2,Y\n     3AED   85 32      STA &32\n     3AEF   20 BD 1A   JSR &1ABD\n     3AF2   88         DEY\n     3AF3   D0 E0      BNE &3AD5\n.WPSHPS\n     3AF5   A2 00      LDX #&00\n.WSL1\n     3AF7   BD 40 0D   LDA &0D40,X\n     3AFA   F0 23      BEQ &3B1F\n     3AFC   30 1E      BMI &3B1C\n     3AFE   85 9B      STA &9B\n     3B00   20 4F 3C   JSR &3C4F\n     3B03   A0 1F      LDY #&1F\n.WSL2\n     3B05   B1 20      LDA (&20),Y\n     3B07   99 53 00   STA &0053,Y\n     3B0A   88         DEY\n     3B0B   10 F8      BPL &3B05\n     3B0D   86 93      STX &93\n     3B0F   20 20 2C   JSR &2C20\n     3B12   A6 93      LDX &93\n     3B14   A0 1F      LDY #&1F\n     3B16   B1 20      LDA (&20),Y\n     3B18   29 A7      AND #&A7\n     3B1A   91 20      STA (&20),Y\n.WS1\n     3B1C   E8         INX\n     3B1D   D0 D8      BNE &3AF7\n.WS2\n     3B1F   A2 FF      LDX #&FF\n     3B21   8E 26 0E   STX &0E26\n     3B24   8E 74 0E   STX &0E74\n.FLFLLS\n     3B27   A0 BF      LDY #&BF\n     3B29   A9 00      LDA #&00\n.SAL6\n     3B2B   99 66 0D   STA &0D66,Y\n     3B2E   88         DEY\n     3B2F   D0 FA      BNE &3B2B\n     3B31   88         DEY\n     3B32   8C 66 0D   STY &0D66\n     3B35   60         RTS\n.DET1\n     3B36   A9 06      LDA #&06\n     3B38   78         SEI\n     3B39   8D 00 FE   STA &FE00\n     3B3C   8E 01 FE   STX &FE01\n     3B3F   58         CLI\n     3B40   60         RTS\n     3B41   CA         DEX\n     3B42   60         RTS\n.SHD\n     3B43   E8         INX\n     3B44   F0 FB      BEQ &3B41\n.DENGY\n     3B46   CE 13 0F   DEC &0F13\n     3B49   08         PHP\n     3B4A   D0 03      BNE &3B4F\n     3B4C   EE 13 0F   INC &0F13\n     3B4F   28         PLP\n     3B50   60         RTS\n.COMPAS\n     3B51   20 B1 3B   JSR &3BB1\n     3B54   AD 55 0D   LDA &0D55\n     3B57   D0 31      BNE &3B8A\n     3B59   20 DE 48   JSR &48DE\n     3B5C   4C 8D 3B   JMP &3B8D\n.SPS2\n     3B5F   0A         ASL A\n     3B60   AA         TAX\n     3B61   A9 00      LDA #&00\n     3B63   6A         ROR A\n     3B64   A8         TAY\n     3B65   A9 14      LDA #&14\n     3B67   85 90      STA &90\n     3B69   8A         TXA\n     3B6A   20 C5 28   JSR &28C5\n     3B6D   A6 1B      LDX &1B\n     3B6F   98         TYA\n     3B70   30 03      BMI &3B75\n     3B72   A0 00      LDY #&00\n     3B74   60         RTS\n.LL163\n     3B75   A0 FF      LDY #&FF\n     3B77   8A         TXA\n     3B78   49 FF      EOR #&FF\n     3B7A   AA         TAX\n     3B7B   E8         INX\n     3B7C   60         RTS\n.SPS4\n     3B7D   A2 08      LDX #&08\n.SPL1\n     3B7F   BD 24 09   LDA &0924,X\n     3B82   95 D2      STA &D2,X\n     3B84   CA         DEX\n     3B85   10 F8      BPL &3B7F\n     3B87   4C ED 48   JMP &48ED\n.SP1\n     3B8A   20 7D 3B   JSR &3B7D\n.SP2\n     3B8D   A5 31      LDA &31\n     3B8F   20 5F 3B   JSR &3B5F\n     3B92   8A         TXA\n     3B93   69 C3      ADC #&C3\n     3B95   8D 16 0F   STA &0F16\n     3B98   A5 32      LDA &32\n     3B9A   20 5F 3B   JSR &3B5F\n     3B9D   86 D1      STX &D1\n     3B9F   A9 CC      LDA #&CC\n     3BA1   E5 D1      SBC &D1\n     3BA3   8D 17 0F   STA &0F17\n     3BA6   A9 F0      LDA #&F0\n     3BA8   A6 33      LDX &33\n     3BAA   10 02      BPL &3BAE\n     3BAC   A9 FF      LDA #&FF\n     3BAE   8D 48 0F   STA &0F48\n.DOT\n     3BB1   AD 17 0F   LDA &0F17\n     3BB4   85 32      STA &32\n     3BB6   AD 16 0F   LDA &0F16\n     3BB9   85 31      STA &31\n     3BBB   AD 48 0F   LDA &0F48\n     3BBE   85 A2      STA &A2\n     3BC0   C9 F0      CMP #&F0\n     3BC2   D0 05      BNE &3BC9\n.CPIX4\n     3BC4   20 C9 3B   JSR &3BC9\n     3BC7   C6 32      DEC &32\n.CPIX2\n     3BC9   A5 32      LDA &32\n     3BCB   A8         TAY\n     3BCC   4A         LSR A\n     3BCD   4A         LSR A\n     3BCE   4A         LSR A\n     3BCF   09 60      ORA #&60\n     3BD1   85 08      STA &08\n     3BD3   A5 31      LDA &31\n     3BD5   29 F8      AND #&F8\n     3BD7   85 07      STA &07\n     3BD9   98         TYA\n     3BDA   29 07      AND #&07\n     3BDC   A8         TAY\n     3BDD   A5 31      LDA &31\n     3BDF   29 06      AND #&06\n     3BE1   4A         LSR A\n     3BE2   AA         TAX\n     3BE3   BD 72 18   LDA &1872,X\n     3BE6   25 A2      AND &A2\n     3BE8   51 07      EOR (&07),Y\n     3BEA   91 07      STA (&07),Y\n     3BEC   BD 73 18   LDA &1873,X\n     3BEF   10 09      BPL &3BFA\n     3BF1   A5 07      LDA &07\n     3BF3   69 08      ADC #&08\n     3BF5   85 07      STA &07\n     3BF7   BD 73 18   LDA &1873,X\n.CP1\n     3BFA   25 A2      AND &A2\n     3BFC   51 07      EOR (&07),Y\n     3BFE   91 07      STA (&07),Y\n     3C00   60         RTS\n.OOPS\n     3C01   85 D1      STA &D1\n     3C03   A0 08      LDY #&08\n     3C05   A2 00      LDX #&00\n     3C07   B1 20      LDA (&20),Y\n     3C09   30 10      BMI &3C1B\n     3C0B   AD 11 0F   LDA &0F11\n     3C0E   E5 D1      SBC &D1\n     3C10   90 04      BCC &3C16\n     3C12   8D 11 0F   STA &0F11\n     3C15   60         RTS\n.OO2\n     3C16   8E 11 0F   STX &0F11\n     3C19   90 0E      BCC &3C29\n.OO1\n     3C1B   AD 12 0F   LDA &0F12\n     3C1E   E5 D1      SBC &D1\n     3C20   90 04      BCC &3C26\n     3C22   8D 12 0F   STA &0F12\n     3C25   60         RTS\n.OO5\n     3C26   8E 12 0F   STX &0F12\n.OO3\n     3C29   6D 13 0F   ADC &0F13\n     3C2C   8D 13 0F   STA &0F13\n     3C2F   F0 02      BEQ &3C33\n     3C31   B0 03      BCS &3C36\n     3C33   4C 7F 46   JMP &467F\n     3C36   20 8C 49   JSR &498C\n     3C39   4C 4D 4B   JMP &4B4D\n.SPS3\n     3C3C   BD 01 09   LDA &0901,X\n     3C3F   95 D2      STA &D2,X\n     3C41   BD 02 09   LDA &0902,X\n     3C44   A8         TAY\n     3C45   29 7F      AND #&7F\n     3C47   95 D3      STA &D3,X\n     3C49   98         TYA\n     3C4A   29 80      AND #&80\n     3C4C   95 D4      STA &D4,X\n     3C4E   60         RTS\n.GINF\n     3C4F   8A         TXA\n     3C50   0A         ASL A\n     3C51   A8         TAY\n     3C52   B9 48 18   LDA &1848,Y\n     3C55   85 20      STA &20\n     3C57   B9 49 18   LDA &1849,Y\n     3C5A   85 21      STA &21\n     3C5C   60         RTS\n.NWSPS\n     3C5D   20 25 3D   JSR &3D25\n     3C60   A2 01      LDX #&01\n     3C62   86 73      STX &73\n     3C64   CA         DEX\n     3C65   86 71      STX &71\n     3C67   8E 41 0D   STX &0D41\n     3C6A   CA         DEX\n     3C6B   86 70      STX &70\n     3C6D   A2 0A      LDX #&0A\n     3C6F   20 FE 3C   JSR &3CFE\n     3C72   20 FE 3C   JSR &3CFE\n     3C75   20 FE 3C   JSR &3CFE\n     3C78   A9 66      LDA #&66\n     3C7A   85 74      STA &74\n     3C7C   A9 0D      LDA #&0D\n     3C7E   85 75      STA &75\n     3C80   A9 08      LDA #&08\n.NWSHP\n     3C82   85 D1      STA &D1\n     3C84   A2 00      LDX #&00\n.NWL1\n     3C86   BD 40 0D   LDA &0D40,X\n     3C89   F0 07      BEQ &3C92\n     3C8B   E8         INX\n     3C8C   E0 0C      CPX #&0C\n     3C8E   90 F6      BCC &3C86\n.NW3\n     3C90   18         CLC\n     3C91   60         RTS\n.NW1\n     3C92   20 4F 3C   JSR &3C4F\n     3C95   A5 D1      LDA &D1\n     3C97   30 50      BMI &3CE9\n     3C99   0A         ASL A\n     3C9A   A8         TAY\n     3C9B   B9 38 56   LDA &5638,Y\n     3C9E   85 1E      STA &1E\n     3CA0   B9 39 56   LDA &5639,Y\n     3CA3   85 1F      STA &1F\n     3CA5   C0 10      CPY #&10\n     3CA7   F0 30      BEQ &3CD9\n     3CA9   A0 05      LDY #&05\n     3CAB   B1 1E      LDA (&1E),Y\n     3CAD   85 06      STA &06\n     3CAF   AD 1E 0F   LDA &0F1E\n     3CB2   38         SEC\n     3CB3   E5 06      SBC &06\n     3CB5   85 74      STA &74\n     3CB7   AD 1F 0F   LDA &0F1F\n     3CBA   E9 00      SBC #&00\n     3CBC   85 75      STA &75\n     3CBE   A5 74      LDA &74\n     3CC0   E5 20      SBC &20\n     3CC2   A8         TAY\n     3CC3   A5 75      LDA &75\n     3CC5   E5 21      SBC &21\n     3CC7   90 C8      BCC &3C91\n     3CC9   D0 04      BNE &3CCF\n     3CCB   C0 24      CPY #&24\n     3CCD   90 C2      BCC &3C91\n.NW4\n     3CCF   A5 74      LDA &74\n     3CD1   8D 1E 0F   STA &0F1E\n     3CD4   A5 75      LDA &75\n     3CD6   8D 1F 0F   STA &0F1F\n.NW6\n     3CD9   A0 0E      LDY #&0E\n     3CDB   B1 1E      LDA (&1E),Y\n     3CDD   85 76      STA &76\n     3CDF   A0 13      LDY #&13\n     3CE1   B1 1E      LDA (&1E),Y\n     3CE3   29 07      AND #&07\n     3CE5   85 72      STA &72\n     3CE7   A5 D1      LDA &D1\n.NW2\n     3CE9   9D 40 0D   STA &0D40,X\n     3CEC   AA         TAX\n     3CED   30 03      BMI &3CF2\n     3CEF   FE 4D 0D   INC &0D4D,X\n     3CF2   A0 23      LDY #&23\n.NWL3\n     3CF4   B9 53 00   LDA &0053,Y\n     3CF7   91 20      STA (&20),Y\n     3CF9   88         DEY\n     3CFA   10 F8      BPL &3CF4\n     3CFC   38         SEC\n     3CFD   60         RTS\n.NwS1\n     3CFE   B5 53      LDA &53,X\n     3D00   49 80      EOR #&80\n     3D02   95 53      STA &53,X\n     3D04   E8         INX\n     3D05   E8         INX\n     3D06   60         RTS\n.ABORT\n     3D07   A2 FF      LDX #&FF\n.ABORT2\n     3D09   86 52      STX &52\n     3D0B   AE 33 03   LDX &0333\n     3D0E   20 41 3D   JSR &3D41\n     3D11   8C 5E 0D   STY &0D5E\n     3D14   60         RTS\n.ECBLB2\n     3D15   A9 20      LDA #&20\n     3D17   85 30      STA &30\n     3D19   0A         ASL A\n     3D1A   20 CD 49   JSR &49CD\n.ECBLB\n     3D1D   A9 38      LDA #&38\n     3D1F   A2 36      LDX #&36\n     3D21   A0 3D      LDY #&3D\n     3D23   D0 04      BNE &3D29\n.SPBLB\n     3D25   A9 C0      LDA #&C0\n     3D27   A2 39      LDX #&39\n     3D29   A0 3D      LDY #&3D\n.BULB\n     3D2B   85 07      STA &07\n     3D2D   86 1C      STX &1C\n     3D2F   84 1D      STY &1D\n     3D31   A9 7D      LDA #&7D\n     3D33   4C DB 1F   JMP &1FDB\n.ECBT\n     3D36   E0\n     3D37   E0\n     3D38   80\n.SPBT\n     3D39   E0\n     3D3A   E0\n     3D3B   80\n     3D3C   E0\n     3D3D   E0\n     3D3E   20\n     3D3F   E0\n     3D40   E0\n.MSBAR\n     3D41   8A         TXA\n     3D42   0A         ASL A\n     3D43   0A         ASL A\n     3D44   0A         ASL A\n     3D45   85 D1      STA &D1\n     3D47   A9 31      LDA #&31\n     3D49   E5 D1      SBC &D1\n     3D4B   85 07      STA &07\n     3D4D   A9 7E      LDA #&7E\n     3D4F   85 08      STA &08\n     3D51   98         TYA\n     3D52   A0 05      LDY #&05\n.MBL1\n     3D54   91 07      STA (&07),Y\n     3D56   88         DEY\n     3D57   D0 FB      BNE &3D54\n     3D59   60         RTS\n.PROJ\n     3D5A   A5 53      LDA &53\n     3D5C   85 1B      STA &1B\n     3D5E   A5 54      LDA &54\n     3D60   85 1C      STA &1C\n     3D62   A5 55      LDA &55\n     3D64   20 00 42   JSR &4200\n     3D67   B0 28      BCS &3D91\n     3D69   A5 3D      LDA &3D\n     3D6B   69 80      ADC #&80\n     3D6D   85 D2      STA &D2\n     3D6F   8A         TXA\n     3D70   69 00      ADC #&00\n     3D72   85 D3      STA &D3\n     3D74   A5 56      LDA &56\n     3D76   85 1B      STA &1B\n     3D78   A5 57      LDA &57\n     3D7A   85 1C      STA &1C\n     3D7C   A5 58      LDA &58\n     3D7E   49 80      EOR #&80\n     3D80   20 00 42   JSR &4200\n     3D83   B0 0C      BCS &3D91\n     3D85   A5 3D      LDA &3D\n     3D87   69 60      ADC #&60\n     3D89   85 E0      STA &E0\n     3D8B   8A         TXA\n     3D8C   69 00      ADC #&00\n     3D8E   85 E1      STA &E1\n     3D90   18         CLC\n     3D91   60         RTS\n.PL2\n     3D92   A5 9B      LDA &9B\n     3D94   4A         LSR A\n     3D95   B0 03      BCS &3D9A\n     3D97   4C F3 40   JMP &40F3\n     3D9A   4C 36 41   JMP &4136\n.PLANET\n     3D9D   A5 5B      LDA &5B\n     3D9F   30 F1      BMI &3D92\n     3DA1   C9 30      CMP #&30\n     3DA3   B0 ED      BCS &3D92\n     3DA5   05 5A      ORA &5A\n     3DA7   F0 E9      BEQ &3D92\n     3DA9   20 5A 3D   JSR &3D5A\n     3DAC   B0 E4      BCS &3D92\n     3DAE   A9 60      LDA #&60\n     3DB0   85 1C      STA &1C\n     3DB2   A9 00      LDA #&00\n     3DB4   85 1B      STA &1B\n     3DB6   20 DE 28   JSR &28DE\n     3DB9   A5 3E      LDA &3E\n     3DBB   F0 04      BEQ &3DC1\n     3DBD   A9 F8      LDA #&F8\n     3DBF   85 3D      STA &3D\n.PL82\n     3DC1   A5 9B      LDA &9B\n     3DC3   4A         LSR A\n     3DC4   90 03      BCC &3DC9\n     3DC6   4C 5A 3F   JMP &3F5A\n.PL9\n     3DC9   20 F3 40   JSR &40F3\n     3DCC   20 7C 40   JSR &407C\n     3DCF   B0 04      BCS &3DD5\n     3DD1   A5 3E      LDA &3E\n     3DD3   F0 01      BEQ &3DD6\n.PL20\n     3DD5   60         RTS\n.PL25\n     3DD6   A5 9B      LDA &9B\n     3DD8   C9 80      CMP #&80\n     3DDA   D0 3C      BNE &3E18\n     3DDC   A5 3D      LDA &3D\n     3DDE   C9 06      CMP #&06\n     3DE0   90 F3      BCC &3DD5\n     3DE2   A5 61      LDA &61\n     3DE4   49 80      EOR #&80\n     3DE6   85 1B      STA &1B\n     3DE8   A5 67      LDA &67\n     3DEA   20 E1 41   JSR &41E1\n     3DED   A2 09      LDX #&09\n     3DEF   20 6E 3E   JSR &3E6E\n     3DF2   85 AC      STA &AC\n     3DF4   84 09      STY &09\n     3DF6   20 6E 3E   JSR &3E6E\n     3DF9   85 AD      STA &AD\n     3DFB   84 0A      STY &0A\n     3DFD   A2 0F      LDX #&0F\n     3DFF   20 F1 41   JSR &41F1\n     3E02   20 8C 3E   JSR &3E8C\n     3E05   A5 61      LDA &61\n     3E07   49 80      EOR #&80\n     3E09   85 1B      STA &1B\n     3E0B   A5 6D      LDA &6D\n     3E0D   20 E1 41   JSR &41E1\n     3E10   A2 15      LDX #&15\n     3E12   20 F1 41   JSR &41F1\n     3E15   4C 8C 3E   JMP &3E8C\n.PL26\n     3E18   A5 67      LDA &67\n     3E1A   30 B9      BMI &3DD5\n     3E1C   A2 0F      LDX #&0F\n     3E1E   20 C0 41   JSR &41C0\n     3E21   18         CLC\n     3E22   65 D2      ADC &D2\n     3E24   85 D2      STA &D2\n     3E26   98         TYA\n     3E27   65 D3      ADC &D3\n     3E29   85 D3      STA &D3\n     3E2B   20 C0 41   JSR &41C0\n     3E2E   85 1B      STA &1B\n     3E30   A5 E0      LDA &E0\n     3E32   38         SEC\n     3E33   E5 1B      SBC &1B\n     3E35   85 E0      STA &E0\n     3E37   84 1B      STY &1B\n     3E39   A5 E1      LDA &E1\n     3E3B   E5 1B      SBC &1B\n     3E3D   85 E1      STA &E1\n     3E3F   A2 09      LDX #&09\n     3E41   20 6E 3E   JSR &3E6E\n     3E44   4A         LSR A\n     3E45   85 AC      STA &AC\n     3E47   84 09      STY &09\n     3E49   20 6E 3E   JSR &3E6E\n     3E4C   4A         LSR A\n     3E4D   85 AD      STA &AD\n     3E4F   84 0A      STY &0A\n     3E51   A2 15      LDX #&15\n     3E53   20 6E 3E   JSR &3E6E\n     3E56   4A         LSR A\n     3E57   85 AE      STA &AE\n     3E59   84 0B      STY &0B\n     3E5B   20 6E 3E   JSR &3E6E\n     3E5E   4A         LSR A\n     3E5F   85 AF      STA &AF\n     3E61   84 0C      STY &0C\n     3E63   A9 40      LDA #&40\n     3E65   85 A0      STA &A0\n     3E67   A9 00      LDA #&00\n     3E69   85 A5      STA &A5\n     3E6B   4C 90 3E   JMP &3E90\n.PLS1\n     3E6E   B5 53      LDA &53,X\n     3E70   85 1B      STA &1B\n     3E72   B5 54      LDA &54,X\n     3E74   29 7F      AND #&7F\n     3E76   85 1C      STA &1C\n     3E78   B5 54      LDA &54,X\n     3E7A   29 80      AND #&80\n     3E7C   20 DE 28   JSR &28DE\n     3E7F   A5 3D      LDA &3D\n     3E81   A4 3E      LDY &3E\n     3E83   F0 02      BEQ &3E87\n     3E85   A9 FE      LDA #&FE\n     3E87   A4 40      LDY &40\n     3E89   E8         INX\n     3E8A   E8         INX\n     3E8B   60         RTS\n.PLS2\n     3E8C   A9 1F      LDA #&1F\n     3E8E   85 A0      STA &A0\n.PLS22\n     3E90   A2 00      LDX #&00\n     3E92   86 A4      STX &A4\n     3E94   CA         DEX\n     3E95   86 A3      STX &A3\n.PLL4\n     3E97   A5 A5      LDA &A5\n     3E99   29 1F      AND #&1F\n     3E9B   AA         TAX\n     3E9C   BD BA 26   LDA &26BA,X\n     3E9F   85 90      STA &90\n     3EA1   A5 AE      LDA &AE\n     3EA3   20 A9 27   JSR &27A9\n     3EA6   85 91      STA &91\n     3EA8   A5 AF      LDA &AF\n     3EAA   20 A9 27   JSR &27A9\n     3EAD   85 3D      STA &3D\n     3EAF   A6 A5      LDX &A5\n     3EB1   E0 21      CPX #&21\n     3EB3   A9 00      LDA #&00\n     3EB5   6A         ROR A\n     3EB6   85 0E      STA &0E\n     3EB8   A5 A5      LDA &A5\n     3EBA   18         CLC\n     3EBB   69 10      ADC #&10\n     3EBD   29 1F      AND #&1F\n     3EBF   AA         TAX\n     3EC0   BD BA 26   LDA &26BA,X\n     3EC3   85 90      STA &90\n     3EC5   A5 AD      LDA &AD\n     3EC7   20 A9 27   JSR &27A9\n     3ECA   85 3F      STA &3F\n     3ECC   A5 AC      LDA &AC\n     3ECE   20 A9 27   JSR &27A9\n     3ED1   85 1B      STA &1B\n     3ED3   A5 A5      LDA &A5\n     3ED5   69 0F      ADC #&0F\n     3ED7   29 3F      AND #&3F\n     3ED9   C9 21      CMP #&21\n     3EDB   A9 00      LDA #&00\n     3EDD   6A         ROR A\n     3EDE   85 0D      STA &0D\n     3EE0   A5 0E      LDA &0E\n     3EE2   45 0B      EOR &0B\n     3EE4   85 92      STA &92\n     3EE6   A5 0D      LDA &0D\n     3EE8   45 09      EOR &09\n     3EEA   20 5F 28   JSR &285F\n     3EED   85 D1      STA &D1\n     3EEF   10 0F      BPL &3F00\n     3EF1   8A         TXA\n     3EF2   49 FF      EOR #&FF\n     3EF4   18         CLC\n     3EF5   69 01      ADC #&01\n     3EF7   AA         TAX\n     3EF8   A5 D1      LDA &D1\n     3EFA   49 7F      EOR #&7F\n     3EFC   69 00      ADC #&00\n     3EFE   85 D1      STA &D1\n.PL42\n     3F00   8A         TXA\n     3F01   65 D2      ADC &D2\n     3F03   85 82      STA &82\n     3F05   A5 D1      LDA &D1\n     3F07   65 D3      ADC &D3\n     3F09   85 83      STA &83\n     3F0B   A5 3D      LDA &3D\n     3F0D   85 91      STA &91\n     3F0F   A5 0E      LDA &0E\n     3F11   45 0C      EOR &0C\n     3F13   85 92      STA &92\n     3F15   A5 3F      LDA &3F\n     3F17   85 1B      STA &1B\n     3F19   A5 0D      LDA &0D\n     3F1B   45 0A      EOR &0A\n     3F1D   20 5F 28   JSR &285F\n     3F20   49 80      EOR #&80\n     3F22   85 D1      STA &D1\n     3F24   10 0F      BPL &3F35\n     3F26   8A         TXA\n     3F27   49 FF      EOR #&FF\n     3F29   18         CLC\n     3F2A   69 01      ADC #&01\n     3F2C   AA         TAX\n     3F2D   A5 D1      LDA &D1\n     3F2F   49 7F      EOR #&7F\n     3F31   69 00      ADC #&00\n     3F33   85 D1      STA &D1\n.PL43\n     3F35   20 18 1B   JSR &1B18\n     3F38   C5 A0      CMP &A0\n     3F3A   F0 02      BEQ &3F3E\n     3F3C   B0 0C      BCS &3F4A\n     3F3E   A5 A5      LDA &A5\n     3F40   18         CLC\n     3F41   65 A6      ADC &A6\n     3F43   29 3F      AND #&3F\n     3F45   85 A5      STA &A5\n     3F47   4C 97 3E   JMP &3E97\n.PL40\n     3F4A   60         RTS\n     3F4B   4C 36 41   JMP &4136\n.PLF3\n     3F4E   8A         TXA\n     3F4F   49 FF      EOR #&FF\n     3F51   18         CLC\n     3F52   69 01      ADC #&01\n     3F54   AA         TAX\n.PLF17\n     3F55   A9 FF      LDA #&FF\n     3F57   4C 9F 3F   JMP &3F9F\n.SUN\n     3F5A   A9 01      LDA #&01\n     3F5C   8D 66 0D   STA &0D66\n     3F5F   20 86 41   JSR &4186\n     3F62   B0 E7      BCS &3F4B\n     3F64   A9 00      LDA #&00\n     3F66   A6 3D      LDX &3D\n     3F68   E0 60      CPX #&60\n     3F6A   2A         ROL A\n     3F6B   E0 28      CPX #&28\n     3F6D   2A         ROL A\n     3F6E   E0 10      CPX #&10\n     3F70   2A         ROL A\n.PLF18\n     3F71   85 A4      STA &A4\n     3F73   A9 BF      LDA #&BF\n     3F75   A6 1D      LDX &1D\n     3F77   D0 0A      BNE &3F83\n     3F79   C5 1C      CMP &1C\n     3F7B   90 06      BCC &3F83\n     3F7D   A5 1C      LDA &1C\n     3F7F   D0 02      BNE &3F83\n     3F81   A9 01      LDA #&01\n.PLF2\n     3F83   85 A0      STA &A0\n     3F85   A9 BF      LDA #&BF\n     3F87   38         SEC\n     3F88   E5 E0      SBC &E0\n     3F8A   AA         TAX\n     3F8B   A9 00      LDA #&00\n     3F8D   E5 E1      SBC &E1\n     3F8F   30 BD      BMI &3F4E\n     3F91   D0 08      BNE &3F9B\n     3F93   E8         INX\n     3F94   CA         DEX\n     3F95   F0 BE      BEQ &3F55\n     3F97   E4 3D      CPX &3D\n     3F99   90 04      BCC &3F9F\n.PLF4\n     3F9B   A6 3D      LDX &3D\n     3F9D   A9 00      LDA #&00\n.PLF5\n     3F9F   86 22      STX &22\n     3FA1   85 23      STA &23\n     3FA3   A5 3D      LDA &3D\n     3FA5   20 6F 27   JSR &276F\n     3FA8   85 AD      STA &AD\n     3FAA   A5 1B      LDA &1B\n     3FAC   85 AC      STA &AC\n     3FAE   A0 BF      LDY #&BF\n     3FB0   A5 28      LDA &28\n     3FB2   85 26      STA &26\n     3FB4   A5 29      LDA &29\n     3FB6   85 27      STA &27\n.PLFL2\n     3FB8   C4 A0      CPY &A0\n     3FBA   F0 0B      BEQ &3FC7\n     3FBC   B9 66 0D   LDA &0D66,Y\n     3FBF   F0 03      BEQ &3FC4\n     3FC1   20 0B 1A   JSR &1A0B\n.PLF13\n     3FC4   88         DEY\n     3FC5   D0 F1      BNE &3FB8\n.PLFL\n     3FC7   A5 22      LDA &22\n     3FC9   20 6F 27   JSR &276F\n     3FCC   85 D1      STA &D1\n     3FCE   A5 AC      LDA &AC\n     3FD0   38         SEC\n     3FD1   E5 1B      SBC &1B\n     3FD3   85 90      STA &90\n     3FD5   A5 AD      LDA &AD\n     3FD7   E5 D1      SBC &D1\n     3FD9   85 91      STA &91\n     3FDB   84 32      STY &32\n     3FDD   20 5B 4D   JSR &4D5B\n     3FE0   A4 32      LDY &32\n     3FE2   20 57 44   JSR &4457\n     3FE5   25 A4      AND &A4\n     3FE7   18         CLC\n     3FE8   65 90      ADC &90\n     3FEA   90 02      BCC &3FEE\n     3FEC   A9 FF      LDA #&FF\n.PLF44\n     3FEE   BE 66 0D   LDX &0D66,Y\n     3FF1   99 66 0D   STA &0D66,Y\n     3FF4   F0 4A      BEQ &4040\n     3FF6   A5 28      LDA &28\n     3FF8   85 26      STA &26\n     3FFA   A5 29      LDA &29\n     3FFC   85 27      STA &27\n     3FFE   8A         TXA\n     3FFF   20 55 41   JSR &4155\n     4002   A5 31      LDA &31\n     4004   85 24      STA &24\n     4006   A5 33      LDA &33\n     4008   85 25      STA &25\n     400A   A5 D2      LDA &D2\n     400C   85 26      STA &26\n     400E   A5 D3      LDA &D3\n     4010   85 27      STA &27\n     4012   B9 66 0D   LDA &0D66,Y\n     4015   20 55 41   JSR &4155\n     4018   B0 0B      BCS &4025\n     401A   A5 33      LDA &33\n     401C   A6 24      LDX &24\n     401E   86 33      STX &33\n     4020   85 24      STA &24\n     4022   20 15 1A   JSR &1A15\n.PLF23\n     4025   A5 24      LDA &24\n     4027   85 31      STA &31\n     4029   A5 25      LDA &25\n     402B   85 33      STA &33\n.PLF16\n     402D   20 15 1A   JSR &1A15\n.PLF6\n     4030   88         DEY\n     4031   F0 3F      BEQ &4072\n     4033   A5 23      LDA &23\n     4035   D0 1D      BNE &4054\n     4037   C6 22      DEC &22\n     4039   D0 8C      BNE &3FC7\n     403B   C6 23      DEC &23\n.PLFLS\n     403D   4C C7 3F   JMP &3FC7\n.PLF11\n     4040   A6 D2      LDX &D2\n     4042   86 26      STX &26\n     4044   A6 D3      LDX &D3\n     4046   86 27      STX &27\n     4048   20 55 41   JSR &4155\n     404B   90 E0      BCC &402D\n     404D   A9 00      LDA #&00\n     404F   99 66 0D   STA &0D66,Y\n     4052   F0 DC      BEQ &4030\n.PLF10\n     4054   A6 22      LDX &22\n     4056   E8         INX\n     4057   86 22      STX &22\n     4059   E4 3D      CPX &3D\n     405B   90 E0      BCC &403D\n     405D   F0 DE      BEQ &403D\n     405F   A5 28      LDA &28\n     4061   85 26      STA &26\n     4063   A5 29      LDA &29\n     4065   85 27      STA &27\n.PLFL3\n     4067   B9 66 0D   LDA &0D66,Y\n     406A   F0 03      BEQ &406F\n     406C   20 0B 1A   JSR &1A0B\n.PLF9\n     406F   88         DEY\n     4070   D0 F5      BNE &4067\n.PLF8\n     4072   18         CLC\n     4073   A5 D2      LDA &D2\n     4075   85 28      STA &28\n     4077   A5 D3      LDA &D3\n     4079   85 29      STA &29\n.RTS2\n     407B   60         RTS\n.CIRCLE\n     407C   20 86 41   JSR &4186\n     407F   B0 FA      BCS &407B\n     4081   A9 00      LDA #&00\n     4083   8D 26 0E   STA &0E26\n     4086   A6 3D      LDX &3D\n     4088   A9 08      LDA #&08\n     408A   E0 08      CPX #&08\n     408C   90 06      BCC &4094\n     408E   4A         LSR A\n     408F   E0 3C      CPX #&3C\n     4091   90 01      BCC &4094\n     4093   4A         LSR A\n.PL89\n     4094   85 A6      STA &A6\n.CIRCLE2\n     4096   A2 FF      LDX #&FF\n     4098   86 A3      STX &A3\n     409A   E8         INX\n     409B   86 A4      STX &A4\n.PLL3\n     409D   A5 A4      LDA &A4\n     409F   20 9F 27   JSR &279F\n     40A2   A2 00      LDX #&00\n     40A4   86 D1      STX &D1\n     40A6   A6 A4      LDX &A4\n     40A8   E0 21      CPX #&21\n     40AA   90 0D      BCC &40B9\n     40AC   49 FF      EOR #&FF\n     40AE   69 00      ADC #&00\n     40B0   AA         TAX\n     40B1   A9 FF      LDA #&FF\n     40B3   69 00      ADC #&00\n     40B5   85 D1      STA &D1\n     40B7   8A         TXA\n     40B8   18         CLC\n.PL37\n     40B9   65 D2      ADC &D2\n     40BB   85 82      STA &82\n     40BD   A5 D3      LDA &D3\n     40BF   65 D1      ADC &D1\n     40C1   85 83      STA &83\n     40C3   A5 A4      LDA &A4\n     40C5   18         CLC\n     40C6   69 10      ADC #&10\n     40C8   20 9F 27   JSR &279F\n     40CB   AA         TAX\n     40CC   A9 00      LDA #&00\n     40CE   85 D1      STA &D1\n     40D0   A5 A4      LDA &A4\n     40D2   69 0F      ADC #&0F\n     40D4   29 3F      AND #&3F\n     40D6   C9 21      CMP #&21\n     40D8   90 0D      BCC &40E7\n     40DA   8A         TXA\n     40DB   49 FF      EOR #&FF\n     40DD   69 00      ADC #&00\n     40DF   AA         TAX\n     40E0   A9 FF      LDA #&FF\n     40E2   69 00      ADC #&00\n     40E4   85 D1      STA &D1\n     40E6   18         CLC\n.PL38\n     40E7   20 18 1B   JSR &1B18\n     40EA   C9 41      CMP #&41\n     40EC   B0 03      BCS &40F1\n     40EE   4C 9D 40   JMP &409D\n     40F1   18         CLC\n     40F2   60         RTS\n.WPLS2\n     40F3   AC 26 0E   LDY &0E26\n     40F6   D0 34      BNE &412C\n.WPL1\n     40F8   C4 77      CPY &77\n     40FA   B0 30      BCS &412C\n     40FC   B9 74 0E   LDA &0E74,Y\n     40FF   C9 FF      CMP #&FF\n     4101   F0 1A      BEQ &411D\n     4103   85 34      STA &34\n     4105   B9 26 0E   LDA &0E26,Y\n     4108   85 33      STA &33\n     410A   20 77 18   JSR &1877\n     410D   C8         INY\n     410E   A5 A1      LDA &A1\n     4110   D0 E6      BNE &40F8\n     4112   A5 33      LDA &33\n     4114   85 31      STA &31\n     4116   A5 34      LDA &34\n     4118   85 32      STA &32\n     411A   4C F8 40   JMP &40F8\n.WP2\n     411D   C8         INY\n     411E   B9 26 0E   LDA &0E26,Y\n     4121   85 31      STA &31\n     4123   B9 74 0E   LDA &0E74,Y\n     4126   85 32      STA &32\n     4128   C8         INY\n     4129   4C F8 40   JMP &40F8\n.WP1\n     412C   A9 01      LDA #&01\n     412E   85 77      STA &77\n     4130   A9 FF      LDA #&FF\n     4132   8D 26 0E   STA &0E26\n     4135   60         RTS\n.WPLS\n     4136   AD 66 0D   LDA &0D66\n     4139   30 FA      BMI &4135\n     413B   A5 28      LDA &28\n     413D   85 26      STA &26\n     413F   A5 29      LDA &29\n     4141   85 27      STA &27\n     4143   A0 BF      LDY #&BF\n.WPL2\n     4145   B9 66 0D   LDA &0D66,Y\n     4148   F0 03      BEQ &414D\n     414A   20 0B 1A   JSR &1A0B\n     414D   88         DEY\n     414E   D0 F5      BNE &4145\n     4150   88         DEY\n     4151   8C 66 0D   STY &0D66\n     4154   60         RTS\n.EDGES\n     4155   85 D1      STA &D1\n     4157   18         CLC\n     4158   65 26      ADC &26\n     415A   85 33      STA &33\n     415C   A5 27      LDA &27\n     415E   69 00      ADC #&00\n     4160   30 1D      BMI &417F\n     4162   F0 04      BEQ &4168\n     4164   A9 FE      LDA #&FE\n     4166   85 33      STA &33\n     4168   A5 26      LDA &26\n     416A   38         SEC\n     416B   E5 D1      SBC &D1\n     416D   85 31      STA &31\n     416F   A5 27      LDA &27\n     4171   E9 00      SBC #&00\n     4173   D0 02      BNE &4177\n     4175   18         CLC\n     4176   60         RTS\n.ED3\n     4177   10 06      BPL &417F\n     4179   A9 02      LDA #&02\n     417B   85 31      STA &31\n     417D   18         CLC\n     417E   60         RTS\n.ED1\n     417F   A9 00      LDA #&00\n     4181   99 66 0D   STA &0D66,Y\n     4184   38         SEC\n     4185   60         RTS\n.CHKON\n     4186   A5 D2      LDA &D2\n     4188   18         CLC\n     4189   65 3D      ADC &3D\n     418B   A5 D3      LDA &D3\n     418D   69 00      ADC #&00\n     418F   30 2D      BMI &41BE\n     4191   A5 D2      LDA &D2\n     4193   38         SEC\n     4194   E5 3D      SBC &3D\n     4196   A5 D3      LDA &D3\n     4198   E9 00      SBC #&00\n     419A   30 02      BMI &419E\n     419C   D0 20      BNE &41BE\n.PL31\n     419E   A5 E0      LDA &E0\n     41A0   18         CLC\n     41A1   65 3D      ADC &3D\n     41A3   85 1C      STA &1C\n     41A5   A5 E1      LDA &E1\n     41A7   69 00      ADC #&00\n     41A9   30 13      BMI &41BE\n     41AB   85 1D      STA &1D\n     41AD   A5 E0      LDA &E0\n     41AF   38         SEC\n     41B0   E5 3D      SBC &3D\n     41B2   AA         TAX\n     41B3   A5 E1      LDA &E1\n     41B5   E9 00      SBC #&00\n     41B7   30 6A      BMI &4223\n     41B9   D0 03      BNE &41BE\n     41BB   E0 BF      CPX #&BF\n     41BD   60         RTS\n.PL21\n     41BE   38         SEC\n     41BF   60         RTS\n.PLS3\n     41C0   20 6E 3E   JSR &3E6E\n     41C3   85 1B      STA &1B\n     41C5   A9 DE      LDA #&DE\n     41C7   85 90      STA &90\n     41C9   86 8F      STX &8F\n     41CB   20 82 27   JSR &2782\n     41CE   A6 8F      LDX &8F\n     41D0   A4 40      LDY &40\n     41D2   10 0A      BPL &41DE\n     41D4   49 FF      EOR #&FF\n     41D6   18         CLC\n     41D7   69 01      ADC #&01\n     41D9   F0 03      BEQ &41DE\n     41DB   A0 FF      LDY #&FF\n     41DD   60         RTS\n.PL12\n     41DE   A0 00      LDY #&00\n     41E0   60         RTS\n.PLS4\n     41E1   85 90      STA &90\n     41E3   20 97 29   JSR &2997\n     41E6   A6 61      LDX &61\n     41E8   30 02      BMI &41EC\n     41EA   49 80      EOR #&80\n     41EC   4A         LSR A\n     41ED   4A         LSR A\n     41EE   85 A5      STA &A5\n     41F0   60         RTS\n.PLS5\n     41F1   20 6E 3E   JSR &3E6E\n     41F4   85 AE      STA &AE\n     41F6   84 0B      STY &0B\n     41F8   20 6E 3E   JSR &3E6E\n     41FB   85 AF      STA &AF\n     41FD   84 0C      STY &0C\n     41FF   60         RTS\n.PLS6\n     4200   20 DE 28   JSR &28DE\n     4203   A5 40      LDA &40\n     4205   29 7F      AND #&7F\n     4207   05 3F      ORA &3F\n     4209   D0 B3      BNE &41BE\n     420B   A6 3E      LDX &3E\n     420D   E0 04      CPX #&04\n     420F   B0 13      BCS &4224\n     4211   A5 40      LDA &40\n     4213   10 0F      BPL &4224\n     4215   A5 3D      LDA &3D\n     4217   49 FF      EOR #&FF\n     4219   69 01      ADC #&01\n     421B   85 3D      STA &3D\n     421D   8A         TXA\n     421E   49 FF      EOR #&FF\n     4220   69 00      ADC #&00\n     4222   AA         TAX\n.PL44\n     4223   18         CLC\n.PL6\n     4224   60         RTS\n.TT17\n     4225   20 7F 4A   JSR &4A7F\n     4228   AD 50 0F   LDA &0F50\n     422B   F0 22      BEQ &424F\n     422D   A5 9C      LDA &9C\n     422F   49 FF      EOR #&FF\n     4231   20 38 42   JSR &4238\n     4234   98         TYA\n     4235   AA         TAX\n     4236   A5 9D      LDA &9D\n.TJS1\n     4238   A8         TAY\n     4239   A9 00      LDA #&00\n     423B   C0 10      CPY #&10\n     423D   E9 00      SBC #&00\n     423F   C0 40      CPY #&40\n     4241   E9 00      SBC #&00\n     4243   C0 C0      CPY #&C0\n     4245   69 00      ADC #&00\n     4247   C0 E0      CPY #&E0\n     4249   69 00      ADC #&00\n     424B   A8         TAY\n     424C   A5 41      LDA &41\n     424E   60         RTS\n.TJ1\n     424F   A5 41      LDA &41\n     4251   A2 00      LDX #&00\n     4253   A0 00      LDY #&00\n     4255   C9 19      CMP #&19\n     4257   D0 01      BNE &425A\n     4259   CA         DEX\n     425A   C9 79      CMP #&79\n     425C   D0 01      BNE &425F\n     425E   E8         INX\n     425F   C9 39      CMP #&39\n     4261   D0 01      BNE &4264\n     4263   C8         INY\n     4264   C9 29      CMP #&29\n     4266   D0 01      BNE &4269\n     4268   88         DEY\n     4269   60         RTS\n.ping\n     426A   A2 01      LDX #&01\n.pl1\n     426C   BD 01 03   LDA &0301,X\n     426F   9D 31 0F   STA &0F31,X\n     4272   CA         DEX\n     4273   10 F7      BPL &426C\n     4275   60         RTS\nELITE E\nAssembled at &380F \nEnds at &4276 \nCode size is &A67 \nExecute at &1128 \nReload at &39F7 \nS.ELTE &380F  &4276  &1128  &39F7 \nSaving file '3-assembled-output/ELTE.bin'\n.KS3\n     4276   A5 1B      LDA &1B\n     4278   8D 1E 0F   STA &0F1E\n     427B   A5 1C      LDA &1C\n     427D   8D 1F 0F   STA &0F1F\n     4280   60         RTS\n.KS1\n     4281   A6 93      LDX &93\n     4283   20 DA 42   JSR &42DA\n     4286   A6 93      LDX &93\n     4288   4C 76 10   JMP &1076\n.KS4\n     428B   20 F9 43   JSR &43F9\n     428E   20 27 3B   JSR &3B27\n     4291   8D 41 0D   STA &0D41\n     4294   8D 55 0D   STA &0D55\n     4297   20 25 3D   JSR &3D25\n     429A   A9 06      LDA #&06\n     429C   85 58      STA &58\n     429E   A9 81      LDA #&81\n     42A0   4C 82 3C   JMP &3C82\n.KS2\n     42A3   A2 FF      LDX #&FF\n.KSL4\n     42A5   E8         INX\n     42A6   BD 40 0D   LDA &0D40,X\n     42A9   F0 CB      BEQ &4276\n     42AB   C9 09      CMP #&09\n     42AD   D0 F6      BNE &42A5\n     42AF   8A         TXA\n     42B0   0A         ASL A\n     42B1   A8         TAY\n     42B2   B9 48 18   LDA &1848,Y\n     42B5   85 07      STA &07\n     42B7   B9 49 18   LDA &1849,Y\n     42BA   85 08      STA &08\n     42BC   A0 20      LDY #&20\n     42BE   B1 07      LDA (&07),Y\n     42C0   10 E3      BPL &42A5\n     42C2   29 7F      AND #&7F\n     42C4   4A         LSR A\n     42C5   C5 A7      CMP &A7\n     42C7   90 DC      BCC &42A5\n     42C9   F0 09      BEQ &42D4\n     42CB   E9 01      SBC #&01\n     42CD   0A         ASL A\n     42CE   09 80      ORA #&80\n     42D0   91 07      STA (&07),Y\n     42D2   D0 D1      BNE &42A5\n.KS6\n     42D4   A9 00      LDA #&00\n     42D6   91 07      STA (&07),Y\n     42D8   F0 CB      BEQ &42A5\n.KILLSHP\n     42DA   86 A7      STX &A7\n     42DC   E4 52      CPX &52\n     42DE   D0 0A      BNE &42EA\n     42E0   A0 EE      LDY #&EE\n     42E2   20 07 3D   JSR &3D07\n     42E5   A9 C8      LDA #&C8\n     42E7   20 29 4B   JSR &4B29\n.KS5\n     42EA   A4 A7      LDY &A7\n     42EC   BE 40 0D   LDX &0D40,Y\n     42EF   E0 08      CPX #&08\n     42F1   F0 98      BEQ &428B\n     42F3   DE 4D 0D   DEC &0D4D,X\n     42F6   A6 A7      LDX &A7\n     42F8   A0 05      LDY #&05\n     42FA   B1 1E      LDA (&1E),Y\n     42FC   A0 21      LDY #&21\n     42FE   18         CLC\n     42FF   71 20      ADC (&20),Y\n     4301   85 1B      STA &1B\n     4303   C8         INY\n     4304   B1 20      LDA (&20),Y\n     4306   69 00      ADC #&00\n     4308   85 1C      STA &1C\n.KSL1\n     430A   E8         INX\n     430B   BD 40 0D   LDA &0D40,X\n     430E   9D 3F 0D   STA &0D3F,X\n     4311   F0 90      BEQ &42A3\n     4313   0A         ASL A\n     4314   A8         TAY\n     4315   B9 38 56   LDA &5638,Y\n     4318   85 07      STA &07\n     431A   B9 39 56   LDA &5639,Y\n     431D   85 08      STA &08\n     431F   A0 05      LDY #&05\n     4321   B1 07      LDA (&07),Y\n     4323   85 D1      STA &D1\n     4325   A5 1B      LDA &1B\n     4327   38         SEC\n     4328   E5 D1      SBC &D1\n     432A   85 1B      STA &1B\n     432C   A5 1C      LDA &1C\n     432E   E9 00      SBC #&00\n     4330   85 1C      STA &1C\n     4332   8A         TXA\n     4333   0A         ASL A\n     4334   A8         TAY\n     4335   B9 48 18   LDA &1848,Y\n     4338   85 07      STA &07\n     433A   B9 49 18   LDA &1849,Y\n     433D   85 08      STA &08\n     433F   A0 23      LDY #&23\n     4341   B1 07      LDA (&07),Y\n     4343   91 20      STA (&20),Y\n     4345   88         DEY\n     4346   B1 07      LDA (&07),Y\n     4348   85 3E      STA &3E\n     434A   A5 1C      LDA &1C\n     434C   91 20      STA (&20),Y\n     434E   88         DEY\n     434F   B1 07      LDA (&07),Y\n     4351   85 3D      STA &3D\n     4353   A5 1B      LDA &1B\n     4355   91 20      STA (&20),Y\n     4357   88         DEY\n.KSL2\n     4358   B1 07      LDA (&07),Y\n     435A   91 20      STA (&20),Y\n     435C   88         DEY\n     435D   10 F9      BPL &4358\n     435F   A5 07      LDA &07\n     4361   85 20      STA &20\n     4363   A5 08      LDA &08\n     4365   85 21      STA &21\n     4367   A4 D1      LDY &D1\n.KSL3\n     4369   88         DEY\n     436A   B1 3D      LDA (&3D),Y\n     436C   91 1B      STA (&1B),Y\n     436E   98         TYA\n     436F   D0 F8      BNE &4369\n     4371   F0 97      BEQ &430A\n.SFX\n     4373   12\n     4374   01\n     4375   00\n     4376   10\n     4377   12\n     4378   02\n     4379   2C\n     437A   08\n     437B   11\n     437C   03\n     437D   F0\n     437E   18\n     437F   10\n     4380   F1\n     4381   07\n     4382   1A\n     4383   03\n     4384   F1\n     4385   BC\n     4386   01\n     4387   13\n     4388   F4\n     4389   0C\n     438A   08\n     438B   10\n     438C   F1\n     438D   06\n     438E   0C\n     438F   10\n     4390   02\n     4391   60\n     4392   10\n     4393   13\n     4394   04\n     4395   C2\n     4396   FF\n     4397   13\n     4398   00\n     4399   00\n     439A   00\n.RESET\n     439B   20 23 48   JSR &4823\n     439E   A2 06      LDX #&06\n.SAL3\n     43A0   95 2A      STA &2A,X\n     43A2   CA         DEX\n     43A3   10 FB      BPL &43A0\n     43A5   86 9F      STX &9F\n.RES4\n     43A7   A9 FF      LDA #&FF\n     43A9   A2 02      LDX #&02\n.REL5\n     43AB   9D 11 0F   STA &0F11,X\n     43AE   CA         DEX\n     43AF   10 FA      BPL &43AB\n.RES2\n     43B1   A9 12      LDA #&12\n     43B3   8D 33 0F   STA &0F33\n     43B6   A2 FF      LDX #&FF\n     43B8   8E 26 0E   STX &0E26\n     43BB   8E 74 0E   STX &0E74\n     43BE   86 52      STX &52\n     43C0   A9 80      LDA #&80\n     43C2   85 9D      STA &9D\n     43C4   85 88      STA &88\n     43C6   85 8A      STA &8A\n     43C8   0A         ASL A\n     43C9   85 89      STA &89\n     43CB   85 8B      STA &8B\n     43CD   85 99      STA &99\n     43CF   A9 03      LDA #&03\n     43D1   85 8C      STA &8C\n     43D3   85 9E      STA &9E\n     43D5   85 87      STA &87\n     43D7   AD 55 0D   LDA &0D55\n     43DA   F0 03      BEQ &43DF\n     43DC   20 25 3D   JSR &3D25\n     43DF   A5 30      LDA &30\n     43E1   F0 03      BEQ &43E6\n     43E3   20 7E 49   JSR &497E\n.yu\n     43E6   20 F5 3A   JSR &3AF5\n     43E9   20 23 48   JSR &4823\n     43EC   A9 3F      LDA #&3F\n     43EE   8D 1E 0F   STA &0F1E\n     43F1   A9 0D      LDA #&0D\n     43F3   8D 1F 0F   STA &0F1F\n     43F6   20 F8 1F   JSR &1FF8\n.ZINF\n     43F9   A0 23      LDY #&23\n     43FB   A9 00      LDA #&00\n.ZI1\n     43FD   99 53 00   STA &0053,Y\n     4400   88         DEY\n     4401   10 FA      BPL &43FD\n     4403   A9 60      LDA #&60\n     4405   85 65      STA &65\n     4407   85 69      STA &69\n     4409   09 80      ORA #&80\n     440B   85 61      STA &61\n     440D   60         RTS\n.msblob\n     440E   A2 04      LDX #&04\n.ss\n     4410   EC 33 03   CPX &0333\n     4413   F0 09      BEQ &441E\n     4415   A0 00      LDY #&00\n     4417   20 41 3D   JSR &3D41\n     441A   CA         DEX\n     441B   D0 F3      BNE &4410\n     441D   60         RTS\n.SAL8\n     441E   A0 EE      LDY #&EE\n     4420   20 41 3D   JSR &3D41\n     4423   CA         DEX\n     4424   D0 F8      BNE &441E\n     4426   60         RTS\n.me2\n     4427   AD 10 0F   LDA &0F10\n     442A   20 29 4B   JSR &4B29\n     442D   A9 00      LDA #&00\n     442F   8D 64 0D   STA &0D64\n     4432   4C 8A 44   JMP &448A\n.Ze\n     4435   20 F9 43   JSR &43F9\n     4438   20 57 44   JSR &4457\n     443B   85 06      STA &06\n     443D   29 80      AND #&80\n     443F   85 55      STA &55\n     4441   8A         TXA\n     4442   29 80      AND #&80\n     4444   85 58      STA &58\n     4446   A9 20      LDA #&20\n     4448   85 54      STA &54\n     444A   85 57      STA &57\n     444C   85 5A      STA &5A\n     444E   8A         TXA\n     444F   C9 F5      CMP #&F5\n     4451   2A         ROL A\n     4452   09 C0      ORA #&C0\n     4454   85 73      STA &73\n.DORND2\n     4456   18         CLC\n.DORND\n     4457   A5 00      LDA &00\n     4459   2A         ROL A\n     445A   AA         TAX\n     445B   65 02      ADC &02\n     445D   85 00      STA &00\n     445F   86 02      STX &02\n     4461   A5 01      LDA &01\n     4463   AA         TAX\n     4464   65 03      ADC &03\n     4466   85 01      STA &01\n     4468   86 03      STX &03\n     446A   60         RTS\n.MTT4\n     446B   4A         LSR A\n     446C   85 73      STA &73\n     446E   85 70      STA &70\n     4470   26 72      ROL &72\n     4472   29 1F      AND #&1F\n     4474   09 10      ORA #&10\n     4476   85 6E      STA &6E\n     4478   A9 07      LDA #&07\n     447A   20 82 3C   JSR &3C82\n.TT100\n     447D   20 51 0F   JSR &0F51\n     4480   CE 64 0D   DEC &0D64\n     4483   F0 A2      BEQ &4427\n     4485   10 03      BPL &448A\n     4487   EE 64 0D   INC &0D64\n.me3\n     448A   C6 99      DEC &99\n     448C   F0 03      BEQ &4491\n.ytq\n     448E   4C 60 45   JMP &4560\n     4491   AD 5C 0D   LDA &0D5C\n     4494   D0 F8      BNE &448E\n     4496   20 57 44   JSR &4457\n     4499   C9 23      CMP #&23\n     449B   B0 4D      BCS &44EA\n     449D   AD 57 0D   LDA &0D57\n     44A0   C9 03      CMP #&03\n     44A2   B0 46      BCS &44EA\n     44A4   20 F9 43   JSR &43F9\n     44A7   A9 26      LDA #&26\n     44A9   85 5A      STA &5A\n     44AB   20 57 44   JSR &4457\n     44AE   85 53      STA &53\n     44B0   86 56      STX &56\n     44B2   29 80      AND #&80\n     44B4   85 55      STA &55\n     44B6   8A         TXA\n     44B7   29 80      AND #&80\n     44B9   85 58      STA &58\n     44BB   26 54      ROL &54\n     44BD   26 54      ROL &54\n     44BF   20 57 44   JSR &4457\n     44C2   70 A7      BVS &446B\n     44C4   09 6F      ORA #&6F\n     44C6   85 70      STA &70\n     44C8   AD 55 0D   LDA &0D55\n     44CB   D0 1D      BNE &44EA\n     44CD   8A         TXA\n     44CE   B0 08      BCS &44D8\n     44D0   29 1F      AND #&1F\n     44D2   09 10      ORA #&10\n     44D4   85 6E      STA &6E\n     44D6   90 04      BCC &44DC\n.MTT2\n     44D8   09 7F      ORA #&7F\n     44DA   85 71      STA &71\n.MTT3\n     44DC   20 57 44   JSR &4457\n     44DF   C9 05      CMP #&05\n     44E1   A9 0A      LDA #&0A\n     44E3   B0 02      BCS &44E7\n     44E5   A9 0B      LDA #&0B\n     44E7   20 82 3C   JSR &3C82\n.MTT1\n     44EA   AD 55 0D   LDA &0D55\n     44ED   D0 71      BNE &4560\n     44EF   20 5F 46   JSR &465F\n     44F2   0A         ASL A\n     44F3   AE 4F 0D   LDX &0D4F\n     44F6   F0 03      BEQ &44FB\n     44F8   0D 34 03   ORA &0334\n     44FB   85 D1      STA &D1\n     44FD   20 35 44   JSR &4435\n     4500   C5 D1      CMP &D1\n     4502   B0 05      BCS &4509\n     4504   A9 02      LDA #&02\n     4506   20 82 3C   JSR &3C82\n     4509   AD 4F 0D   LDA &0D4F\n     450C   D0 52      BNE &4560\n     450E   CE 63 0D   DEC &0D63\n     4511   10 4D      BPL &4560\n     4513   EE 63 0D   INC &0D63\n     4516   20 57 44   JSR &4457\n     4519   AC 1C 0F   LDY &0F1C\n     451C   F0 0B      BEQ &4529\n     451E   C9 5A      CMP #&5A\n     4520   B0 3E      BCS &4560\n     4522   29 07      AND #&07\n     4524   CD 1C 0F   CMP &0F1C\n     4527   90 37      BCC &4560\n.LABEL_2\n     4529   20 35 44   JSR &4435\n     452C   C9 C8      CMP #&C8\n     452E   B0 1B      BCS &454B\n     4530   EE 63 0D   INC &0D63\n     4533   29 03      AND #&03\n     4535   69 03      ADC #&03\n     4537   A8         TAY\n     4538   8A         TXA\n     4539   C9 C8      CMP #&C8\n     453B   2A         ROL A\n     453C   09 C0      ORA #&C0\n     453E   C0 06      CPY #&06\n     4540   F0 4B      BEQ &458D\n     4542   85 73      STA &73\n     4544   98         TYA\n     4545   20 82 3C   JSR &3C82\n.mj1\n     4548   4C 60 45   JMP &4560\n.mt1\n     454B   29 03      AND #&03\n     454D   8D 63 0D   STA &0D63\n     4550   85 98      STA &98\n.mt3\n     4552   20 57 44   JSR &4457\n     4555   29 03      AND #&03\n     4557   09 01      ORA #&01\n     4559   20 82 3C   JSR &3C82\n     455C   C6 98      DEC &98\n     455E   10 F2      BPL &4552\n.MLOOP\n     4560   A9 01      LDA #&01\n     4562   8D 4E FE   STA &FE4E\n     4565   A2 FF      LDX #&FF\n     4567   9A         TXS\n     4568   AE 61 0D   LDX &0D61\n     456B   F0 03      BEQ &4570\n     456D   CE 61 0D   DEC &0D61\n.EE20\n     4570   20 F8 1F   JSR &1FF8\n     4573   A5 96      LDA &96\n     4575   F0 09      BEQ &4580\n     4577   2D 4C 0F   AND &0F4C\n     457A   4A         LSR A\n     457B   B0 03      BCS &4580\n     457D   20 E1 2B   JSR &2BE1\n     4580   20 25 42   JSR &4225\n.FRCE\n     4583   20 9A 45   JSR &459A\n     4586   A5 9F      LDA &9F\n     4588   D0 D6      BNE &4560\n     458A   4C 7D 44   JMP &447D\n.tha\n     458D   20 57 44   JSR &4457\n     4590   C9 C8      CMP #&C8\n     4592   90 03      BCC &4597\n     4594   20 3D 35   JSR &353D\n     4597   4C 60 45   JMP &4560\n.TT102\n     459A   C9 76      CMP #&76\n     459C   D0 03      BNE &45A1\n     459E   4C F8 1D   JMP &1DF8\n     45A1   C9 14      CMP #&14\n     45A3   D0 03      BNE &45A8\n     45A5   4C C0 2E   JMP &2EC0\n     45A8   C9 74      CMP #&74\n     45AA   D0 03      BNE &45AF\n     45AC   4C EF 31   JMP &31EF\n     45AF   C9 75      CMP #&75\n     45B1   D0 06      BNE &45B9\n     45B3   20 A4 32   JSR &32A4\n     45B6   4C 4A 2D   JMP &2D4A\n.TT92\n     45B9   C9 77      CMP #&77\n     45BB   D0 03      BNE &45C0\n     45BD   4C 24 31   JMP &3124\n     45C0   C9 16      CMP #&16\n     45C2   D0 03      BNE &45C7\n     45C4   4C 8E 34   JMP &348E\n     45C7   C9 20      CMP #&20\n     45C9   D0 03      BNE &45CE\n     45CB   4C BA 35   JMP &35BA\n.fvw\n     45CE   24 9F      BIT &9F\n     45D0   10 1C      BPL &45EE\n     45D2   C9 73      CMP #&73\n     45D4   D0 03      BNE &45D9\n     45D6   4C 49 36   JMP &3649\n     45D9   C9 71      CMP #&71\n     45DB   D0 03      BNE &45E0\n     45DD   4C B3 2F   JMP &2FB3\n     45E0   C9 47      CMP #&47\n     45E2   D0 03      BNE &45E7\n     45E4   4C 3B 48   JMP &483B\n     45E7   C9 72      CMP #&72\n     45E9   D0 11      BNE &45FC\n     45EB   4C 95 30   JMP &3095\n.INSP\n     45EE   C9 71      CMP #&71\n     45F0   90 0A      BCC &45FC\n     45F2   C9 74      CMP #&74\n     45F4   B0 06      BCS &45FC\n     45F6   29 03      AND #&03\n     45F8   AA         TAX\n     45F9   4C 44 2B   JMP &2B44\n.LABEL_3\n     45FC   C9 54      CMP #&54\n     45FE   D0 03      BNE &4603\n     4600   4C 4A 33   JMP &334A\n     4603   C9 32      CMP #&32\n     4605   F0 3D      BEQ &4644\n     4607   85 06      STA &06\n     4609   A5 96      LDA &96\n     460B   29 C0      AND #&C0\n     460D   F0 16      BEQ &4625\n     460F   A5 2F      LDA &2F\n     4611   D0 12      BNE &4625\n     4613   A5 06      LDA &06\n     4615   C9 36      CMP #&36\n     4617   D0 09      BNE &4622\n     4619   20 94 31   JSR &3194\n     461C   20 6A 42   JSR &426A\n     461F   20 94 31   JSR &3194\n.ee2\n     4622   20 67 31   JSR &3167\n.TT107\n     4625   A5 2F      LDA &2F\n     4627   F0 1A      BEQ &4643\n     4629   C6 2E      DEC &2E\n     462B   D0 16      BNE &4643\n     462D   A6 2F      LDX &2F\n     462F   CA         DEX\n     4630   20 E0 33   JSR &33E0\n     4633   A9 05      LDA #&05\n     4635   85 2E      STA &2E\n     4637   A6 2F      LDX &2F\n     4639   20 E0 33   JSR &33E0\n     463C   C6 2F      DEC &2F\n     463E   D0 03      BNE &4643\n     4640   4C 7C 35   JMP &357C\n.t95\n     4643   60         RTS\n.T95\n     4644   A5 96      LDA &96\n     4646   29 C0      AND #&C0\n     4648   F0 F9      BEQ &4643\n     464A   20 ED 2B   JSR &2BED\n     464D   85 7E      STA &7E\n     464F   20 21 38   JSR &3821\n     4652   A9 80      LDA #&80\n     4654   85 7E      STA &7E\n     4656   A9 01      LDA #&01\n     4658   85 2C      STA &2C\n     465A   E6 2D      INC &2D\n     465C   4C 12 2D   JMP &2D12\n.BAD\n     465F   AD 1A 03   LDA &031A\n     4662   18         CLC\n     4663   6D 1D 03   ADC &031D\n     4666   0A         ASL A\n     4667   6D 21 03   ADC &0321\n     466A   60         RTS\n.FAROF\n     466B   A9 E0      LDA #&E0\n.FAROF2\n     466D   C5 54      CMP &54\n     466F   90 06      BCC &4677\n     4671   C5 57      CMP &57\n     4673   90 02      BCC &4677\n     4675   C5 5A      CMP &5A\n.MA34\n     4677   60         RTS\n.MAS4\n     4678   05 54      ORA &54\n     467A   05 57      ORA &57\n     467C   05 5A      ORA &5A\n     467E   60         RTS\n.DEATH\n     467F   20 8C 49   JSR &498C\n     4682   20 B1 43   JSR &43B1\n     4685   06 8C      ASL &8C\n     4687   06 8C      ASL &8C\n     4689   A2 18      LDX #&18\n     468B   20 36 3B   JSR &3B36\n     468E   20 7B 2B   JSR &2B7B\n     4691   20 9C 2B   JSR &2B9C\n     4694   20 D2 3A   JSR &3AD2\n     4697   A9 0C      LDA #&0C\n     4699   85 2D      STA &2D\n     469B   85 2C      STA &2C\n     469D   A9 92      LDA #&92\n     469F   20 49 39   JSR &3949\n.D1\n     46A2   20 35 44   JSR &4435\n     46A5   4A         LSR A\n     46A6   4A         LSR A\n     46A7   85 53      STA &53\n     46A9   A0 00      LDY #&00\n     46AB   84 96      STY &96\n     46AD   84 54      STY &54\n     46AF   84 57      STY &57\n     46B1   84 5A      STY &5A\n     46B3   84 73      STY &73\n     46B5   88         DEY\n     46B6   84 99      STY &99\n     46B8   8C 60 0D   STY &0D60\n     46BB   49 2A      EOR #&2A\n     46BD   85 56      STA &56\n     46BF   09 50      ORA #&50\n     46C1   85 59      STA &59\n     46C3   8A         TXA\n     46C4   29 8F      AND #&8F\n     46C6   85 70      STA &70\n     46C8   6A         ROR A\n     46C9   29 87      AND #&87\n     46CB   85 71      STA &71\n     46CD   08         PHP\n     46CE   A2 0B      LDX #&0B\n     46D0   20 7B 24   JSR &247B\n     46D3   28         PLP\n     46D4   A9 00      LDA #&00\n     46D6   6A         ROR A\n     46D7   A0 1F      LDY #&1F\n     46D9   91 20      STA (&20),Y\n     46DB   AD 43 0D   LDA &0D43\n     46DE   F0 C2      BEQ &46A2\n     46E0   20 74 4A   JSR &4A74\n     46E3   85 8C      STA &8C\n.D2\n     46E5   20 51 0F   JSR &0F51\n     46E8   AD 60 0D   LDA &0D60\n     46EB   D0 F8      BNE &46E5\n     46ED   A2 1F      LDX #&1F\n     46EF   20 36 3B   JSR &3B36\n.DEATH2\n     46F2   20 B1 43   JSR &43B1\n.TT170\n     46F5   A2 FF      LDX #&FF\n     46F7   9A         TXS\n.BR1\n     46F8   A2 03      LDX #&03\n     46FA   86 2C      STX &2C\n     46FC   20 D6 48   JSR &48D6\n     46FF   A2 07      LDX #&07\n     4701   A9 80      LDA #&80\n     4703   20 56 47   JSR &4756\n     4706   C9 44      CMP #&44\n     4708   D0 0C      BNE &4716\n     470A   20 F5 47   JSR &47F5\n     470D   20 AE 48   JSR &48AE\n     4710   20 E0 47   JSR &47E0\n     4713   20 7D 2B   JSR &2B7D\n.QU5\n     4716   A2 4B      LDX #&4B\n.QUL1\n     4718   BD FB 17   LDA &17FB,X\n     471B   9D FF 02   STA &02FF,X\n     471E   CA         DEX\n     471F   D0 F7      BNE &4718\n     4721   86 96      STX &96\n     4723   20 D2 47   JSR &47D2\n     4726   CD 47 18   CMP &1847\n     4729   D0 F8      BNE &4723\n     472B   49 A9      EOR #&A9\n     472D   AA         TAX\n     472E   AD 0E 03   LDA &030E\n     4731   EC 46 18   CPX &1846\n     4734   F0 02      BEQ &4738\n     4736   09 80      ORA #&80\n.tZ\n     4738   09 02      ORA #&02\n     473A   8D 0E 03   STA &030E\n     473D   20 0E 44   JSR &440E\n     4740   A9 93      LDA #&93\n     4742   A2 03      LDX #&03\n     4744   20 56 47   JSR &4756\n     4747   20 6A 42   JSR &426A\n     474A   20 D6 34   JSR &34D6\n.BAY\n     474D   A9 FF      LDA #&FF\n     474F   85 9F      STA &9F\n     4751   A9 76      LDA #&76\n     4753   4C 83 45   JMP &4583\n.TITLE\n     4756   48         PHA\n     4757   86 9B      STX &9B\n     4759   20 9B 43   JSR &439B\n     475C   A9 01      LDA #&01\n     475E   20 7B 2B   JSR &2B7B\n     4761   C6 96      DEC &96\n     4763   A9 60      LDA #&60\n     4765   85 61      STA &61\n     4767   85 5A      STA &5A\n     4769   A2 7F      LDX #&7F\n     476B   86 70      STX &70\n     476D   86 71      STX &71\n     476F   E8         INX\n     4770   86 7E      STX &7E\n     4772   A5 9B      LDA &9B\n     4774   20 82 3C   JSR &3C82\n     4777   A0 06      LDY #&06\n     4779   84 2C      STY &2C\n     477B   20 E6 2B   JSR &2BE6\n     477E   A9 1E      LDA #&1E\n     4780   20 AB 38   JSR &38AB\n     4783   A0 06      LDY #&06\n     4785   84 2C      STY &2C\n     4787   E6 2D      INC &2D\n     4789   AD 4C 0F   LDA &0F4C\n     478C   F0 05      BEQ &4793\n     478E   A9 FE      LDA #&FE\n     4790   20 B6 38   JSR &38B6\n.awe\n     4793   20 FA 2B   JSR &2BFA\n     4796   84 8C      STY &8C\n     4798   8C 50 0F   STY &0F50\n     479B   68         PLA\n     479C   20 49 39   JSR &3949\n     479F   A9 94      LDA #&94\n     47A1   A2 07      LDX #&07\n     47A3   86 2C      STX &2C\n     47A5   20 49 39   JSR &3949\n.TLL2\n     47A8   A5 5A      LDA &5A\n     47AA   C9 01      CMP #&01\n     47AC   F0 02      BEQ &47B0\n     47AE   C6 5A      DEC &5A\n.TL1\n     47B0   20 A9 13   JSR &13A9\n     47B3   A9 80      LDA #&80\n     47B5   85 59      STA &59\n     47B7   0A         ASL A\n     47B8   85 53      STA &53\n     47BA   85 56      STA &56\n     47BC   20 2F 4E   JSR &4E2F\n     47BF   C6 99      DEC &99\n     47C1   AD 40 FE   LDA &FE40\n     47C4   29 10      AND #&10\n     47C6   F0 06      BEQ &47CE\n     47C8   20 6F 49   JSR &496F\n     47CB   F0 DB      BEQ &47A8\n     47CD   60         RTS\n.TL2\n     47CE   CE 50 0F   DEC &0F50\n     47D1   60         RTS\n.CHECK\n     47D2   A2 49      LDX #&49\n     47D4   18         CLC\n     47D5   8A         TXA\n.QUL2\n     47D6   7D FB 17   ADC &17FB,X\n     47D9   5D FC 17   EOR &17FC,X\n     47DC   CA         DEX\n     47DD   D0 F7      BNE &47D6\n     47DF   60         RTS\n.TRNME\n     47E0   A2 07      LDX #&07\n.GTL1\n     47E2   B5 53      LDA &53,X\n     47E4   9D F4 17   STA &17F4,X\n     47E7   CA         DEX\n     47E8   10 F8      BPL &47E2\n.TR1\n     47EA   A2 07      LDX #&07\n.GTL2\n     47EC   BD F4 17   LDA &17F4,X\n     47EF   95 53      STA &53,X\n     47F1   CA         DEX\n     47F2   10 F8      BPL &47EC\n     47F4   60         RTS\n.GTNME\n     47F5   A9 01      LDA #&01\n     47F7   20 7B 2B   JSR &2B7B\n     47FA   A9 7B      LDA #&7B\n     47FC   20 B6 38   JSR &38B6\n     47FF   20 E4 2B   JSR &2BE4\n     4802   A9 81      LDA #&81\n     4804   8D 4E FE   STA &FE4E\n     4807   A9 0F      LDA #&0F\n     4809   AA         TAX\n     480A   20 F4 FF   JSR &FFF4\n     480D   A2 1E      LDX #&1E\n     480F   A0 48      LDY #&48\n     4811   A9 00      LDA #&00\n     4813   20 F1 FF   JSR &FFF1\n     4816   B0 D2      BCS &47EA\n     4818   98         TYA\n     4819   F0 CF      BEQ &47EA\n     481B   4C 37 2D   JMP &2D37\n.RLINE\n     481E   53 00\n     4820   07\n     4821   21\n     4822   7A\n.ZERO\n     4823   A2 0D      LDX #&0D\n.ZEL\n     4825   20 2D 48   JSR &482D\n     4828   CA         DEX\n     4829   E0 09      CPX #&09\n     482B   D0 F8      BNE &4825\n.ZES1\n     482D   A0 00      LDY #&00\n     482F   84 07      STY &07\n.ZES2\n     4831   A9 00      LDA #&00\n     4833   86 08      STX &08\n.ZEL1\n     4835   91 07      STA (&07),Y\n     4837   C8         INY\n     4838   D0 FB      BNE &4835\n     483A   60         RTS\n.SVE\n     483B   20 F5 47   JSR &47F5\n     483E   20 E0 47   JSR &47E0\n     4841   20 23 48   JSR &4823\n     4844   4E 49 03   LSR &0349\n     4847   A2 4B      LDX #&4B\n.SVL1\n     4849   BD 00 03   LDA &0300,X\n     484C   9D 00 0B   STA &0B00,X\n     484F   9D FC 17   STA &17FC,X\n     4852   CA         DEX\n     4853   10 F4      BPL &4849\n     4855   20 D2 47   JSR &47D2\n     4858   8D 47 18   STA &1847\n     485B   48         PHA\n     485C   09 80      ORA #&80\n     485E   85 3D      STA &3D\n     4860   4D 0E 03   EOR &030E\n     4863   85 3F      STA &3F\n     4865   4D 0B 03   EOR &030B\n     4868   85 3E      STA &3E\n     486A   49 5A      EOR #&5A\n     486C   4D 48 03   EOR &0348\n     486F   85 40      STA &40\n     4871   20 CD 1E   JSR &1ECD\n     4874   20 37 2D   JSR &2D37\n     4877   20 37 2D   JSR &2D37\n     487A   68         PLA\n     487B   8D 4B 0B   STA &0B4B\n     487E   49 A9      EOR #&A9\n     4880   8D 46 18   STA &1846\n     4883   8D 4A 0B   STA &0B4A\n     4886   A0 0B      LDY #&0B\n     4888   8C 0B 0C   STY &0C0B\n     488B   C8         INY\n     488C   8C 0F 0C   STY &0C0F\n     488F   A9 81      LDA #&81\n     4891   8D 4E FE   STA &FE4E\n     4894   EE FD 7F   INC &7FFD\n     4897   A9 00      LDA #&00\n     4899   20 A4 48   JSR &48A4\n     489C   A2 00      LDX #&00\n     489E   8E FD 7F   STX &7FFD\n     48A1   4C 4D 47   JMP &474D\n.QUS1\n     48A4   A2 53      LDX #&53\n     48A6   8E 00 0C   STX &0C00\n     48A9   A2 00      LDX #&00\n     48AB   4C DD FF   JMP &FFDD\n.LOD\n     48AE   A2 02      LDX #&02\n     48B0   20 D6 48   JSR &48D6\n     48B3   20 23 48   JSR &4823\n     48B6   A0 0B      LDY #&0B\n     48B8   8C 03 0C   STY &0C03\n     48BB   EE 0B 0C   INC &0C0B\n     48BE   C8         INY\n     48BF   A9 FF      LDA #&FF\n     48C1   20 A4 48   JSR &48A4\n     48C4   AD 00 0B   LDA &0B00\n     48C7   30 16      BMI &48DF\n     48C9   A2 4B      LDX #&4B\n.LOL1\n     48CB   BD 00 0B   LDA &0B00,X\n     48CE   9D FC 17   STA &17FC,X\n     48D1   CA         DEX\n     48D2   10 F7      BPL &48CB\n     48D4   A2 03      LDX #&03\n.FX200\n     48D6   A0 00      LDY #&00\n     48D8   A9 C8      LDA #&C8\n     48DA   4C F4 FF   JMP &FFF4\n     48DD   60         RTS\n.SPS1\n     48DE   A2 00      LDX #&00\n     48E0   20 3C 3C   JSR &3C3C\n     48E3   A2 03      LDX #&03\n     48E5   20 3C 3C   JSR &3C3C\n     48E8   A2 06      LDX #&06\n     48EA   20 3C 3C   JSR &3C3C\n.TAS2\n     48ED   A5 D2      LDA &D2\n     48EF   05 D5      ORA &D5\n     48F1   05 D8      ORA &D8\n     48F3   09 01      ORA #&01\n     48F5   85 DB      STA &DB\n     48F7   A5 D3      LDA &D3\n     48F9   05 D6      ORA &D6\n     48FB   05 D9      ORA &D9\n.TAL2\n     48FD   06 DB      ASL &DB\n     48FF   2A         ROL A\n     4900   B0 0E      BCS &4910\n     4902   06 D2      ASL &D2\n     4904   26 D3      ROL &D3\n     4906   06 D5      ASL &D5\n     4908   26 D6      ROL &D6\n     490A   06 D8      ASL &D8\n     490C   26 D9      ROL &D9\n     490E   90 ED      BCC &48FD\n.TA2\n     4910   A5 D3      LDA &D3\n     4912   4A         LSR A\n     4913   05 D4      ORA &D4\n     4915   85 31      STA &31\n     4917   A5 D6      LDA &D6\n     4919   4A         LSR A\n     491A   05 D7      ORA &D7\n     491C   85 32      STA &32\n     491E   A5 D9      LDA &D9\n     4920   4A         LSR A\n     4921   05 DA      ORA &DA\n     4923   85 33      STA &33\n.NORM\n     4925   A5 31      LDA &31\n     4927   20 6D 27   JSR &276D\n     492A   85 91      STA &91\n     492C   A5 1B      LDA &1B\n     492E   85 90      STA &90\n     4930   A5 32      LDA &32\n     4932   20 6D 27   JSR &276D\n     4935   85 D1      STA &D1\n     4937   A5 1B      LDA &1B\n     4939   65 90      ADC &90\n     493B   85 90      STA &90\n     493D   A5 D1      LDA &D1\n     493F   65 91      ADC &91\n     4941   85 91      STA &91\n     4943   A5 33      LDA &33\n     4945   20 6D 27   JSR &276D\n     4948   85 D1      STA &D1\n     494A   A5 1B      LDA &1B\n     494C   65 90      ADC &90\n     494E   85 90      STA &90\n     4950   A5 D1      LDA &D1\n     4952   65 91      ADC &91\n     4954   85 91      STA &91\n     4956   20 5B 4D   JSR &4D5B\n     4959   A5 31      LDA &31\n     495B   20 A2 4C   JSR &4CA2\n     495E   85 31      STA &31\n     4960   A5 32      LDA &32\n     4962   20 A2 4C   JSR &4CA2\n     4965   85 32      STA &32\n     4967   A5 33      LDA &33\n     4969   20 A2 4C   JSR &4CA2\n     496C   85 33      STA &33\n.NO1\n     496E   60         RTS\n.RDKEY\n     496F   A2 10      LDX #&10\n.Rd1\n     4971   20 11 4A   JSR &4A11\n     4974   30 04      BMI &497A\n     4976   E8         INX\n     4977   10 F8      BPL &4971\n     4979   8A         TXA\n.Rd2\n     497A   49 80      EOR #&80\n     497C   AA         TAX\n     497D   60         RTS\n.ECMOF\n     497E   A9 00      LDA #&00\n     4980   85 30      STA &30\n     4982   8D 5B 0D   STA &0D5B\n     4985   20 1D 3D   JSR &3D1D\n     4988   A9 48      LDA #&48\n     498A   D0 41      BNE &49CD\n.EXNO3\n     498C   A9 10      LDA #&10\n     498E   20 CD 49   JSR &49CD\n     4991   A9 18      LDA #&18\n     4993   D0 38      BNE &49CD\n.SFRMIS\n     4995   A2 09      LDX #&09\n     4997   20 DE 24   JSR &24DE\n     499A   90 D2      BCC &496E\n     499C   A9 78      LDA #&78\n     499E   20 29 4B   JSR &4B29\n     49A1   A9 30      LDA #&30\n     49A3   D0 28      BNE &49CD\n.EXNO2\n     49A5   EE 47 03   INC &0347\n     49A8   D0 08      BNE &49B2\n     49AA   EE 48 03   INC &0348\n     49AD   A9 65      LDA #&65\n     49AF   20 29 4B   JSR &4B29\n     49B2   A2 07      LDX #&07\n.EXNO\n     49B4   86 D1      STX &D1\n     49B6   A9 18      LDA #&18\n     49B8   20 DE 49   JSR &49DE\n     49BB   A5 5A      LDA &5A\n     49BD   4A         LSR A\n     49BE   4A         LSR A\n     49BF   25 D1      AND &D1\n     49C1   09 F1      ORA #&F1\n     49C3   85 0B      STA &0B\n     49C5   20 D0 49   JSR &49D0\n     49C8   A9 10      LDA #&10\n     49CA   2C\n.BEEP\n     49CB   A9 20      LDA #&20\n.NOISE\n     49CD   20 DE 49   JSR &49DE\n.NO3\n     49D0   AE 49 0F   LDX &0F49\n     49D3   D0 99      BNE &496E\n     49D5   A2 09      LDX #&09\n     49D7   A0 00      LDY #&00\n     49D9   A9 07      LDA #&07\n     49DB   4C F1 FF   JMP &FFF1\n.NOS1\n     49DE   4A         LSR A\n     49DF   69 03      ADC #&03\n     49E1   A8         TAY\n     49E2   A2 07      LDX #&07\n.NOL1\n     49E4   A9 00      LDA #&00\n     49E6   95 09      STA &09,X\n     49E8   CA         DEX\n     49E9   B9 73 43   LDA &4373,Y\n     49EC   95 09      STA &09,X\n     49EE   88         DEY\n     49EF   CA         DEX\n     49F0   10 F2      BPL &49E4\n.KYTB\n     49F2   60         RTS\n     49F3   E8\n     49F4   E2\n     49F5   E6\n     49F6   E7\n     49F7   C2\n     49F8   D1\n     49F9   C1\n     49FA   60\n     49FB   70\n     49FC   23\n     49FD   35\n     49FE   65\n     49FF   22\n     4A00   45\n     4A01   52\n.DKS1\n     4A02   BE F2 49   LDX &49F2,Y\n     4A05   20 11 4A   JSR &4A11\n     4A08   10 1F      BPL &4A29\n     4A0A   A2 FF      LDX #&FF\n     4A0C   96 41      STX &41,Y\n     4A0E   60         RTS\n.CTRL\n     4A0F   A2 01      LDX #&01\n.DKS4\n     4A11   A9 03      LDA #&03\n     4A13   78         SEI\n     4A14   8D 40 FE   STA &FE40\n     4A17   A9 7F      LDA #&7F\n     4A19   8D 43 FE   STA &FE43\n     4A1C   8E 4F FE   STX &FE4F\n     4A1F   AE 4F FE   LDX &FE4F\n     4A22   A9 0B      LDA #&0B\n     4A24   8D 40 FE   STA &FE40\n     4A27   58         CLI\n     4A28   8A         TXA\n     4A29   60         RTS\n.DKS2\n     4A2A   A9 80      LDA #&80\n     4A2C   20 F4 FF   JSR &FFF4\n     4A2F   98         TYA\n     4A30   4D 4F 0F   EOR &0F4F\n     4A33   60         RTS\n.DKS3\n     4A34   84 D1      STY &D1\n     4A36   E4 D1      CPX &D1\n     4A38   D0 10      BNE &4A4A\n     4A3A   BD 0A 0F   LDA &0F0A,X\n     4A3D   49 FF      EOR #&FF\n     4A3F   9D 0A 0F   STA &0F0A,X\n     4A42   20 7F 1F   JSR &1F7F\n     4A45   20 E6 2B   JSR &2BE6\n     4A48   A4 D1      LDY &D1\n.Dk3\n     4A4A   60         RTS\n.DKJ1\n     4A4B   A0 01      LDY #&01\n     4A4D   20 02 4A   JSR &4A02\n     4A50   C8         INY\n     4A51   20 02 4A   JSR &4A02\n     4A54   AD 40 FE   LDA &FE40\n     4A57   AA         TAX\n     4A58   29 10      AND #&10\n     4A5A   49 10      EOR #&10\n     4A5C   85 48      STA &48\n     4A5E   A2 01      LDX #&01\n     4A60   20 2A 4A   JSR &4A2A\n     4A63   09 01      ORA #&01\n     4A65   85 9C      STA &9C\n     4A67   A2 02      LDX #&02\n     4A69   20 2A 4A   JSR &4A2A\n     4A6C   4D 4E 0F   EOR &0F4E\n     4A6F   85 9D      STA &9D\n     4A71   4C B6 4A   JMP &4AB6\n.U%\n     4A74   A9 00      LDA #&00\n     4A76   A0 0F      LDY #&0F\n.DKL3\n     4A78   99 41 00   STA &0041,Y\n     4A7B   88         DEY\n     4A7C   D0 FA      BNE &4A78\n     4A7E   60         RTS\n.DOKEY\n     4A7F   20 74 4A   JSR &4A74\n     4A82   AD 50 0F   LDA &0F50\n     4A85   D0 C4      BNE &4A4B\n     4A87   A0 07      LDY #&07\n.DKL2\n     4A89   20 02 4A   JSR &4A02\n     4A8C   88         DEY\n     4A8D   D0 FA      BNE &4A89\n     4A8F   A6 9C      LDX &9C\n     4A91   A9 07      LDA #&07\n     4A93   A4 44      LDY &44\n     4A95   F0 03      BEQ &4A9A\n     4A97   20 71 29   JSR &2971\n     4A9A   A4 45      LDY &45\n     4A9C   F0 03      BEQ &4AA1\n     4A9E   20 81 29   JSR &2981\n     4AA1   86 9C      STX &9C\n     4AA3   0A         ASL A\n     4AA4   A6 9D      LDX &9D\n     4AA6   A4 46      LDY &46\n     4AA8   F0 03      BEQ &4AAD\n     4AAA   20 81 29   JSR &2981\n     4AAD   A4 47      LDY &47\n     4AAF   F0 03      BEQ &4AB4\n     4AB1   20 71 29   JSR &2971\n     4AB4   86 9D      STX &9D\n.DK4\n     4AB6   20 6F 49   JSR &496F\n     4AB9   86 41      STX &41\n     4ABB   E0 69      CPX #&69\n     4ABD   D0 2B      BNE &4AEA\n.FREEZE\n     4ABF   20 BF 2C   JSR &2CBF\n     4AC2   20 6F 49   JSR &496F\n     4AC5   E0 51      CPX #&51\n     4AC7   D0 05      BNE &4ACE\n     4AC9   A9 00      LDA #&00\n     4ACB   8D 49 0F   STA &0F49\n.DK6\n     4ACE   A0 40      LDY #&40\n.DKL4\n     4AD0   20 34 4A   JSR &4A34\n     4AD3   C8         INY\n     4AD4   C0 47      CPY #&47\n     4AD6   D0 F8      BNE &4AD0\n.DK55\n     4AD8   E0 10      CPX #&10\n     4ADA   D0 03      BNE &4ADF\n     4ADC   8E 49 0F   STX &0F49\n.DK7\n     4ADF   E0 70      CPX #&70\n     4AE1   D0 03      BNE &4AE6\n     4AE3   4C F2 46   JMP &46F2\n     4AE6   E0 59      CPX #&59\n     4AE8   D0 D5      BNE &4ABF\n.DK2\n     4AEA   A5 96      LDA &96\n     4AEC   D0 13      BNE &4B01\n     4AEE   A0 0F      LDY #&0F\n     4AF0   A9 FF      LDA #&FF\n.DKL1\n     4AF2   BE F2 49   LDX &49F2,Y\n     4AF5   E4 41      CPX &41\n     4AF7   D0 03      BNE &4AFC\n     4AF9   99 41 00   STA &0041,Y\n.DK1\n     4AFC   88         DEY\n     4AFD   C0 07      CPY #&07\n     4AFF   D0 F1      BNE &4AF2\n.DK5\n     4B01   60         RTS\n.TT217\n     4B02   84 94      STY &94\n.t\n     4B04   20 E1 2B   JSR &2BE1\n     4B07   20 6F 49   JSR &496F\n     4B0A   D0 F8      BNE &4B04\n.t2\n     4B0C   20 6F 49   JSR &496F\n     4B0F   F0 FB      BEQ &4B0C\n     4B11   A8         TAY\n     4B12   B1 04      LDA (&04),Y\n     4B14   A4 94      LDY &94\n     4B16   AA         TAX\n.out\n     4B17   60         RTS\n.me1\n     4B18   8E 64 0D   STX &0D64\n     4B1B   48         PHA\n     4B1C   AD 10 0F   LDA &0F10\n     4B1F   20 40 4B   JSR &4B40\n     4B22   68         PLA\n     4B23   2C\n.ou2\n     4B24   A9 6C      LDA #&6C\n     4B26   2C\n.ou3\n     4B27   A9 6F      LDA #&6F\n.MESS\n     4B29   A2 00      LDX #&00\n     4B2B   86 7E      STX &7E\n     4B2D   A0 09      LDY #&09\n     4B2F   84 2C      STY &2C\n     4B31   A0 16      LDY #&16\n     4B33   84 2D      STY &2D\n     4B35   EC 64 0D   CPX &0D64\n     4B38   D0 DE      BNE &4B18\n     4B3A   8C 64 0D   STY &0D64\n     4B3D   8D 10 0F   STA &0F10\n.mes9\n     4B40   20 B6 38   JSR &38B6\n     4B43   4E 65 0D   LSR &0D65\n     4B46   90 CF      BCC &4B17\n     4B48   A9 FD      LDA #&FD\n     4B4A   4C B6 38   JMP &38B6\n.OUCH\n     4B4D   20 57 44   JSR &4457\n     4B50   30 C5      BMI &4B17\n     4B52   E0 16      CPX #&16\n     4B54   B0 C1      BCS &4B17\n     4B56   BD 17 03   LDA &0317,X\n     4B59   F0 BC      BEQ &4B17\n     4B5B   AD 64 0D   LDA &0D64\n     4B5E   D0 B7      BNE &4B17\n     4B60   A0 03      LDY #&03\n     4B62   8C 65 0D   STY &0D65\n     4B65   9D 17 03   STA &0317,X\n     4B68   E0 11      CPX #&11\n     4B6A   B0 05      BCS &4B71\n     4B6C   8A         TXA\n     4B6D   69 D0      ADC #&D0\n     4B6F   D0 B8      BNE &4B29\n.ou1\n     4B71   F0 B1      BEQ &4B24\n     4B73   E0 12      CPX #&12\n     4B75   F0 B0      BEQ &4B27\n     4B77   8A         TXA\n     4B78   69 5D      ADC #&5D\n     4B7A   D0 AD      BNE &4B29\n.QQ16\n     4B7C   41 4C \n     4B7E   4C 45 \n     4B80   58 45 \n     4B82   47 45 \n     4B84   5A 41 \n     4B86   43 45 \n     4B88   42 49 \n     4B8A   53 4F \n     4B8C   55 53 \n     4B8E   45 53 \n     4B90   41 52 \n     4B92   4D 41 \n     4B94   49 4E \n     4B96   44 49 \n     4B98   52 45 \n     4B9A   41 3F \n     4B9C   45 52 \n     4B9E   41 54 \n     4BA0   45 4E \n     4BA2   42 45 \n     4BA4   52 41 \n     4BA6   4C 41 \n     4BA8   56 45 \n     4BAA   54 49 \n     4BAC   45 44 \n     4BAE   4F 52 \n     4BB0   51 55 \n     4BB2   41 4E \n     4BB4   54 45 \n     4BB6   49 53 \n     4BB8   52 49 \n     4BBA   4F 4E \n.QQ23\nMacro ITEM:\n     4BBC   13\n     4BBD   82\n     4BBE   06\n     4BBF   01\nEnd macro ITEM\nMacro ITEM:\n     4BC0   14\n     4BC1   81\n     4BC2   0A\n     4BC3   03\nEnd macro ITEM\nMacro ITEM:\n     4BC4   41\n     4BC5   83\n     4BC6   02\n     4BC7   07\nEnd macro ITEM\nMacro ITEM:\n     4BC8   28\n     4BC9   85\n     4BCA   E2\n     4BCB   1F\nEnd macro ITEM\nMacro ITEM:\n     4BCC   53\n     4BCD   85\n     4BCE   FB\n     4BCF   0F\nEnd macro ITEM\nMacro ITEM:\n     4BD0   C4\n     4BD1   08\n     4BD2   36\n     4BD3   03\nEnd macro ITEM\nMacro ITEM:\n     4BD4   EB\n     4BD5   1D\n     4BD6   08\n     4BD7   78\nEnd macro ITEM\nMacro ITEM:\n     4BD8   9A\n     4BD9   0E\n     4BDA   38\n     4BDB   03\nEnd macro ITEM\nMacro ITEM:\n     4BDC   75\n     4BDD   06\n     4BDE   28\n     4BDF   07\nEnd macro ITEM\nMacro ITEM:\n     4BE0   4E\n     4BE1   01\n     4BE2   11\n     4BE3   1F\nEnd macro ITEM\nMacro ITEM:\n     4BE4   7C\n     4BE5   0D\n     4BE6   1D\n     4BE7   07\nEnd macro ITEM\nMacro ITEM:\n     4BE8   B0\n     4BE9   89\n     4BEA   DC\n     4BEB   3F\nEnd macro ITEM\nMacro ITEM:\n     4BEC   20\n     4BED   81\n     4BEE   35\n     4BEF   03\nEnd macro ITEM\nMacro ITEM:\n     4BF0   61\n     4BF1   A1\n     4BF2   42\n     4BF3   07\nEnd macro ITEM\nMacro ITEM:\n     4BF4   AB\n     4BF5   A2\n     4BF6   37\n     4BF7   1F\nEnd macro ITEM\nMacro ITEM:\n     4BF8   2D\n     4BF9   C1\n     4BFA   FA\n     4BFB   0F\nEnd macro ITEM\nMacro ITEM:\n     4BFC   35\n     4BFD   0F\n     4BFE   C0\n     4BFF   07\nEnd macro ITEM\n.TI2\n     4C00   98         TYA\n     4C01   A0 02      LDY #&02\n     4C03   20 CF 4C   JSR &4CCF\n     4C06   85 67      STA &67\n     4C08   4C 48 4C   JMP &4C48\n.TI1\n     4C0B   AA         TAX\n     4C0C   A5 32      LDA &32\n     4C0E   29 60      AND #&60\n     4C10   F0 EE      BEQ &4C00\n     4C12   A9 02      LDA #&02\n     4C14   20 CF 4C   JSR &4CCF\n     4C17   85 65      STA &65\n     4C19   4C 48 4C   JMP &4C48\n.TIDY\n     4C1C   A5 5D      LDA &5D\n     4C1E   85 31      STA &31\n     4C20   A5 5F      LDA &5F\n     4C22   85 32      STA &32\n     4C24   A5 61      LDA &61\n     4C26   85 33      STA &33\n     4C28   20 25 49   JSR &4925\n     4C2B   A5 31      LDA &31\n     4C2D   85 5D      STA &5D\n     4C2F   A5 32      LDA &32\n     4C31   85 5F      STA &5F\n     4C33   A5 33      LDA &33\n     4C35   85 61      STA &61\n     4C37   A0 04      LDY #&04\n     4C39   A5 31      LDA &31\n     4C3B   29 60      AND #&60\n     4C3D   F0 CC      BEQ &4C0B\n     4C3F   A2 02      LDX #&02\n     4C41   A9 00      LDA #&00\n     4C43   20 CF 4C   JSR &4CCF\n     4C46   85 63      STA &63\n.TI3\n     4C48   A5 63      LDA &63\n     4C4A   85 31      STA &31\n     4C4C   A5 65      LDA &65\n     4C4E   85 32      STA &32\n     4C50   A5 67      LDA &67\n     4C52   85 33      STA &33\n     4C54   20 25 49   JSR &4925\n     4C57   A5 31      LDA &31\n     4C59   85 63      STA &63\n     4C5B   A5 32      LDA &32\n     4C5D   85 65      STA &65\n     4C5F   A5 33      LDA &33\n     4C61   85 67      STA &67\n     4C63   A5 5F      LDA &5F\n     4C65   85 90      STA &90\n     4C67   A5 67      LDA &67\n     4C69   20 36 28   JSR &2836\n     4C6C   A6 61      LDX &61\n     4C6E   A5 65      LDA &65\n     4C70   20 9B 28   JSR &289B\n     4C73   49 80      EOR #&80\n     4C75   85 69      STA &69\n     4C77   A5 63      LDA &63\n     4C79   20 36 28   JSR &2836\n     4C7C   A6 5D      LDX &5D\n     4C7E   A5 67      LDA &67\n     4C80   20 9B 28   JSR &289B\n     4C83   49 80      EOR #&80\n     4C85   85 6B      STA &6B\n     4C87   A5 65      LDA &65\n     4C89   20 36 28   JSR &2836\n     4C8C   A6 5F      LDX &5F\n     4C8E   A5 63      LDA &63\n     4C90   20 9B 28   JSR &289B\n     4C93   49 80      EOR #&80\n     4C95   85 6D      STA &6D\n     4C97   A9 00      LDA #&00\n     4C99   A2 0E      LDX #&0E\n.TIL1\n     4C9B   95 5C      STA &5C,X\n     4C9D   CA         DEX\n     4C9E   CA         DEX\n     4C9F   10 FA      BPL &4C9B\n     4CA1   60         RTS\n.TIS2\n     4CA2   A8         TAY\n     4CA3   29 7F      AND #&7F\n     4CA5   C5 90      CMP &90\n     4CA7   B0 20      BCS &4CC9\n     4CA9   A2 FE      LDX #&FE\n     4CAB   86 D1      STX &D1\n.TIL2\n     4CAD   0A         ASL A\n     4CAE   C5 90      CMP &90\n     4CB0   90 02      BCC &4CB4\n     4CB2   E5 90      SBC &90\n     4CB4   26 D1      ROL &D1\n     4CB6   B0 F5      BCS &4CAD\n     4CB8   A5 D1      LDA &D1\n     4CBA   4A         LSR A\n     4CBB   4A         LSR A\n     4CBC   85 D1      STA &D1\n     4CBE   4A         LSR A\n     4CBF   65 D1      ADC &D1\n     4CC1   85 D1      STA &D1\n     4CC3   98         TYA\n     4CC4   29 80      AND #&80\n     4CC6   05 D1      ORA &D1\n     4CC8   60         RTS\n.TI4\n     4CC9   98         TYA\n     4CCA   29 80      AND #&80\n     4CCC   09 60      ORA #&60\n     4CCE   60         RTS\n.TIS3\n     4CCF   85 1D      STA &1D\n     4CD1   B5 5D      LDA &5D,X\n     4CD3   85 90      STA &90\n     4CD5   B5 63      LDA &63,X\n     4CD7   20 36 28   JSR &2836\n     4CDA   B6 5D      LDX &5D,Y\n     4CDC   86 90      STX &90\n     4CDE   B9 63 00   LDA &0063,Y\n     4CE1   20 5C 28   JSR &285C\n     4CE4   86 1B      STX &1B\n     4CE6   A4 1D      LDY &1D\n     4CE8   B6 5D      LDX &5D,Y\n     4CEA   86 90      STX &90\n     4CEC   49 80      EOR #&80\n.DVIDT\n     4CEE   85 1C      STA &1C\n     4CF0   45 90      EOR &90\n     4CF2   29 80      AND #&80\n     4CF4   85 D1      STA &D1\n     4CF6   A9 00      LDA #&00\n     4CF8   A2 10      LDX #&10\n     4CFA   06 1B      ASL &1B\n     4CFC   26 1C      ROL &1C\n     4CFE   06 90      ASL &90\n     4D00   46 90      LSR &90\n.DVL2\n     4D02   2A         ROL A\n     4D03   C5 90      CMP &90\n     4D05   90 02      BCC &4D09\n     4D07   E5 90      SBC &90\n     4D09   26 1B      ROL &1B\n     4D0B   26 1C      ROL &1C\n     4D0D   CA         DEX\n     4D0E   D0 F2      BNE &4D02\n     4D10   A5 1B      LDA &1B\n     4D12   05 D1      ORA &D1\n     4D14   60         RTS\nELITE F\nAssembled at &4276 \nEnds at &4D15 \nCode size is &A9F \nExecute at &1128 \nReload at &445E \nS.ELTF &4276  &4D15  &1128  &445E \nSaving file '3-assembled-output/ELTF.bin'\n.SHPPT\n     4D15   20 7D 4E   JSR &4E7D\n     4D18   20 5A 3D   JSR &3D5A\n     4D1B   05 D3      ORA &D3\n     4D1D   D0 21      BNE &4D40\n     4D1F   A5 E0      LDA &E0\n     4D21   C9 BE      CMP #&BE\n     4D23   B0 1B      BCS &4D40\n     4D25   A0 02      LDY #&02\n     4D27   20 47 4D   JSR &4D47\n     4D2A   A0 06      LDY #&06\n     4D2C   A5 E0      LDA &E0\n     4D2E   69 01      ADC #&01\n     4D30   20 47 4D   JSR &4D47\n     4D33   A9 08      LDA #&08\n     4D35   05 72      ORA &72\n     4D37   85 72      STA &72\n     4D39   A9 08      LDA #&08\n     4D3B   4C E7 53   JMP &53E7\n     4D3E   68         PLA\n     4D3F   68         PLA\n.nono\n     4D40   A9 F7      LDA #&F7\n     4D42   25 72      AND &72\n     4D44   85 72      STA &72\n     4D46   60         RTS\n.Shpt\n     4D47   91 74      STA (&74),Y\n     4D49   C8         INY\n     4D4A   C8         INY\n     4D4B   91 74      STA (&74),Y\n     4D4D   A5 D2      LDA &D2\n     4D4F   88         DEY\n     4D50   91 74      STA (&74),Y\n     4D52   69 03      ADC #&03\n     4D54   B0 E8      BCS &4D3E\n     4D56   88         DEY\n     4D57   88         DEY\n     4D58   91 74      STA (&74),Y\n     4D5A   60         RTS\n.LL5\n     4D5B   A4 91      LDY &91\n     4D5D   A5 90      LDA &90\n     4D5F   85 92      STA &92\n     4D61   A2 00      LDX #&00\n     4D63   86 90      STX &90\n     4D65   A9 08      LDA #&08\n     4D67   85 D1      STA &D1\n.LL6\n     4D69   E4 90      CPX &90\n     4D6B   90 0E      BCC &4D7B\n     4D6D   D0 04      BNE &4D73\n     4D6F   C0 40      CPY #&40\n     4D71   90 08      BCC &4D7B\n.LL8\n     4D73   98         TYA\n     4D74   E9 40      SBC #&40\n     4D76   A8         TAY\n     4D77   8A         TXA\n     4D78   E5 90      SBC &90\n     4D7A   AA         TAX\n.LL7\n     4D7B   26 90      ROL &90\n     4D7D   06 92      ASL &92\n     4D7F   98         TYA\n     4D80   2A         ROL A\n     4D81   A8         TAY\n     4D82   8A         TXA\n     4D83   2A         ROL A\n     4D84   AA         TAX\n     4D85   06 92      ASL &92\n     4D87   98         TYA\n     4D88   2A         ROL A\n     4D89   A8         TAY\n     4D8A   8A         TXA\n     4D8B   2A         ROL A\n     4D8C   AA         TAX\n     4D8D   C6 D1      DEC &D1\n     4D8F   D0 D8      BNE &4D69\n     4D91   60         RTS\n.LL28\n     4D92   C5 90      CMP &90\n     4D94   B0 1A      BCS &4DB0\n     4D96   A2 FE      LDX #&FE\n     4D98   86 91      STX &91\n.LL31\n     4D9A   0A         ASL A\n     4D9B   B0 0B      BCS &4DA8\n     4D9D   C5 90      CMP &90\n     4D9F   90 02      BCC &4DA3\n     4DA1   E5 90      SBC &90\n     4DA3   26 91      ROL &91\n     4DA5   B0 F3      BCS &4D9A\n     4DA7   60         RTS\n.LL29\n     4DA8   E5 90      SBC &90\n     4DAA   38         SEC\n     4DAB   26 91      ROL &91\n     4DAD   B0 EB      BCS &4D9A\n     4DAF   60         RTS\n.LL2\n     4DB0   A9 FF      LDA #&FF\n     4DB2   85 91      STA &91\n     4DB4   60         RTS\n.LL38\n     4DB5   45 92      EOR &92\n     4DB7   30 06      BMI &4DBF\n     4DB9   A5 90      LDA &90\n     4DBB   18         CLC\n     4DBC   65 91      ADC &91\n     4DBE   60         RTS\n.LL39\n     4DBF   A5 91      LDA &91\n     4DC1   38         SEC\n     4DC2   E5 90      SBC &90\n     4DC4   90 02      BCC &4DC8\n     4DC6   18         CLC\n     4DC7   60         RTS\n     4DC8   48         PHA\n     4DC9   A5 92      LDA &92\n     4DCB   49 80      EOR #&80\n     4DCD   85 92      STA &92\n     4DCF   68         PLA\n     4DD0   49 FF      EOR #&FF\n     4DD2   69 01      ADC #&01\n     4DD4   60         RTS\n.LL51\n     4DD5   A2 00      LDX #&00\n     4DD7   A0 00      LDY #&00\n.ll51\n     4DD9   A5 31      LDA &31\n     4DDB   85 90      STA &90\n     4DDD   B5 09      LDA &09,X\n     4DDF   20 A9 27   JSR &27A9\n     4DE2   85 D1      STA &D1\n     4DE4   A5 32      LDA &32\n     4DE6   55 0A      EOR &0A,X\n     4DE8   85 92      STA &92\n     4DEA   A5 33      LDA &33\n     4DEC   85 90      STA &90\n     4DEE   B5 0B      LDA &0B,X\n     4DF0   20 A9 27   JSR &27A9\n     4DF3   85 90      STA &90\n     4DF5   A5 D1      LDA &D1\n     4DF7   85 91      STA &91\n     4DF9   A5 34      LDA &34\n     4DFB   55 0C      EOR &0C,X\n     4DFD   20 B5 4D   JSR &4DB5\n     4E00   85 D1      STA &D1\n     4E02   A5 35      LDA &35\n     4E04   85 90      STA &90\n     4E06   B5 0D      LDA &0D,X\n     4E08   20 A9 27   JSR &27A9\n     4E0B   85 90      STA &90\n     4E0D   A5 D1      LDA &D1\n     4E0F   85 91      STA &91\n     4E11   A5 36      LDA &36\n     4E13   55 0E      EOR &0E,X\n     4E15   20 B5 4D   JSR &4DB5\n     4E18   99 37 00   STA &0037,Y\n     4E1B   A5 92      LDA &92\n     4E1D   99 38 00   STA &0038,Y\n     4E20   C8         INY\n     4E21   C8         INY\n     4E22   8A         TXA\n     4E23   18         CLC\n     4E24   69 06      ADC #&06\n     4E26   AA         TAX\n     4E27   C9 11      CMP #&11\n     4E29   90 AE      BCC &4DD9\n     4E2B   60         RTS\n.LL25\n     4E2C   4C 9D 3D   JMP &3D9D\n.LL9\n     4E2F   A5 9B      LDA &9B\n     4E31   30 F9      BMI &4E2C\n     4E33   A9 1F      LDA #&1F\n     4E35   85 A7      STA &A7\n     4E37   A9 20      LDA #&20\n     4E39   24 72      BIT &72\n     4E3B   D0 2D      BNE &4E6A\n     4E3D   10 2B      BPL &4E6A\n     4E3F   05 72      ORA &72\n     4E41   29 3F      AND #&3F\n     4E43   85 72      STA &72\n     4E45   A9 00      LDA #&00\n     4E47   A0 1C      LDY #&1C\n     4E49   91 20      STA (&20),Y\n     4E4B   A0 1E      LDY #&1E\n     4E4D   91 20      STA (&20),Y\n     4E4F   20 7D 4E   JSR &4E7D\n     4E52   A0 01      LDY #&01\n     4E54   A9 12      LDA #&12\n     4E56   91 74      STA (&74),Y\n     4E58   A0 07      LDY #&07\n     4E5A   B1 1E      LDA (&1E),Y\n     4E5C   A0 02      LDY #&02\n     4E5E   91 74      STA (&74),Y\n.EE55\n     4E60   C8         INY\n     4E61   20 57 44   JSR &4457\n     4E64   91 74      STA (&74),Y\n     4E66   C0 06      CPY #&06\n     4E68   D0 F6      BNE &4E60\n.EE28\n     4E6A   A5 5B      LDA &5B\n.EE49\n     4E6C   10 1D      BPL &4E8B\n.LL14\n     4E6E   A5 72      LDA &72\n     4E70   29 20      AND #&20\n     4E72   F0 09      BEQ &4E7D\n     4E74   A5 72      LDA &72\n     4E76   29 F7      AND #&F7\n     4E78   85 72      STA &72\n     4E7A   4C 8C 39   JMP &398C\n.EE51\n     4E7D   A9 08      LDA #&08\n     4E7F   24 72      BIT &72\n     4E81   F0 07      BEQ &4E8A\n     4E83   45 72      EOR &72\n     4E85   85 72      STA &72\n     4E87   4C EB 53   JMP &53EB\n     4E8A   60         RTS\n.LL10\n     4E8B   A5 5A      LDA &5A\n     4E8D   C9 C0      CMP #&C0\n     4E8F   B0 DD      BCS &4E6E\n     4E91   A5 53      LDA &53\n     4E93   C5 59      CMP &59\n     4E95   A5 54      LDA &54\n     4E97   E5 5A      SBC &5A\n     4E99   B0 D3      BCS &4E6E\n     4E9B   A5 56      LDA &56\n     4E9D   C5 59      CMP &59\n     4E9F   A5 57      LDA &57\n     4EA1   E5 5A      SBC &5A\n     4EA3   B0 C9      BCS &4E6E\n     4EA5   A0 06      LDY #&06\n     4EA7   B1 1E      LDA (&1E),Y\n     4EA9   AA         TAX\n     4EAA   A9 FF      LDA #&FF\n     4EAC   9D 00 01   STA &0100,X\n     4EAF   9D 01 01   STA &0101,X\n     4EB2   A5 59      LDA &59\n     4EB4   85 D1      STA &D1\n     4EB6   A5 5A      LDA &5A\n     4EB8   4A         LSR A\n     4EB9   66 D1      ROR &D1\n     4EBB   4A         LSR A\n     4EBC   66 D1      ROR &D1\n     4EBE   4A         LSR A\n     4EBF   66 D1      ROR &D1\n     4EC1   4A         LSR A\n     4EC2   D0 0A      BNE &4ECE\n     4EC4   A5 D1      LDA &D1\n     4EC6   6A         ROR A\n     4EC7   4A         LSR A\n     4EC8   4A         LSR A\n     4EC9   4A         LSR A\n     4ECA   85 A7      STA &A7\n     4ECC   10 11      BPL &4EDF\n.LL13\n     4ECE   A0 0D      LDY #&0D\n     4ED0   B1 1E      LDA (&1E),Y\n     4ED2   C5 5A      CMP &5A\n     4ED4   B0 09      BCS &4EDF\n     4ED6   A9 20      LDA #&20\n     4ED8   25 72      AND &72\n     4EDA   D0 03      BNE &4EDF\n     4EDC   4C 15 4D   JMP &4D15\n.LL17\n     4EDF   A2 05      LDX #&05\n.LL15\n     4EE1   B5 68      LDA &68,X\n     4EE3   95 09      STA &09,X\n     4EE5   B5 62      LDA &62,X\n     4EE7   95 0F      STA &0F,X\n     4EE9   B5 5C      LDA &5C,X\n     4EEB   95 15      STA &15,X\n     4EED   CA         DEX\n     4EEE   10 F1      BPL &4EE1\n     4EF0   A9 C5      LDA #&C5\n     4EF2   85 90      STA &90\n     4EF4   A0 10      LDY #&10\n.LL21\n     4EF6   B9 09 00   LDA &0009,Y\n     4EF9   0A         ASL A\n     4EFA   B9 0A 00   LDA &000A,Y\n     4EFD   2A         ROL A\n     4EFE   20 92 4D   JSR &4D92\n     4F01   A6 91      LDX &91\n     4F03   96 09      STX &09,Y\n     4F05   88         DEY\n     4F06   88         DEY\n     4F07   10 ED      BPL &4EF6\n     4F09   A2 08      LDX #&08\n.ll91\n     4F0B   B5 53      LDA &53,X\n     4F0D   95 7E      STA &7E,X\n     4F0F   CA         DEX\n     4F10   10 F9      BPL &4F0B\n     4F12   A9 FF      LDA #&FF\n     4F14   85 E1      STA &E1\n     4F16   A0 0C      LDY #&0C\n     4F18   A5 72      LDA &72\n     4F1A   29 20      AND #&20\n     4F1C   F0 12      BEQ &4F30\n     4F1E   B1 1E      LDA (&1E),Y\n     4F20   4A         LSR A\n     4F21   4A         LSR A\n     4F22   AA         TAX\n     4F23   A9 FF      LDA #&FF\n.EE30\n     4F25   95 D2      STA &D2,X\n     4F27   CA         DEX\n     4F28   10 FB      BPL &4F25\n     4F2A   E8         INX\n     4F2B   86 A7      STX &A7\n.LL41\n     4F2D   4C A3 50   JMP &50A3\n.EE29\n     4F30   B1 1E      LDA (&1E),Y\n     4F32   F0 F9      BEQ &4F2D\n     4F34   85 A8      STA &A8\n     4F36   A0 12      LDY #&12\n     4F38   B1 1E      LDA (&1E),Y\n     4F3A   AA         TAX\n     4F3B   A5 85      LDA &85\n.LL90\n     4F3D   A8         TAY\n     4F3E   F0 0F      BEQ &4F4F\n     4F40   E8         INX\n     4F41   46 82      LSR &82\n     4F43   66 81      ROR &81\n     4F45   46 7F      LSR &7F\n     4F47   66 7E      ROR &7E\n     4F49   4A         LSR A\n     4F4A   66 84      ROR &84\n     4F4C   A8         TAY\n     4F4D   D0 F1      BNE &4F40\n.LL91\n     4F4F   86 95      STX &95\n     4F51   A5 86      LDA &86\n     4F53   85 36      STA &36\n     4F55   A5 7E      LDA &7E\n     4F57   85 31      STA &31\n     4F59   A5 80      LDA &80\n     4F5B   85 32      STA &32\n     4F5D   A5 81      LDA &81\n     4F5F   85 33      STA &33\n     4F61   A5 83      LDA &83\n     4F63   85 34      STA &34\n     4F65   A5 84      LDA &84\n     4F67   85 35      STA &35\n     4F69   20 D5 4D   JSR &4DD5\n     4F6C   A5 37      LDA &37\n     4F6E   85 7E      STA &7E\n     4F70   A5 38      LDA &38\n     4F72   85 80      STA &80\n     4F74   A5 39      LDA &39\n     4F76   85 81      STA &81\n     4F78   A5 3A      LDA &3A\n     4F7A   85 83      STA &83\n     4F7C   A5 3B      LDA &3B\n     4F7E   85 84      STA &84\n     4F80   A5 3C      LDA &3C\n     4F82   85 86      STA &86\n     4F84   A0 04      LDY #&04\n     4F86   B1 1E      LDA (&1E),Y\n     4F88   18         CLC\n     4F89   65 1E      ADC &1E\n     4F8B   85 22      STA &22\n     4F8D   A0 11      LDY #&11\n     4F8F   B1 1E      LDA (&1E),Y\n     4F91   65 1F      ADC &1F\n     4F93   85 23      STA &23\n     4F95   A0 00      LDY #&00\n.LL86\n     4F97   B1 22      LDA (&22),Y\n     4F99   85 38      STA &38\n     4F9B   29 1F      AND #&1F\n     4F9D   C5 A7      CMP &A7\n     4F9F   B0 0F      BCS &4FB0\n     4FA1   98         TYA\n     4FA2   4A         LSR A\n     4FA3   4A         LSR A\n     4FA4   AA         TAX\n     4FA5   A9 FF      LDA #&FF\n     4FA7   95 D2      STA &D2,X\n     4FA9   98         TYA\n     4FAA   69 04      ADC #&04\n     4FAC   A8         TAY\n     4FAD   4C 9C 50   JMP &509C\n.LL87\n     4FB0   A5 38      LDA &38\n     4FB2   0A         ASL A\n     4FB3   85 3A      STA &3A\n     4FB5   0A         ASL A\n     4FB6   85 3C      STA &3C\n     4FB8   C8         INY\n     4FB9   B1 22      LDA (&22),Y\n     4FBB   85 37      STA &37\n     4FBD   C8         INY\n     4FBE   B1 22      LDA (&22),Y\n     4FC0   85 39      STA &39\n     4FC2   C8         INY\n     4FC3   B1 22      LDA (&22),Y\n     4FC5   85 3B      STA &3B\n     4FC7   A6 95      LDX &95\n     4FC9   E0 04      CPX #&04\n     4FCB   90 23      BCC &4FF0\n.LL143\n     4FCD   A5 7E      LDA &7E\n     4FCF   85 31      STA &31\n     4FD1   A5 80      LDA &80\n     4FD3   85 32      STA &32\n     4FD5   A5 81      LDA &81\n     4FD7   85 33      STA &33\n     4FD9   A5 83      LDA &83\n     4FDB   85 34      STA &34\n     4FDD   A5 84      LDA &84\n     4FDF   85 35      STA &35\n     4FE1   A5 86      LDA &86\n     4FE3   85 36      STA &36\n     4FE5   4C 4E 50   JMP &504E\n.ovflw\n     4FE8   46 7E      LSR &7E\n     4FEA   46 84      LSR &84\n     4FEC   46 81      LSR &81\n     4FEE   A2 01      LDX #&01\n.LL92\n     4FF0   A5 37      LDA &37\n     4FF2   85 31      STA &31\n     4FF4   A5 39      LDA &39\n     4FF6   85 33      STA &33\n     4FF8   A5 3B      LDA &3B\n.LL93\n     4FFA   CA         DEX\n     4FFB   30 08      BMI &5005\n     4FFD   46 31      LSR &31\n     4FFF   46 33      LSR &33\n     5001   4A         LSR A\n     5002   CA         DEX\n     5003   10 F8      BPL &4FFD\n.LL94\n     5005   85 91      STA &91\n     5007   A5 3C      LDA &3C\n     5009   85 92      STA &92\n     500B   A5 84      LDA &84\n     500D   85 90      STA &90\n     500F   A5 86      LDA &86\n     5011   20 B5 4D   JSR &4DB5\n     5014   B0 D2      BCS &4FE8\n     5016   85 35      STA &35\n     5018   A5 92      LDA &92\n     501A   85 36      STA &36\n     501C   A5 31      LDA &31\n     501E   85 91      STA &91\n     5020   A5 38      LDA &38\n     5022   85 92      STA &92\n     5024   A5 7E      LDA &7E\n     5026   85 90      STA &90\n     5028   A5 80      LDA &80\n     502A   20 B5 4D   JSR &4DB5\n     502D   B0 B9      BCS &4FE8\n     502F   85 31      STA &31\n     5031   A5 92      LDA &92\n     5033   85 32      STA &32\n     5035   A5 33      LDA &33\n     5037   85 91      STA &91\n     5039   A5 3A      LDA &3A\n     503B   85 92      STA &92\n     503D   A5 81      LDA &81\n     503F   85 90      STA &90\n     5041   A5 83      LDA &83\n     5043   20 B5 4D   JSR &4DB5\n     5046   B0 A0      BCS &4FE8\n     5048   85 33      STA &33\n     504A   A5 92      LDA &92\n     504C   85 34      STA &34\n.LL89\n     504E   A5 37      LDA &37\n     5050   85 90      STA &90\n     5052   A5 31      LDA &31\n     5054   20 A9 27   JSR &27A9\n     5057   85 D1      STA &D1\n     5059   A5 38      LDA &38\n     505B   45 32      EOR &32\n     505D   85 92      STA &92\n     505F   A5 39      LDA &39\n     5061   85 90      STA &90\n     5063   A5 33      LDA &33\n     5065   20 A9 27   JSR &27A9\n     5068   85 90      STA &90\n     506A   A5 D1      LDA &D1\n     506C   85 91      STA &91\n     506E   A5 3A      LDA &3A\n     5070   45 34      EOR &34\n     5072   20 B5 4D   JSR &4DB5\n     5075   85 D1      STA &D1\n     5077   A5 3B      LDA &3B\n     5079   85 90      STA &90\n     507B   A5 35      LDA &35\n     507D   20 A9 27   JSR &27A9\n     5080   85 90      STA &90\n     5082   A5 D1      LDA &D1\n     5084   85 91      STA &91\n     5086   A5 36      LDA &36\n     5088   45 3C      EOR &3C\n     508A   20 B5 4D   JSR &4DB5\n     508D   48         PHA\n     508E   98         TYA\n     508F   4A         LSR A\n     5090   4A         LSR A\n     5091   AA         TAX\n     5092   68         PLA\n     5093   24 92      BIT &92\n     5095   30 02      BMI &5099\n     5097   A9 00      LDA #&00\n     5099   95 D2      STA &D2,X\n     509B   C8         INY\n.LL88\n     509C   C4 A8      CPY &A8\n     509E   B0 03      BCS &50A3\n     50A0   4C 97 4F   JMP &4F97\n.LL42\n     50A3   A4 0B      LDY &0B\n     50A5   A6 0C      LDX &0C\n     50A7   A5 0F      LDA &0F\n     50A9   85 0B      STA &0B\n     50AB   A5 10      LDA &10\n     50AD   85 0C      STA &0C\n     50AF   84 0F      STY &0F\n     50B1   86 10      STX &10\n     50B3   A4 0D      LDY &0D\n     50B5   A6 0E      LDX &0E\n     50B7   A5 15      LDA &15\n     50B9   85 0D      STA &0D\n     50BB   A5 16      LDA &16\n     50BD   85 0E      STA &0E\n     50BF   84 15      STY &15\n     50C1   86 16      STX &16\n     50C3   A4 13      LDY &13\n     50C5   A6 14      LDX &14\n     50C7   A5 17      LDA &17\n     50C9   85 13      STA &13\n     50CB   A5 18      LDA &18\n     50CD   85 14      STA &14\n     50CF   84 17      STY &17\n     50D1   86 18      STX &18\n     50D3   A0 08      LDY #&08\n     50D5   B1 1E      LDA (&1E),Y\n     50D7   85 A8      STA &A8\n     50D9   A5 1E      LDA &1E\n     50DB   18         CLC\n     50DC   69 14      ADC #&14\n     50DE   85 22      STA &22\n     50E0   A5 1F      LDA &1F\n     50E2   69 00      ADC #&00\n     50E4   85 23      STA &23\n     50E6   A0 00      LDY #&00\n     50E8   84 A4      STY &A4\n.LL48\n     50EA   84 95      STY &95\n     50EC   B1 22      LDA (&22),Y\n     50EE   85 31      STA &31\n     50F0   C8         INY\n     50F1   B1 22      LDA (&22),Y\n     50F3   85 33      STA &33\n     50F5   C8         INY\n     50F6   B1 22      LDA (&22),Y\n     50F8   85 35      STA &35\n     50FA   C8         INY\n     50FB   B1 22      LDA (&22),Y\n     50FD   85 D1      STA &D1\n     50FF   29 1F      AND #&1F\n     5101   C5 A7      CMP &A7\n     5103   90 2E      BCC &5133\n     5105   C8         INY\n     5106   B1 22      LDA (&22),Y\n     5108   85 1B      STA &1B\n     510A   29 0F      AND #&0F\n     510C   AA         TAX\n     510D   B5 D2      LDA &D2,X\n     510F   D0 25      BNE &5136\n     5111   A5 1B      LDA &1B\n     5113   4A         LSR A\n     5114   4A         LSR A\n     5115   4A         LSR A\n     5116   4A         LSR A\n     5117   AA         TAX\n     5118   B5 D2      LDA &D2,X\n     511A   D0 1A      BNE &5136\n     511C   C8         INY\n     511D   B1 22      LDA (&22),Y\n     511F   85 1B      STA &1B\n     5121   29 0F      AND #&0F\n     5123   AA         TAX\n     5124   B5 D2      LDA &D2,X\n     5126   D0 0E      BNE &5136\n     5128   A5 1B      LDA &1B\n     512A   4A         LSR A\n     512B   4A         LSR A\n     512C   4A         LSR A\n     512D   4A         LSR A\n     512E   AA         TAX\n     512F   B5 D2      LDA &D2,X\n     5131   D0 03      BNE &5136\n     5133   4C AB 52   JMP &52AB\n.LL49\n     5136   A5 D1      LDA &D1\n     5138   85 32      STA &32\n     513A   0A         ASL A\n     513B   85 34      STA &34\n     513D   0A         ASL A\n     513E   85 36      STA &36\n     5140   20 D5 4D   JSR &4DD5\n     5143   A5 55      LDA &55\n     5145   85 33      STA &33\n     5147   45 38      EOR &38\n     5149   30 10      BMI &515B\n     514B   18         CLC\n     514C   A5 37      LDA &37\n     514E   65 53      ADC &53\n     5150   85 31      STA &31\n     5152   A5 54      LDA &54\n     5154   69 00      ADC #&00\n     5156   85 32      STA &32\n     5158   4C 7E 51   JMP &517E\n.LL52\n     515B   A5 53      LDA &53\n     515D   38         SEC\n     515E   E5 37      SBC &37\n     5160   85 31      STA &31\n     5162   A5 54      LDA &54\n     5164   E9 00      SBC #&00\n     5166   85 32      STA &32\n     5168   B0 14      BCS &517E\n     516A   49 FF      EOR #&FF\n     516C   85 32      STA &32\n     516E   A9 01      LDA #&01\n     5170   E5 31      SBC &31\n     5172   85 31      STA &31\n     5174   90 02      BCC &5178\n     5176   E6 32      INC &32\n     5178   A5 33      LDA &33\n     517A   49 80      EOR #&80\n     517C   85 33      STA &33\n.LL53\n     517E   A5 58      LDA &58\n     5180   85 36      STA &36\n     5182   45 3A      EOR &3A\n     5184   30 10      BMI &5196\n     5186   18         CLC\n     5187   A5 39      LDA &39\n     5189   65 56      ADC &56\n     518B   85 34      STA &34\n     518D   A5 57      LDA &57\n     518F   69 00      ADC #&00\n     5191   85 35      STA &35\n     5193   4C BB 51   JMP &51BB\n.LL54\n     5196   A5 56      LDA &56\n     5198   38         SEC\n     5199   E5 39      SBC &39\n     519B   85 34      STA &34\n     519D   A5 57      LDA &57\n     519F   E9 00      SBC #&00\n     51A1   85 35      STA &35\n     51A3   B0 16      BCS &51BB\n     51A5   49 FF      EOR #&FF\n     51A7   85 35      STA &35\n     51A9   A5 34      LDA &34\n     51AB   49 FF      EOR #&FF\n     51AD   69 01      ADC #&01\n     51AF   85 34      STA &34\n     51B1   A5 36      LDA &36\n     51B3   49 80      EOR #&80\n     51B5   85 36      STA &36\n     51B7   90 02      BCC &51BB\n     51B9   E6 35      INC &35\n.LL55\n     51BB   A5 3C      LDA &3C\n     51BD   30 4A      BMI &5209\n     51BF   A5 3B      LDA &3B\n     51C1   18         CLC\n     51C2   65 59      ADC &59\n     51C4   85 D1      STA &D1\n     51C6   A5 5A      LDA &5A\n     51C8   69 00      ADC #&00\n     51CA   85 8F      STA &8F\n     51CC   4C 28 52   JMP &5228\n.LL61\n     51CF   A6 90      LDX &90\n     51D1   F0 1C      BEQ &51EF\n     51D3   A2 00      LDX #&00\n.LL63\n     51D5   4A         LSR A\n     51D6   E8         INX\n     51D7   C5 90      CMP &90\n     51D9   B0 FA      BCS &51D5\n     51DB   86 92      STX &92\n     51DD   20 92 4D   JSR &4D92\n     51E0   A6 92      LDX &92\n     51E2   A5 91      LDA &91\n.LL64\n     51E4   0A         ASL A\n     51E5   26 8F      ROL &8F\n     51E7   30 06      BMI &51EF\n     51E9   CA         DEX\n     51EA   D0 F8      BNE &51E4\n     51EC   85 91      STA &91\n     51EE   60         RTS\n.LL84\n     51EF   A9 32      LDA #&32\n     51F1   85 91      STA &91\n     51F3   85 8F      STA &8F\n     51F5   60         RTS\n.LL62\n     51F6   A9 80      LDA #&80\n     51F8   38         SEC\n     51F9   E5 91      SBC &91\n     51FB   9D 00 01   STA &0100,X\n     51FE   E8         INX\n     51FF   A9 00      LDA #&00\n     5201   E5 8F      SBC &8F\n     5203   9D 00 01   STA &0100,X\n     5206   4C 68 52   JMP &5268\n.LL56\n     5209   A5 59      LDA &59\n     520B   38         SEC\n     520C   E5 3B      SBC &3B\n     520E   85 D1      STA &D1\n     5210   A5 5A      LDA &5A\n     5212   E9 00      SBC #&00\n     5214   85 8F      STA &8F\n     5216   90 08      BCC &5220\n     5218   D0 0E      BNE &5228\n     521A   A5 D1      LDA &D1\n     521C   C9 04      CMP #&04\n     521E   B0 08      BCS &5228\n.LL140\n     5220   A9 00      LDA #&00\n     5222   85 8F      STA &8F\n     5224   A9 04      LDA #&04\n     5226   85 D1      STA &D1\n.LL57\n     5228   A5 8F      LDA &8F\n     522A   05 32      ORA &32\n     522C   05 35      ORA &35\n     522E   F0 0F      BEQ &523F\n     5230   46 32      LSR &32\n     5232   66 31      ROR &31\n     5234   46 35      LSR &35\n     5236   66 34      ROR &34\n     5238   46 8F      LSR &8F\n     523A   66 D1      ROR &D1\n     523C   4C 28 52   JMP &5228\n.LL60\n     523F   A5 D1      LDA &D1\n     5241   85 90      STA &90\n     5243   A5 31      LDA &31\n     5245   C5 90      CMP &90\n     5247   90 06      BCC &524F\n     5249   20 CF 51   JSR &51CF\n     524C   4C 52 52   JMP &5252\n.LL69\n     524F   20 92 4D   JSR &4D92\n.LL65\n     5252   A6 A4      LDX &A4\n     5254   A5 33      LDA &33\n     5256   30 9E      BMI &51F6\n     5258   A5 91      LDA &91\n     525A   18         CLC\n     525B   69 80      ADC #&80\n     525D   9D 00 01   STA &0100,X\n     5260   E8         INX\n     5261   A5 8F      LDA &8F\n     5263   69 00      ADC #&00\n     5265   9D 00 01   STA &0100,X\n.LL66\n     5268   8A         TXA\n     5269   48         PHA\n     526A   A9 00      LDA #&00\n     526C   85 8F      STA &8F\n     526E   A5 D1      LDA &D1\n     5270   85 90      STA &90\n     5272   A5 34      LDA &34\n     5274   C5 90      CMP &90\n     5276   90 19      BCC &5291\n     5278   20 CF 51   JSR &51CF\n     527B   4C 94 52   JMP &5294\n.LL70\n     527E   A9 60      LDA #&60\n     5280   18         CLC\n     5281   65 91      ADC &91\n     5283   9D 00 01   STA &0100,X\n     5286   E8         INX\n     5287   A9 00      LDA #&00\n     5289   65 8F      ADC &8F\n     528B   9D 00 01   STA &0100,X\n     528E   4C AB 52   JMP &52AB\n.LL67\n     5291   20 92 4D   JSR &4D92\n.LL68\n     5294   68         PLA\n     5295   AA         TAX\n     5296   E8         INX\n     5297   A5 36      LDA &36\n     5299   30 E3      BMI &527E\n     529B   A9 60      LDA #&60\n     529D   38         SEC\n     529E   E5 91      SBC &91\n     52A0   9D 00 01   STA &0100,X\n     52A3   E8         INX\n     52A4   A9 00      LDA #&00\n     52A6   E5 8F      SBC &8F\n     52A8   9D 00 01   STA &0100,X\n.LL50\n     52AB   18         CLC\n     52AC   A5 A4      LDA &A4\n     52AE   69 04      ADC #&04\n     52B0   85 A4      STA &A4\n     52B2   A5 95      LDA &95\n     52B4   69 06      ADC #&06\n     52B6   A8         TAY\n     52B7   B0 07      BCS &52C0\n     52B9   C5 A8      CMP &A8\n     52BB   B0 03      BCS &52C0\n     52BD   4C EA 50   JMP &50EA\n.LL72\n     52C0   A5 72      LDA &72\n     52C2   29 20      AND #&20\n     52C4   F0 09      BEQ &52CF\n     52C6   A5 72      LDA &72\n     52C8   09 08      ORA #&08\n     52CA   85 72      STA &72\n     52CC   4C 8C 39   JMP &398C\n.EE31\n     52CF   A9 08      LDA #&08\n     52D1   24 72      BIT &72\n     52D3   F0 05      BEQ &52DA\n     52D5   20 EB 53   JSR &53EB\n     52D8   A9 08      LDA #&08\n.LL74\n     52DA   05 72      ORA &72\n     52DC   85 72      STA &72\n     52DE   A0 09      LDY #&09\n     52E0   B1 1E      LDA (&1E),Y\n     52E2   85 A8      STA &A8\n     52E4   A0 00      LDY #&00\n     52E6   84 8F      STY &8F\n     52E8   84 95      STY &95\n     52EA   E6 8F      INC &8F\n     52EC   24 72      BIT &72\n     52EE   50 54      BVC &5344\n     52F0   A5 72      LDA &72\n     52F2   29 BF      AND #&BF\n     52F4   85 72      STA &72\n     52F6   A0 06      LDY #&06\n     52F8   B1 1E      LDA (&1E),Y\n     52FA   A8         TAY\n     52FB   BE 00 01   LDX &0100,Y\n     52FE   86 31      STX &31\n     5300   E8         INX\n     5301   F0 41      BEQ &5344\n     5303   BE 01 01   LDX &0101,Y\n     5306   86 32      STX &32\n     5308   E8         INX\n     5309   F0 39      BEQ &5344\n     530B   BE 02 01   LDX &0102,Y\n     530E   86 33      STX &33\n     5310   BE 03 01   LDX &0103,Y\n     5313   86 34      STX &34\n     5315   A9 00      LDA #&00\n     5317   85 35      STA &35\n     5319   85 36      STA &36\n     531B   85 38      STA &38\n     531D   A5 59      LDA &59\n     531F   85 37      STA &37\n     5321   A5 55      LDA &55\n     5323   10 02      BPL &5327\n     5325   C6 35      DEC &35\n     5327   20 13 55   JSR &5513\n     532A   B0 18      BCS &5344\n     532C   A4 8F      LDY &8F\n     532E   A5 31      LDA &31\n     5330   91 74      STA (&74),Y\n     5332   C8         INY\n     5333   A5 32      LDA &32\n     5335   91 74      STA (&74),Y\n     5337   C8         INY\n     5338   A5 33      LDA &33\n     533A   91 74      STA (&74),Y\n     533C   C8         INY\n     533D   A5 34      LDA &34\n     533F   91 74      STA (&74),Y\n     5341   C8         INY\n     5342   84 8F      STY &8F\n.LL170\n     5344   A0 03      LDY #&03\n     5346   18         CLC\n     5347   B1 1E      LDA (&1E),Y\n     5349   65 1E      ADC &1E\n     534B   85 22      STA &22\n     534D   A0 10      LDY #&10\n     534F   B1 1E      LDA (&1E),Y\n     5351   65 1F      ADC &1F\n     5353   85 23      STA &23\n     5355   A0 05      LDY #&05\n     5357   B1 1E      LDA (&1E),Y\n     5359   85 06      STA &06\n     535B   A4 95      LDY &95\n.LL75\n     535D   B1 22      LDA (&22),Y\n     535F   C5 A7      CMP &A7\n     5361   90 6B      BCC &53CE\n     5363   C8         INY\n     5364   B1 22      LDA (&22),Y\n     5366   C8         INY\n     5367   85 1B      STA &1B\n     5369   29 0F      AND #&0F\n     536B   AA         TAX\n     536C   B5 D2      LDA &D2,X\n     536E   D0 0B      BNE &537B\n     5370   A5 1B      LDA &1B\n     5372   4A         LSR A\n     5373   4A         LSR A\n     5374   4A         LSR A\n     5375   4A         LSR A\n     5376   AA         TAX\n     5377   B5 D2      LDA &D2,X\n     5379   F0 53      BEQ &53CE\n.LL79\n     537B   B1 22      LDA (&22),Y\n     537D   AA         TAX\n     537E   C8         INY\n     537F   B1 22      LDA (&22),Y\n     5381   85 90      STA &90\n     5383   BD 01 01   LDA &0101,X\n     5386   85 32      STA &32\n     5388   BD 00 01   LDA &0100,X\n     538B   85 31      STA &31\n     538D   BD 02 01   LDA &0102,X\n     5390   85 33      STA &33\n     5392   BD 03 01   LDA &0103,X\n     5395   85 34      STA &34\n     5397   A6 90      LDX &90\n     5399   BD 00 01   LDA &0100,X\n     539C   85 35      STA &35\n     539E   BD 03 01   LDA &0103,X\n     53A1   85 38      STA &38\n     53A3   BD 02 01   LDA &0102,X\n     53A6   85 37      STA &37\n     53A8   BD 01 01   LDA &0101,X\n     53AB   85 36      STA &36\n     53AD   20 19 55   JSR &5519\n     53B0   B0 1C      BCS &53CE\n.LL80\n     53B2   A4 8F      LDY &8F\n     53B4   A5 31      LDA &31\n     53B6   91 74      STA (&74),Y\n     53B8   C8         INY\n     53B9   A5 32      LDA &32\n     53BB   91 74      STA (&74),Y\n     53BD   C8         INY\n     53BE   A5 33      LDA &33\n     53C0   91 74      STA (&74),Y\n     53C2   C8         INY\n     53C3   A5 34      LDA &34\n     53C5   91 74      STA (&74),Y\n     53C7   C8         INY\n     53C8   84 8F      STY &8F\n     53CA   C4 06      CPY &06\n     53CC   B0 17      BCS &53E5\n.LL78\n     53CE   E6 95      INC &95\n     53D0   A4 95      LDY &95\n     53D2   C4 A8      CPY &A8\n     53D4   B0 0F      BCS &53E5\n     53D6   A0 00      LDY #&00\n     53D8   A5 22      LDA &22\n     53DA   69 04      ADC #&04\n     53DC   85 22      STA &22\n     53DE   90 02      BCC &53E2\n     53E0   E6 23      INC &23\n.ll81\n     53E2   4C 5D 53   JMP &535D\n.LL81\n     53E5   A5 8F      LDA &8F\n     53E7   A0 00      LDY #&00\n     53E9   91 74      STA (&74),Y\n.LL155\n     53EB   A0 00      LDY #&00\n     53ED   B1 74      LDA (&74),Y\n     53EF   85 A8      STA &A8\n     53F1   C9 04      CMP #&04\n     53F3   90 1C      BCC &5411\n     53F5   C8         INY\n.LL27\n     53F6   B1 74      LDA (&74),Y\n     53F8   85 31      STA &31\n     53FA   C8         INY\n     53FB   B1 74      LDA (&74),Y\n     53FD   85 32      STA &32\n     53FF   C8         INY\n     5400   B1 74      LDA (&74),Y\n     5402   85 33      STA &33\n     5404   C8         INY\n     5405   B1 74      LDA (&74),Y\n     5407   85 34      STA &34\n     5409   20 77 18   JSR &1877\n     540C   C8         INY\n     540D   C4 A8      CPY &A8\n     540F   90 E5      BCC &53F6\n     5411   60         RTS\n.LL118\n     5412   A5 32      LDA &32\n     5414   10 17      BPL &542D\n     5416   85 92      STA &92\n     5418   20 8C 54   JSR &548C\n     541B   8A         TXA\n     541C   18         CLC\n     541D   65 33      ADC &33\n     541F   85 33      STA &33\n     5421   98         TYA\n     5422   65 34      ADC &34\n     5424   85 34      STA &34\n     5426   A9 00      LDA #&00\n     5428   85 31      STA &31\n     542A   85 32      STA &32\n     542C   AA         TAX\n.LL119\n     542D   F0 19      BEQ &5448\n     542F   85 92      STA &92\n     5431   C6 92      DEC &92\n     5433   20 8C 54   JSR &548C\n     5436   8A         TXA\n     5437   18         CLC\n     5438   65 33      ADC &33\n     543A   85 33      STA &33\n     543C   98         TYA\n     543D   65 34      ADC &34\n     543F   85 34      STA &34\n     5441   A2 FF      LDX #&FF\n     5443   86 31      STX &31\n     5445   E8         INX\n     5446   86 32      STX &32\n.LL134\n     5448   A5 34      LDA &34\n     544A   10 1A      BPL &5466\n     544C   85 92      STA &92\n     544E   A5 33      LDA &33\n     5450   85 91      STA &91\n     5452   20 BB 54   JSR &54BB\n     5455   8A         TXA\n     5456   18         CLC\n     5457   65 31      ADC &31\n     5459   85 31      STA &31\n     545B   98         TYA\n     545C   65 32      ADC &32\n     545E   85 32      STA &32\n     5460   A9 00      LDA #&00\n     5462   85 33      STA &33\n     5464   85 34      STA &34\n.LL135\n     5466   A5 33      LDA &33\n     5468   38         SEC\n     5469   E9 C0      SBC #&C0\n     546B   85 91      STA &91\n     546D   A5 34      LDA &34\n     546F   E9 00      SBC #&00\n     5471   85 92      STA &92\n     5473   90 16      BCC &548B\n.LL139\n     5475   20 BB 54   JSR &54BB\n     5478   8A         TXA\n     5479   18         CLC\n     547A   65 31      ADC &31\n     547C   85 31      STA &31\n     547E   98         TYA\n     547F   65 32      ADC &32\n     5481   85 32      STA &32\n     5483   A9 BF      LDA #&BF\n     5485   85 33      STA &33\n     5487   A9 00      LDA #&00\n     5489   85 34      STA &34\n.LL136\n     548B   60         RTS\n.LL120\n     548C   A5 31      LDA &31\n     548E   85 91      STA &91\n     5490   20 F7 54   JSR &54F7\n     5493   48         PHA\n     5494   A6 D1      LDX &D1\n     5496   D0 2B      BNE &54C3\n.LL122\n     5498   A9 00      LDA #&00\n     549A   AA         TAX\n     549B   A8         TAY\n     549C   46 92      LSR &92\n     549E   66 91      ROR &91\n     54A0   06 90      ASL &90\n     54A2   90 09      BCC &54AD\n.LL125\n     54A4   8A         TXA\n     54A5   18         CLC\n     54A6   65 91      ADC &91\n     54A8   AA         TAX\n     54A9   98         TYA\n     54AA   65 92      ADC &92\n     54AC   A8         TAY\n.LL126\n     54AD   46 92      LSR &92\n     54AF   66 91      ROR &91\n     54B1   06 90      ASL &90\n     54B3   B0 EF      BCS &54A4\n     54B5   D0 F6      BNE &54AD\n     54B7   68         PLA\n     54B8   10 30      BPL &54EA\n     54BA   60         RTS\n.LL123\n     54BB   20 F7 54   JSR &54F7\n     54BE   48         PHA\n     54BF   A6 D1      LDX &D1\n     54C1   D0 D5      BNE &5498\n.LL121\n     54C3   A9 FF      LDA #&FF\n     54C5   A8         TAY\n     54C6   0A         ASL A\n     54C7   AA         TAX\n.LL130\n     54C8   06 91      ASL &91\n     54CA   26 92      ROL &92\n     54CC   A5 92      LDA &92\n     54CE   B0 04      BCS &54D4\n     54D0   C5 90      CMP &90\n     54D2   90 0B      BCC &54DF\n.LL131\n     54D4   E5 90      SBC &90\n     54D6   85 92      STA &92\n     54D8   A5 91      LDA &91\n     54DA   E9 00      SBC #&00\n     54DC   85 91      STA &91\n     54DE   38         SEC\n.LL132\n     54DF   8A         TXA\n     54E0   2A         ROL A\n     54E1   AA         TAX\n     54E2   98         TYA\n     54E3   2A         ROL A\n     54E4   A8         TAY\n     54E5   B0 E1      BCS &54C8\n     54E7   68         PLA\n     54E8   30 0C      BMI &54F6\n.LL133\n     54EA   8A         TXA\n     54EB   49 FF      EOR #&FF\n     54ED   69 01      ADC #&01\n     54EF   AA         TAX\n     54F0   98         TYA\n     54F1   49 FF      EOR #&FF\n     54F3   69 00      ADC #&00\n     54F5   A8         TAY\n.LL128\n     54F6   60         RTS\n.LL129\n     54F7   A6 39      LDX &39\n     54F9   86 90      STX &90\n     54FB   A5 92      LDA &92\n     54FD   10 11      BPL &5510\n     54FF   A9 00      LDA #&00\n     5501   38         SEC\n     5502   E5 91      SBC &91\n     5504   85 91      STA &91\n     5506   A5 92      LDA &92\n     5508   48         PHA\n     5509   49 FF      EOR #&FF\n     550B   69 00      ADC #&00\n     550D   85 92      STA &92\n     550F   68         PLA\n.LL127\n     5510   45 3A      EOR &3A\n     5512   60         RTS\n.LL145\n     5513   A9 00      LDA #&00\n     5515   85 A1      STA &A1\n     5517   A5 36      LDA &36\n.LL147\n     5519   A2 BF      LDX #&BF\n     551B   05 38      ORA &38\n     551D   D0 06      BNE &5525\n     551F   E4 37      CPX &37\n     5521   90 02      BCC &5525\n     5523   A2 00      LDX #&00\n.LL107\n     5525   86 98      STX &98\n     5527   A5 32      LDA &32\n     5529   05 34      ORA &34\n     552B   D0 1C      BNE &5549\n     552D   A9 BF      LDA #&BF\n     552F   C5 33      CMP &33\n     5531   90 16      BCC &5549\n     5533   A5 98      LDA &98\n     5535   D0 10      BNE &5547\n.LL146\n     5537   A5 33      LDA &33\n     5539   85 32      STA &32\n     553B   A5 35      LDA &35\n     553D   85 33      STA &33\n     553F   A5 37      LDA &37\n     5541   85 34      STA &34\n     5543   18         CLC\n     5544   60         RTS\n.LL109\n     5545   38         SEC\n     5546   60         RTS\n.LL108\n     5547   46 98      LSR &98\n.LL83\n     5549   A5 98      LDA &98\n     554B   10 2F      BPL &557C\n     554D   A5 32      LDA &32\n     554F   25 36      AND &36\n     5551   30 F2      BMI &5545\n     5553   A5 34      LDA &34\n     5555   25 38      AND &38\n     5557   30 EC      BMI &5545\n     5559   A6 32      LDX &32\n     555B   CA         DEX\n     555C   8A         TXA\n     555D   A6 36      LDX &36\n     555F   CA         DEX\n     5560   86 39      STX &39\n     5562   05 39      ORA &39\n     5564   10 DF      BPL &5545\n     5566   A5 33      LDA &33\n     5568   C9 C0      CMP #&C0\n     556A   A5 34      LDA &34\n     556C   E9 00      SBC #&00\n     556E   85 39      STA &39\n     5570   A5 37      LDA &37\n     5572   C9 C0      CMP #&C0\n     5574   A5 38      LDA &38\n     5576   E9 00      SBC #&00\n     5578   05 39      ORA &39\n     557A   10 C9      BPL &5545\n.LL115\n     557C   98         TYA\n     557D   48         PHA\n     557E   A5 35      LDA &35\n     5580   38         SEC\n     5581   E5 31      SBC &31\n     5583   85 39      STA &39\n     5585   A5 36      LDA &36\n     5587   E5 32      SBC &32\n     5589   85 3A      STA &3A\n     558B   A5 37      LDA &37\n     558D   38         SEC\n     558E   E5 33      SBC &33\n     5590   85 3B      STA &3B\n     5592   A5 38      LDA &38\n     5594   E5 34      SBC &34\n     5596   85 3C      STA &3C\n     5598   45 3A      EOR &3A\n     559A   85 92      STA &92\n     559C   A5 3C      LDA &3C\n     559E   10 0D      BPL &55AD\n     55A0   A9 00      LDA #&00\n     55A2   38         SEC\n     55A3   E5 3B      SBC &3B\n     55A5   85 3B      STA &3B\n     55A7   A9 00      LDA #&00\n     55A9   E5 3C      SBC &3C\n     55AB   85 3C      STA &3C\n.LL110\n     55AD   A5 3A      LDA &3A\n     55AF   10 0B      BPL &55BC\n     55B1   38         SEC\n     55B2   A9 00      LDA #&00\n     55B4   E5 39      SBC &39\n     55B6   85 39      STA &39\n     55B8   A9 00      LDA #&00\n     55BA   E5 3A      SBC &3A\n.LL111\n     55BC   AA         TAX\n     55BD   D0 04      BNE &55C3\n     55BF   A6 3C      LDX &3C\n     55C1   F0 0A      BEQ &55CD\n.LL112\n     55C3   4A         LSR A\n     55C4   66 39      ROR &39\n     55C6   46 3C      LSR &3C\n     55C8   66 3B      ROR &3B\n     55CA   4C BC 55   JMP &55BC\n.LL113\n     55CD   86 D1      STX &D1\n     55CF   A5 39      LDA &39\n     55D1   C5 3B      CMP &3B\n     55D3   90 0A      BCC &55DF\n     55D5   85 90      STA &90\n     55D7   A5 3B      LDA &3B\n     55D9   20 92 4D   JSR &4D92\n     55DC   4C EA 55   JMP &55EA\n.LL114\n     55DF   A5 3B      LDA &3B\n     55E1   85 90      STA &90\n     55E3   A5 39      LDA &39\n     55E5   20 92 4D   JSR &4D92\n     55E8   C6 D1      DEC &D1\n.LL116\n     55EA   A5 91      LDA &91\n     55EC   85 39      STA &39\n     55EE   A5 92      LDA &92\n     55F0   85 3A      STA &3A\n     55F2   A5 98      LDA &98\n     55F4   F0 02      BEQ &55F8\n     55F6   10 13      BPL &560B\n.LL138\n     55F8   20 12 54   JSR &5412\n     55FB   A5 98      LDA &98\n     55FD   10 31      BPL &5630\n.LL117\n     55FF   A5 32      LDA &32\n     5601   05 34      ORA &34\n     5603   D0 30      BNE &5635\n     5605   A5 33      LDA &33\n     5607   C9 C0      CMP #&C0\n     5609   B0 2A      BCS &5635\n.LLX117\n     560B   A6 31      LDX &31\n     560D   A5 35      LDA &35\n     560F   85 31      STA &31\n     5611   86 35      STX &35\n     5613   A5 36      LDA &36\n     5615   A6 32      LDX &32\n     5617   86 36      STX &36\n     5619   85 32      STA &32\n     561B   A6 33      LDX &33\n     561D   A5 37      LDA &37\n     561F   85 33      STA &33\n     5621   86 37      STX &37\n     5623   A5 38      LDA &38\n     5625   A6 34      LDX &34\n     5627   86 38      STX &38\n     5629   85 34      STA &34\n     562B   20 12 54   JSR &5412\n     562E   C6 A1      DEC &A1\n.LL124\n     5630   68         PLA\n     5631   A8         TAY\n     5632   4C 37 55   JMP &5537\n.LL137\n     5635   68         PLA\n     5636   A8         TAY\n     5637   38         SEC\n     5638   60         RTS\nELITE G\nAssembled at &4D15 \nEnds at &5639 \nCode size is &924 \nExecute at &1128 \nReload at &4EFD \nS.ELTG &4D15  &5639  &1128  &4EFD \nSaving file '3-assembled-output/ELTG.bin'\n.checksum0\n     5639\n.XX21\n     563A   54 56\n     563C   FC 56\n     563E   D6 57\n     5640   00 7F\n     5642   04 59\n     5644   8C 5A\n     5646   04 59\n     5648   A8 5B\n     564A   C4 5C\n     564C   C2 5D\n     564E   98 5E\n     5650   40 5F\n     5652   AC 5F\n.SHIP_SIDEWINDER\n     5654   00\n     5655   81 10\n     5657   50\n     5658   8C\n     5659   3D\n     565A   00\n     565B   1E\n     565C   3C\n     565D   0F\n     565E   32 00\n     5660   1C\n     5661   14\n     5662   46\n     5663   25\n     5664   00\n     5665   00\n     5666   02\n     5667   10\n.SHIP_SIDEWINDER_VERTICES\nMacro VERTEX:\n     5668   20\n     5669   00\n     566A   24\n     566B   9F\n     566C   10\n     566D   54\nEnd macro VERTEX\nMacro VERTEX:\n     566E   20\n     566F   00\n     5670   24\n     5671   1F\n     5672   20\n     5673   65\nEnd macro VERTEX\nMacro VERTEX:\n     5674   40\n     5675   00\n     5676   1C\n     5677   3F\n     5678   32\n     5679   66\nEnd macro VERTEX\nMacro VERTEX:\n     567A   40\n     567B   00\n     567C   1C\n     567D   BF\n     567E   31\n     567F   44\nEnd macro VERTEX\nMacro VERTEX:\n     5680   00\n     5681   10\n     5682   1C\n     5683   3F\n     5684   10\n     5685   32\nEnd macro VERTEX\nMacro VERTEX:\n     5686   00\n     5687   10\n     5688   1C\n     5689   7F\n     568A   43\n     568B   65\nEnd macro VERTEX\nMacro VERTEX:\n     568C   0C\n     568D   06\n     568E   1C\n     568F   AF\n     5690   33\n     5691   33\nEnd macro VERTEX\nMacro VERTEX:\n     5692   0C\n     5693   06\n     5694   1C\n     5695   2F\n     5696   33\n     5697   33\nEnd macro VERTEX\nMacro VERTEX:\n     5698   0C\n     5699   06\n     569A   1C\n     569B   6C\n     569C   33\n     569D   33\nEnd macro VERTEX\nMacro VERTEX:\n     569E   0C\n     569F   06\n     56A0   1C\n     56A1   EC\n     56A2   33\n     56A3   33\nEnd macro VERTEX\n.SHIP_SIDEWINDER_EDGES\nMacro EDGE:\n     56A4   1F\n     56A5   50\n     56A6   00\n     56A7   04\nEnd macro EDGE\nMacro EDGE:\n     56A8   1F\n     56A9   62\n     56AA   04\n     56AB   08\nEnd macro EDGE\nMacro EDGE:\n     56AC   1F\n     56AD   20\n     56AE   04\n     56AF   10\nEnd macro EDGE\nMacro EDGE:\n     56B0   1F\n     56B1   10\n     56B2   00\n     56B3   10\nEnd macro EDGE\nMacro EDGE:\n     56B4   1F\n     56B5   41\n     56B6   00\n     56B7   0C\nEnd macro EDGE\nMacro EDGE:\n     56B8   1F\n     56B9   31\n     56BA   0C\n     56BB   10\nEnd macro EDGE\nMacro EDGE:\n     56BC   1F\n     56BD   32\n     56BE   08\n     56BF   10\nEnd macro EDGE\nMacro EDGE:\n     56C0   1F\n     56C1   43\n     56C2   0C\n     56C3   14\nEnd macro EDGE\nMacro EDGE:\n     56C4   1F\n     56C5   63\n     56C6   08\n     56C7   14\nEnd macro EDGE\nMacro EDGE:\n     56C8   1F\n     56C9   65\n     56CA   04\n     56CB   14\nEnd macro EDGE\nMacro EDGE:\n     56CC   1F\n     56CD   54\n     56CE   00\n     56CF   14\nEnd macro EDGE\nMacro EDGE:\n     56D0   0F\n     56D1   33\n     56D2   18\n     56D3   1C\nEnd macro EDGE\nMacro EDGE:\n     56D4   0C\n     56D5   33\n     56D6   1C\n     56D7   20\nEnd macro EDGE\nMacro EDGE:\n     56D8   0C\n     56D9   33\n     56DA   18\n     56DB   24\nEnd macro EDGE\nMacro EDGE:\n     56DC   0C\n     56DD   33\n     56DE   20\n     56DF   24\nEnd macro EDGE\n.SHIP_SIDEWINDER_FACES\nMacro FACE:\n     56E0   1F\n     56E1   00\n     56E2   20\n     56E3   08\nEnd macro FACE\nMacro FACE:\n     56E4   9F\n     56E5   0C\n     56E6   2F\n     56E7   06\nEnd macro FACE\nMacro FACE:\n     56E8   1F\n     56E9   0C\n     56EA   2F\n     56EB   06\nEnd macro FACE\nMacro FACE:\n     56EC   3F\n     56ED   00\n     56EE   00\n     56EF   70\nEnd macro FACE\nMacro FACE:\n     56F0   DF\n     56F1   0C\n     56F2   2F\n     56F3   06\nEnd macro FACE\nMacro FACE:\n     56F4   5F\n     56F5   00\n     56F6   20\n     56F7   08\nEnd macro FACE\nMacro FACE:\n     56F8   5F\n     56F9   0C\n     56FA   2F\n     56FB   06\nEnd macro FACE\n.SHIP_VIPER\n     56FC   00\n     56FD   F9 15\n     56FF   6E\n     5700   BE\n     5701   4D\n     5702   00\n     5703   2A\n     5704   5A\n     5705   14\n     5706   00 00\n     5708   1C\n     5709   17\n     570A   78\n     570B   20\n     570C   00\n     570D   00\n     570E   01\n     570F   11\n.SHIP_VIPER_VERTICES\nMacro VERTEX:\n     5710   00\n     5711   00\n     5712   48\n     5713   1F\n     5714   21\n     5715   43\nEnd macro VERTEX\nMacro VERTEX:\n     5716   00\n     5717   10\n     5718   18\n     5719   1E\n     571A   10\n     571B   22\nEnd macro VERTEX\nMacro VERTEX:\n     571C   00\n     571D   10\n     571E   18\n     571F   5E\n     5720   43\n     5721   55\nEnd macro VERTEX\nMacro VERTEX:\n     5722   30\n     5723   00\n     5724   18\n     5725   3F\n     5726   42\n     5727   66\nEnd macro VERTEX\nMacro VERTEX:\n     5728   30\n     5729   00\n     572A   18\n     572B   BF\n     572C   31\n     572D   66\nEnd macro VERTEX\nMacro VERTEX:\n     572E   18\n     572F   10\n     5730   18\n     5731   7E\n     5732   54\n     5733   66\nEnd macro VERTEX\nMacro VERTEX:\n     5734   18\n     5735   10\n     5736   18\n     5737   FE\n     5738   35\n     5739   66\nEnd macro VERTEX\nMacro VERTEX:\n     573A   18\n     573B   10\n     573C   18\n     573D   3F\n     573E   20\n     573F   66\nEnd macro VERTEX\nMacro VERTEX:\n     5740   18\n     5741   10\n     5742   18\n     5743   BF\n     5744   10\n     5745   66\nEnd macro VERTEX\nMacro VERTEX:\n     5746   20\n     5747   00\n     5748   18\n     5749   B3\n     574A   66\n     574B   66\nEnd macro VERTEX\nMacro VERTEX:\n     574C   20\n     574D   00\n     574E   18\n     574F   33\n     5750   66\n     5751   66\nEnd macro VERTEX\nMacro VERTEX:\n     5752   08\n     5753   08\n     5754   18\n     5755   33\n     5756   66\n     5757   66\nEnd macro VERTEX\nMacro VERTEX:\n     5758   08\n     5759   08\n     575A   18\n     575B   B3\n     575C   66\n     575D   66\nEnd macro VERTEX\nMacro VERTEX:\n     575E   08\n     575F   08\n     5760   18\n     5761   F2\n     5762   66\n     5763   66\nEnd macro VERTEX\nMacro VERTEX:\n     5764   08\n     5765   08\n     5766   18\n     5767   72\n     5768   66\n     5769   66\nEnd macro VERTEX\n.SHIP_VIPER_EDGES\nMacro EDGE:\n     576A   1F\n     576B   42\n     576C   00\n     576D   0C\nEnd macro EDGE\nMacro EDGE:\n     576E   1E\n     576F   21\n     5770   00\n     5771   04\nEnd macro EDGE\nMacro EDGE:\n     5772   1E\n     5773   43\n     5774   00\n     5775   08\nEnd macro EDGE\nMacro EDGE:\n     5776   1F\n     5777   31\n     5778   00\n     5779   10\nEnd macro EDGE\nMacro EDGE:\n     577A   1E\n     577B   20\n     577C   04\n     577D   1C\nEnd macro EDGE\nMacro EDGE:\n     577E   1E\n     577F   10\n     5780   04\n     5781   20\nEnd macro EDGE\nMacro EDGE:\n     5782   1E\n     5783   54\n     5784   08\n     5785   14\nEnd macro EDGE\nMacro EDGE:\n     5786   1E\n     5787   53\n     5788   08\n     5789   18\nEnd macro EDGE\nMacro EDGE:\n     578A   1F\n     578B   60\n     578C   1C\n     578D   20\nEnd macro EDGE\nMacro EDGE:\n     578E   1E\n     578F   65\n     5790   14\n     5791   18\nEnd macro EDGE\nMacro EDGE:\n     5792   1F\n     5793   61\n     5794   10\n     5795   20\nEnd macro EDGE\nMacro EDGE:\n     5796   1E\n     5797   63\n     5798   10\n     5799   18\nEnd macro EDGE\nMacro EDGE:\n     579A   1F\n     579B   62\n     579C   0C\n     579D   1C\nEnd macro EDGE\nMacro EDGE:\n     579E   1E\n     579F   46\n     57A0   0C\n     57A1   14\nEnd macro EDGE\nMacro EDGE:\n     57A2   13\n     57A3   66\n     57A4   24\n     57A5   30\nEnd macro EDGE\nMacro EDGE:\n     57A6   12\n     57A7   66\n     57A8   24\n     57A9   34\nEnd macro EDGE\nMacro EDGE:\n     57AA   13\n     57AB   66\n     57AC   28\n     57AD   2C\nEnd macro EDGE\nMacro EDGE:\n     57AE   12\n     57AF   66\n     57B0   28\n     57B1   38\nEnd macro EDGE\nMacro EDGE:\n     57B2   10\n     57B3   66\n     57B4   2C\n     57B5   38\nEnd macro EDGE\nMacro EDGE:\n     57B6   10\n     57B7   66\n     57B8   30\n     57B9   34\nEnd macro EDGE\n.SHIP_VIPER_FACES\nMacro FACE:\n     57BA   1F\n     57BB   00\n     57BC   20\n     57BD   00\nEnd macro FACE\nMacro FACE:\n     57BE   9F\n     57BF   16\n     57C0   21\n     57C1   0B\nEnd macro FACE\nMacro FACE:\n     57C2   1F\n     57C3   16\n     57C4   21\n     57C5   0B\nEnd macro FACE\nMacro FACE:\n     57C6   DF\n     57C7   16\n     57C8   21\n     57C9   0B\nEnd macro FACE\nMacro FACE:\n     57CA   5F\n     57CB   16\n     57CC   21\n     57CD   0B\nEnd macro FACE\nMacro FACE:\n     57CE   5F\n     57CF   00\n     57D0   20\n     57D1   00\nEnd macro FACE\nMacro FACE:\n     57D2   3F\n     57D3   00\n     57D4   00\n     57D5   30\nEnd macro FACE\n.SHIP_MAMBA\n     57D6   01\n     57D7   24 13\n     57D9   AA\n     57DA   1A\n     57DB   5D\n     57DC   00\n     57DD   22\n     57DE   96\n     57DF   1C\n     57E0   96 00\n     57E2   14\n     57E3   19\n     57E4   5A\n     57E5   1E\n     57E6   00\n     57E7   01\n     57E8   02\n     57E9   12\n.SHIP_MAMBA_VERTICES\nMacro VERTEX:\n     57EA   00\n     57EB   00\n     57EC   40\n     57ED   1F\n     57EE   10\n     57EF   32\nEnd macro VERTEX\nMacro VERTEX:\n     57F0   40\n     57F1   08\n     57F2   20\n     57F3   FF\n     57F4   20\n     57F5   44\nEnd macro VERTEX\nMacro VERTEX:\n     57F6   20\n     57F7   08\n     57F8   20\n     57F9   BE\n     57FA   21\n     57FB   44\nEnd macro VERTEX\nMacro VERTEX:\n     57FC   20\n     57FD   08\n     57FE   20\n     57FF   3E\n     5800   31\n     5801   44\nEnd macro VERTEX\nMacro VERTEX:\n     5802   40\n     5803   08\n     5804   20\n     5805   7F\n     5806   30\n     5807   44\nEnd macro VERTEX\nMacro VERTEX:\n     5808   04\n     5809   04\n     580A   10\n     580B   8E\n     580C   11\n     580D   11\nEnd macro VERTEX\nMacro VERTEX:\n     580E   04\n     580F   04\n     5810   10\n     5811   0E\n     5812   11\n     5813   11\nEnd macro VERTEX\nMacro VERTEX:\n     5814   08\n     5815   03\n     5816   1C\n     5817   0D\n     5818   11\n     5819   11\nEnd macro VERTEX\nMacro VERTEX:\n     581A   08\n     581B   03\n     581C   1C\n     581D   8D\n     581E   11\n     581F   11\nEnd macro VERTEX\nMacro VERTEX:\n     5820   14\n     5821   04\n     5822   10\n     5823   D4\n     5824   00\n     5825   00\nEnd macro VERTEX\nMacro VERTEX:\n     5826   14\n     5827   04\n     5828   10\n     5829   54\n     582A   00\n     582B   00\nEnd macro VERTEX\nMacro VERTEX:\n     582C   18\n     582D   07\n     582E   14\n     582F   F4\n     5830   00\n     5831   00\nEnd macro VERTEX\nMacro VERTEX:\n     5832   10\n     5833   07\n     5834   14\n     5835   F0\n     5836   00\n     5837   00\nEnd macro VERTEX\nMacro VERTEX:\n     5838   10\n     5839   07\n     583A   14\n     583B   70\n     583C   00\n     583D   00\nEnd macro VERTEX\nMacro VERTEX:\n     583E   18\n     583F   07\n     5840   14\n     5841   74\n     5842   00\n     5843   00\nEnd macro VERTEX\nMacro VERTEX:\n     5844   08\n     5845   04\n     5846   20\n     5847   AD\n     5848   44\n     5849   44\nEnd macro VERTEX\nMacro VERTEX:\n     584A   08\n     584B   04\n     584C   20\n     584D   2D\n     584E   44\n     584F   44\nEnd macro VERTEX\nMacro VERTEX:\n     5850   08\n     5851   04\n     5852   20\n     5853   6E\n     5854   44\n     5855   44\nEnd macro VERTEX\nMacro VERTEX:\n     5856   08\n     5857   04\n     5858   20\n     5859   EE\n     585A   44\n     585B   44\nEnd macro VERTEX\nMacro VERTEX:\n     585C   20\n     585D   04\n     585E   20\n     585F   A7\n     5860   44\n     5861   44\nEnd macro VERTEX\nMacro VERTEX:\n     5862   20\n     5863   04\n     5864   20\n     5865   27\n     5866   44\n     5867   44\nEnd macro VERTEX\nMacro VERTEX:\n     5868   24\n     5869   04\n     586A   20\n     586B   67\n     586C   44\n     586D   44\nEnd macro VERTEX\nMacro VERTEX:\n     586E   24\n     586F   04\n     5870   20\n     5871   E7\n     5872   44\n     5873   44\nEnd macro VERTEX\nMacro VERTEX:\n     5874   26\n     5875   00\n     5876   20\n     5877   A5\n     5878   44\n     5879   44\nEnd macro VERTEX\nMacro VERTEX:\n     587A   26\n     587B   00\n     587C   20\n     587D   25\n     587E   44\n     587F   44\nEnd macro VERTEX\n.SHIP_MAMBA_EDGES\nMacro EDGE:\n     5880   1F\n     5881   20\n     5882   00\n     5883   04\nEnd macro EDGE\nMacro EDGE:\n     5884   1F\n     5885   30\n     5886   00\n     5887   10\nEnd macro EDGE\nMacro EDGE:\n     5888   1F\n     5889   40\n     588A   04\n     588B   10\nEnd macro EDGE\nMacro EDGE:\n     588C   1E\n     588D   42\n     588E   04\n     588F   08\nEnd macro EDGE\nMacro EDGE:\n     5890   1E\n     5891   41\n     5892   08\n     5893   0C\nEnd macro EDGE\nMacro EDGE:\n     5894   1E\n     5895   43\n     5896   0C\n     5897   10\nEnd macro EDGE\nMacro EDGE:\n     5898   0E\n     5899   11\n     589A   14\n     589B   18\nEnd macro EDGE\nMacro EDGE:\n     589C   0C\n     589D   11\n     589E   18\n     589F   1C\nEnd macro EDGE\nMacro EDGE:\n     58A0   0D\n     58A1   11\n     58A2   1C\n     58A3   20\nEnd macro EDGE\nMacro EDGE:\n     58A4   0C\n     58A5   11\n     58A6   14\n     58A7   20\nEnd macro EDGE\nMacro EDGE:\n     58A8   14\n     58A9   00\n     58AA   24\n     58AB   2C\nEnd macro EDGE\nMacro EDGE:\n     58AC   10\n     58AD   00\n     58AE   24\n     58AF   30\nEnd macro EDGE\nMacro EDGE:\n     58B0   10\n     58B1   00\n     58B2   28\n     58B3   34\nEnd macro EDGE\nMacro EDGE:\n     58B4   14\n     58B5   00\n     58B6   28\n     58B7   38\nEnd macro EDGE\nMacro EDGE:\n     58B8   0E\n     58B9   00\n     58BA   34\n     58BB   38\nEnd macro EDGE\nMacro EDGE:\n     58BC   0E\n     58BD   00\n     58BE   2C\n     58BF   30\nEnd macro EDGE\nMacro EDGE:\n     58C0   0D\n     58C1   44\n     58C2   3C\n     58C3   40\nEnd macro EDGE\nMacro EDGE:\n     58C4   0E\n     58C5   44\n     58C6   44\n     58C7   48\nEnd macro EDGE\nMacro EDGE:\n     58C8   0C\n     58C9   44\n     58CA   3C\n     58CB   48\nEnd macro EDGE\nMacro EDGE:\n     58CC   0C\n     58CD   44\n     58CE   40\n     58CF   44\nEnd macro EDGE\nMacro EDGE:\n     58D0   07\n     58D1   44\n     58D2   50\n     58D3   54\nEnd macro EDGE\nMacro EDGE:\n     58D4   05\n     58D5   44\n     58D6   50\n     58D7   60\nEnd macro EDGE\nMacro EDGE:\n     58D8   05\n     58D9   44\n     58DA   54\n     58DB   60\nEnd macro EDGE\nMacro EDGE:\n     58DC   07\n     58DD   44\n     58DE   4C\n     58DF   58\nEnd macro EDGE\nMacro EDGE:\n     58E0   05\n     58E1   44\n     58E2   4C\n     58E3   5C\nEnd macro EDGE\nMacro EDGE:\n     58E4   05\n     58E5   44\n     58E6   58\n     58E7   5C\nEnd macro EDGE\nMacro EDGE:\n     58E8   1E\n     58E9   21\n     58EA   00\n     58EB   08\nEnd macro EDGE\nMacro EDGE:\n     58EC   1E\n     58ED   31\n     58EE   00\n     58EF   0C\nEnd macro EDGE\n.SHIP_MAMBA_FACES\nMacro FACE:\n     58F0   5E\n     58F1   00\n     58F2   18\n     58F3   02\nEnd macro FACE\nMacro FACE:\n     58F4   1E\n     58F5   00\n     58F6   18\n     58F7   02\nEnd macro FACE\nMacro FACE:\n     58F8   9E\n     58F9   20\n     58FA   40\n     58FB   10\nEnd macro FACE\nMacro FACE:\n     58FC   1E\n     58FD   20\n     58FE   40\n     58FF   10\nEnd macro FACE\nMacro FACE:\n     5900   3E\n     5901   00\n     5902   00\n     5903   7F\nEnd macro FACE\n.SHIP_COBRA_MK_3\n     5904   03\n     5905   41 23\n     5907   BC\n     5908   54\n     5909   99\n     590A   54\n     590B   2A\n     590C   A8\n     590D   26\n     590E   00 00\n     5910   34\n     5911   32\n     5912   96\n     5913   1C\n     5914   00\n     5915   01\n     5916   01\n     5917   13\n.SHIP_COBRA_MK_3_VERTICES\nMacro VERTEX:\n     5918   20\n     5919   00\n     591A   4C\n     591B   1F\n     591C   FF\n     591D   FF\nEnd macro VERTEX\nMacro VERTEX:\n     591E   20\n     591F   00\n     5920   4C\n     5921   9F\n     5922   FF\n     5923   FF\nEnd macro VERTEX\nMacro VERTEX:\n     5924   00\n     5925   1A\n     5926   18\n     5927   1F\n     5928   FF\n     5929   FF\nEnd macro VERTEX\nMacro VERTEX:\n     592A   78\n     592B   03\n     592C   08\n     592D   FF\n     592E   73\n     592F   AA\nEnd macro VERTEX\nMacro VERTEX:\n     5930   78\n     5931   03\n     5932   08\n     5933   7F\n     5934   84\n     5935   CC\nEnd macro VERTEX\nMacro VERTEX:\n     5936   58\n     5937   10\n     5938   28\n     5939   BF\n     593A   FF\n     593B   FF\nEnd macro VERTEX\nMacro VERTEX:\n     593C   58\n     593D   10\n     593E   28\n     593F   3F\n     5940   FF\n     5941   FF\nEnd macro VERTEX\nMacro VERTEX:\n     5942   80\n     5943   08\n     5944   28\n     5945   7F\n     5946   98\n     5947   CC\nEnd macro VERTEX\nMacro VERTEX:\n     5948   80\n     5949   08\n     594A   28\n     594B   FF\n     594C   97\n     594D   AA\nEnd macro VERTEX\nMacro VERTEX:\n     594E   00\n     594F   1A\n     5950   28\n     5951   3F\n     5952   65\n     5953   99\nEnd macro VERTEX\nMacro VERTEX:\n     5954   20\n     5955   18\n     5956   28\n     5957   FF\n     5958   A9\n     5959   BB\nEnd macro VERTEX\nMacro VERTEX:\n     595A   20\n     595B   18\n     595C   28\n     595D   7F\n     595E   B9\n     595F   CC\nEnd macro VERTEX\nMacro VERTEX:\n     5960   24\n     5961   08\n     5962   28\n     5963   B4\n     5964   99\n     5965   99\nEnd macro VERTEX\nMacro VERTEX:\n     5966   08\n     5967   0C\n     5968   28\n     5969   B4\n     596A   99\n     596B   99\nEnd macro VERTEX\nMacro VERTEX:\n     596C   08\n     596D   0C\n     596E   28\n     596F   34\n     5970   99\n     5971   99\nEnd macro VERTEX\nMacro VERTEX:\n     5972   24\n     5973   08\n     5974   28\n     5975   34\n     5976   99\n     5977   99\nEnd macro VERTEX\nMacro VERTEX:\n     5978   24\n     5979   0C\n     597A   28\n     597B   74\n     597C   99\n     597D   99\nEnd macro VERTEX\nMacro VERTEX:\n     597E   08\n     597F   10\n     5980   28\n     5981   74\n     5982   99\n     5983   99\nEnd macro VERTEX\nMacro VERTEX:\n     5984   08\n     5985   10\n     5986   28\n     5987   F4\n     5988   99\n     5989   99\nEnd macro VERTEX\nMacro VERTEX:\n     598A   24\n     598B   0C\n     598C   28\n     598D   F4\n     598E   99\n     598F   99\nEnd macro VERTEX\nMacro VERTEX:\n     5990   00\n     5991   00\n     5992   4C\n     5993   06\n     5994   B0\n     5995   BB\nEnd macro VERTEX\nMacro VERTEX:\n     5996   00\n     5997   00\n     5998   5A\n     5999   1F\n     599A   B0\n     599B   BB\nEnd macro VERTEX\nMacro VERTEX:\n     599C   50\n     599D   06\n     599E   28\n     599F   E8\n     59A0   99\n     59A1   99\nEnd macro VERTEX\nMacro VERTEX:\n     59A2   50\n     59A3   06\n     59A4   28\n     59A5   A8\n     59A6   99\n     59A7   99\nEnd macro VERTEX\nMacro VERTEX:\n     59A8   58\n     59A9   00\n     59AA   28\n     59AB   A6\n     59AC   99\n     59AD   99\nEnd macro VERTEX\nMacro VERTEX:\n     59AE   50\n     59AF   06\n     59B0   28\n     59B1   28\n     59B2   99\n     59B3   99\nEnd macro VERTEX\nMacro VERTEX:\n     59B4   58\n     59B5   00\n     59B6   28\n     59B7   26\n     59B8   99\n     59B9   99\nEnd macro VERTEX\nMacro VERTEX:\n     59BA   50\n     59BB   06\n     59BC   28\n     59BD   68\n     59BE   99\n     59BF   99\nEnd macro VERTEX\n.SHIP_COBRA_MK_3_EDGES\nMacro EDGE:\n     59C0   1F\n     59C1   B0\n     59C2   00\n     59C3   04\nEnd macro EDGE\nMacro EDGE:\n     59C4   1F\n     59C5   C4\n     59C6   00\n     59C7   10\nEnd macro EDGE\nMacro EDGE:\n     59C8   1F\n     59C9   A3\n     59CA   04\n     59CB   0C\nEnd macro EDGE\nMacro EDGE:\n     59CC   1F\n     59CD   A7\n     59CE   0C\n     59CF   20\nEnd macro EDGE\nMacro EDGE:\n     59D0   1F\n     59D1   C8\n     59D2   10\n     59D3   1C\nEnd macro EDGE\nMacro EDGE:\n     59D4   1F\n     59D5   98\n     59D6   18\n     59D7   1C\nEnd macro EDGE\nMacro EDGE:\n     59D8   1F\n     59D9   96\n     59DA   18\n     59DB   24\nEnd macro EDGE\nMacro EDGE:\n     59DC   1F\n     59DD   95\n     59DE   14\n     59DF   24\nEnd macro EDGE\nMacro EDGE:\n     59E0   1F\n     59E1   97\n     59E2   14\n     59E3   20\nEnd macro EDGE\nMacro EDGE:\n     59E4   1F\n     59E5   51\n     59E6   08\n     59E7   14\nEnd macro EDGE\nMacro EDGE:\n     59E8   1F\n     59E9   62\n     59EA   08\n     59EB   18\nEnd macro EDGE\nMacro EDGE:\n     59EC   1F\n     59ED   73\n     59EE   0C\n     59EF   14\nEnd macro EDGE\nMacro EDGE:\n     59F0   1F\n     59F1   84\n     59F2   10\n     59F3   18\nEnd macro EDGE\nMacro EDGE:\n     59F4   1F\n     59F5   10\n     59F6   04\n     59F7   08\nEnd macro EDGE\nMacro EDGE:\n     59F8   1F\n     59F9   20\n     59FA   00\n     59FB   08\nEnd macro EDGE\nMacro EDGE:\n     59FC   1F\n     59FD   A9\n     59FE   20\n     59FF   28\nEnd macro EDGE\nMacro EDGE:\n     5A00   1F\n     5A01   B9\n     5A02   28\n     5A03   2C\nEnd macro EDGE\nMacro EDGE:\n     5A04   1F\n     5A05   C9\n     5A06   1C\n     5A07   2C\nEnd macro EDGE\nMacro EDGE:\n     5A08   1F\n     5A09   BA\n     5A0A   04\n     5A0B   28\nEnd macro EDGE\nMacro EDGE:\n     5A0C   1F\n     5A0D   CB\n     5A0E   00\n     5A0F   2C\nEnd macro EDGE\nMacro EDGE:\n     5A10   1D\n     5A11   31\n     5A12   04\n     5A13   14\nEnd macro EDGE\nMacro EDGE:\n     5A14   1D\n     5A15   42\n     5A16   00\n     5A17   18\nEnd macro EDGE\nMacro EDGE:\n     5A18   06\n     5A19   B0\n     5A1A   50\n     5A1B   54\nEnd macro EDGE\nMacro EDGE:\n     5A1C   14\n     5A1D   99\n     5A1E   30\n     5A1F   34\nEnd macro EDGE\nMacro EDGE:\n     5A20   14\n     5A21   99\n     5A22   48\n     5A23   4C\nEnd macro EDGE\nMacro EDGE:\n     5A24   14\n     5A25   99\n     5A26   38\n     5A27   3C\nEnd macro EDGE\nMacro EDGE:\n     5A28   14\n     5A29   99\n     5A2A   40\n     5A2B   44\nEnd macro EDGE\nMacro EDGE:\n     5A2C   13\n     5A2D   99\n     5A2E   3C\n     5A2F   40\nEnd macro EDGE\nMacro EDGE:\n     5A30   11\n     5A31   99\n     5A32   38\n     5A33   44\nEnd macro EDGE\nMacro EDGE:\n     5A34   13\n     5A35   99\n     5A36   34\n     5A37   48\nEnd macro EDGE\nMacro EDGE:\n     5A38   13\n     5A39   99\n     5A3A   30\n     5A3B   4C\nEnd macro EDGE\nMacro EDGE:\n     5A3C   1E\n     5A3D   65\n     5A3E   08\n     5A3F   24\nEnd macro EDGE\nMacro EDGE:\n     5A40   06\n     5A41   99\n     5A42   58\n     5A43   60\nEnd macro EDGE\nMacro EDGE:\n     5A44   06\n     5A45   99\n     5A46   5C\n     5A47   60\nEnd macro EDGE\nMacro EDGE:\n     5A48   08\n     5A49   99\n     5A4A   58\n     5A4B   5C\nEnd macro EDGE\nMacro EDGE:\n     5A4C   06\n     5A4D   99\n     5A4E   64\n     5A4F   68\nEnd macro EDGE\nMacro EDGE:\n     5A50   06\n     5A51   99\n     5A52   68\n     5A53   6C\nEnd macro EDGE\nMacro EDGE:\n     5A54   08\n     5A55   99\n     5A56   64\n     5A57   6C\nEnd macro EDGE\n.SHIP_COBRA_MK_3_FACES\nMacro FACE:\n     5A58   1F\n     5A59   00\n     5A5A   3E\n     5A5B   1F\nEnd macro FACE\nMacro FACE:\n     5A5C   9F\n     5A5D   12\n     5A5E   37\n     5A5F   10\nEnd macro FACE\nMacro FACE:\n     5A60   1F\n     5A61   12\n     5A62   37\n     5A63   10\nEnd macro FACE\nMacro FACE:\n     5A64   9F\n     5A65   10\n     5A66   34\n     5A67   0E\nEnd macro FACE\nMacro FACE:\n     5A68   1F\n     5A69   10\n     5A6A   34\n     5A6B   0E\nEnd macro FACE\nMacro FACE:\n     5A6C   9F\n     5A6D   0E\n     5A6E   2F\n     5A6F   00\nEnd macro FACE\nMacro FACE:\n     5A70   1F\n     5A71   0E\n     5A72   2F\n     5A73   00\nEnd macro FACE\nMacro FACE:\n     5A74   9F\n     5A75   3D\n     5A76   66\n     5A77   00\nEnd macro FACE\nMacro FACE:\n     5A78   1F\n     5A79   3D\n     5A7A   66\n     5A7B   00\nEnd macro FACE\nMacro FACE:\n     5A7C   3F\n     5A7D   00\n     5A7E   00\n     5A7F   50\nEnd macro FACE\nMacro FACE:\n     5A80   DF\n     5A81   07\n     5A82   2A\n     5A83   09\nEnd macro FACE\nMacro FACE:\n     5A84   5F\n     5A85   00\n     5A86   1E\n     5A87   06\nEnd macro FACE\nMacro FACE:\n     5A88   5F\n     5A89   07\n     5A8A   2A\n     5A8B   09\nEnd macro FACE\n.SHIP_THARGOID\n     5A8C   00\n     5A8D   49 26\n     5A8F   8C\n     5A90   F4\n     5A91   65\n     5A92   3C\n     5A93   26\n     5A94   78\n     5A95   1A\n     5A96   F4 01\n     5A98   28\n     5A99   37\n     5A9A   F0\n     5A9B   27\n     5A9C   00\n     5A9D   00\n     5A9E   02\n     5A9F   16\n.SHIP_THARGOID_VERTICES\nMacro VERTEX:\n     5AA0   20\n     5AA1   30\n     5AA2   30\n     5AA3   5F\n     5AA4   40\n     5AA5   88\nEnd macro VERTEX\nMacro VERTEX:\n     5AA6   20\n     5AA7   44\n     5AA8   00\n     5AA9   5F\n     5AAA   10\n     5AAB   44\nEnd macro VERTEX\nMacro VERTEX:\n     5AAC   20\n     5AAD   30\n     5AAE   30\n     5AAF   7F\n     5AB0   21\n     5AB1   44\nEnd macro VERTEX\nMacro VERTEX:\n     5AB2   20\n     5AB3   00\n     5AB4   44\n     5AB5   3F\n     5AB6   32\n     5AB7   44\nEnd macro VERTEX\nMacro VERTEX:\n     5AB8   20\n     5AB9   30\n     5ABA   30\n     5ABB   3F\n     5ABC   43\n     5ABD   55\nEnd macro VERTEX\nMacro VERTEX:\n     5ABE   20\n     5ABF   44\n     5AC0   00\n     5AC1   1F\n     5AC2   54\n     5AC3   66\nEnd macro VERTEX\nMacro VERTEX:\n     5AC4   20\n     5AC5   30\n     5AC6   30\n     5AC7   1F\n     5AC8   64\n     5AC9   77\nEnd macro VERTEX\nMacro VERTEX:\n     5ACA   20\n     5ACB   00\n     5ACC   44\n     5ACD   1F\n     5ACE   74\n     5ACF   88\nEnd macro VERTEX\nMacro VERTEX:\n     5AD0   18\n     5AD1   74\n     5AD2   74\n     5AD3   DF\n     5AD4   80\n     5AD5   99\nEnd macro VERTEX\nMacro VERTEX:\n     5AD6   18\n     5AD7   A4\n     5AD8   00\n     5AD9   DF\n     5ADA   10\n     5ADB   99\nEnd macro VERTEX\nMacro VERTEX:\n     5ADC   18\n     5ADD   74\n     5ADE   74\n     5ADF   FF\n     5AE0   21\n     5AE1   99\nEnd macro VERTEX\nMacro VERTEX:\n     5AE2   18\n     5AE3   00\n     5AE4   A4\n     5AE5   BF\n     5AE6   32\n     5AE7   99\nEnd macro VERTEX\nMacro VERTEX:\n     5AE8   18\n     5AE9   74\n     5AEA   74\n     5AEB   BF\n     5AEC   53\n     5AED   99\nEnd macro VERTEX\nMacro VERTEX:\n     5AEE   18\n     5AEF   A4\n     5AF0   00\n     5AF1   9F\n     5AF2   65\n     5AF3   99\nEnd macro VERTEX\nMacro VERTEX:\n     5AF4   18\n     5AF5   74\n     5AF6   74\n     5AF7   9F\n     5AF8   76\n     5AF9   99\nEnd macro VERTEX\nMacro VERTEX:\n     5AFA   18\n     5AFB   00\n     5AFC   A4\n     5AFD   9F\n     5AFE   87\n     5AFF   99\nEnd macro VERTEX\nMacro VERTEX:\n     5B00   18\n     5B01   40\n     5B02   50\n     5B03   9E\n     5B04   99\n     5B05   99\nEnd macro VERTEX\nMacro VERTEX:\n     5B06   18\n     5B07   40\n     5B08   50\n     5B09   BE\n     5B0A   99\n     5B0B   99\nEnd macro VERTEX\nMacro VERTEX:\n     5B0C   18\n     5B0D   40\n     5B0E   50\n     5B0F   FE\n     5B10   99\n     5B11   99\nEnd macro VERTEX\nMacro VERTEX:\n     5B12   18\n     5B13   40\n     5B14   50\n     5B15   DE\n     5B16   99\n     5B17   99\nEnd macro VERTEX\n.SHIP_THARGOID_EDGES\nMacro EDGE:\n     5B18   1F\n     5B19   84\n     5B1A   00\n     5B1B   1C\nEnd macro EDGE\nMacro EDGE:\n     5B1C   1F\n     5B1D   40\n     5B1E   00\n     5B1F   04\nEnd macro EDGE\nMacro EDGE:\n     5B20   1F\n     5B21   41\n     5B22   04\n     5B23   08\nEnd macro EDGE\nMacro EDGE:\n     5B24   1F\n     5B25   42\n     5B26   08\n     5B27   0C\nEnd macro EDGE\nMacro EDGE:\n     5B28   1F\n     5B29   43\n     5B2A   0C\n     5B2B   10\nEnd macro EDGE\nMacro EDGE:\n     5B2C   1F\n     5B2D   54\n     5B2E   10\n     5B2F   14\nEnd macro EDGE\nMacro EDGE:\n     5B30   1F\n     5B31   64\n     5B32   14\n     5B33   18\nEnd macro EDGE\nMacro EDGE:\n     5B34   1F\n     5B35   74\n     5B36   18\n     5B37   1C\nEnd macro EDGE\nMacro EDGE:\n     5B38   1F\n     5B39   80\n     5B3A   00\n     5B3B   20\nEnd macro EDGE\nMacro EDGE:\n     5B3C   1F\n     5B3D   10\n     5B3E   04\n     5B3F   24\nEnd macro EDGE\nMacro EDGE:\n     5B40   1F\n     5B41   21\n     5B42   08\n     5B43   28\nEnd macro EDGE\nMacro EDGE:\n     5B44   1F\n     5B45   32\n     5B46   0C\n     5B47   2C\nEnd macro EDGE\nMacro EDGE:\n     5B48   1F\n     5B49   53\n     5B4A   10\n     5B4B   30\nEnd macro EDGE\nMacro EDGE:\n     5B4C   1F\n     5B4D   65\n     5B4E   14\n     5B4F   34\nEnd macro EDGE\nMacro EDGE:\n     5B50   1F\n     5B51   76\n     5B52   18\n     5B53   38\nEnd macro EDGE\nMacro EDGE:\n     5B54   1F\n     5B55   87\n     5B56   1C\n     5B57   3C\nEnd macro EDGE\nMacro EDGE:\n     5B58   1F\n     5B59   98\n     5B5A   20\n     5B5B   3C\nEnd macro EDGE\nMacro EDGE:\n     5B5C   1F\n     5B5D   90\n     5B5E   20\n     5B5F   24\nEnd macro EDGE\nMacro EDGE:\n     5B60   1F\n     5B61   91\n     5B62   24\n     5B63   28\nEnd macro EDGE\nMacro EDGE:\n     5B64   1F\n     5B65   92\n     5B66   28\n     5B67   2C\nEnd macro EDGE\nMacro EDGE:\n     5B68   1F\n     5B69   93\n     5B6A   2C\n     5B6B   30\nEnd macro EDGE\nMacro EDGE:\n     5B6C   1F\n     5B6D   95\n     5B6E   30\n     5B6F   34\nEnd macro EDGE\nMacro EDGE:\n     5B70   1F\n     5B71   96\n     5B72   34\n     5B73   38\nEnd macro EDGE\nMacro EDGE:\n     5B74   1F\n     5B75   97\n     5B76   38\n     5B77   3C\nEnd macro EDGE\nMacro EDGE:\n     5B78   1E\n     5B79   99\n     5B7A   40\n     5B7B   44\nEnd macro EDGE\nMacro EDGE:\n     5B7C   1E\n     5B7D   99\n     5B7E   48\n     5B7F   4C\nEnd macro EDGE\n.SHIP_THARGOID_FACES\nMacro FACE:\n     5B80   5F\n     5B81   67\n     5B82   3C\n     5B83   19\nEnd macro FACE\nMacro FACE:\n     5B84   7F\n     5B85   67\n     5B86   3C\n     5B87   19\nEnd macro FACE\nMacro FACE:\n     5B88   7F\n     5B89   67\n     5B8A   19\n     5B8B   3C\nEnd macro FACE\nMacro FACE:\n     5B8C   3F\n     5B8D   67\n     5B8E   19\n     5B8F   3C\nEnd macro FACE\nMacro FACE:\n     5B90   1F\n     5B91   40\n     5B92   00\n     5B93   00\nEnd macro FACE\nMacro FACE:\n     5B94   3F\n     5B95   67\n     5B96   3C\n     5B97   19\nEnd macro FACE\nMacro FACE:\n     5B98   1F\n     5B99   67\n     5B9A   3C\n     5B9B   19\nEnd macro FACE\nMacro FACE:\n     5B9C   1F\n     5B9D   67\n     5B9E   19\n     5B9F   3C\nEnd macro FACE\nMacro FACE:\n     5BA0   5F\n     5BA1   67\n     5BA2   19\n     5BA3   3C\nEnd macro FACE\nMacro FACE:\n     5BA4   9F\n     5BA5   30\n     5BA6   00\n     5BA7   00\nEnd macro FACE\n.SHIP_CORIOLIS\n     5BA8   00\n     5BA9   00 64\n     5BAB   74\n     5BAC   E4\n     5BAD   55\n     5BAE   00\n     5BAF   36\n     5BB0   60\n     5BB1   1C\n     5BB2   00 00\n     5BB4   38\n     5BB5   78\n     5BB6   F0\n     5BB7   00\n     5BB8   00\n     5BB9   00\n     5BBA   00\n     5BBB   06\n.SHIP_CORIOLIS_VERTICES\nMacro VERTEX:\n     5BBC   A0\n     5BBD   00\n     5BBE   A0\n     5BBF   1F\n     5BC0   10\n     5BC1   62\nEnd macro VERTEX\nMacro VERTEX:\n     5BC2   00\n     5BC3   A0\n     5BC4   A0\n     5BC5   1F\n     5BC6   20\n     5BC7   83\nEnd macro VERTEX\nMacro VERTEX:\n     5BC8   A0\n     5BC9   00\n     5BCA   A0\n     5BCB   9F\n     5BCC   30\n     5BCD   74\nEnd macro VERTEX\nMacro VERTEX:\n     5BCE   00\n     5BCF   A0\n     5BD0   A0\n     5BD1   5F\n     5BD2   10\n     5BD3   54\nEnd macro VERTEX\nMacro VERTEX:\n     5BD4   A0\n     5BD5   A0\n     5BD6   00\n     5BD7   5F\n     5BD8   51\n     5BD9   A6\nEnd macro VERTEX\nMacro VERTEX:\n     5BDA   A0\n     5BDB   A0\n     5BDC   00\n     5BDD   1F\n     5BDE   62\n     5BDF   B8\nEnd macro VERTEX\nMacro VERTEX:\n     5BE0   A0\n     5BE1   A0\n     5BE2   00\n     5BE3   9F\n     5BE4   73\n     5BE5   C8\nEnd macro VERTEX\nMacro VERTEX:\n     5BE6   A0\n     5BE7   A0\n     5BE8   00\n     5BE9   DF\n     5BEA   54\n     5BEB   97\nEnd macro VERTEX\nMacro VERTEX:\n     5BEC   A0\n     5BED   00\n     5BEE   A0\n     5BEF   3F\n     5BF0   A6\n     5BF1   DB\nEnd macro VERTEX\nMacro VERTEX:\n     5BF2   00\n     5BF3   A0\n     5BF4   A0\n     5BF5   3F\n     5BF6   B8\n     5BF7   DC\nEnd macro VERTEX\nMacro VERTEX:\n     5BF8   A0\n     5BF9   00\n     5BFA   A0\n     5BFB   BF\n     5BFC   97\n     5BFD   DC\nEnd macro VERTEX\nMacro VERTEX:\n     5BFE   00\n     5BFF   A0\n     5C00   A0\n     5C01   7F\n     5C02   95\n     5C03   DA\nEnd macro VERTEX\nMacro VERTEX:\n     5C04   0A\n     5C05   1E\n     5C06   A0\n     5C07   5E\n     5C08   00\n     5C09   00\nEnd macro VERTEX\nMacro VERTEX:\n     5C0A   0A\n     5C0B   1E\n     5C0C   A0\n     5C0D   1E\n     5C0E   00\n     5C0F   00\nEnd macro VERTEX\nMacro VERTEX:\n     5C10   0A\n     5C11   1E\n     5C12   A0\n     5C13   9E\n     5C14   00\n     5C15   00\nEnd macro VERTEX\nMacro VERTEX:\n     5C16   0A\n     5C17   1E\n     5C18   A0\n     5C19   DE\n     5C1A   00\n     5C1B   00\nEnd macro VERTEX\n.SHIP_CORIOLIS_EDGES\nMacro EDGE:\n     5C1C   1F\n     5C1D   10\n     5C1E   00\n     5C1F   0C\nEnd macro EDGE\nMacro EDGE:\n     5C20   1F\n     5C21   20\n     5C22   00\n     5C23   04\nEnd macro EDGE\nMacro EDGE:\n     5C24   1F\n     5C25   30\n     5C26   04\n     5C27   08\nEnd macro EDGE\nMacro EDGE:\n     5C28   1F\n     5C29   40\n     5C2A   08\n     5C2B   0C\nEnd macro EDGE\nMacro EDGE:\n     5C2C   1F\n     5C2D   51\n     5C2E   0C\n     5C2F   10\nEnd macro EDGE\nMacro EDGE:\n     5C30   1F\n     5C31   61\n     5C32   00\n     5C33   10\nEnd macro EDGE\nMacro EDGE:\n     5C34   1F\n     5C35   62\n     5C36   00\n     5C37   14\nEnd macro EDGE\nMacro EDGE:\n     5C38   1F\n     5C39   82\n     5C3A   14\n     5C3B   04\nEnd macro EDGE\nMacro EDGE:\n     5C3C   1F\n     5C3D   83\n     5C3E   04\n     5C3F   18\nEnd macro EDGE\nMacro EDGE:\n     5C40   1F\n     5C41   73\n     5C42   08\n     5C43   18\nEnd macro EDGE\nMacro EDGE:\n     5C44   1F\n     5C45   74\n     5C46   08\n     5C47   1C\nEnd macro EDGE\nMacro EDGE:\n     5C48   1F\n     5C49   54\n     5C4A   0C\n     5C4B   1C\nEnd macro EDGE\nMacro EDGE:\n     5C4C   1F\n     5C4D   DA\n     5C4E   20\n     5C4F   2C\nEnd macro EDGE\nMacro EDGE:\n     5C50   1F\n     5C51   DB\n     5C52   20\n     5C53   24\nEnd macro EDGE\nMacro EDGE:\n     5C54   1F\n     5C55   DC\n     5C56   24\n     5C57   28\nEnd macro EDGE\nMacro EDGE:\n     5C58   1F\n     5C59   D9\n     5C5A   28\n     5C5B   2C\nEnd macro EDGE\nMacro EDGE:\n     5C5C   1F\n     5C5D   A5\n     5C5E   10\n     5C5F   2C\nEnd macro EDGE\nMacro EDGE:\n     5C60   1F\n     5C61   A6\n     5C62   10\n     5C63   20\nEnd macro EDGE\nMacro EDGE:\n     5C64   1F\n     5C65   B6\n     5C66   14\n     5C67   20\nEnd macro EDGE\nMacro EDGE:\n     5C68   1F\n     5C69   B8\n     5C6A   14\n     5C6B   24\nEnd macro EDGE\nMacro EDGE:\n     5C6C   1F\n     5C6D   C8\n     5C6E   18\n     5C6F   24\nEnd macro EDGE\nMacro EDGE:\n     5C70   1F\n     5C71   C7\n     5C72   18\n     5C73   28\nEnd macro EDGE\nMacro EDGE:\n     5C74   1F\n     5C75   97\n     5C76   1C\n     5C77   28\nEnd macro EDGE\nMacro EDGE:\n     5C78   1F\n     5C79   95\n     5C7A   1C\n     5C7B   2C\nEnd macro EDGE\nMacro EDGE:\n     5C7C   1E\n     5C7D   00\n     5C7E   30\n     5C7F   34\nEnd macro EDGE\nMacro EDGE:\n     5C80   1E\n     5C81   00\n     5C82   34\n     5C83   38\nEnd macro EDGE\nMacro EDGE:\n     5C84   1E\n     5C85   00\n     5C86   38\n     5C87   3C\nEnd macro EDGE\nMacro EDGE:\n     5C88   1E\n     5C89   00\n     5C8A   3C\n     5C8B   30\nEnd macro EDGE\n.SHIP_CORIOLIS_FACES\nMacro FACE:\n     5C8C   1F\n     5C8D   00\n     5C8E   00\n     5C8F   A0\nEnd macro FACE\nMacro FACE:\n     5C90   5F\n     5C91   6B\n     5C92   6B\n     5C93   6B\nEnd macro FACE\nMacro FACE:\n     5C94   1F\n     5C95   6B\n     5C96   6B\n     5C97   6B\nEnd macro FACE\nMacro FACE:\n     5C98   9F\n     5C99   6B\n     5C9A   6B\n     5C9B   6B\nEnd macro FACE\nMacro FACE:\n     5C9C   DF\n     5C9D   6B\n     5C9E   6B\n     5C9F   6B\nEnd macro FACE\nMacro FACE:\n     5CA0   5F\n     5CA1   00\n     5CA2   A0\n     5CA3   00\nEnd macro FACE\nMacro FACE:\n     5CA4   1F\n     5CA5   A0\n     5CA6   00\n     5CA7   00\nEnd macro FACE\nMacro FACE:\n     5CA8   9F\n     5CA9   A0\n     5CAA   00\n     5CAB   00\nEnd macro FACE\nMacro FACE:\n     5CAC   1F\n     5CAD   00\n     5CAE   A0\n     5CAF   00\nEnd macro FACE\nMacro FACE:\n     5CB0   FF\n     5CB1   6B\n     5CB2   6B\n     5CB3   6B\nEnd macro FACE\nMacro FACE:\n     5CB4   7F\n     5CB5   6B\n     5CB6   6B\n     5CB7   6B\nEnd macro FACE\nMacro FACE:\n     5CB8   3F\n     5CB9   6B\n     5CBA   6B\n     5CBB   6B\nEnd macro FACE\nMacro FACE:\n     5CBC   BF\n     5CBD   6B\n     5CBE   6B\n     5CBF   6B\nEnd macro FACE\nMacro FACE:\n     5CC0   3F\n     5CC1   00\n     5CC2   00\n     5CC3   A0\nEnd macro FACE\n.SHIP_MISSILE\n     5CC4   00\n     5CC5   40 06\n     5CC7   7A\n     5CC8   DA\n     5CC9   51\n     5CCA   00\n     5CCB   0A\n     5CCC   66\n     5CCD   18\n     5CCE   00 00\n     5CD0   24\n     5CD1   0E\n     5CD2   02\n     5CD3   2C\n     5CD4   00\n     5CD5   00\n     5CD6   02\n     5CD7   00\n.SHIP_MISSILE_VERTICES\nMacro VERTEX:\n     5CD8   00\n     5CD9   00\n     5CDA   44\n     5CDB   1F\n     5CDC   10\n     5CDD   32\nEnd macro VERTEX\nMacro VERTEX:\n     5CDE   08\n     5CDF   08\n     5CE0   24\n     5CE1   5F\n     5CE2   21\n     5CE3   54\nEnd macro VERTEX\nMacro VERTEX:\n     5CE4   08\n     5CE5   08\n     5CE6   24\n     5CE7   1F\n     5CE8   32\n     5CE9   74\nEnd macro VERTEX\nMacro VERTEX:\n     5CEA   08\n     5CEB   08\n     5CEC   24\n     5CED   9F\n     5CEE   30\n     5CEF   76\nEnd macro VERTEX\nMacro VERTEX:\n     5CF0   08\n     5CF1   08\n     5CF2   24\n     5CF3   DF\n     5CF4   10\n     5CF5   65\nEnd macro VERTEX\nMacro VERTEX:\n     5CF6   08\n     5CF7   08\n     5CF8   2C\n     5CF9   3F\n     5CFA   74\n     5CFB   88\nEnd macro VERTEX\nMacro VERTEX:\n     5CFC   08\n     5CFD   08\n     5CFE   2C\n     5CFF   7F\n     5D00   54\n     5D01   88\nEnd macro VERTEX\nMacro VERTEX:\n     5D02   08\n     5D03   08\n     5D04   2C\n     5D05   FF\n     5D06   65\n     5D07   88\nEnd macro VERTEX\nMacro VERTEX:\n     5D08   08\n     5D09   08\n     5D0A   2C\n     5D0B   BF\n     5D0C   76\n     5D0D   88\nEnd macro VERTEX\nMacro VERTEX:\n     5D0E   0C\n     5D0F   0C\n     5D10   2C\n     5D11   28\n     5D12   74\n     5D13   88\nEnd macro VERTEX\nMacro VERTEX:\n     5D14   0C\n     5D15   0C\n     5D16   2C\n     5D17   68\n     5D18   54\n     5D19   88\nEnd macro VERTEX\nMacro VERTEX:\n     5D1A   0C\n     5D1B   0C\n     5D1C   2C\n     5D1D   E8\n     5D1E   65\n     5D1F   88\nEnd macro VERTEX\nMacro VERTEX:\n     5D20   0C\n     5D21   0C\n     5D22   2C\n     5D23   A8\n     5D24   76\n     5D25   88\nEnd macro VERTEX\nMacro VERTEX:\n     5D26   08\n     5D27   08\n     5D28   0C\n     5D29   A8\n     5D2A   76\n     5D2B   77\nEnd macro VERTEX\nMacro VERTEX:\n     5D2C   08\n     5D2D   08\n     5D2E   0C\n     5D2F   E8\n     5D30   65\n     5D31   66\nEnd macro VERTEX\nMacro VERTEX:\n     5D32   08\n     5D33   08\n     5D34   0C\n     5D35   28\n     5D36   74\n     5D37   77\nEnd macro VERTEX\nMacro VERTEX:\n     5D38   08\n     5D39   08\n     5D3A   0C\n     5D3B   68\n     5D3C   54\n     5D3D   55\nEnd macro VERTEX\n.SHIP_MISSILE_EDGES\nMacro EDGE:\n     5D3E   1F\n     5D3F   21\n     5D40   00\n     5D41   04\nEnd macro EDGE\nMacro EDGE:\n     5D42   1F\n     5D43   32\n     5D44   00\n     5D45   08\nEnd macro EDGE\nMacro EDGE:\n     5D46   1F\n     5D47   30\n     5D48   00\n     5D49   0C\nEnd macro EDGE\nMacro EDGE:\n     5D4A   1F\n     5D4B   10\n     5D4C   00\n     5D4D   10\nEnd macro EDGE\nMacro EDGE:\n     5D4E   1F\n     5D4F   24\n     5D50   04\n     5D51   08\nEnd macro EDGE\nMacro EDGE:\n     5D52   1F\n     5D53   51\n     5D54   04\n     5D55   10\nEnd macro EDGE\nMacro EDGE:\n     5D56   1F\n     5D57   60\n     5D58   0C\n     5D59   10\nEnd macro EDGE\nMacro EDGE:\n     5D5A   1F\n     5D5B   73\n     5D5C   08\n     5D5D   0C\nEnd macro EDGE\nMacro EDGE:\n     5D5E   1F\n     5D5F   74\n     5D60   08\n     5D61   14\nEnd macro EDGE\nMacro EDGE:\n     5D62   1F\n     5D63   54\n     5D64   04\n     5D65   18\nEnd macro EDGE\nMacro EDGE:\n     5D66   1F\n     5D67   65\n     5D68   10\n     5D69   1C\nEnd macro EDGE\nMacro EDGE:\n     5D6A   1F\n     5D6B   76\n     5D6C   0C\n     5D6D   20\nEnd macro EDGE\nMacro EDGE:\n     5D6E   1F\n     5D6F   86\n     5D70   1C\n     5D71   20\nEnd macro EDGE\nMacro EDGE:\n     5D72   1F\n     5D73   87\n     5D74   14\n     5D75   20\nEnd macro EDGE\nMacro EDGE:\n     5D76   1F\n     5D77   84\n     5D78   14\n     5D79   18\nEnd macro EDGE\nMacro EDGE:\n     5D7A   1F\n     5D7B   85\n     5D7C   18\n     5D7D   1C\nEnd macro EDGE\nMacro EDGE:\n     5D7E   08\n     5D7F   85\n     5D80   18\n     5D81   28\nEnd macro EDGE\nMacro EDGE:\n     5D82   08\n     5D83   87\n     5D84   14\n     5D85   24\nEnd macro EDGE\nMacro EDGE:\n     5D86   08\n     5D87   87\n     5D88   20\n     5D89   30\nEnd macro EDGE\nMacro EDGE:\n     5D8A   08\n     5D8B   85\n     5D8C   1C\n     5D8D   2C\nEnd macro EDGE\nMacro EDGE:\n     5D8E   08\n     5D8F   74\n     5D90   24\n     5D91   3C\nEnd macro EDGE\nMacro EDGE:\n     5D92   08\n     5D93   54\n     5D94   28\n     5D95   40\nEnd macro EDGE\nMacro EDGE:\n     5D96   08\n     5D97   76\n     5D98   30\n     5D99   34\nEnd macro EDGE\nMacro EDGE:\n     5D9A   08\n     5D9B   65\n     5D9C   2C\n     5D9D   38\nEnd macro EDGE\n.SHIP_MISSILE_FACES\nMacro FACE:\n     5D9E   9F\n     5D9F   40\n     5DA0   00\n     5DA1   10\nEnd macro FACE\nMacro FACE:\n     5DA2   5F\n     5DA3   00\n     5DA4   40\n     5DA5   10\nEnd macro FACE\nMacro FACE:\n     5DA6   1F\n     5DA7   40\n     5DA8   00\n     5DA9   10\nEnd macro FACE\nMacro FACE:\n     5DAA   1F\n     5DAB   00\n     5DAC   40\n     5DAD   10\nEnd macro FACE\nMacro FACE:\n     5DAE   1F\n     5DAF   20\n     5DB0   00\n     5DB1   00\nEnd macro FACE\nMacro FACE:\n     5DB2   5F\n     5DB3   00\n     5DB4   20\n     5DB5   00\nEnd macro FACE\nMacro FACE:\n     5DB6   9F\n     5DB7   20\n     5DB8   00\n     5DB9   00\nEnd macro FACE\nMacro FACE:\n     5DBA   1F\n     5DBB   00\n     5DBC   20\n     5DBD   00\nEnd macro FACE\nMacro FACE:\n     5DBE   3F\n     5DBF   00\n     5DC0   00\n     5DC1   B0\nEnd macro FACE\n.SHIP_ASTEROID\n     5DC2   00\n     5DC3   00 19\n     5DC5   4A\n     5DC6   9E\n     5DC7   41\n     5DC8   00\n     5DC9   22\n     5DCA   36\n     5DCB   15\n     5DCC   05 00\n     5DCE   38\n     5DCF   32\n     5DD0   3C\n     5DD1   1E\n     5DD2   00\n     5DD3   00\n     5DD4   01\n     5DD5   00\n.SHIP_ASTEROID_VERTICES\nMacro VERTEX:\n     5DD6   00\n     5DD7   50\n     5DD8   00\n     5DD9   1F\n     5DDA   FF\n     5DDB   FF\nEnd macro VERTEX\nMacro VERTEX:\n     5DDC   50\n     5DDD   0A\n     5DDE   00\n     5DDF   DF\n     5DE0   FF\n     5DE1   FF\nEnd macro VERTEX\nMacro VERTEX:\n     5DE2   00\n     5DE3   50\n     5DE4   00\n     5DE5   5F\n     5DE6   FF\n     5DE7   FF\nEnd macro VERTEX\nMacro VERTEX:\n     5DE8   46\n     5DE9   28\n     5DEA   00\n     5DEB   5F\n     5DEC   FF\n     5DED   FF\nEnd macro VERTEX\nMacro VERTEX:\n     5DEE   3C\n     5DEF   32\n     5DF0   00\n     5DF1   1F\n     5DF2   65\n     5DF3   DC\nEnd macro VERTEX\nMacro VERTEX:\n     5DF4   32\n     5DF5   00\n     5DF6   3C\n     5DF7   1F\n     5DF8   FF\n     5DF9   FF\nEnd macro VERTEX\nMacro VERTEX:\n     5DFA   28\n     5DFB   00\n     5DFC   46\n     5DFD   9F\n     5DFE   10\n     5DFF   32\nEnd macro VERTEX\nMacro VERTEX:\n     5E00   00\n     5E01   1E\n     5E02   4B\n     5E03   3F\n     5E04   FF\n     5E05   FF\nEnd macro VERTEX\nMacro VERTEX:\n     5E06   00\n     5E07   32\n     5E08   3C\n     5E09   7F\n     5E0A   98\n     5E0B   BA\nEnd macro VERTEX\n.SHIP_ASTEROID_EDGES\nMacro EDGE:\n     5E0C   1F\n     5E0D   72\n     5E0E   00\n     5E0F   04\nEnd macro EDGE\nMacro EDGE:\n     5E10   1F\n     5E11   D6\n     5E12   00\n     5E13   10\nEnd macro EDGE\nMacro EDGE:\n     5E14   1F\n     5E15   C5\n     5E16   0C\n     5E17   10\nEnd macro EDGE\nMacro EDGE:\n     5E18   1F\n     5E19   B4\n     5E1A   08\n     5E1B   0C\nEnd macro EDGE\nMacro EDGE:\n     5E1C   1F\n     5E1D   A3\n     5E1E   04\n     5E1F   08\nEnd macro EDGE\nMacro EDGE:\n     5E20   1F\n     5E21   32\n     5E22   04\n     5E23   18\nEnd macro EDGE\nMacro EDGE:\n     5E24   1F\n     5E25   31\n     5E26   08\n     5E27   18\nEnd macro EDGE\nMacro EDGE:\n     5E28   1F\n     5E29   41\n     5E2A   08\n     5E2B   14\nEnd macro EDGE\nMacro EDGE:\n     5E2C   1F\n     5E2D   10\n     5E2E   14\n     5E2F   18\nEnd macro EDGE\nMacro EDGE:\n     5E30   1F\n     5E31   60\n     5E32   00\n     5E33   14\nEnd macro EDGE\nMacro EDGE:\n     5E34   1F\n     5E35   54\n     5E36   0C\n     5E37   14\nEnd macro EDGE\nMacro EDGE:\n     5E38   1F\n     5E39   20\n     5E3A   00\n     5E3B   18\nEnd macro EDGE\nMacro EDGE:\n     5E3C   1F\n     5E3D   65\n     5E3E   10\n     5E3F   14\nEnd macro EDGE\nMacro EDGE:\n     5E40   1F\n     5E41   A8\n     5E42   04\n     5E43   20\nEnd macro EDGE\nMacro EDGE:\n     5E44   1F\n     5E45   87\n     5E46   04\n     5E47   1C\nEnd macro EDGE\nMacro EDGE:\n     5E48   1F\n     5E49   D7\n     5E4A   00\n     5E4B   1C\nEnd macro EDGE\nMacro EDGE:\n     5E4C   1F\n     5E4D   DC\n     5E4E   10\n     5E4F   1C\nEnd macro EDGE\nMacro EDGE:\n     5E50   1F\n     5E51   C9\n     5E52   0C\n     5E53   1C\nEnd macro EDGE\nMacro EDGE:\n     5E54   1F\n     5E55   B9\n     5E56   0C\n     5E57   20\nEnd macro EDGE\nMacro EDGE:\n     5E58   1F\n     5E59   BA\n     5E5A   08\n     5E5B   20\nEnd macro EDGE\nMacro EDGE:\n     5E5C   1F\n     5E5D   98\n     5E5E   1C\n     5E5F   20\nEnd macro EDGE\n.SHIP_ASTEROID_FACES\nMacro FACE:\n     5E60   1F\n     5E61   09\n     5E62   42\n     5E63   51\nEnd macro FACE\nMacro FACE:\n     5E64   5F\n     5E65   09\n     5E66   42\n     5E67   51\nEnd macro FACE\nMacro FACE:\n     5E68   9F\n     5E69   48\n     5E6A   40\n     5E6B   1F\nEnd macro FACE\nMacro FACE:\n     5E6C   DF\n     5E6D   40\n     5E6E   49\n     5E6F   2F\nEnd macro FACE\nMacro FACE:\n     5E70   5F\n     5E71   2D\n     5E72   4F\n     5E73   41\nEnd macro FACE\nMacro FACE:\n     5E74   1F\n     5E75   87\n     5E76   0F\n     5E77   23\nEnd macro FACE\nMacro FACE:\n     5E78   1F\n     5E79   26\n     5E7A   4C\n     5E7B   46\nEnd macro FACE\nMacro FACE:\n     5E7C   BF\n     5E7D   42\n     5E7E   3B\n     5E7F   27\nEnd macro FACE\nMacro FACE:\n     5E80   FF\n     5E81   43\n     5E82   0F\n     5E83   50\nEnd macro FACE\nMacro FACE:\n     5E84   7F\n     5E85   42\n     5E86   0E\n     5E87   4B\nEnd macro FACE\nMacro FACE:\n     5E88   FF\n     5E89   46\n     5E8A   50\n     5E8B   28\nEnd macro FACE\nMacro FACE:\n     5E8C   7F\n     5E8D   3A\n     5E8E   66\n     5E8F   33\nEnd macro FACE\nMacro FACE:\n     5E90   3F\n     5E91   51\n     5E92   09\n     5E93   43\nEnd macro FACE\nMacro FACE:\n     5E94   3F\n     5E95   2F\n     5E96   5E\n     5E97   3F\nEnd macro FACE\n.SHIP_CANISTER\n     5E98   00\n     5E99   90 01\n     5E9B   50\n     5E9C   8C\n     5E9D   31\n     5E9E   00\n     5E9F   12\n     5EA0   3C\n     5EA1   0F\n     5EA2   00 00\n     5EA4   1C\n     5EA5   0C\n     5EA6   11\n     5EA7   0F\n     5EA8   00\n     5EA9   00\n     5EAA   02\n     5EAB   00\n.SHIP_CANISTER_VERTICES\nMacro VERTEX:\n     5EAC   18\n     5EAD   10\n     5EAE   00\n     5EAF   1F\n     5EB0   10\n     5EB1   55\nEnd macro VERTEX\nMacro VERTEX:\n     5EB2   18\n     5EB3   05\n     5EB4   0F\n     5EB5   1F\n     5EB6   10\n     5EB7   22\nEnd macro VERTEX\nMacro VERTEX:\n     5EB8   18\n     5EB9   0D\n     5EBA   09\n     5EBB   5F\n     5EBC   20\n     5EBD   33\nEnd macro VERTEX\nMacro VERTEX:\n     5EBE   18\n     5EBF   0D\n     5EC0   09\n     5EC1   7F\n     5EC2   30\n     5EC3   44\nEnd macro VERTEX\nMacro VERTEX:\n     5EC4   18\n     5EC5   05\n     5EC6   0F\n     5EC7   3F\n     5EC8   40\n     5EC9   55\nEnd macro VERTEX\nMacro VERTEX:\n     5ECA   18\n     5ECB   10\n     5ECC   00\n     5ECD   9F\n     5ECE   51\n     5ECF   66\nEnd macro VERTEX\nMacro VERTEX:\n     5ED0   18\n     5ED1   05\n     5ED2   0F\n     5ED3   9F\n     5ED4   21\n     5ED5   66\nEnd macro VERTEX\nMacro VERTEX:\n     5ED6   18\n     5ED7   0D\n     5ED8   09\n     5ED9   DF\n     5EDA   32\n     5EDB   66\nEnd macro VERTEX\nMacro VERTEX:\n     5EDC   18\n     5EDD   0D\n     5EDE   09\n     5EDF   FF\n     5EE0   43\n     5EE1   66\nEnd macro VERTEX\nMacro VERTEX:\n     5EE2   18\n     5EE3   05\n     5EE4   0F\n     5EE5   BF\n     5EE6   54\n     5EE7   66\nEnd macro VERTEX\n.SHIP_CANISTER_EDGES\nMacro EDGE:\n     5EE8   1F\n     5EE9   10\n     5EEA   00\n     5EEB   04\nEnd macro EDGE\nMacro EDGE:\n     5EEC   1F\n     5EED   20\n     5EEE   04\n     5EEF   08\nEnd macro EDGE\nMacro EDGE:\n     5EF0   1F\n     5EF1   30\n     5EF2   08\n     5EF3   0C\nEnd macro EDGE\nMacro EDGE:\n     5EF4   1F\n     5EF5   40\n     5EF6   0C\n     5EF7   10\nEnd macro EDGE\nMacro EDGE:\n     5EF8   1F\n     5EF9   50\n     5EFA   00\n     5EFB   10\nEnd macro EDGE\nMacro EDGE:\n     5EFC   1F\n     5EFD   51\n     5EFE   00\n     5EFF   14\nEnd macro EDGE\nMacro EDGE:\n     5F00   1F\n     5F01   21\n     5F02   04\n     5F03   18\nEnd macro EDGE\nMacro EDGE:\n     5F04   1F\n     5F05   32\n     5F06   08\n     5F07   1C\nEnd macro EDGE\nMacro EDGE:\n     5F08   1F\n     5F09   43\n     5F0A   0C\n     5F0B   20\nEnd macro EDGE\nMacro EDGE:\n     5F0C   1F\n     5F0D   54\n     5F0E   10\n     5F0F   24\nEnd macro EDGE\nMacro EDGE:\n     5F10   1F\n     5F11   61\n     5F12   14\n     5F13   18\nEnd macro EDGE\nMacro EDGE:\n     5F14   1F\n     5F15   62\n     5F16   18\n     5F17   1C\nEnd macro EDGE\nMacro EDGE:\n     5F18   1F\n     5F19   63\n     5F1A   1C\n     5F1B   20\nEnd macro EDGE\nMacro EDGE:\n     5F1C   1F\n     5F1D   64\n     5F1E   20\n     5F1F   24\nEnd macro EDGE\nMacro EDGE:\n     5F20   1F\n     5F21   65\n     5F22   24\n     5F23   14\nEnd macro EDGE\n.SHIP_CANISTER_FACES\nMacro FACE:\n     5F24   1F\n     5F25   60\n     5F26   00\n     5F27   00\nEnd macro FACE\nMacro FACE:\n     5F28   1F\n     5F29   00\n     5F2A   29\n     5F2B   1E\nEnd macro FACE\nMacro FACE:\n     5F2C   5F\n     5F2D   00\n     5F2E   12\n     5F2F   30\nEnd macro FACE\nMacro FACE:\n     5F30   5F\n     5F31   00\n     5F32   33\n     5F33   00\nEnd macro FACE\nMacro FACE:\n     5F34   7F\n     5F35   00\n     5F36   12\n     5F37   30\nEnd macro FACE\nMacro FACE:\n     5F38   3F\n     5F39   00\n     5F3A   29\n     5F3B   1E\nEnd macro FACE\nMacro FACE:\n     5F3C   9F\n     5F3D   60\n     5F3E   00\n     5F3F   00\nEnd macro FACE\n.SHIP_THARGON\n     5F40   00\n     5F41   40 06\n     5F43   A8\n     5F44   50\n     5F45   41\n     5F46   00\n     5F47   12\n     5F48   3C\n     5F49   0F\n     5F4A   32 00\n     5F4C   1C\n     5F4D   14\n     5F4E   14\n     5F4F   1E\n     5F50   FF\n     5F51   00\n     5F52   02\n     5F53   10\n.SHIP_THARGON_VERTICES\nMacro VERTEX:\n     5F54   09\n     5F55   00\n     5F56   28\n     5F57   9F\n     5F58   01\n     5F59   55\nEnd macro VERTEX\nMacro VERTEX:\n     5F5A   09\n     5F5B   26\n     5F5C   0C\n     5F5D   DF\n     5F5E   01\n     5F5F   22\nEnd macro VERTEX\nMacro VERTEX:\n     5F60   09\n     5F61   18\n     5F62   20\n     5F63   FF\n     5F64   02\n     5F65   33\nEnd macro VERTEX\nMacro VERTEX:\n     5F66   09\n     5F67   18\n     5F68   20\n     5F69   BF\n     5F6A   03\n     5F6B   44\nEnd macro VERTEX\nMacro VERTEX:\n     5F6C   09\n     5F6D   26\n     5F6E   0C\n     5F6F   9F\n     5F70   04\n     5F71   55\nEnd macro VERTEX\nMacro VERTEX:\n     5F72   09\n     5F73   00\n     5F74   08\n     5F75   3F\n     5F76   15\n     5F77   66\nEnd macro VERTEX\nMacro VERTEX:\n     5F78   09\n     5F79   0A\n     5F7A   0F\n     5F7B   7F\n     5F7C   12\n     5F7D   66\nEnd macro VERTEX\nMacro VERTEX:\n     5F7E   09\n     5F7F   06\n     5F80   1A\n     5F81   7F\n     5F82   23\n     5F83   66\nEnd macro VERTEX\nMacro VERTEX:\n     5F84   09\n     5F85   06\n     5F86   1A\n     5F87   3F\n     5F88   34\n     5F89   66\nEnd macro VERTEX\nMacro VERTEX:\n     5F8A   09\n     5F8B   0A\n     5F8C   0F\n     5F8D   3F\n     5F8E   45\n     5F8F   66\nEnd macro VERTEX\n.SHIP_THARGON_FACES\nMacro FACE:\n     5F90   9F\n     5F91   24\n     5F92   00\n     5F93   00\nEnd macro FACE\nMacro FACE:\n     5F94   5F\n     5F95   14\n     5F96   05\n     5F97   07\nEnd macro FACE\nMacro FACE:\n     5F98   7F\n     5F99   2E\n     5F9A   2A\n     5F9B   0E\nEnd macro FACE\nMacro FACE:\n     5F9C   3F\n     5F9D   24\n     5F9E   00\n     5F9F   68\nEnd macro FACE\nMacro FACE:\n     5FA0   3F\n     5FA1   2E\n     5FA2   2A\n     5FA3   0E\nEnd macro FACE\nMacro FACE:\n     5FA4   1F\n     5FA5   14\n     5FA6   05\n     5FA7   07\nEnd macro FACE\nMacro FACE:\n     5FA8   1F\n     5FA9   24\n     5FAA   00\n     5FAB   00\nEnd macro FACE\n.SHIP_ESCAPE_POD\n     5FAC   00\n     5FAD   00 01\n     5FAF   2C\n     5FB0   44\n     5FB1   19\n     5FB2   00\n     5FB3   16\n     5FB4   18\n     5FB5   06\n     5FB6   00 00\n     5FB8   10\n     5FB9   08\n     5FBA   11\n     5FBB   08\n     5FBC   00\n     5FBD   00\n     5FBE   03\n     5FBF   00\n.SHIP_ESCAPE_POD_VERTICES\nMacro VERTEX:\n     5FC0   07\n     5FC1   00\n     5FC2   24\n     5FC3   9F\n     5FC4   12\n     5FC5   33\nEnd macro VERTEX\nMacro VERTEX:\n     5FC6   07\n     5FC7   0E\n     5FC8   0C\n     5FC9   FF\n     5FCA   02\n     5FCB   33\nEnd macro VERTEX\nMacro VERTEX:\n     5FCC   07\n     5FCD   0E\n     5FCE   0C\n     5FCF   BF\n     5FD0   01\n     5FD1   33\nEnd macro VERTEX\nMacro VERTEX:\n     5FD2   15\n     5FD3   00\n     5FD4   00\n     5FD5   1F\n     5FD6   01\n     5FD7   22\nEnd macro VERTEX\n.SHIP_ESCAPE_POD_EDGES\nMacro EDGE:\n     5FD8   1F\n     5FD9   23\n     5FDA   00\n     5FDB   04\nEnd macro EDGE\nMacro EDGE:\n     5FDC   1F\n     5FDD   03\n     5FDE   04\n     5FDF   08\nEnd macro EDGE\nMacro EDGE:\n     5FE0   1F\n     5FE1   01\n     5FE2   08\n     5FE3   0C\nEnd macro EDGE\nMacro EDGE:\n     5FE4   1F\n     5FE5   12\n     5FE6   0C\n     5FE7   00\nEnd macro EDGE\nMacro EDGE:\n     5FE8   1F\n     5FE9   13\n     5FEA   00\n     5FEB   08\nEnd macro EDGE\nMacro EDGE:\n     5FEC   1F\n     5FED   02\n     5FEE   0C\n     5FEF   04\nEnd macro EDGE\n.SHIP_ESCAPE_POD_FACES\nMacro FACE:\n     5FF0   3F\n     5FF1   1A\n     5FF2   00\n     5FF3   3D\nEnd macro FACE\nMacro FACE:\n     5FF4   1F\n     5FF5   13\n     5FF6   33\n     5FF7   0F\nEnd macro FACE\nMacro FACE:\n     5FF8   5F\n     5FF9   13\n     5FFA   33\n     5FFB   0F\nEnd macro FACE\nMacro FACE:\n     5FFC   9F\n     5FFD   38\n     5FFE   00\n     5FFF   00\nEnd macro FACE\nSHIPS\nAssembled at &563A \nEnds at &6000 \nCode size is &9C6 \nExecute at &1128 \nReload at &5822 \nS.SHIPS &563A  &6000  &1128  &5822 \nSaving file '3-assembled-output/SHIPS.bin'\n.SHIP_PYTHON\n     7F00   03\n     7F01   40 38\n     7F03   56\n     7F04   BE\n     7F05   55\n     7F06   00\n     7F07   2E\n     7F08   42\n     7F09   1A\n     7F0A   C8 00\n     7F0C   34\n     7F0D   28\n     7F0E   FA\n     7F0F   14\n     7F10   00\n     7F11   00\n     7F12   00\n     7F13   1B\n.SHIP_PYTHON_VERTICES\nMacro VERTEX:\n     7F14   00\n     7F15   00\n     7F16   E0\n     7F17   1F\n     7F18   10\n     7F19   32\nEnd macro VERTEX\nMacro VERTEX:\n     7F1A   00\n     7F1B   30\n     7F1C   30\n     7F1D   1E\n     7F1E   10\n     7F1F   54\nEnd macro VERTEX\nMacro VERTEX:\n     7F20   60\n     7F21   00\n     7F22   10\n     7F23   3F\n     7F24   FF\n     7F25   FF\nEnd macro VERTEX\nMacro VERTEX:\n     7F26   60\n     7F27   00\n     7F28   10\n     7F29   BF\n     7F2A   FF\n     7F2B   FF\nEnd macro VERTEX\nMacro VERTEX:\n     7F2C   00\n     7F2D   30\n     7F2E   20\n     7F2F   3E\n     7F30   54\n     7F31   98\nEnd macro VERTEX\nMacro VERTEX:\n     7F32   00\n     7F33   18\n     7F34   70\n     7F35   3F\n     7F36   89\n     7F37   CC\nEnd macro VERTEX\nMacro VERTEX:\n     7F38   30\n     7F39   00\n     7F3A   70\n     7F3B   BF\n     7F3C   B8\n     7F3D   CC\nEnd macro VERTEX\nMacro VERTEX:\n     7F3E   30\n     7F3F   00\n     7F40   70\n     7F41   3F\n     7F42   A9\n     7F43   CC\nEnd macro VERTEX\nMacro VERTEX:\n     7F44   00\n     7F45   30\n     7F46   30\n     7F47   5E\n     7F48   32\n     7F49   76\nEnd macro VERTEX\nMacro VERTEX:\n     7F4A   00\n     7F4B   30\n     7F4C   20\n     7F4D   7E\n     7F4E   76\n     7F4F   BA\nEnd macro VERTEX\nMacro VERTEX:\n     7F50   00\n     7F51   18\n     7F52   70\n     7F53   7E\n     7F54   BA\n     7F55   CC\nEnd macro VERTEX\n.SHIP_PYTHON_EDGES\nMacro EDGE:\n     7F56   1E\n     7F57   32\n     7F58   00\n     7F59   20\nEnd macro EDGE\nMacro EDGE:\n     7F5A   1F\n     7F5B   20\n     7F5C   00\n     7F5D   0C\nEnd macro EDGE\nMacro EDGE:\n     7F5E   1F\n     7F5F   31\n     7F60   00\n     7F61   08\nEnd macro EDGE\nMacro EDGE:\n     7F62   1E\n     7F63   10\n     7F64   00\n     7F65   04\nEnd macro EDGE\nMacro EDGE:\n     7F66   1D\n     7F67   59\n     7F68   08\n     7F69   10\nEnd macro EDGE\nMacro EDGE:\n     7F6A   1D\n     7F6B   51\n     7F6C   04\n     7F6D   08\nEnd macro EDGE\nMacro EDGE:\n     7F6E   1D\n     7F6F   37\n     7F70   08\n     7F71   20\nEnd macro EDGE\nMacro EDGE:\n     7F72   1D\n     7F73   40\n     7F74   04\n     7F75   0C\nEnd macro EDGE\nMacro EDGE:\n     7F76   1D\n     7F77   62\n     7F78   0C\n     7F79   20\nEnd macro EDGE\nMacro EDGE:\n     7F7A   1D\n     7F7B   A7\n     7F7C   08\n     7F7D   24\nEnd macro EDGE\nMacro EDGE:\n     7F7E   1D\n     7F7F   84\n     7F80   0C\n     7F81   10\nEnd macro EDGE\nMacro EDGE:\n     7F82   1D\n     7F83   B6\n     7F84   0C\n     7F85   24\nEnd macro EDGE\nMacro EDGE:\n     7F86   05\n     7F87   88\n     7F88   0C\n     7F89   14\nEnd macro EDGE\nMacro EDGE:\n     7F8A   05\n     7F8B   BB\n     7F8C   0C\n     7F8D   28\nEnd macro EDGE\nMacro EDGE:\n     7F8E   05\n     7F8F   99\n     7F90   08\n     7F91   14\nEnd macro EDGE\nMacro EDGE:\n     7F92   05\n     7F93   AA\n     7F94   08\n     7F95   28\nEnd macro EDGE\nMacro EDGE:\n     7F96   1F\n     7F97   A9\n     7F98   08\n     7F99   1C\nEnd macro EDGE\nMacro EDGE:\n     7F9A   1F\n     7F9B   B8\n     7F9C   0C\n     7F9D   18\nEnd macro EDGE\nMacro EDGE:\n     7F9E   1F\n     7F9F   C8\n     7FA0   14\n     7FA1   18\nEnd macro EDGE\nMacro EDGE:\n     7FA2   1F\n     7FA3   C9\n     7FA4   14\n     7FA5   1C\nEnd macro EDGE\nMacro EDGE:\n     7FA6   1D\n     7FA7   AC\n     7FA8   1C\n     7FA9   28\nEnd macro EDGE\nMacro EDGE:\n     7FAA   1D\n     7FAB   CB\n     7FAC   18\n     7FAD   28\nEnd macro EDGE\nMacro EDGE:\n     7FAE   1D\n     7FAF   98\n     7FB0   10\n     7FB1   14\nEnd macro EDGE\nMacro EDGE:\n     7FB2   1D\n     7FB3   BA\n     7FB4   24\n     7FB5   28\nEnd macro EDGE\nMacro EDGE:\n     7FB6   1D\n     7FB7   54\n     7FB8   04\n     7FB9   10\nEnd macro EDGE\nMacro EDGE:\n     7FBA   1D\n     7FBB   76\n     7FBC   20\n     7FBD   24\nEnd macro EDGE\n.SHIP_PYTHON_FACES\nMacro FACE:\n     7FBE   9E\n     7FBF   1B\n     7FC0   28\n     7FC1   0B\nEnd macro FACE\nMacro FACE:\n     7FC2   1E\n     7FC3   1B\n     7FC4   28\n     7FC5   0B\nEnd macro FACE\nMacro FACE:\n     7FC6   DE\n     7FC7   1B\n     7FC8   28\n     7FC9   0B\nEnd macro FACE\nMacro FACE:\n     7FCA   5E\n     7FCB   1B\n     7FCC   28\n     7FCD   0B\nEnd macro FACE\nMacro FACE:\n     7FCE   9E\n     7FCF   13\n     7FD0   26\n     7FD1   00\nEnd macro FACE\nMacro FACE:\n     7FD2   1E\n     7FD3   13\n     7FD4   26\n     7FD5   00\nEnd macro FACE\nMacro FACE:\n     7FD6   DE\n     7FD7   13\n     7FD8   26\n     7FD9   00\nEnd macro FACE\nMacro FACE:\n     7FDA   5E\n     7FDB   13\n     7FDC   26\n     7FDD   00\nEnd macro FACE\nMacro FACE:\n     7FDE   BE\n     7FDF   19\n     7FE0   25\n     7FE1   0B\nEnd macro FACE\nMacro FACE:\n     7FE2   3E\n     7FE3   19\n     7FE4   25\n     7FE5   0B\nEnd macro FACE\nMacro FACE:\n     7FE6   7E\n     7FE7   19\n     7FE8   25\n     7FE9   0B\nEnd macro FACE\nMacro FACE:\n     7FEA   FE\n     7FEB   19\n     7FEC   25\n     7FED   0B\nEnd macro FACE\nMacro FACE:\n     7FEE   3E\n     7FEF   00\n     7FF0   00\n     7FF1   70\nEnd macro FACE\n     7FF2\n.SVN\n     7FFD\n.VEC\n     7FFE\nPYTHON\nAssembled at &7F00 \nEnds at &8000 \nCode size is &100 \nExecute at &1128 \nReload at &1B00 \nS.PYTHON &17F4  &8000  &1128  &1B00 \nSaving file '3-assembled-output/PYTHON.bin'\nELITE game code &FFFFE000  bytes free\nEnds at &8000 \n.ZP\n     0070\n.LBL\n     1100   6C\n     1101   A2 60      LDX #&60\n     1103   A9 0B      LDA #&0B\n     1105   85 71      STA &71\n     1107   A0 00      LDY #&00\n     1109   84 70      STY &70\n     110B   98         TYA\n     110C   C8         INY\n.CHK3\n     110D   18         CLC\n     110E   71 70      ADC (&70),Y\n     1110   C8         INY\n     1111   D0 FA      BNE &110D\n     1113   E6 71      INC &71\n.CHK4\n     1115   18         CLC\n     1116   71 70      ADC (&70),Y\n     1118   C8         INY\n     1119   10 FA      BPL &1115\n     111B   CD 00 0B   CMP &0B00\n     111E   F0 E2      BEQ &1102\n     1120   A9 7F      LDA #&7F\n     1122   8D 4E FE   STA &FE4E\n     1125   6C FC FF   JMP (&FFFC)\n.elitea\nelitea = &1128 \n     1128   F5 46 81 ... INCBIN \"3-assembled-output/ELTA.bin\"\n.eliteb\neliteb = &19DC \n     19DC   4A 41 4D ... INCBIN \"3-assembled-output/ELTB.bin\"\n.elitec\nelitec = &2404 \n     2404   A9 00 20 ... INCBIN \"3-assembled-output/ELTC.bin\"\n.elited\nelited = &2EB0 \n     2EB0   48 A2 0C ... INCBIN \"3-assembled-output/ELTD.bin\"\n.elitee\nelitee = &39F7 \n     39F7   8C E7 8D ... INCBIN \"3-assembled-output/ELTE.bin\"\n.elitef\nelitef = &445E \n     445E   A5 1B 8D ... INCBIN \"3-assembled-output/ELTF.bin\"\n.eliteg\neliteg = &4EFD \n     4EFD   20 7D 4E ... INCBIN \"3-assembled-output/ELTG.bin\"\n.checksum0\nchecksum0 = &5821 \n     5821   20\n.ships\nships = &5822 \n     5822   54 56 FC ... INCBIN \"3-assembled-output/SHIPS.bin\"\n.end\nP% = &61E8 \nS.ELTcode 1100 &61E8  &1128  &1128 \nSaving file '3-assembled-output/ELTcode.unprot.bin'\nSaving file '3-assembled-output/ELThead.bin'\n.TRTB%\n     0004\n.ZP\n     0070\n.P\n     0072\n.Q\n     0073\n.YY\n     0074\n.T\n     0075\n.SC\n     0076\n.SCH\n     0077\n.BLPTR\n     0078\n.V219\n     007A\n     007C\n.K3\n     0080\n.BLCNT\n     0081\n.BLN\n     0083\n.EXCN\n     0085\nWORDS9 = &1100 \n     1100   4C 32 24 ... INCBIN \"3-assembled-output/WORDS9.bin\"\nP.DIALS = &1500 \n     1500   F0 80 87 ... INCBIN \"1-source-files/images/P.DIALS.bin\"\nPYTHON = &1C00 \n     1C00   03 40 38 ... INCBIN \"3-assembled-output/PYTHON.bin\"\nP.ELITE = &1D00 \n     1D00   00 00 00 ... INCBIN \"1-source-files/images/P.ELITE.bin\"\nP.A-SOFT = &1E00 \n     1E00   00 00 00 ... INCBIN \"1-source-files/images/P.A-SOFT.bin\"\nP.(C)ASFT = &1F00 \n     1F00   00 00 00 ... INCBIN \"1-source-files/images/P.(C)ASFT.bin\"\n.run\n     2000   4C C9 20   JMP &20C9\n.B%\n     2003   16\n     2004   04\n     2005   1C\n     2006   02\n     2007   11\n     2008   0F\n     2009   10\n     200A   17\n     200B   00\n     200C   06\n     200D   1F\n     200E   00\n     200F   00\n     2010   00\n     2011   00\n     2012   00\n     2013   00\n     2014   17\n     2015   00\n     2016   0C\n     2017   0C\n     2018   00\n     2019   00\n     201A   00\n     201B   00\n     201C   00\n     201D   00\n     201E   17\n     201F   00\n     2020   0D\n     2021   00\n     2022   00\n     2023   00\n     2024   00\n     2025   00\n     2026   00\n     2027   00\n     2028   17\n     2029   00\n     202A   01\n     202B   20\n     202C   00\n     202D   00\n     202E   00\n     202F   00\n     2030   00\n     2031   00\n     2032   17\n     2033   00\n     2034   02\n     2035   2D\n     2036   00\n     2037   00\n     2038   00\n     2039   00\n     203A   00\n     203B   00\n     203C   17\n     203D   00\n     203E   0A\n     203F   20\n     2040   00\n     2041   00\n     2042   00\n     2043   00\n     2044   00\n     2045   00\n.E%\n     2046   01\n     2047   01\n     2048   00\n     2049   6F\n     204A   F8\n     204B   04\n     204C   01\n     204D   08\n     204E   08\n     204F   FE\n     2050   00\n     2051   FF\n     2052   70\n     2053   2C\n     2054   02\n     2055   01\n     2056   0E\n     2057   EE\n     2058   FF\n     2059   2C\n     205A   20\n     205B   32\n     205C   06\n     205D   01\n     205E   00\n     205F   FE\n     2060   78\n     2061   7E\n     2062   03\n     2063   01\n     2064   01\n     2065   FF\n     2066   FD\n     2067   11\n     2068   20\n     2069   80\n     206A   01\n     206B   00\n     206C   00\n     206D   FF\n     206E   01\n     206F   01\n     2070   04\n     2071   01\n     2072   04\n     2073   F8\n     2074   2C\n     2075   04\n     2076   06\n     2077   08\n     2078   16\n     2079   00\n     207A   00\n     207B   81\n     207C   7E\n     207D   00\n.swine\n     207E   A9 7F      LDA #&7F\n     2080   8D 4E FE   STA &FE4E\n     2083   6C FC FF   JMP (&FFFC)\n.OSB\n     2086   A0 00      LDY #&00\n     2088   4C F4 FF   JMP &FFF4\n     208B   52 2E 45 ...\n     2096   0D\n     2097   42 79 20 ...\n     20A9   0D\n     20AA   B0\n.oscliv\n     20AB   F7 FF\n.David9\n     20AD   68 22\n     20AF   D8         CLD\n.David23\n     20B0   DF 01\n.doPROT1\n     20B2   A0 DB      LDY #&DB\n     20B4   84 04      STY &04\n     20B6   A0 EF      LDY #&EF\n     20B8   84 05      STY &05\n     20BA   A0 02      LDY #&02\n     20BC   84 7B      STY &7B\n     20BE   9D 7D 20   STA &207D,X\n     20C1   A0 18      LDY #&18\n     20C3   94 7B      STY &7B,X\n     20C5   60         RTS\n.MHCA\n     20C6   CA\n.David7\n     20C7   90 48      BCC &2111\n.ENTRY\n     20C9   78         SEI\n     20CA   D8         CLD\n     20CB   A9 7F      LDA #&7F\n     20CD   8D 4E FE   STA &FE4E\n     20D0   8D 6E FE   STA &FE6E\n     20D3   AD FC FF   LDA &FFFC\n     20D6   8D 00 02   STA &0200\n     20D9   8D 02 02   STA &0202\n     20DC   8D 06 02   STA &0206\n     20DF   8D 20 02   STA &0220\n     20E2   AD FD FF   LDA &FFFD\n     20E5   8D 01 02   STA &0201\n     20E8   8D 03 02   STA &0203\n     20EB   8D 07 02   STA &0207\n     20EE   8D 21 02   STA &0221\n     20F1   A2 2D      LDX #&2D\n.purge\n     20F3   BD 02 02   LDA &0202,X\n     20F6   09 C0      ORA #&C0\n     20F8   9D 02 02   STA &0202,X\n     20FB   CA         DEX\n     20FC   CA         DEX\n     20FD   10 F4      BPL &20F3\n     20FF   A9 60      LDA #&60\n     2101   8D 32 02   STA &0232\n     2104   A9 02      LDA #&02\n     2106   8D 25 02   STA &0225\n     2109   A9 32      LDA #&32\n     210B   8D 24 02   STA &0224\n     210E   A9 20      LDA #&20\n     2110   2C\n.Ian1\n     2111   D0 66      BNE &2179\n     2113   8D 4B 22   STA &224B\n     2116   4A         LSR A\n     2117   A2 03      LDX #&03\n     2119   86 79      STX &79\n     211B   86 84      STX &84\n     211D   86 86      STX &86\n     211F   CA         DEX\n     2120   20 F4 FF   JSR &FFF4\n     2123   2C\n.FRED1\n     2124   D0 A1      BNE &20C7\n     2126   A2 FF      LDX #&FF\n     2128   A9 48      LDA #&48\n     212A   20 B2 20   JSR &20B2\n     212D   A9 90      LDA #&90\n     212F   20 86 20   JSR &2086\n     2132   A9 F7      LDA #&F7\n     2134   A2 00      LDX #&00\n     2136   20 86 20   JSR &2086\n     2139   A9 BE      LDA #&BE\n     213B   A2 08      LDX #&08\n     213D   20 86 20   JSR &2086\n     2140   2C\n.David8\n     2141   D0 E1      BNE &2124\n     2143   A9 8F      LDA #&8F\n     2145   A2 0C      LDX #&0C\n     2147   A0 FF      LDY #&FF\n     2149   20 F4 FF   JSR &FFF4\n     214C   A9 0D      LDA #&0D\n.abrk\n     214E   A2 00      LDX #&00\n     2150   20 86 20   JSR &2086\n     2153   A9 E1      LDA #&E1\n     2155   A2 80      LDX #&80\n     2157   20 86 20   JSR &2086\n     215A   A9 AC      LDA #&AC\n     215C   A2 00      LDX #&00\n     215E   A0 FF      LDY #&FF\n     2160   20 F4 FF   JSR &FFF4\n     2163   86 04      STX &04\n     2165   84 05      STY &05\n     2167   A9 C8      LDA #&C8\n     2169   A2 03      LDX #&03\n     216B   20 86 20   JSR &2086\n     216E   A9 0D      LDA #&0D\n     2170   A2 02      LDX #&02\n     2172   20 86 20   JSR &2086\n.OS01\n     2175   A2 FF      LDX #&FF\n     2177   9A         TXS\n     2178   E8         INX\n.David3\n     2179   BD 13 24   LDA &2413,X\n.PROT1\n     217C   C8         INY\n     217D   E8         INX\n     217E   E0 21      CPX #&21\n     2180   D0 BF      BNE &2141\n     2182   A9 03      LDA #&03\n     2184   85 70      STA &70\n     2186   A9 C8      LDA #&C8\n     2188   8D 7C 21   STA &217C\n     218B   A9 20      LDA #&20\n     218D   85 71      STA &71\n     218F   A0 00      LDY #&00\n.LOOP\n     2191   B1 70      LDA (&70),Y\n     2193   20 EE FF   JSR &FFEE\n     2196   C8         INY\n     2197   C0 43      CPY #&43\n     2199   D0 F6      BNE &2191\n     219B   A9 01      LDA #&01\n     219D   AA         TAX\n     219E   A8         TAY\n     219F   91 7A      STA (&7A),Y\n     21A1   A9 04      LDA #&04\n     21A3   20 86 20   JSR &2086\n     21A6   A9 09      LDA #&09\n     21A8   A2 00      LDX #&00\n     21AA   20 86 20   JSR &2086\n     21AD   A9 6C      LDA #&6C\n     21AF   4D 61 22   EOR &2261\n     21B2   8D 61 22   STA &2261\nMacro FNE:\n     21B5   A2 46      LDX #&46\n     21B7   A0 20      LDY #&20\n     21B9   A9 08      LDA #&08\n     21BB   20 F1 FF   JSR &FFF1\nEnd macro FNE\nMacro FNE:\n     21BE   A2 54      LDX #&54\n     21C0   A0 20      LDY #&20\n     21C2   A9 08      LDA #&08\n     21C4   20 F1 FF   JSR &FFF1\nEnd macro FNE\nMacro FNE:\n     21C7   A2 62      LDX #&62\n     21C9   A0 20      LDY #&20\n     21CB   A9 08      LDA #&08\n     21CD   20 F1 FF   JSR &FFF1\nEnd macro FNE\nMacro FNE:\n     21D0   A2 70      LDX #&70\n     21D2   A0 20      LDY #&20\n     21D4   A9 08      LDA #&08\n     21D6   20 F1 FF   JSR &FFF1\nEnd macro FNE\n     21D9   A2 04      LDX #&04\n     21DB   86 73      STX &73\n     21DD   A9 11      LDA #&11\n     21DF   85 71      STA &71\n     21E1   A0 00      LDY #&00\n     21E3   A9 F1      LDA #&F1\n     21E5   81 76      STA (&76,X)\n     21E7   84 70      STY &70\n     21E9   84 72      STY &72\n     21EB   20 61 22   JSR &2261\n     21EE   A2 01      LDX #&01\n     21F0   A9 1D      LDA #&1D\n     21F2   85 71      STA &71\n     21F4   A9 63      LDA #&63\n     21F6   85 73      STA &73\n     21F8   A0 00      LDY #&00\n     21FA   20 61 22   JSR &2261\n     21FD   A2 01      LDX #&01\n     21FF   A9 1E      LDA #&1E\n     2201   85 71      STA &71\n     2203   A9 61      LDA #&61\n     2205   85 73      STA &73\n     2207   A0 00      LDY #&00\n     2209   20 61 22   JSR &2261\n     220C   A2 01      LDX #&01\n     220E   A9 1F      LDA #&1F\n     2210   85 71      STA &71\n     2212   A9 76      LDA #&76\n     2214   85 73      STA &73\n     2216   A0 00      LDY #&00\n     2218   20 61 22   JSR &2261\n     221B   20 A6 22   JSR &22A6\n     221E   A2 08      LDX #&08\n     2220   A9 15      LDA #&15\n     2222   85 71      STA &71\n     2224   A9 78      LDA #&78\n     2226   85 73      STA &73\n     2228   A0 00      LDY #&00\n     222A   84 70      STY &70\n     222C   84 81      STY &81\n     222E   84 72      STY &72\n     2230   20 61 22   JSR &2261\n     2233   A2 02      LDX #&02\n     2235   A9 24      LDA #&24\n     2237   85 71      STA &71\n     2239   A9 34      LDA #&34\n     223B   85 70      STA &70\n     223D   A9 0B      LDA #&0B\n     223F   85 73      STA &73\n     2241   A0 00      LDY #&00\n     2243   84 72      STY &72\n     2245   20 61 22   JSR &2261\n     2248   8C 77 21   STY &2177\n.David2\n     224B   AC\n     224C   D4 FF\n.LBLa\n     224E   BD 40 0F   LDA &0F40,X\n     2251   49 A5      EOR #&A5\n     2253   9D 40 0F   STA &0F40,X\n     2256   CA         DEX\n     2257   D0 F5      BNE &224E\n     2259   6C 0F 10   JMP (&100F)\n.swine2\n     225C   4C 7E 20   JMP &207E\n     225F   FF 4C\n.crunchit\n     2261   00         BRK\n     2262   B0 20\n.RAND\n     2264   49 53 78 6C\n.David5\n     2268   C8         INY\n     2269   C0 80      CPY #&80\n     226B   D0 DE      BNE &224B\n     226D   78         SEI\n     226E   A9 C2      LDA #&C2\n     2270   8D 4E FE   STA &FE4E\n     2273   A9 7F      LDA #&7F\n     2275   8D 6E FE   STA &FE6E\n     2278   AD 04 02   LDA &0204\n     227B   8D FE 7F   STA &7FFE\n     227E   AD 05 02   LDA &0205\n     2281   10 D9      BPL &225C\n     2283   8D FF 7F   STA &7FFF\n     2286   A9 0C      LDA #&0C\n     2288   8D 05 02   STA &0205\n     228B   A9 4A      LDA #&4A\n     228D   8D 04 02   STA &0204\n     2290   A9 38      LDA #&38\n     2292   8D 45 FE   STA &FE45\n     2295   58         CLI\n     2296   A9 81      LDA #&81\n     2298   8D 4E FE   STA &FE4E\n     229B   A0 14      LDY #&14\n     229D   20 F4 FF   JSR &FFF4\n     22A0   A9 01      LDA #&01\n     22A2   8D 4E FE   STA &FE4E\n     22A5   60         RTS\n.PLL1\n     22A6   AD 44 FE   LDA &FE44\n     22A9   8D 65 22   STA &2265\n     22AC   20 75 23   JSR &2375\n     22AF   20 90 23   JSR &2390\n     22B2   85 71      STA &71\n     22B4   A5 72      LDA &72\n     22B6   85 70      STA &70\n     22B8   20 75 23   JSR &2375\n     22BB   85 74      STA &74\n     22BD   20 90 23   JSR &2390\n     22C0   AA         TAX\n     22C1   A5 72      LDA &72\n     22C3   65 70      ADC &70\n     22C5   85 70      STA &70\n     22C7   8A         TXA\n     22C8   65 71      ADC &71\n     22CA   B0 1F      BCS &22EB\n     22CC   85 71      STA &71\n     22CE   A9 01      LDA #&01\n     22D0   E5 70      SBC &70\n     22D2   85 70      STA &70\n     22D4   A9 40      LDA #&40\n     22D6   E5 71      SBC &71\n     22D8   85 71      STA &71\n     22DA   90 0F      BCC &22EB\n     22DC   20 DC 23   JSR &23DC\n     22DF   A5 70      LDA &70\n     22E1   4A         LSR A\n     22E2   AA         TAX\n     22E3   A5 74      LDA &74\n     22E5   C9 80      CMP #&80\n     22E7   6A         ROR A\n     22E8   20 AD 23   JSR &23AD\n.PLC1\n     22EB   CE D6 23   DEC &23D6\n     22EE   D0 B6      BNE &22A6\n     22F0   CE D7 23   DEC &23D7\n     22F3   D0 B1      BNE &22A6\n     22F5   A2 C2      LDX #&C2\n     22F7   86 85      STX &85\n.PLL2\n     22F9   20 75 23   JSR &2375\n     22FC   AA         TAX\n     22FD   20 90 23   JSR &2390\n     2300   85 71      STA &71\n     2302   20 75 23   JSR &2375\n     2305   85 74      STA &74\n     2307   20 90 23   JSR &2390\n     230A   65 71      ADC &71\n     230C   C9 11      CMP #&11\n     230E   90 05      BCC &2315\n     2310   A5 74      LDA &74\n     2312   20 AD 23   JSR &23AD\n.PLC2\n     2315   CE D8 23   DEC &23D8\n     2318   D0 DF      BNE &22F9\n     231A   CE D9 23   DEC &23D9\n     231D   D0 DA      BNE &22F9\n     231F   AE C6 20   LDX &20C6\n     2322   86 78      STX &78\n     2324   A2 C6      LDX #&C6\n     2326   86 83      STX &83\n.PLL3\n     2328   20 75 23   JSR &2375\n     232B   85 70      STA &70\n     232D   20 90 23   JSR &2390\n     2330   85 71      STA &71\n     2332   20 75 23   JSR &2375\n     2335   85 74      STA &74\n     2337   20 90 23   JSR &2390\n     233A   85 75      STA &75\n     233C   65 71      ADC &71\n     233E   85 71      STA &71\n     2340   A5 70      LDA &70\n     2342   C9 80      CMP #&80\n     2344   6A         ROR A\n     2345   C9 80      CMP #&80\n     2347   6A         ROR A\n     2348   65 74      ADC &74\n     234A   AA         TAX\n     234B   20 90 23   JSR &2390\n     234E   A8         TAY\n     234F   65 71      ADC &71\n     2351   B0 18      BCS &236B\n     2353   C9 50      CMP #&50\n     2355   B0 14      BCS &236B\n     2357   C9 20      CMP #&20\n     2359   90 10      BCC &236B\n     235B   98         TYA\n     235C   65 75      ADC &75\n     235E   C9 10      CMP #&10\n     2360   B0 04      BCS &2366\n     2362   A5 70      LDA &70\n     2364   10 05      BPL &236B\n.PL1\n     2366   A5 74      LDA &74\n     2368   20 AD 23   JSR &23AD\n.PLC3\n     236B   CE DA 23   DEC &23DA\n     236E   D0 B8      BNE &2328\n     2370   CE DB 23   DEC &23DB\n     2373   D0 B3      BNE &2328\n.DORND\n     2375   AD 65 22   LDA &2265\n     2378   AA         TAX\n     2379   6D 67 22   ADC &2267\n     237C   8D 65 22   STA &2265\n     237F   8E 67 22   STX &2267\n     2382   AD 64 22   LDA &2264\n     2385   AA         TAX\n     2386   6D 66 22   ADC &2266\n     2389   8D 64 22   STA &2264\n     238C   8E 66 22   STX &2266\n     238F   60         RTS\n.SQUA2\n     2390   10 05      BPL &2397\n     2392   49 FF      EOR #&FF\n     2394   18         CLC\n     2395   69 01      ADC #&01\n.SQUA\n     2397   85 73      STA &73\n     2399   85 72      STA &72\n     239B   A9 00      LDA #&00\n     239D   A0 08      LDY #&08\n     239F   46 72      LSR &72\n.SQL1\n     23A1   90 03      BCC &23A6\n     23A3   18         CLC\n     23A4   65 73      ADC &73\n.SQ1\n     23A6   6A         ROR A\n     23A7   66 72      ROR &72\n     23A9   88         DEY\n     23AA   D0 F5      BNE &23A1\n     23AC   60         RTS\n.PIX\n     23AD   A8         TAY\n     23AE   49 80      EOR #&80\n     23B0   4A         LSR A\n     23B1   4A         LSR A\n     23B2   4A         LSR A\n     23B3   09 60      ORA #&60\n     23B5   85 71      STA &71\n     23B7   8A         TXA\n     23B8   49 80      EOR #&80\n     23BA   29 F8      AND #&F8\n     23BC   85 70      STA &70\n     23BE   98         TYA\n     23BF   29 07      AND #&07\n     23C1   A8         TAY\n     23C2   8A         TXA\n     23C3   29 07      AND #&07\n     23C5   AA         TAX\n     23C6   BD CE 23   LDA &23CE,X\n     23C9   11 70      ORA (&70),Y\n     23CB   91 70      STA (&70),Y\n     23CD   60         RTS\n.TWOS\n     23CE   80\n     23CF   40\n     23D0   20\n     23D1   10\n     23D2   08\n     23D3   04\n     23D4   02\n     23D5   01\n.CNT\n     23D6   00 05\n.CNT2\n     23D8   DD 01\n.CNT3\n     23DA   00 05\n.ROOT\n     23DC   A4 71      LDY &71\n     23DE   A5 70      LDA &70\n     23E0   85 73      STA &73\n     23E2   A2 00      LDX #&00\n     23E4   86 70      STX &70\n     23E6   A9 08      LDA #&08\n     23E8   85 72      STA &72\n.LL6\n     23EA   E4 70      CPX &70\n     23EC   90 0E      BCC &23FC\n     23EE   D0 04      BNE &23F4\n     23F0   C0 40      CPY #&40\n     23F2   90 08      BCC &23FC\n.LL8\n     23F4   98         TYA\n     23F5   E9 40      SBC #&40\n     23F7   A8         TAY\n     23F8   8A         TXA\n     23F9   E5 70      SBC &70\n     23FB   AA         TAX\n.LL7\n     23FC   26 70      ROL &70\n     23FE   06 73      ASL &73\n     2400   98         TYA\n     2401   2A         ROL A\n     2402   A8         TAY\n     2403   8A         TXA\n     2404   2A         ROL A\n     2405   AA         TAX\n     2406   06 73      ASL &73\n     2408   98         TYA\n     2409   2A         ROL A\n     240A   A8         TAY\n     240B   8A         TXA\n     240C   2A         ROL A\n     240D   AA         TAX\n     240E   C6 72      DEC &72\n     2410   D0 D8      BNE &23EA\n     2412   60         RTS\n.BEGIN%\n     2413   20\n     2414   AD\n     2415   6C\n     2416   0B\n     2417   AD\n     2418   99\n     2419   0B\n     241A   AD\n     241B   59\n     241C   48         PHA\n     241D   0C\n     241E   7C\n     241F   B9\n     2420   68         PLA\n     2421   68         PLA\n.DOMOVE\n     2422   60         RTS\n     2423   EF D0\n     2425   CA         DEX\n     2426   71\n     2427   E6 73      INC &73\n     2429   E6\n     242A   F6 D0\n     242C   88         DEY\n     242D   72\n     242E   91\n     242F   20\n     2430   86\n     2431   59\n     2432   70\n     2433   B1\n.UU%\n.CHECKbyt\n     0B00   00         BRK\n.MAINSUM\n     0B01   CB\n     0B02   00\n.FOOLV\n     0B03   A4 0B\n.CHECKV\n     0B05   01 11\n.block1\n     0B07   F5\n     0B08   E5\n     0B09   B5\n     0B0A   A5\n     0B0B   76\n     0B0C   66\n     0B0D   36\n     0B0E   26\n     0B0F   D4\n     0B10   C4\n     0B11   94\n     0B12   84\n.block2\n     0B13   D0\n     0B14   C0\n     0B15   B0\n     0B16   A0\n     0B17   F0\n     0B18   E0\n     0B19   90\n     0B1A   80\n     0B1B   77\n     0B1C   67\n     0B1D   37\n     0B1E   27\n.TT26\n     0B1F   85 80      STA &80\n     0B21   98         TYA\n     0B22   48         PHA\n     0B23   8A         TXA\n     0B24   48         PHA\n.rr\n     0B25   A5 80      LDA &80\n     0B27   C9 07      CMP #&07\n     0B29   F0 7A      BEQ &0BA5\n     0B2B   C9 20      CMP #&20\n     0B2D   B0 0E      BCS &0B3D\n     0B2F   C9 0D      CMP #&0D\n     0B31   F0 03      BEQ &0B36\n     0B33   EE FD 0C   INC &0CFD\n.RRX1\n     0B36   A2 07      LDX #&07\n     0B38   8E FC 0C   STX &0CFC\n     0B3B   D0 61      BNE &0B9E\n.RR1\n     0B3D   A2 BF      LDX #&BF\n     0B3F   0A         ASL A\n     0B40   0A         ASL A\n     0B41   90 02      BCC &0B45\n     0B43   A2 C1      LDX #&C1\n     0B45   0A         ASL A\n     0B46   90 01      BCC &0B49\n     0B48   E8         INX\n     0B49   85 72      STA &72\n     0B4B   86 73      STX &73\n     0B4D   AD FC 0C   LDA &0CFC\n     0B50   C9 14      CMP #&14\n     0B52   90 08      BCC &0B5C\n     0B54   A9 07      LDA #&07\n     0B56   8D FC 0C   STA &0CFC\n     0B59   EE FD 0C   INC &0CFD\n.NOLF\n     0B5C   0A         ASL A\n     0B5D   0A         ASL A\n     0B5E   0A         ASL A\n     0B5F   85 70      STA &70\n     0B61   EE FC 0C   INC &0CFC\n     0B64   AD FD 0C   LDA &0CFD\n     0B67   C9 13      CMP #&13\n     0B69   90 26      BCC &0B91\n     0B6B   A9 07      LDA #&07\n     0B6D   8D FC 0C   STA &0CFC\n     0B70   A9 65      LDA #&65\n     0B72   85 77      STA &77\n     0B74   A0 38      LDY #&38\n     0B76   A2 0E      LDX #&0E\n     0B78   84 76      STY &76\n     0B7A   A9 00      LDA #&00\n     0B7C   A8         TAY\n.David1\n     0B7D   91 76      STA (&76),Y\n     0B7F   C8         INY\n     0B80   C0 70      CPY #&70\n     0B82   90 F9      BCC &0B7D\n     0B84   A8         TAY\n     0B85   E6 77      INC &77\n     0B87   CA         DEX\n     0B88   10 F3      BPL &0B7D\n     0B8A   A9 05      LDA #&05\n     0B8C   8D FD 0C   STA &0CFD\n     0B8F   D0 94      BNE &0B25\n.RR3\n     0B91   09 60      ORA #&60\n     0B93   85 71      STA &71\n     0B95   A0 07      LDY #&07\n.RRL1\n     0B97   B1 72      LDA (&72),Y\n     0B99   91 70      STA (&70),Y\n     0B9B   88         DEY\n     0B9C   10 F9      BPL &0B97\n.RR4\n     0B9E   68         PLA\n     0B9F   AA         TAX\n     0BA0   68         PLA\n     0BA1   A8         TAY\n     0BA2   A5 80      LDA &80\n.FOOL\n     0BA4   60         RTS\n.R5\n     0BA5   A9 07      LDA #&07\n     0BA7   20 AD 0B   JSR &0BAD\n     0BAA   4C 9E 0B   JMP &0B9E\n.TUT\n.osprint\n     0BAD   6C 34 02   JMP (&0234)\n     0BB0   6C\n.command\n     0BB1   6C AB 20   JMP (&20AB)\n.MESS1\n     0BB4   4C 2E 45 ...\n     0BC2   0D\n.ENTRY2\n     0BC3   AD 0E 02   LDA &020E\n     0BC6   8D 34 02   STA &0234\n     0BC9   A9 1F      LDA #&1F\n     0BCB   8D 0E 02   STA &020E\n     0BCE   A2 B4      LDX #&B4\n     0BD0   AD 0F 02   LDA &020F\n     0BD3   8D 35 02   STA &0235\n     0BD6   A9 0B      LDA #&0B\n     0BD8   A0 0B      LDY #&0B\n     0BDA   8D 0F 02   STA &020F\n     0BDD   20 31 0C   JSR &0C31\n     0BE0   20 B1 0B   JSR &0BB1\n     0BE3   20 B4 01   JSR &01B4\n     0BE6   20 31 0C   JSR &0C31\n     0BE9   A9 8C      LDA #&8C\n     0BEB   A2 0C      LDX #&0C\n     0BED   20 F4 FF   JSR &FFF4\n     0BF0   A9 00      LDA #&00\n     0BF2   8D FD 7F   STA &7FFD\n     0BF5   A2 50      LDX #&50\n     0BF7   A9 28      LDA #&28\n     0BF9   85 70      STA &70\n     0BFB   A9 11      LDA #&11\n     0BFD   85 71      STA &71\n     0BFF   A9 40      LDA #&40\n     0C01   85 72      STA &72\n     0C03   A9 0F      LDA #&0F\n     0C05   85 73      STA &73\n     0C07   A0 00      LDY #&00\n.ML1\n     0C09   98         TYA\n     0C0A   51 70      EOR (&70),Y\n     0C0C   91 72      STA (&72),Y\n     0C0E   C8         INY\n     0C0F   D0 F8      BNE &0C09\n     0C11   E6 71      INC &71\n     0C13   E6 73      INC &73\n     0C15   CA         DEX\n     0C16   10 F1      BPL &0C09\n     0C18   AD 46 0F   LDA &0F46\n     0C1B   8D 02 02   STA &0202\n     0C1E   AD 47 0F   LDA &0F47\n     0C21   8D 03 02   STA &0203\n     0C24   AD 42 0F   LDA &0F42\n     0C27   8D 0E 02   STA &020E\n     0C2A   AD 43 0F   LDA &0F43\n     0C2D   8D 0F 02   STA &020F\n     0C30   60         RTS\n.AFOOL\n     0C31   6C 03 0B   JMP (&0B03)\n.M2\n     0C34   02\n.VIA2\n     0C35   A9 04      LDA #&04\n     0C37   8D 20 FE   STA &FE20\n     0C3A   A0 0B      LDY #&0B\n.inlp1\n     0C3C   B9 07 0B   LDA &0B07,Y\n     0C3F   8D 21 FE   STA &FE21\n     0C42   88         DEY\n     0C43   10 F7      BPL &0C3C\n     0C45   68         PLA\n     0C46   A8         TAY\n     0C47   6C FE 7F   JMP (&7FFE)\n.IRQ1\n     0C4A   98         TYA\n     0C4B   48         PHA\n     0C4C   AD 4D FE   LDA &FE4D\n     0C4F   2C 34 0C   BIT &0C34\n     0C52   D0 09      BNE &0C5D\n     0C54   29 40      AND #&40\n     0C56   D0 DD      BNE &0C35\n     0C58   68         PLA\n     0C59   A8         TAY\n     0C5A   6C FE 7F   JMP (&7FFE)\n.LINSCN\n     0C5D   A9 32      LDA #&32\n     0C5F   8D 44 FE   STA &FE44\n     0C62   A9 38      LDA #&38\n     0C64   8D 45 FE   STA &FE45\n     0C67   A9 08      LDA #&08\n     0C69   8D 20 FE   STA &FE20\n     0C6C   A0 0B      LDY #&0B\n.inlp2\n     0C6E   B9 13 0B   LDA &0B13,Y\n     0C71   8D 21 FE   STA &FE21\n     0C74   88         DEY\n     0C75   10 F7      BPL &0C6E\n     0C77   68         PLA\n     0C78   A8         TAY\n     0C79   6C FE 7F   JMP (&7FFE)\n.BLOCK\n     0C7C   C2 0B\n     0C7E   62 01\n     0C80   AD 44 FE   LDA &FE44\n     0C83   85 01      STA &01\n     0C85   78         SEI\n     0C86   A9 39      LDA #&39\n     0C88   8D 4E FE   STA &FE4E\n     0C8B   AD 44 0F   LDA &0F44\n     0C8E   8D 04 02   STA &0204\n     0C91   AD 45 0F   LDA &0F45\n     0C94   8D 05 02   STA &0205\n     0C97   A9 38      LDA #&38\n     0C99   8D 45 FE   STA &FE45\n     0C9C   58         CLI\n     0C9D   A0 00      LDY #&00\n     0C9F   A9 C8      LDA #&C8\n     0CA1   A2 03      LDX #&03\n     0CA3   20 F4 FF   JSR &FFF4\n.BLAST\n     0CA6   A9 0F      LDA #&0F\n     0CA8   85 71      STA &71\n     0CAA   A9 40      LDA #&40\n     0CAC   85 70      STA &70\n     0CAE   A2 45      LDX #&45\n     0CB0   A0 00      LDY #&00\n     0CB2   98         TYA\n.CHK\n     0CB3   18         CLC\n     0CB4   71 70      ADC (&70),Y\n     0CB6   C8         INY\n     0CB7   D0 FA      BNE &0CB3\n     0CB9   E6 71      INC &71\n     0CBB   CA         DEX\n     0CBC   10 F5      BPL &0CB3\n     0CBE   CD 39 56   CMP &5639\n     0CC1   F0 0B      BEQ &0CCE\n.nononono\n     0CC3   8D 41 0F   STA &0F41\n     0CC6   A9 7F      LDA #&7F\n     0CC8   8D 4E FE   STA &FE4E\n     0CCB   6C FC FF   JMP (&FFFC)\n.itsOK\n     0CCE   6C 40 0F   JMP (&0F40)\n.CHECKER\n     0CD1   A0 00      LDY #&00\n     0CD3   A2 04      LDX #&04\n     0CD5   86 71      STX &71\n     0CD7   84 70      STY &70\n     0CD9   98         TYA\n.CHKq\n     0CDA   18         CLC\n     0CDB   71 70      ADC (&70),Y\n     0CDD   C8         INY\n     0CDE   D0 FA      BNE &0CDA\n     0CE0   E6 71      INC &71\n     0CE2   CA         DEX\n     0CE3   D0 F5      BNE &0CDA\n     0CE5   CD 02 0B   CMP &0B02\n     0CE8   D0 D9      BNE &0CC3\n     0CEA   98         TYA\n.CHKb\n     0CEB   18         CLC\n     0CEC   79 00 11   ADC &1100,Y\n     0CEF   C8         INY\n     0CF0   C0 28      CPY #&28\n     0CF2   D0 F7      BNE &0CEB\n     0CF4   CD 01 0B   CMP &0B01\n     0CF7   D0 CA      BNE &0CC3\n     0CF9   6C 05 0B   JMP (&0B05)\n.ENDBLOCK\n.XC\n     0CFC   07\n.YC\n     0CFD   06\nAddresses for the scramble routines in elite-checksum.py\nBLOCK_offset = &14B0 \nENDBLOCK_offset = &1530 \nMAINSUM_offset = &1335 \nTUT_offset = &13E1 \nCHECKbyt_offset = &1334 \nCODE_offset = &F86 \nUU% = &2434 \nQ% = &1934 \nOSB = &2086 \nMemory usage: &B00  - &CFE \nStack: 161 \nS. ELITE &1100  &2632  &2000  &1100 \nSaving file '3-assembled-output/ELITE.unprot.bin'\n.readme\n     0000   0A\n     0001   0D\n     0002   2D 2D 2D ...\n     0029   0A\n     002A   0D\n     002B   41 63 6F ...\n     003A   0A\n     003B   0D\n     003C   0A\n     003D   0D\n     003E   56 65 72 ...\n     0059   0A\n     005A   0D\n     005B   56 61 72 ...\n     007D   0A\n     007E   0D\n     007F   50 72 6F ...\n     0097   0A\n     0098   0D\n     0099   0A\n     009A   0D\n     009B   53 65 65 ...\n     00BB   0A\n     00BC   0D\n     00BD   2D 2D 2D ...\n     00E4   0A\n     00E5   0D\nSaving file '3-assembled-output/README.txt'\n"
  },
  {
    "path": "4-reference-binaries/README.md",
    "content": "# Reference binaries for the BBC Micro cassette version of Elite\n\nThis folder contains the binaries from the original sources for the BBC Micro cassette version of Elite on Ian Bell's personal website, as well as reference binaries for the other releases.\n\n* [source-disc](source-disc) contains the binaries from the source disc on Ian Bell's personal website\n\n* [sth](sth) contains the binaries from the Stairway to Hell version\n\n* [sth-for-tape](sth-for-tape) contains the binaries from the Stairway to Hell version when built for tape (i.e. with disc=no)\n\n* [text-sources](text-sources) contains the binaries from the text version of the source code on Ian Bell's personal website\n\n---\n\nRight on, Commanders!\n\n_Mark Moxon_"
  },
  {
    "path": "5-compiled-game-discs/README.md",
    "content": "# Compiled game discs for the BBC Micro cassette version of Elite\n\nThis folder contains the SSD disc images for the BBC Micro cassette version of Elite, as produced by the build process. There is one SSD file for each supported release. These SSD images can be loaded into an emulator like JSBeeb or BeebEm, or into a real BBC Micro using a device like a Gotek.\n\nIt also contains UEF tape images that will work with emulators and the TZXDuino (though you may need to unzip them before they will work with the latter).\n\n---\n\nRight on, Commanders!\n\n_Mark Moxon_"
  },
  {
    "path": "Makefile",
    "content": "BEEBASM?=beebasm\nPYTHON?=python\nPHP?=php\n\n# A make command with no arguments will build the source disc variant with\n# encrypted binaries, checksums enabled, the standard commander and crc32\n# verification of the game binaries\n#\n# Optional arguments for the make command are:\n#\n#   variant=<release>   Build the specified variant:\n#\n#                         source-disc (default)\n#                         text-sources\n#                         sth\n#\n#   disc=no             Build a version to load from cassette rather than disc\n#\n#   protect=no          Disable block-level tape protection code (disc=no only)\n#\n#   commander=max       Start with a maxed-out commander\n#\n#   encrypt=no          Disable encryption and checksum routines\n#\n#   verify=no           Disable crc32 verification of the game binaries\n#\n# So, for example:\n#\n#   make variant=text-sources commander=max encrypt=no verify=no\n#\n# will build an unencrypted text sources variant with a maxed-out commander\n# and no crc32 verification\n#\n# The following variables are written into elite-build-options.asm depending on\n# the above arguments, so they can be passed to BeebAsm:\n#\n# _VERSION\n#   1 = BBC Micro cassette\n#\n# _VARIANT\n#   1 = Source disc\n#   2 = Text sources\n#   3 = Stairway to Hell (default)\n#\n# _MAX_COMMANDER\n#   TRUE  = Maxed-out commander\n#   FALSE = Standard commander\n#\n# _REMOVE_CHECKSUMS\n#   TRUE  = Disable checksum routines\n#   FALSE = Enable checksum routines\n#\n# _MATCH_ORIGINAL_BINARIES\n#   TRUE  = Match binaries to released version (i.e. fill workspaces with noise)\n#   FALSE = Zero-fill workspaces\n#\n# _DISC\n#   TRUE  = Build for loading from disc\n#   FALSE = Build for loading from cassette\n#\n# _PROT\n#   TRUE  = Apply block-level tape protection\n#   FALSE = Do not apply block-level tape protection\n#\n# The encrypt and verify arguments are passed to the elite-checksum.py and\n# crc32.py scripts, rather than BeebAsm\n\nifeq ($(commander), max)\n  max-commander=TRUE\nelse\n  max-commander=FALSE\nendif\n\nifeq ($(encrypt), no)\n  unencrypt=-u\n  remove-checksums=TRUE\nelse\n  unencrypt=\n  remove-checksums=FALSE\nendif\n\nifeq ($(match), no)\n  match-original-binaries=FALSE\nelse\n  match-original-binaries=TRUE\nendif\n\nifeq ($(protect), no)\n  protect-tape=\n  prot=FALSE\nelse\n  protect-tape=-p\n  prot=TRUE\nendif\n\nifeq ($(disc), no)\n  tape-or-disc=-t\n  build-for-disc=FALSE\nelse\n  tape-or-disc=\n  build-for-disc=TRUE\n  protect-tape=\n  prot=FALSE\nendif\n\nifeq ($(variant), text-sources)\n  variant-number=2\n  folder=text-sources\n  suffix=-from-text-sources\nelse ifeq ($(variant), source-disc)\n  variant-number=1\n  folder=source-disc\n  suffix=-from-source-disc\nelse\n  variant-number=3\n  suffix=-sth\n  ifeq ($(disc), no)\n    folder=sth-for-tape\n  else\n    folder=sth\n  endif\nendif\n\n.PHONY:all\nall:\n\techo _VERSION=1 > 1-source-files/main-sources/elite-build-options.asm\n\techo _VARIANT=$(variant-number) >> 1-source-files/main-sources/elite-build-options.asm\n\techo _REMOVE_CHECKSUMS=$(remove-checksums) >> 1-source-files/main-sources/elite-build-options.asm\n\techo _MAX_COMMANDER=$(max-commander) >> 1-source-files/main-sources/elite-build-options.asm\n\techo _DISC=$(build-for-disc) >> 1-source-files/main-sources/elite-build-options.asm\n\techo _PROT=$(prot) >> 1-source-files/main-sources/elite-build-options.asm\n\t$(BEEBASM) -i 1-source-files/main-sources/elite-source.asm -v > 3-assembled-output/compile.txt\n\t$(BEEBASM) -i 1-source-files/main-sources/elite-bcfs.asm -v >> 3-assembled-output/compile.txt\n\t$(BEEBASM) -i 1-source-files/main-sources/elite-loader.asm -v >> 3-assembled-output/compile.txt\n\t$(BEEBASM) -i 1-source-files/main-sources/elite-readme.asm -v >> 3-assembled-output/compile.txt\n\t$(PYTHON) 2-build-files/elite-checksum.py $(unencrypt) $(tape-or-disc) $(protect-tape) -rel$(variant-number)\n\t$(BEEBASM) -i 1-source-files/main-sources/elite-disc.asm -do 5-compiled-game-discs/elite-cassette$(suffix).ssd -opt 3 -title \"E L I T E\"\nifneq ($(verify), no)\n\t@$(PYTHON) 2-build-files/crc32.py 4-reference-binaries/$(folder) 3-assembled-output\nendif\n\n.PHONY:b2\nb2:\n\tcurl -G \"http://localhost:48075/reset/b2\"\n\tcurl -H \"Content-Type:application/binary\" --upload-file \"5-compiled-game-discs/elite-cassette$(suffix).ssd\" \"http://localhost:48075/run/b2?name=elite-cassette$(suffix).ssd\"\n\n.PHONY:uef\nuef: all\n\t$(PHP) 2-build-files/mktibet-0.3.php +t temp.tbt +n ELITE +d FFFF0E00 +x FFFF8023 1-source-files/basic-programs/$$.ELITE-cassette.bin +n ELITEdata +d FFFF0E00 +x FFFF1D00 3-assembled-output/ELITE.bin +n ELITEcode +d 00000E00 +x 00000132 3-assembled-output/ELTcode.bin +n README +d FFFFFFFF +x FFFFFFFF 3-assembled-output/README.txt\n\tphp 2-build-files/tibetuef-0.8.php +nz temp.tbt 5-compiled-game-discs/elite-cassette$(suffix).uef\n\trm temp.tbt\n"
  },
  {
    "path": "README.md",
    "content": "# Fully documented source code for the cassette version of Elite on the BBC Micro\n\n<details>\n<summary>Links to my other software archaeology repositories</summary>\n<hr>\n\n**Elite sources:** [BBC Micro (cassette)](https://github.com/markmoxon/elite-source-code-bbc-micro-cassette) | [BBC Micro (disc)](https://github.com/markmoxon/elite-source-code-bbc-micro-disc) | [Elite Demonstration Disc](https://github.com/markmoxon/elite-demo-source-code-bbc-micro) | [Acorn Electron](https://github.com/markmoxon/elite-source-code-acorn-electron) | [6502 Second Processor](https://github.com/markmoxon/elite-source-code-6502-second-processor) | [Commodore 64](https://github.com/markmoxon/elite-source-code-commodore-64) | [Apple II](https://github.com/markmoxon/elite-source-code-apple-ii) | [BBC Master](https://github.com/markmoxon/elite-source-code-bbc-master) | [NES](https://github.com/markmoxon/elite-source-code-nes)\n\n**Elite hacks:** [Elite-A](https://github.com/markmoxon/elite-a-source-code-bbc-micro) | [Teletext Elite](https://github.com/markmoxon/teletext-elite) | [Elite Universe Editor](https://github.com/markmoxon/elite-universe-editor) | [Flicker-free Commodore 64 Elite](https://github.com/markmoxon/c64-elite-flicker-free) | [Elite over Econet](https://github.com/markmoxon/elite-over-econet) | [!EliteNet](https://github.com/markmoxon/elite-over-econet-acorn-archimedes)\n\n**Elite Compendium:** [BBC Master](https://github.com/markmoxon/elite-compendium-bbc-master) | [BBC Micro](https://github.com/markmoxon/elite-compendium-bbc-micro) | [BBC Micro B+](https://github.com/markmoxon/elite-compendium-bbc-micro-b-plus) | [Acorn Electron](https://github.com/markmoxon/elite-compendium-acorn-electron)\n\n**Other sources:** [Aviator (BBC Micro)](https://github.com/markmoxon/aviator-source-code-bbc-micro) | [Revs (BBC Micro)](https://github.com/markmoxon/revs-source-code-bbc-micro) | [The Sentinel (BBC Micro)](https://github.com/markmoxon/the-sentinel-source-code-bbc-micro) | [Lander (Acorn Archimedes)](https://github.com/markmoxon/lander-source-code-acorn-archimedes)\n\nSee [my profile](https://github.com/markmoxon) for more repositories to explore.\n<hr>\n</details>\n\n![Screenshot of Elite on the BBC Micro](https://elite.bbcelite.com/images/github/Elite-BBCMicro.png)\n\nThis repository contains the original source code for the cassette version of Ian Bell and David Braben's classic game Elite on the BBC Micro, with every single line documented and (for the most part) explained. It is literally the original source code, just heavily commented.\n\nIt is a companion to the [elite.bbcelite.com website](https://elite.bbcelite.com).\n\nSee the [introduction](#introduction) for more information, or jump straight into the [documented source code](1-source-files/main-sources).\n\n## Contents\n\n* [Introduction](#introduction)\n\n* [Acknowledgements](#acknowledgements)\n\n  * [A note on licences, copyright etc.](#user-content-a-note-on-licences-copyright-etc)\n\n* [Browsing the source in an IDE](#browsing-the-source-in-an-ide)\n\n* [Folder structure](#folder-structure)\n\n* [Flicker-free Elite](#flicker-free-elite)\n\n* [Elite Compendium](#elite-compendium)\n\n* [Building BBC Micro cassette Elite from the source](#building-bbc-micro-cassette-elite-from-the-source)\n\n  * [Requirements](#requirements)\n  * [Windows](#windows)\n  * [Mac and Linux](#mac-and-linux)\n  * [Build options](#build-options)\n  * [Updating the checksum scripts if you change the code](#updating-the-checksum-scripts-if-you-change-the-code)\n  * [Verifying the output](#verifying-the-output)\n  * [Log files](#log-files)\n  * [Auto-deploying to the b2 emulator](#auto-deploying-to-the-b2-emulator)\n  * [Building a UEF tape image](#building-a-uef-tape-image)\n\n* [Building different variants of the cassette version of Elite](#building-different-variants-of-the-cassette-version-of-elite)\n\n  * [Building the Stairway to Hell variant](#building-the-stairway-to-hell-variant)\n  * [Building the source disc variant](#building-the-source-disc-variant)\n  * [Building the text sources variant](#building-the-text-sources-variant)\n  * [Differences between the variants](#differences-between-the-variants)\n\n* [Notes on the original source files](#notes-on-the-original-source-files)\n\n  * [Fixing a bug in the source disc](#fixing-a-bug-in-the-source-disc)\n\n## Introduction\n\nThis repository contains the original source code for the cassette version of Elite on the BBC Micro, with every single line documented and (for the most part) explained.\n\nYou can build the fully functioning game from this source. [Three variants](#building-different-variants-of-the-cassette-version-of-elite) are currently supported: the tape version from the Stairway to Hell archive, the version produced by the original source discs from Ian Bell's personal website, and the version built from the text sources from the same site.\n\nThis repository is a companion to the [elite.bbcelite.com website](https://elite.bbcelite.com), which contains all the code from this repository, but laid out in a much more human-friendly fashion. The links at the top of this page will take you to repositories for the other versions of Elite that are covered by this project.\n\n* If you want to browse the source and read about how Elite works under the hood, you will probably find [the website](https://elite.bbcelite.com) a better place to start than this repository.\n\n* If you would rather explore the source code in your favourite IDE, then the [annotated source](1-source-files/main-sources) is what you're looking for. It contains the exact same content as the website, so you won't be missing out (the website is generated from the source files, so they are guaranteed to be identical). You might also like to read the section on [browsing the source in an IDE](#browsing-the-source-in-an-ide) for some tips.\n\n* If you want to build BBC Micro cassette Elite from the source on a modern computer, to produce a working game disc that can be loaded into a BBC Micro or an emulator, then you want the section on [building BBC Micro cassette Elite from the source](#building-bbc-micro-cassette-elite-from-the-source).\n\nMy hope is that this repository and the [accompanying website](https://elite.bbcelite.com) will be useful for those who want to learn more about Elite and what makes it tick. It is provided on an educational and non-profit basis, with the aim of helping people appreciate one of the most iconic games of the 8-bit era.\n\n## Acknowledgements\n\nBBC Micro Elite was written by Ian Bell and David Braben and is copyright &copy; Acornsoft 1984.\n\nThe code on this site is identical to the source discs released on [Ian Bell's personal website](http://www.elitehomepage.org/) (it's just been reformatted to be more readable).\n\nThe commentary is copyright &copy; Mark Moxon. Any misunderstandings or mistakes in the documentation are entirely my fault.\n\nHuge thanks are due to the original authors for not only creating such an important piece of my childhood, but also for releasing the source code for us to play with; to Paul Brink for his annotated disassembly; and to Kieran Connell for his [BeebAsm version](https://github.com/kieranhj/elite-beebasm), which I forked as the original basis for this project. You can find more information about this project in the [accompanying website's project page](https://elite.bbcelite.com/about_site/about_this_project.html).\n\nThank you to Diminished for the UEF scripts, which are part of the [Quadbike 2](https://stardot.org.uk/forums/viewtopic.php?t=26669) tape transcriber.\n\nThe following archives from Ian Bell's personal website form the basis for this project:\n\n* [BBC Micro cassette Elite sources as a disc image](http://www.elitehomepage.org/archive/a/a4080602.zip)\n* [BBC Micro cassette Elite sources as text files](http://www.elitehomepage.org/archive/a/a4080610.zip)\n\n### A note on licences, copyright etc.\n\nThis repository is _not_ provided with a licence, and there is intentionally no `LICENSE` file provided.\n\nAccording to [GitHub's licensing documentation](https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/licensing-a-repository), this means that \"the default copyright laws apply, meaning that you retain all rights to your source code and no one may reproduce, distribute, or create derivative works from your work\".\n\nThe reason for this is that my commentary is intertwined with the original source code for Elite, and the original source code is copyright. The whole site is therefore covered by default copyright law, to ensure that this copyright is respected.\n\nUnder GitHub's rules, you have the right to read and fork this repository... but that's it. No other use is permitted, I'm afraid.\n\nMy hope is that the educational and non-profit intentions of this repository will enable it to stay hosted and available, but the original copyright holders do have the right to ask for it to be taken down, in which case I will comply without hesitation. I do hope, though, that along with the various other disassemblies and commentaries of this source, it will remain viable.\n\n## Browsing the source in an IDE\n\nIf you want to browse the source in an IDE, you might find the following useful.\n\n* The most interesting files are in the [main-sources](1-source-files/main-sources) folder:\n\n  * The main game's source code is in the [elite-source.asm](1-source-files/main-sources/elite-source.asm) file - this is the motherlode and probably contains all the stuff you're interested in.\n\n  * The game's loader is in the [elite-loader.asm](1-source-files/main-sources/elite-loader.asm) file - this is mainly concerned with setup and copy protection.\n\n* It's probably worth skimming through the [notes on terminology and notations](https://elite.bbcelite.com/terminology/) on the accompanying website, as this explains a number of terms used in the commentary, without which it might be a bit tricky to follow at times (in particular, you should understand the terminology I use for multi-byte numbers).\n\n* The accompanying website contains [a number of \"deep dive\" articles](https://elite.bbcelite.com/deep_dives/), each of which goes into an aspect of the game in detail. Routines that are explained further in these articles are tagged with the label `Deep dive:` and the relevant article name.\n\n* There are loads of routines and variables in Elite - literally hundreds. You can find them in the source files by searching for the following: `Type: Subroutine`, `Type: Variable`, `Type: Workspace` and `Type: Macro`.\n\n* If you know the name of a routine, you can find it by searching for `Name: <name>`, as in `Name: SCAN` (for the 3D scanner routine) or `Name: LL9` (for the ship-drawing routine).\n\n* The entry point for the [main game code](1-source-files/main-sources/elite-source.asm) is routine `TT170`, which you can find by searching for `Name: TT170`. If you want to follow the program flow all the way from the title screen around the main game loop, then you can find a number of [deep dives on program flow](https://elite.bbcelite.com/deep_dives/) on the accompanying website.\n\n* The source code is designed to be read at an 80-column width and with a monospaced font, just like in the good old days.\n\nI hope you enjoy exploring the inner workings of BBC Elite as much as I have.\n\n## Folder structure\n\nThere are five main folders in this repository, which reflect the order of the build process.\n\n* [1-source-files](1-source-files) contains all the different source files, such as the main assembler source files, image binaries, fonts, boot files and so on.\n\n* [2-build-files](2-build-files) contains build-related scripts, such as the checksum, encryption and crc32 verification scripts.\n\n* [3-assembled-output](3-assembled-output) contains the output from the assembly process, when the source files are assembled and the results processed by the build files.\n\n* [4-reference-binaries](4-reference-binaries) contains the correct binaries for each variant, so we can verify that our assembled output matches the reference.\n\n* [5-compiled-game-discs](5-compiled-game-discs) contains the final output of the build process: an SSD disc image that contains the compiled game and which can be run on real hardware or in an emulator.\n\n## Flicker-free Elite\n\nThis repository also includes a flicker-free version, which incorporates the backported flicker-free ship-drawing routines from the BBC Master. The flicker-free code is in a separate branch called `flicker-free`, and apart from the code differences for reducing flicker, this branch is identical to the main branch and the same build process applies.\n\nThe annotated source files in the `flicker-free` branch contain both the original Acornsoft code and all of the modifications for flicker-free Elite, so you can look through the source to see exactly what's changed. Any code that I've removed from the original version is commented out in the source files, so when they are assembled they produce the flicker-free binaries, while still containing details of all the modifications. You can find all the diffs by searching the sources for `Mod:`.\n\nFor more information on flicker-free Elite, see the [hacks section of the accompanying website](https://elite.bbcelite.com/hacks/flicker-free_elite.html).\n\n## Elite Compendium\n\nThis repository also includes a version of BBC Micro cassette Elite for the Elite Compendium, which incorporates all the available hacks in one game. The Compendium version is in a separate branch called `elite-compendium`, which is included in the [Elite Compendium (BBC Micro)](https://github.com/markmoxon/elite-compendium-bbc-micro) repository as a submodule.\n\nThe annotated source files in the `elite-compendium` branch contain both the original Acornsoft code and all of the modifications for the Elite Compendium, so you can look through the source to see exactly what's changed. Any code that I've removed from the original version is commented out in the source files, so when they are assembled they produce the Compendium binaries, while still containing details of all the modifications. You can find all the diffs by searching the sources for `Mod:`.\n\nFor more information on the Elite Compendium, see the [hacks section of the accompanying website](https://elite.bbcelite.com/hacks/elite_compendium.html).\n\n## Building BBC Micro cassette Elite from the source\n\nBuilds are supported for both Windows and Mac/Linux systems. In all cases the build process is defined in the `Makefile` provided.\n\n### Requirements\n\nYou will need the following to build BBC Micro cassette Elite from the source:\n\n* BeebAsm, which can be downloaded from the [BeebAsm repository](https://github.com/stardot/beebasm). Mac and Linux users will have to build their own executable with `make code`, while Windows users can just download the `beebasm.exe` file.\n\n* Python. The build process has only been tested on 3.x, but 2.7 might work.\n\n* Mac and Linux users may need to install `make` if it isn't already present (for Windows users, `make.exe` is included in this repository).\n\nFor details of how the build process works, see the [build documentation on bbcelite.com](https://elite.bbcelite.com/about_site/building_elite.html).\n\nLet's look at how to build BBC Micro cassette Elite from the source.\n\n### Windows\n\nFor Windows users, there is a batch file called `make.bat` which you can use to build the game. Before this will work, you should edit the batch file and change the values of the `BEEBASM` and `PYTHON` variables to point to the locations of your `beebasm.exe` and `python.exe` executables. You also need to change directory to the repository folder (i.e. the same folder as `make.bat`).\n\nAll being well, entering the following into a command window:\n\n```\nmake.bat\n```\n\nwill produce a file called `elite-cassette-sth.ssd` in the `5-compiled-game-discs` folder that contains the source disc variant, which you can then load into an emulator, or into a real BBC Micro using a device like a Gotek.\n\n### Mac and Linux\n\nThe build process uses a standard GNU `Makefile`, so you just need to install `make` if your system doesn't already have it. If BeebAsm or Python are not on your path, then you can either fix this, or you can edit the `Makefile` and change the `BEEBASM` and `PYTHON` variables in the first two lines to point to their locations. You also need to change directory to the repository folder (i.e. the same folder as `Makefile`).\n\nAll being well, entering the following into a terminal window:\n\n```\nmake\n```\n\nwill produce a file called `elite-cassette-sth.ssd` in the `5-compiled-game-discs` folder that contains the source disc variant, which you can then load into an emulator, or into a real BBC Micro using a device like a Gotek.\n\n### Build options\n\nBy default the build process will create a typical Elite game disc with a standard commander and verified binaries. There are various arguments you can pass to the build to change how it works. They are:\n\n* `variant=<name>` - Build the specified variant:\n\n  * `variant=sth` (default)\n  * `variant=source-disc`\n  * `variant=text-sources`\n\n* `disc=no` - Build a version to load from cassette rather than disc (the default is to build a version that loads from disc)\n\n* `protect=no` - When building for cassette with `disc=no`, the loader contains block-level tape protection code, which you can disable with this argument (the protection only works if you save the ELITEcode file to tape with corrupted block data, so if you want to create a UEF without re-implementing the Acornsoft protection system, you should use this argument)\n\n* `commander=max` - Start with a maxed-out commander (specifically, this is the test commander file from the original source, which is almost but not quite maxed-out)\n\n* `encrypt=no` - Disable encryption and checksum routines\n\n* `verify=no` - Disable crc32 verification of the game binaries\n\nSo, for example:\n\n`make variant=text-sources commander=max encrypt=no match=no verify=no`\n\nwill build an unencrypted text sources variant with a maxed-out commander, no workspace noise and no crc32 verification.\n\nThe unencrypted version should be more useful for anyone who wants to make modifications to the game code. As this argument produces unencrypted files, the binaries produced will be quite different to the binaries on the original source disc, which are encrypted.\n\nSee below for more on the verification process.\n\n### Updating the checksum scripts if you change the code\n\nIf you change the source code in any way, you may break the game; if so, it will typically hang at the loading screen, though in some versions it may hang when launching from the space station.\n\nTo fix this, you may need to update some of the hard-coded addresses in the checksum script so that they match the new addresses in your changed version of the code. See the comments in the [elite-checksum.py](2-build-files/elite-checksum.py) script for details.\n\n### Verifying the output\n\nThe default build process prints out checksums of all the generated files, along with the checksums of the files from the original sources. You can disable verification by passing `verify=no` to the build.\n\nThe Python script `crc32.py` in the `2-build-files` folder does the actual verification, and shows the checksums and file sizes of both sets of files, alongside each other, and with a Match column that flags any discrepancies. If you are building an unencrypted set of files then there will be lots of differences, while the encrypted files should mostly match (see the Differences section below for more on this).\n\nThe binaries in the `4-reference-binaries` folder were taken straight from the [cassette sources disc image](http://www.elitehomepage.org/archive/a/a4080602.zip), while those in the `3-assembled-output` folder are produced by the build process. For example, if you don't make any changes to the code and build the project with `make`, then this is the output of the verification process:\n\n```\nResults for variant: sth\n[--originals--]  [---output----]\nChecksum   Size  Checksum   Size  Match  Filename\n-----------------------------------------------------------\na88ca82b   5426  a88ca82b   5426   Yes   ELITE.bin\nf40816ec   5426  f40816ec   5426   Yes   ELITE.unprot.bin\nb17f9589   2228  b17f9589   2228   Yes   ELTA.bin\n82de44f7   2600  82de44f7   2600   Yes   ELTB.bin\nf005a7bf   2732  f005a7bf   2732   Yes   ELTC.bin\nac3476d9   2887  ac3476d9   2887   Yes   ELTD.bin\n3084f112   2663  3084f112   2663   Yes   ELTE.bin\ne46bac22   2719  e46bac22   2719   Yes   ELTF.bin\nb4ac917d   2340  b4ac917d   2340   Yes   ELTG.bin\nb1bf493e  20712  b1bf493e  20712   Yes   ELTcode.bin\n33de34f5  20712  33de34f5  20712   Yes   ELTcode.unprot.bin\n00d5bb7a     40  00d5bb7a     40   Yes   ELThead.bin\n99529ca8    256  99529ca8    256   Yes   PYTHON.bin\n49ee043c   2502  49ee043c   2502   Yes   SHIPS.bin\nc4547e5e   1023  c4547e5e   1023   Yes   WORDS9.bin\n```\n\nAll the compiled binaries match the originals, so we know we are producing the same final game as the Stairway to Hell variant.\n\n### Log files\n\nDuring compilation, details of every step are output in a file called `compile.txt` in the `3-assembled-output` folder. If you have problems, it might come in handy, and it's a great reference if you need to know the addresses of labels and variables for debugging (or just snooping around).\n\n### Auto-deploying to the b2 emulator\n\nFor users of the excellent [b2 emulator](https://github.com/tom-seddon/b2), you can include the build parameter `b2` to automatically load and boot the assembled disc image in b2. The b2 emulator must be running for this to work.\n\nFor example, to build, verify and load the game into b2, you can do this on Windows:\n\n```\nmake.bat all b2\n```\n\nor this on Mac/Linux:\n\n```\nmake all b2\n```\n\nIf you omit the `all` target then b2 will start up with the results of the last successful build.\n\nNote that you should manually choose the correct platform in b2 (I intentionally haven't automated this part to make it easier to test across multiple platforms).\n\n### Building a UEF tape image\n\nDespite this being the cassette version of BBC Micro Elite, this repository only builds disc images by default, as that's how BeebAsm works. If you want the authentic experience of loading Elite from cassette, then you can build a UEF with the following command on Windows:\n\n```\nmake.bat uef disc=no protect=no\n```\n\nor this on Mac/Linux:\n\n```\nmake uef disc=no protect=no\n```\n\nYou should now be able to load Elite from your UEF on a BBC Micro, by entering `CHAIN \"ELITE\"`. These UEF tape images will work with emulators and the TZXDuino (though you may need to unzip them before they will work with the latter).\n\nFor this to work, you will need PHP installed, and you should edit the `Makefile` (and `make.bat` on Windows) to point to PHP (specifically, you'll need to point the `PHP` variable to point to the locations of your `php` or `php.exe` binary).\n\nNote that in order for your UEF to work, you need to include the `disc=no` and `protect=no` arguments to the build (as above). This ensures that the binaries are built to load at the correct address for tape systems, and it also disables the block-level tape protection system, as this only works with specially created tape images, like the ones that Acornsoft originally released.\n\n## Building different variants of the cassette version of Elite\n\nThis repository contains the source code for three different variants of the cassette version of Elite:\n\n* The variant from the Stairway to Hell archive\n\n* The variant produced by the original source discs from Ian Bell's personal website\n\n* The variant built from the text sources from the same site\n\nBy default the build process builds the Stairway to Hell variant, but you can build a specified variant using the `variant=` build parameter.\n\n### Building the Stairway to Hell variant\n\nYou can add `variant=source-disc` to produce the `elite-cassette-from-source-disc.ssd` file containing the source disc variant, though that's the default value so it isn't necessary. In other words, you can build it like this:\n\n```\nmake.bat variant=sth\n```\n\nor this on a Mac or Linux:\n\n```\nmake variant=sth\n```\n\nThis will produce a file called `elite-cassette-sth.ssd` in the `5-compiled-game-discs` folder that contains the Stairway to Hell variant.\n\nThe verification checksums for this version are as follows:\n\n```\nResults for variant: sth\n[--originals--]  [---output----]\nChecksum   Size  Checksum   Size  Match  Filename\n-----------------------------------------------------------\na88ca82b   5426  a88ca82b   5426   Yes   ELITE.bin\nf40816ec   5426  f40816ec   5426   Yes   ELITE.unprot.bin\nb17f9589   2228  b17f9589   2228   Yes   ELTA.bin\n82de44f7   2600  82de44f7   2600   Yes   ELTB.bin\nf005a7bf   2732  f005a7bf   2732   Yes   ELTC.bin\nac3476d9   2887  ac3476d9   2887   Yes   ELTD.bin\n3084f112   2663  3084f112   2663   Yes   ELTE.bin\ne46bac22   2719  e46bac22   2719   Yes   ELTF.bin\nb4ac917d   2340  b4ac917d   2340   Yes   ELTG.bin\nb1bf493e  20712  b1bf493e  20712   Yes   ELTcode.bin\n33de34f5  20712  33de34f5  20712   Yes   ELTcode.unprot.bin\n00d5bb7a     40  00d5bb7a     40   Yes   ELThead.bin\n99529ca8    256  99529ca8    256   Yes   PYTHON.bin\n49ee043c   2502  49ee043c   2502   Yes   SHIPS.bin\nc4547e5e   1023  c4547e5e   1023   Yes   WORDS9.bin\n```\n\nNote that if you add the `disc=no` build parameter, then the build will produce binaries that are designed to be loaded from cassette rather than disc. The verification step will compare the results to the exact binaries from the UEF from the Stairway to Hell archive. These binaries have block-level tape protection enabled by default, so they will not match. You can override the block-level protection with `protect=no`.\n\n### Building the source disc variant\n\nYou can build the source disc variant by appending `variant=source-disc` to the `make` command, like this on Windows:\n\n```\nmake.bat variant=source-disc\n```\n\nor this on a Mac or Linux:\n\n```\nmake variant=source-disc\n```\n\nThis will produce a file called `elite-cassette-from-source-disc.ssd` in the `5-compiled-game-discs` folder that contains the source disc variant.\n\nThe verification checksums for this version are as follows:\n\n```\nResults for variant: source-disc\n[--originals--]  [---output----]\nChecksum   Size  Checksum   Size  Match  Filename\n-----------------------------------------------------------\na88ca82b   5426  a88ca82b   5426   Yes   ELITE.bin\nf40816ec   5426  f40816ec   5426   Yes   ELITE.unprot.bin\n0f1ad255   2228  0f1ad255   2228   Yes   ELTA.bin\ne725760a   2600  e725760a   2600   Yes   ELTB.bin\n97e338e8   2735  97e338e8   2735   Yes   ELTC.bin\n322b174c   2882  322b174c   2882   Yes   ELTD.bin\n29f7b8cb   2663  29f7b8cb   2663   Yes   ELTE.bin\n8a4cecc2   2721  8a4cecc2   2721   Yes   ELTF.bin\n7a6a5d1a   2340  7a6a5d1a   2340   Yes   ELTG.bin\n01a00dce  20712  01a00dce  20712   Yes   ELTcode.bin\n1e4466ec  20712  1e4466ec  20712   Yes   ELTcode.unprot.bin\n00d5bb7a     40  00d5bb7a     40   Yes   ELThead.bin\n99529ca8    256  99529ca8    256   Yes   PYTHON.bin\n49ee043c   2502  49ee043c   2502   Yes   SHIPS.bin\nc4547e5e   1023  c4547e5e   1023   Yes   WORDS9.bin\n```\n\n### Building the text sources variant\n\nYou can build the text sources variant by appending `variant=text-sources` to the `make` command, like this on Windows:\n\n```\nmake.bat variant=text-sources\n```\n\nor this on a Mac or Linux:\n\n```\nmake variant=text-sources\n```\n\nThis will produce a file called `elite-cassette-from-text-sources.ssd` in the `5-compiled-game-discs` folder that contains the Ian Bell disc variant.\n\nThe verification checksums for this version are as follows:\n\n```\nResults for variant: text-sources\n[--originals--]  [---output----]\nChecksum   Size  Checksum   Size  Match  Filename\n-----------------------------------------------------------\n093c73aa   5426  093c73aa   5426   Yes   ELITE.bin\n24da3246   5426  24da3246   5426   Yes   ELITE.unprot.bin\n6c109c76   2228  6c109c76   2228   Yes   ELTA.bin\ncd8bee0c   2600  cd8bee0c   2600   Yes   ELTB.bin\n20c22628   2732  20c22628   2732   Yes   ELTC.bin\n23c13c71   2885  23c13c71   2885   Yes   ELTD.bin\nce0d9ec7   2663  ce0d9ec7   2663   Yes   ELTE.bin\n5aed3c61   2719  5aed3c61   2719   Yes   ELTF.bin\n13f3eace   2340  13f3eace   2340   Yes   ELTG.bin\n8b79fe39  20710  8b79fe39  20710   Yes   ELTcode.bin\n7c24aab0  20712  7c24aab0  20712   Yes   ELTcode.unprot.bin\n00d5bb7a     40  00d5bb7a     40   Yes   ELThead.bin\n99529ca8    256  99529ca8    256   Yes   PYTHON.bin\n8f4b6f2b   2502  8f4b6f2b   2502   Yes   SHIPS.bin\nc4547e5e   1023  c4547e5e   1023   Yes   WORDS9.bin\n```\n\n### Differences between the variants\n\nYou can see the differences between the variants by searching the source code for `_STH_CASSETTE` (for features in the Stairway to Hell variant), `_SOURCE_DISC` (for features in the source disc variant) or `_TEXT_SOURCES` (for features in the text sources variant). There are only minor differences:\n\n* The text sources contain an extra call in the galactic hyperspace routine that sets the current system to the nearest system to the crosshairs, in an attempt to fix a bug in the original source disc variant (though it doesn't quite fix it properly).\n\n* The Stairway to Hell variant contains the extra call in the galactic hyperspace routine, but in a different place, and it also zeroes the distance to the current system in QQ8. This fixes the galactic hyperspace bug properly, and this full bug fix is present in all other versions of the game.\n\n* In order to fit in this extra call, the text sources and Stairway to Hell variants also contain modifications to create space for the call.\n\n* There is a small change in the TTX66 routine to reset LAS2 to 0 instead of LASCT to stop laser pulsing, as this is slightly more efficient.\n\nSee the [accompanying website](https://elite.bbcelite.com/cassette/releases.html) for a comprehensive list of differences between the variants.\n\n## Notes on the original source files\n\n### Fixing a bug in the source disc\n\nIt also turns out there are two versions of the `ELITEB` BASIC source program on the [cassette sources disc image](http://www.elitehomepage.org/archive/a/a4080602.zip), one called `$.ELITEB` and another called `O.ELITEB`. These two versions of `ELITEB` differ by just one byte in the default commander data. This byte controls whether or not the commander has a rear pulse laser. In `O.ELITEB` this byte is generated by:\n\n```\nEQUB (POW + 128) AND Q%\n```\n\nwhile in `$.ELITEB`, this byte is generated by:\n\n```\nEQUB POW\n```\n\nThe BASIC variable `Q%` is a Boolean flag that, if `TRUE`, will create a default commander with lots of cash and equipment, which is useful for testing. You can see this in action if you build an unencrypted binary with `make build`, as the unencrypted build sets `Q%` to `TRUE` for this build target.\n\nThe BASIC variable `POW` has a value of 15, which is the power of a pulse laser. `POW + 128`, meanwhile, is the power of a beam laser.\n\nGiven the above, we can see that `O.ELITEB` correctly produces a default commander with no a rear laser if `Q%` is `FALSE`, but adds a rear beam laser if `Q%` is `TRUE`. This matches the default commander from the released game, and produces the `ELTcode` executable on the same disc. The version of `ELITEB` in the [cassette sources as text files](http://www.elitehomepage.org/archive/a/a4080610.zip) matches this version, `O.ELITEB`.\n\nIn contrast, `$.ELITEB` will always produce a default commander with a rear pulse laser, irrespective of the setting of `Q%`, so it doesn't match the released version.\n\nThe `ELTB` binary file in the `4-reference-binaries` folder of this repository matches the version generated by the source disc, so we can easily tell whether any changes we've made to the code deviate from this version. However, the `ELTB` binary file on the sources disc matches the version produced by `$.ELITEB`, rather than the version produced by `O.ELITEB` - in other words, `ELTB` on the source disc is not the version generated by the source code on the same disc.\n\nThe implication is that the `ELTB` binary file on the [cassette sources disc image](http://www.elitehomepage.org/archive/a/a4080602.zip) was produced by `$.ELITEB`, while the `ELTcode` file (the released game) used `O.ELITEB`. Perhaps the released game was compiled, and then someone backed up the `ELITEB` source to `O.ELITEB`, edited the `$.ELITEB` to have a rear pulse laser, and then generated a new `ELTB` binary file. Who knows? Unfortunately, files on DFS discs don't have timestamps, so it's hard to tell.\n\n---\n\nRight on, Commanders!\n\n_Mark Moxon_\n"
  },
  {
    "path": "make.bat",
    "content": "@echo off\nSETLOCAL\nSET BEEBASM=C:\\Users\\user\\bin\\beebasm.exe\nSET PYTHON=C:\\Users\\user\\AppData\\Local\\Microsoft\\WindowsApps\\python.exe\n2-build-files\\make %*\n"
  }
]