{
 "schema": 1,
 "platform": "c64",
 "game": "the-spy-who-loved-me",
 "part": "overlay",
 "build": "Domark's PAL disk, 007_the_spy_who_loved_me[domark_1990](pal)(!).g64: the game file S1 is a machine saved with Trilogic's Expert freezer cartridge and packed by its restart routine; the listings come from memory resumed at the game's first instruction, $0A03",
 "source": "regenerator2000 live",
 "regions": {
  "exclude": [
   [
    256,
    511,
    "stack"
   ],
   [
    53248,
    57343,
    "I/O and colour RAM"
   ],
   [
    0,
    16383,
    "The game"
   ],
   [
    18432,
    65535,
    "The game"
   ]
  ],
  "extra": [],
  "edges": [
   0,
   256,
   512,
   1024,
   2048,
   4096,
   16384,
   32768,
   40960,
   49152,
   53248,
   57344
  ],
  "elsewhere": [
   [
    0,
    16383,
    "The game"
   ],
   [
    18432,
    65535,
    "The game"
   ]
  ]
 },
 "blocks": [
  {
   "start": 16384,
   "end": 16584,
   "type": "Byte"
  },
  {
   "start": 16585,
   "end": 16585,
   "type": "Undefined"
  },
  {
   "start": 16586,
   "end": 16615,
   "type": "Byte"
  },
  {
   "start": 16616,
   "end": 16616,
   "type": "Undefined"
  },
  {
   "start": 16617,
   "end": 16679,
   "type": "Byte"
  },
  {
   "start": 16680,
   "end": 17988,
   "type": "Code"
  },
  {
   "start": 17989,
   "end": 18431,
   "type": "Byte"
  }
 ],
 "symbols": [
  {
   "address": 16384,
   "name": "shop_items",
   "type": "UserDefined",
   "kind": "user"
  },
  {
   "address": 16579,
   "name": "cost_text",
   "type": "UserDefined",
   "kind": "user"
  },
  {
   "address": 16585,
   "name": "item_price",
   "type": "AbsoluteAddress",
   "kind": "user"
  },
  {
   "address": 16586,
   "name": "item_pointers",
   "type": "Field",
   "kind": "user"
  },
  {
   "address": 16587,
   "name": "item_pointers_hi",
   "type": "Field",
   "kind": "user"
  },
  {
   "address": 16616,
   "name": "shop_cursor",
   "type": "AbsoluteAddress",
   "kind": "user"
  },
  {
   "address": 16617,
   "name": "high_scores",
   "type": "Field",
   "kind": "user"
  },
  {
   "address": 16618,
   "name": "high_score_letters",
   "type": "Field",
   "kind": "user"
  },
  {
   "address": 16619,
   "name": "high_score_letter_3",
   "type": "Field",
   "kind": "user"
  },
  {
   "address": 16620,
   "name": "high_score_digits",
   "type": "Field",
   "kind": "user"
  },
  {
   "address": 16621,
   "name": "high_score_byte_2",
   "type": "Field",
   "kind": "user"
  },
  {
   "address": 16622,
   "name": "high_score_byte_3",
   "type": "Field",
   "kind": "user"
  },
  {
   "address": 16623,
   "name": "high_score_byte_4",
   "type": "Field",
   "kind": "user"
  },
  {
   "address": 16624,
   "name": "high_scores_rest",
   "type": "Field",
   "kind": "user"
  },
  {
   "address": 16680,
   "name": "draw_high_scores",
   "type": "Subroutine",
   "kind": "user"
  },
  {
   "address": 16683,
   "name": "draw_score_rows",
   "type": "Subroutine",
   "kind": "user"
  },
  {
   "address": 16699,
   "name": "b_413B",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 16767,
   "name": "b_417F",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 16775,
   "name": "game_over_scores",
   "type": "Subroutine",
   "kind": "user"
  },
  {
   "address": 16803,
   "name": "b_41A3",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 16816,
   "name": "b_41B0",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 16855,
   "name": "b_41D7",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 16869,
   "name": "b_41E5",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 16875,
   "name": "b_41EB",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 16881,
   "name": "b_41F1",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 16890,
   "name": "r_41FA",
   "type": "Return",
   "kind": "auto"
  },
  {
   "address": 16891,
   "name": "next_letter",
   "type": "Subroutine",
   "kind": "user"
  },
  {
   "address": 16906,
   "name": "b_420A",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 16911,
   "name": "previous_letter",
   "type": "Subroutine",
   "kind": "user"
  },
  {
   "address": 16926,
   "name": "b_421E",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 16931,
   "name": "letter_done",
   "type": "Subroutine",
   "kind": "user"
  },
  {
   "address": 16949,
   "name": "r_4235",
   "type": "Return",
   "kind": "auto"
  },
  {
   "address": 16950,
   "name": "find_place",
   "type": "Subroutine",
   "kind": "user"
  },
  {
   "address": 16954,
   "name": "j_423A",
   "type": "Jump",
   "kind": "auto"
  },
  {
   "address": 16988,
   "name": "b_425C",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17003,
   "name": "b_426B",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17007,
   "name": "r_426F",
   "type": "Return",
   "kind": "auto"
  },
  {
   "address": 17008,
   "name": "print_bcd_pair",
   "type": "Subroutine",
   "kind": "user"
  },
  {
   "address": 17036,
   "name": "q_truck_shop",
   "type": "Subroutine",
   "kind": "user"
  },
  {
   "address": 17102,
   "name": "save_play_screen",
   "type": "Subroutine",
   "kind": "user"
  },
  {
   "address": 17109,
   "name": "b_42D5",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17124,
   "name": "restore_play_screen",
   "type": "Subroutine",
   "kind": "user"
  },
  {
   "address": 17141,
   "name": "b_42F5",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17166,
   "name": "b_430E",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17184,
   "name": "b_4320",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17200,
   "name": "screen_pointers",
   "type": "Subroutine",
   "kind": "user"
  },
  {
   "address": 17221,
   "name": "b_4345",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17230,
   "name": "sprite_pointers",
   "type": "Subroutine",
   "kind": "user"
  },
  {
   "address": 17243,
   "name": "b_435B",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17252,
   "name": "show_message",
   "type": "Subroutine",
   "kind": "user"
  },
  {
   "address": 17281,
   "name": "shop_loop",
   "type": "Subroutine",
   "kind": "user"
  },
  {
   "address": 17297,
   "name": "j_4391",
   "type": "Jump",
   "kind": "auto"
  },
  {
   "address": 17313,
   "name": "b_43A1",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17326,
   "name": "b_43AE",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17334,
   "name": "b_43B6",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17341,
   "name": "shop_up",
   "type": "Subroutine",
   "kind": "user"
  },
  {
   "address": 17351,
   "name": "b_43C7",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17367,
   "name": "b_43D7",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17373,
   "name": "r_43DD",
   "type": "Return",
   "kind": "auto"
  },
  {
   "address": 17377,
   "name": "shop_down",
   "type": "Subroutine",
   "kind": "user"
  },
  {
   "address": 17387,
   "name": "j_43EB",
   "type": "Jump",
   "kind": "auto"
  },
  {
   "address": 17404,
   "name": "b_43FC",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17410,
   "name": "r_4402",
   "type": "Return",
   "kind": "auto"
  },
  {
   "address": 17414,
   "name": "shop_buy",
   "type": "Jump",
   "kind": "user"
  },
  {
   "address": 17436,
   "name": "b_441C",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17458,
   "name": "b_4432",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17461,
   "name": "r_4435",
   "type": "Return",
   "kind": "auto"
  },
  {
   "address": 17462,
   "name": "draw_shop_icons",
   "type": "Subroutine",
   "kind": "user"
  },
  {
   "address": 17480,
   "name": "b_4448",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17532,
   "name": "show_item",
   "type": "Subroutine",
   "kind": "user"
  },
  {
   "address": 17613,
   "name": "b_44CD",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17632,
   "name": "r_44E0",
   "type": "Return",
   "kind": "auto"
  },
  {
   "address": 17633,
   "name": "print_text",
   "type": "Subroutine",
   "kind": "user"
  },
  {
   "address": 17635,
   "name": "print_text_y",
   "type": "Subroutine",
   "kind": "user"
  },
  {
   "address": 17647,
   "name": "r_44EF",
   "type": "Return",
   "kind": "auto"
  },
  {
   "address": 17648,
   "name": "clear_line",
   "type": "Subroutine",
   "kind": "user"
  },
  {
   "address": 17652,
   "name": "b_44F4",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17658,
   "name": "setup_panel",
   "type": "Subroutine",
   "kind": "user"
  },
  {
   "address": 17662,
   "name": "b_44FE",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17681,
   "name": "b_4511",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17699,
   "name": "b_4523",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17736,
   "name": "b_4548",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17743,
   "name": "b_454F",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17751,
   "name": "b_4557",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17817,
   "name": "reset_sprites",
   "type": "Subroutine",
   "kind": "user"
  },
  {
   "address": 17893,
   "name": "b_45E5",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17901,
   "name": "b_45ED",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17905,
   "name": "b_45F1",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17921,
   "name": "b_4601",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17925,
   "name": "reset_shots",
   "type": "Subroutine",
   "kind": "user"
  },
  {
   "address": 17943,
   "name": "b_4617",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17947,
   "name": "b_461B",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17974,
   "name": "b_4636",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17985,
   "name": "b_4641",
   "type": "Branch",
   "kind": "auto"
  },
  {
   "address": 17989,
   "name": "overlay_spare",
   "type": "UserDefined",
   "kind": "user"
  }
 ],
 "comments": [
  {
   "address": 16384,
   "type": "line",
   "text": "The Q-truck's stock, nine entries the shop reads through the table at $40CA: the icon's sprite frame, its colour, the price in Q tokens (BCD; $FF means it is worked out from the damage), the name in lower-case ASCII ending in 0, then the value to store and the address it goes to. In order: sub capability (75, sets $65), miniature lasers (25, $62 = 31), pursuit missiles (10, $59 = 31), smoke refill (5, $5A = $7F), side rear bolts (10, $64 on), armour replacement ($96F0 full), intercept missiles (15, $5B = 31), torpedoes (15, $63 = 31) and exit the q truck (0)."
  },
  {
   "address": 16579,
   "type": "line",
   "text": "The word \"cost \" printed before an item's price."
  },
  {
   "address": 16585,
   "type": "line",
   "text": "The price of the item under the cursor, set by $447C and paid by $4406."
  },
  {
   "address": 16586,
   "type": "line",
   "text": "The addresses of the shop's entries, two bytes each, indexed by the cursor $40E8 (6 to $16 in steps of 2: the three slots before the first item and those after the last point at $4000, and give the icons drawn above and below the column ($4436))."
  },
  {
   "address": 16587,
   "type": "line",
   "text": "The high bytes of the shop's entry addresses, read with $40CA."
  },
  {
   "address": 16616,
   "type": "line",
   "text": "The shop's cursor, 6 to $16 in steps of 2: which item faces the arrow."
  },
  {
   "address": 16617,
   "type": "line",
   "text": "The high-score table: nine entries of seven bytes, three letters (1-26 for A-Z, 27 a space) and a four-byte BCD score, best first. Offsets from $8844."
  },
  {
   "address": 16618,
   "type": "line",
   "text": "The second and third letters and the score of the first entry, addressed field by field when a new score is put in."
  },
  {
   "address": 16619,
   "type": "line",
   "text": "The first entry's third letter."
  },
  {
   "address": 16620,
   "type": "line",
   "text": "The first entry's score, four BCD bytes from $40EC to $40EF, compared with $9D-$A0 by $4236."
  },
  {
   "address": 16621,
   "type": "line",
   "text": "The first entry's score, second BCD byte."
  },
  {
   "address": 16622,
   "type": "line",
   "text": "The first entry's score, third BCD byte."
  },
  {
   "address": 16623,
   "type": "line",
   "text": "The first entry's score, last BCD byte."
  },
  {
   "address": 16624,
   "type": "line",
   "text": "The high-score table from its second entry on, which $4187 moves down a place to make room for a new score."
  },
  {
   "address": 16680,
   "type": "line",
   "text": "Empties the buffers ($284E) and writes the nine entries of the table into the character buffer from $E28C, two rows apart: the three letters (character $DA plus the letter) and the score's eight digits ($4270), then shows it ($0FC3)."
  },
  {
   "address": 16683,
   "type": "line",
   "text": "The drawing loop of $4128, entered directly with $14/$15 already set: nine rows of letters and digits, then a redraw ($0FC3)."
  },
  {
   "address": 16775,
   "type": "line",
   "text": "After the last life: silences the sound, dissolves the screen, draws the table, and finds the score's place ($4236). If it makes the table, moves the lower entries down, puts the score in with the name AAA and lets the player choose three letters: up and down step through A-Z (wrapping), right moves to the next letter, half a second apart ($1129)."
  },
  {
   "address": 16891,
   "type": "line",
   "text": "Steps the letter under the cursor ($1D) to the next, Z back to A."
  },
  {
   "address": 16911,
   "type": "line",
   "text": "Steps the letter back, A round to Z."
  },
  {
   "address": 16931,
   "type": "line",
   "text": "Fixes this letter and moves to the next (three in all, counted by $90)."
  },
  {
   "address": 16950,
   "type": "line",
   "text": "Compares the score $9D-$A0 with the table's entries in order ($8844); returns the place in $8F, or $FF when it is lower than all nine."
  },
  {
   "address": 17008,
   "type": "line",
   "text": "Writes the BCD byte in A as two digit characters ($86FA) at ($14),Y, moving Y on."
  },
  {
   "address": 17036,
   "type": "line",
   "text": "The Q-truck shop, opened by $0BF6 when the car is inside the truck. Saves the play screen ($42CE), dissolves the screen, puts back the road charset, shows the interior and runs the shop ($4381) from item $0E. On leaving, waits, flips the double buffer and puts the play screen back ($42E4)."
  },
  {
   "address": 17102,
   "type": "line",
   "text": "Copies three pages of the character buffer ($E242) to the hidden screen ($7800 or $7C00), which is used as a store while the shop is open."
  },
  {
   "address": 17124,
   "type": "line",
   "text": "Copies the stored screen back into the character buffer, rebuilding the colour buffer from table $E782, clears colour memory $D800-$DAFF and redraws ($0FC3)."
  },
  {
   "address": 17200,
   "type": "line",
   "text": "Points ($04) at the character buffer and ($06) at the hidden screen."
  },
  {
   "address": 17230,
   "type": "line",
   "text": "Points ($06) at the sprite pointers of the screen not being shown ($7BF8 or $7FF8)."
  },
  {
   "address": 17252,
   "type": "line",
   "text": "Writes the zero-ended message at ($04) into the character buffer at $E38A, and shows it for a few seconds ($1129). Used for \"get ready\", \"bad show james\", \"well done\", \"game over\" and \"congratulations\"."
  },
  {
   "address": 17281,
   "type": "line",
   "text": "Draws the panel, the icons ($4436) and the item name and price ($447C), then reads the joystick: up and down slide the column of icons to the next item ($43BD, $43E1), fire buys it ($4406). Leaves when fire is pressed on the exit."
  },
  {
   "address": 17341,
   "type": "line",
   "text": "Scrolls the icons down one place, a pixel a frame, and moves the cursor to the previous item; nothing at the first."
  },
  {
   "address": 17377,
   "type": "line",
   "text": "Scrolls the icons up one place and moves the cursor to the next item; nothing at the last."
  },
  {
   "address": 17414,
   "type": "line",
   "text": "Fire on an item (once per press, $3D). With a price of 0 it is the exit. Otherwise, if the Q tokens ($6A/$6B) cover the price, takes it off and stores the item's value at its address."
  },
  {
   "address": 17462,
   "type": "line",
   "text": "Puts seven item icons on the seven hardware sprites in a column at x $3C, 32 lines apart from $20, with each entry's frame and colour."
  },
  {
   "address": 17532,
   "type": "line",
   "text": "Prints the name of the item under the cursor and keeps its price in $40C9. For the armour the price comes from the damage: (255 - armour) / 8, ANDed with $17 and plus 1. The mask keeps the low digit at 7 or less, so the binary result is also a valid decimal (BCD) price: 1 to 8 tokens while the armour is above half, 11 to 18 below. Then prints \"cost\" and the price."
  },
  {
   "address": 17633,
   "type": "line",
   "text": "Writes the zero-ended ASCII text at ($04) into ($14), adding $7A to each byte to make the character code (the character set holds its letters from $DB)."
  },
  {
   "address": 17635,
   "type": "line",
   "text": "Entry into $44E1 that starts at the Y already set, so a caller can skip a header."
  },
  {
   "address": 17648,
   "type": "line",
   "text": "Fills 31 characters at ($14) with spaces."
  },
  {
   "address": 17658,
   "type": "line",
   "text": "Run once at start-up. Fills colour memory with 3 (cyan, multicolour off), $DB20-$DBE7 (the panel) with 1, and the four border columns of the play area with 0; clears the panel screen rows ($8300 page) and copies the panel's three rows of characters (31 each) ($8704, $8724, $8744) to $834B, $8373, $839B and their colours ($8764, $8784, $87A4) to colour memory; sets the panel's sprite pointers ($83F8-$83FF) to 12."
  },
  {
   "address": 17817,
   "type": "line",
   "text": "Ends both sprite lists, points the multiplexer at the first ($08, $B1), moves every sprite to y 0, unexpanded and multicolour, sets sprite multicolour 1 to white and 2 to black, and clears all 32 object slots."
  },
  {
   "address": 17925,
   "type": "line",
   "text": "Clears the 16 shots at $9A22 and gives each its own character definition, 8 bytes apart from $E1C2."
  },
  {
   "address": 17989,
   "type": "line",
   "text": "Zeros to the end of the overlay ($47FF)."
  }
 ]
}