web-a2e 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (295) hide show
  1. package/.clangd +5 -0
  2. package/.mcp.json +12 -0
  3. package/CLAUDE.md +362 -0
  4. package/CMakeLists.txt +774 -0
  5. package/LICENSE +21 -0
  6. package/README.md +392 -0
  7. package/build-wasm/generated/roms.cpp +2447 -0
  8. package/docker-compose.staging.yml +9 -0
  9. package/docs/basic-rom-disassembly.md +6663 -0
  10. package/docs/softswitch-comparison.md +273 -0
  11. package/docs/thunderclock-debug.md +89 -0
  12. package/examples/cube.bas +72 -0
  13. package/examples/hello.s +55 -0
  14. package/examples/scroll.s +140 -0
  15. package/package.json +18 -0
  16. package/public/assets/apple-logo-old.png +0 -0
  17. package/public/assets/apple-logo.png +0 -0
  18. package/public/assets/drive-closed-light-on.png +0 -0
  19. package/public/assets/drive-closed.png +0 -0
  20. package/public/assets/drive-open-light-on.png +0 -0
  21. package/public/assets/drive-open.png +0 -0
  22. package/public/audio-worklet.js +82 -0
  23. package/public/disks/Apple DOS 3.3 January 1983.dsk +0 -0
  24. package/public/disks/ProDOS 2.4.3.po +0 -0
  25. package/public/disks/h32mb.2mg +0 -0
  26. package/public/disks/library.json +26 -0
  27. package/public/docs/llms/llm-assembler.txt +90 -0
  28. package/public/docs/llms/llm-basic-program.txt +256 -0
  29. package/public/docs/llms/llm-disk-drives.txt +72 -0
  30. package/public/docs/llms/llm-file-explorer.txt +50 -0
  31. package/public/docs/llms/llm-hard-drives.txt +80 -0
  32. package/public/docs/llms/llm-main.txt +51 -0
  33. package/public/docs/llms/llm-slot-configuration.txt +66 -0
  34. package/public/icons/icon-192.svg +4 -0
  35. package/public/icons/icon-512.svg +4 -0
  36. package/public/index.html +661 -0
  37. package/public/llms.txt +49 -0
  38. package/public/manifest.json +29 -0
  39. package/public/shaders/burnin.glsl +22 -0
  40. package/public/shaders/crt.glsl +706 -0
  41. package/public/shaders/edge.glsl +109 -0
  42. package/public/shaders/vertex.glsl +8 -0
  43. package/public/sw.js +186 -0
  44. package/roms/341-0027.bin +0 -0
  45. package/roms/341-0160-A-US-UK.bin +0 -0
  46. package/roms/341-0160-A.bin +0 -0
  47. package/roms/342-0273-A-US-UK.bin +0 -0
  48. package/roms/342-0349-B-C0-FF.bin +0 -0
  49. package/roms/Apple Mouse Interface Card ROM - 342-0270-C.bin +0 -0
  50. package/roms/Thunderclock Plus ROM.bin +0 -0
  51. package/scripts/generate_roms.sh +69 -0
  52. package/src/bindings/wasm_interface.cpp +1940 -0
  53. package/src/core/assembler/assembler.cpp +1239 -0
  54. package/src/core/assembler/assembler.hpp +115 -0
  55. package/src/core/audio/audio.cpp +160 -0
  56. package/src/core/audio/audio.hpp +81 -0
  57. package/src/core/basic/basic_detokenizer.cpp +436 -0
  58. package/src/core/basic/basic_detokenizer.hpp +41 -0
  59. package/src/core/basic/basic_tokenizer.cpp +286 -0
  60. package/src/core/basic/basic_tokenizer.hpp +26 -0
  61. package/src/core/basic/basic_tokens.hpp +295 -0
  62. package/src/core/cards/disk2_card.cpp +568 -0
  63. package/src/core/cards/disk2_card.hpp +316 -0
  64. package/src/core/cards/expansion_card.hpp +185 -0
  65. package/src/core/cards/mockingboard/ay8910.cpp +616 -0
  66. package/src/core/cards/mockingboard/ay8910.hpp +159 -0
  67. package/src/core/cards/mockingboard/via6522.cpp +530 -0
  68. package/src/core/cards/mockingboard/via6522.hpp +163 -0
  69. package/src/core/cards/mockingboard_card.cpp +312 -0
  70. package/src/core/cards/mockingboard_card.hpp +159 -0
  71. package/src/core/cards/mouse_card.cpp +654 -0
  72. package/src/core/cards/mouse_card.hpp +190 -0
  73. package/src/core/cards/smartport/block_device.cpp +202 -0
  74. package/src/core/cards/smartport/block_device.hpp +60 -0
  75. package/src/core/cards/smartport/smartport_card.cpp +603 -0
  76. package/src/core/cards/smartport/smartport_card.hpp +120 -0
  77. package/src/core/cards/thunderclock_card.cpp +237 -0
  78. package/src/core/cards/thunderclock_card.hpp +122 -0
  79. package/src/core/cpu/cpu6502.cpp +1609 -0
  80. package/src/core/cpu/cpu6502.hpp +203 -0
  81. package/src/core/debug/condition_evaluator.cpp +470 -0
  82. package/src/core/debug/condition_evaluator.hpp +87 -0
  83. package/src/core/disassembler/disassembler.cpp +552 -0
  84. package/src/core/disassembler/disassembler.hpp +171 -0
  85. package/src/core/disk-image/disk_image.hpp +267 -0
  86. package/src/core/disk-image/dsk_disk_image.cpp +827 -0
  87. package/src/core/disk-image/dsk_disk_image.hpp +204 -0
  88. package/src/core/disk-image/gcr_encoding.cpp +147 -0
  89. package/src/core/disk-image/gcr_encoding.hpp +78 -0
  90. package/src/core/disk-image/woz_disk_image.cpp +1049 -0
  91. package/src/core/disk-image/woz_disk_image.hpp +343 -0
  92. package/src/core/emulator.cpp +2126 -0
  93. package/src/core/emulator.hpp +434 -0
  94. package/src/core/filesystem/dos33.cpp +178 -0
  95. package/src/core/filesystem/dos33.hpp +66 -0
  96. package/src/core/filesystem/pascal.cpp +262 -0
  97. package/src/core/filesystem/pascal.hpp +87 -0
  98. package/src/core/filesystem/prodos.cpp +369 -0
  99. package/src/core/filesystem/prodos.hpp +119 -0
  100. package/src/core/input/keyboard.cpp +227 -0
  101. package/src/core/input/keyboard.hpp +111 -0
  102. package/src/core/mmu/mmu.cpp +1387 -0
  103. package/src/core/mmu/mmu.hpp +236 -0
  104. package/src/core/types.hpp +196 -0
  105. package/src/core/video/video.cpp +680 -0
  106. package/src/core/video/video.hpp +156 -0
  107. package/src/css/assembler-editor.css +1617 -0
  108. package/src/css/base.css +470 -0
  109. package/src/css/basic-debugger.css +791 -0
  110. package/src/css/basic-editor.css +792 -0
  111. package/src/css/controls.css +783 -0
  112. package/src/css/cpu-debugger.css +1413 -0
  113. package/src/css/debug-base.css +160 -0
  114. package/src/css/debug-windows.css +6455 -0
  115. package/src/css/disk-drives.css +406 -0
  116. package/src/css/documentation.css +392 -0
  117. package/src/css/file-explorer.css +867 -0
  118. package/src/css/hard-drive.css +180 -0
  119. package/src/css/layout.css +217 -0
  120. package/src/css/memory-windows.css +798 -0
  121. package/src/css/modals.css +510 -0
  122. package/src/css/monitor.css +425 -0
  123. package/src/css/release-notes.css +101 -0
  124. package/src/css/responsive.css +400 -0
  125. package/src/css/rule-builder.css +340 -0
  126. package/src/css/save-states.css +201 -0
  127. package/src/css/settings-windows.css +1231 -0
  128. package/src/css/window-switcher.css +150 -0
  129. package/src/js/agent/agent-manager.js +643 -0
  130. package/src/js/agent/agent-tools.js +293 -0
  131. package/src/js/agent/agent-version-tools.js +131 -0
  132. package/src/js/agent/assembler-tools.js +357 -0
  133. package/src/js/agent/basic-program-tools.js +894 -0
  134. package/src/js/agent/disk-tools.js +417 -0
  135. package/src/js/agent/file-explorer-tools.js +269 -0
  136. package/src/js/agent/index.js +13 -0
  137. package/src/js/agent/main-tools.js +222 -0
  138. package/src/js/agent/slot-tools.js +303 -0
  139. package/src/js/agent/smartport-tools.js +257 -0
  140. package/src/js/agent/window-tools.js +80 -0
  141. package/src/js/audio/audio-driver.js +417 -0
  142. package/src/js/audio/audio-worklet.js +85 -0
  143. package/src/js/audio/index.js +8 -0
  144. package/src/js/config/default-layout.js +34 -0
  145. package/src/js/config/version.js +8 -0
  146. package/src/js/data/apple2-rom-routines.js +577 -0
  147. package/src/js/debug/assembler-editor-window.js +2993 -0
  148. package/src/js/debug/basic-breakpoint-manager.js +529 -0
  149. package/src/js/debug/basic-program-parser.js +436 -0
  150. package/src/js/debug/basic-program-window.js +2594 -0
  151. package/src/js/debug/basic-variable-inspector.js +447 -0
  152. package/src/js/debug/breakpoint-manager.js +472 -0
  153. package/src/js/debug/cpu-debugger-window.js +2396 -0
  154. package/src/js/debug/index.js +22 -0
  155. package/src/js/debug/label-manager.js +238 -0
  156. package/src/js/debug/memory-browser-window.js +416 -0
  157. package/src/js/debug/memory-heat-map-window.js +481 -0
  158. package/src/js/debug/memory-map-window.js +206 -0
  159. package/src/js/debug/mockingboard-window.js +882 -0
  160. package/src/js/debug/mouse-card-window.js +355 -0
  161. package/src/js/debug/rule-builder-window.js +648 -0
  162. package/src/js/debug/soft-switch-window.js +458 -0
  163. package/src/js/debug/stack-viewer-window.js +221 -0
  164. package/src/js/debug/symbols.js +416 -0
  165. package/src/js/debug/trace-panel.js +291 -0
  166. package/src/js/debug/zero-page-watch-window.js +297 -0
  167. package/src/js/disk-manager/disk-drives-window.js +212 -0
  168. package/src/js/disk-manager/disk-operations.js +284 -0
  169. package/src/js/disk-manager/disk-persistence.js +301 -0
  170. package/src/js/disk-manager/disk-surface-renderer.js +388 -0
  171. package/src/js/disk-manager/drive-sounds.js +139 -0
  172. package/src/js/disk-manager/hard-drive-manager.js +481 -0
  173. package/src/js/disk-manager/hard-drive-persistence.js +187 -0
  174. package/src/js/disk-manager/hard-drive-window.js +57 -0
  175. package/src/js/disk-manager/index.js +890 -0
  176. package/src/js/display/display-settings-window.js +383 -0
  177. package/src/js/display/index.js +10 -0
  178. package/src/js/display/screen-window.js +342 -0
  179. package/src/js/display/webgl-renderer.js +705 -0
  180. package/src/js/file-explorer/disassembler.js +574 -0
  181. package/src/js/file-explorer/dos33.js +266 -0
  182. package/src/js/file-explorer/file-viewer.js +359 -0
  183. package/src/js/file-explorer/index.js +1261 -0
  184. package/src/js/file-explorer/prodos.js +549 -0
  185. package/src/js/file-explorer/utils.js +67 -0
  186. package/src/js/help/documentation-window.js +1096 -0
  187. package/src/js/help/index.js +10 -0
  188. package/src/js/help/release-notes-window.js +85 -0
  189. package/src/js/help/release-notes.js +612 -0
  190. package/src/js/input/gamepad-handler.js +176 -0
  191. package/src/js/input/index.js +12 -0
  192. package/src/js/input/input-handler.js +396 -0
  193. package/src/js/input/joystick-window.js +404 -0
  194. package/src/js/input/mouse-handler.js +99 -0
  195. package/src/js/input/text-selection.js +462 -0
  196. package/src/js/main.js +653 -0
  197. package/src/js/state/index.js +15 -0
  198. package/src/js/state/save-states-window.js +393 -0
  199. package/src/js/state/state-manager.js +409 -0
  200. package/src/js/state/state-persistence.js +218 -0
  201. package/src/js/ui/confirm.js +43 -0
  202. package/src/js/ui/disk-drive-positioner.js +347 -0
  203. package/src/js/ui/reminder-controller.js +129 -0
  204. package/src/js/ui/slot-configuration-window.js +560 -0
  205. package/src/js/ui/theme-manager.js +61 -0
  206. package/src/js/ui/toast.js +44 -0
  207. package/src/js/ui/ui-controller.js +897 -0
  208. package/src/js/ui/window-switcher.js +275 -0
  209. package/src/js/utils/basic-autocomplete.js +832 -0
  210. package/src/js/utils/basic-highlighting.js +473 -0
  211. package/src/js/utils/basic-tokenizer.js +153 -0
  212. package/src/js/utils/basic-tokens.js +117 -0
  213. package/src/js/utils/constants.js +28 -0
  214. package/src/js/utils/indexeddb-helper.js +225 -0
  215. package/src/js/utils/merlin-editor-support.js +905 -0
  216. package/src/js/utils/merlin-highlighting.js +551 -0
  217. package/src/js/utils/storage.js +125 -0
  218. package/src/js/utils/string-utils.js +19 -0
  219. package/src/js/utils/wasm-memory.js +54 -0
  220. package/src/js/windows/base-window.js +690 -0
  221. package/src/js/windows/index.js +9 -0
  222. package/src/js/windows/window-manager.js +375 -0
  223. package/tests/catch2/catch.hpp +17976 -0
  224. package/tests/common/basic_program_builder.cpp +119 -0
  225. package/tests/common/basic_program_builder.hpp +209 -0
  226. package/tests/common/disk_image_builder.cpp +444 -0
  227. package/tests/common/disk_image_builder.hpp +141 -0
  228. package/tests/common/test_helpers.hpp +118 -0
  229. package/tests/gcr/gcr-test.cpp +142 -0
  230. package/tests/integration/check-rom.js +70 -0
  231. package/tests/integration/compare-boot.js +239 -0
  232. package/tests/integration/crash-trace.js +102 -0
  233. package/tests/integration/disk-boot-test.js +264 -0
  234. package/tests/integration/memory-crash.js +108 -0
  235. package/tests/integration/nibble-read-test.js +249 -0
  236. package/tests/integration/phase-test.js +159 -0
  237. package/tests/integration/test_emulator.cpp +291 -0
  238. package/tests/integration/test_emulator_basic.cpp +91 -0
  239. package/tests/integration/test_emulator_debug.cpp +344 -0
  240. package/tests/integration/test_emulator_disk.cpp +153 -0
  241. package/tests/integration/test_emulator_state.cpp +163 -0
  242. package/tests/klaus/6502_functional_test.bin +0 -0
  243. package/tests/klaus/65C02_extended_opcodes_test.bin +0 -0
  244. package/tests/klaus/klaus_6502_test.cpp +184 -0
  245. package/tests/klaus/klaus_65c02_test.cpp +197 -0
  246. package/tests/thunderclock/thunderclock_mmu_test.cpp +304 -0
  247. package/tests/thunderclock/thunderclock_test.cpp +550 -0
  248. package/tests/unit/test_assembler.cpp +521 -0
  249. package/tests/unit/test_audio.cpp +196 -0
  250. package/tests/unit/test_ay8910.cpp +311 -0
  251. package/tests/unit/test_basic_detokenizer.cpp +265 -0
  252. package/tests/unit/test_basic_tokenizer.cpp +382 -0
  253. package/tests/unit/test_block_device.cpp +259 -0
  254. package/tests/unit/test_condition_evaluator.cpp +219 -0
  255. package/tests/unit/test_cpu6502.cpp +1301 -0
  256. package/tests/unit/test_cpu_addressing.cpp +361 -0
  257. package/tests/unit/test_cpu_cycle_counts.cpp +409 -0
  258. package/tests/unit/test_cpu_decimal.cpp +166 -0
  259. package/tests/unit/test_cpu_interrupts.cpp +285 -0
  260. package/tests/unit/test_disassembler.cpp +323 -0
  261. package/tests/unit/test_disk2_card.cpp +330 -0
  262. package/tests/unit/test_dos33.cpp +273 -0
  263. package/tests/unit/test_dsk_disk_image.cpp +315 -0
  264. package/tests/unit/test_expansion_card.cpp +178 -0
  265. package/tests/unit/test_gcr_encoding.cpp +232 -0
  266. package/tests/unit/test_keyboard.cpp +262 -0
  267. package/tests/unit/test_mmu.cpp +555 -0
  268. package/tests/unit/test_mmu_slots.cpp +323 -0
  269. package/tests/unit/test_mockingboard.cpp +352 -0
  270. package/tests/unit/test_mouse_card.cpp +386 -0
  271. package/tests/unit/test_pascal.cpp +248 -0
  272. package/tests/unit/test_prodos.cpp +259 -0
  273. package/tests/unit/test_smartport_card.cpp +321 -0
  274. package/tests/unit/test_thunderclock.cpp +354 -0
  275. package/tests/unit/test_via6522.cpp +323 -0
  276. package/tests/unit/test_video.cpp +319 -0
  277. package/tests/unit/test_woz_disk_image.cpp +257 -0
  278. package/vite.config.js +96 -0
  279. package/wiki/AI-Agent.md +372 -0
  280. package/wiki/Architecture-Overview.md +303 -0
  281. package/wiki/Audio-System.md +449 -0
  282. package/wiki/CPU-Emulation.md +477 -0
  283. package/wiki/Debugger.md +516 -0
  284. package/wiki/Disk-Drives.md +161 -0
  285. package/wiki/Disk-System-Internals.md +547 -0
  286. package/wiki/Display-Settings.md +88 -0
  287. package/wiki/Expansion-Slots.md +187 -0
  288. package/wiki/File-Explorer.md +259 -0
  289. package/wiki/Getting-Started.md +156 -0
  290. package/wiki/Home.md +69 -0
  291. package/wiki/Input-Devices.md +183 -0
  292. package/wiki/Keyboard-Shortcuts.md +158 -0
  293. package/wiki/Memory-System.md +364 -0
  294. package/wiki/Save-States.md +172 -0
  295. package/wiki/Video-Rendering.md +658 -0
@@ -0,0 +1,1096 @@
1
+ /*
2
+ * documentation-window.js - Help and documentation window
3
+ *
4
+ * Written by
5
+ * Mike Daley <michael_daley@icloud.com>
6
+ */
7
+
8
+ /**
9
+ * DocumentationWindow - Moveable help & documentation window
10
+ * Extends BaseWindow for drag/resize functionality
11
+ */
12
+
13
+ import { BaseWindow } from "../windows/base-window.js";
14
+
15
+ export class DocumentationWindow extends BaseWindow {
16
+ constructor() {
17
+ super({
18
+ id: "documentation-window",
19
+ title: "Help & Documentation",
20
+ minWidth: 500,
21
+ minHeight: 400,
22
+ defaultWidth: 750,
23
+ defaultHeight: 550,
24
+ });
25
+
26
+ this.navButtons = null;
27
+ this.sections = null;
28
+ }
29
+
30
+ /**
31
+ * Override to add custom class for documentation styling
32
+ */
33
+ create() {
34
+ super.create();
35
+ this.element.classList.add("documentation-window");
36
+
37
+ // Set up F1 keyboard shortcut
38
+ document.addEventListener("keydown", (e) => {
39
+ if (e.key === "F1") {
40
+ e.preventDefault();
41
+ this.toggle();
42
+ }
43
+ });
44
+
45
+ // Set up help button (inside help menu dropdown)
46
+ const helpButton = document.getElementById("btn-help");
47
+ if (helpButton) {
48
+ helpButton.addEventListener("click", () => {
49
+ this.toggle();
50
+ // Close the help menu dropdown
51
+ const menuContainer = helpButton.closest(".header-menu-container");
52
+ if (menuContainer) menuContainer.classList.remove("open");
53
+ });
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Render the documentation content
59
+ */
60
+ renderContent() {
61
+ return `
62
+ <div class="documentation-layout">
63
+ <nav class="documentation-nav">
64
+ <button data-section="getting-started" class="active">
65
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
66
+ <path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>
67
+ <polyline points="9 22 9 12 15 12 15 22"/>
68
+ </svg>
69
+ Getting Started
70
+ </button>
71
+ <button data-section="install">
72
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
73
+ <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
74
+ <polyline points="7 10 12 15 17 10"/>
75
+ <line x1="12" y1="15" x2="12" y2="3"/>
76
+ </svg>
77
+ Install App
78
+ </button>
79
+ <button data-section="keyboard">
80
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
81
+ <rect x="2" y="4" width="20" height="16" rx="2"/>
82
+ <line x1="6" y1="8" x2="6.01" y2="8"/>
83
+ <line x1="10" y1="8" x2="10.01" y2="8"/>
84
+ <line x1="14" y1="8" x2="14.01" y2="8"/>
85
+ <line x1="18" y1="8" x2="18.01" y2="8"/>
86
+ <line x1="8" y1="12" x2="8.01" y2="12"/>
87
+ <line x1="12" y1="12" x2="12.01" y2="12"/>
88
+ <line x1="16" y1="12" x2="16.01" y2="12"/>
89
+ <line x1="7" y1="16" x2="17" y2="16"/>
90
+ </svg>
91
+ Keyboard
92
+ </button>
93
+ <button data-section="display">
94
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
95
+ <rect x="2" y="3" width="20" height="14" rx="2"/>
96
+ <line x1="8" y1="21" x2="16" y2="21"/>
97
+ <line x1="12" y1="17" x2="12" y2="21"/>
98
+ </svg>
99
+ Display
100
+ </button>
101
+ <button data-section="disks">
102
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
103
+ <rect x="2" y="6" width="20" height="12" rx="2"/>
104
+ <rect x="5" y="9" width="10" height="1.5" rx="0.5"/>
105
+ <circle cx="18" cy="12" r="1.5"/>
106
+ </svg>
107
+ Disk Drives
108
+ </button>
109
+ <button data-section="smartport">
110
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
111
+ <rect x="4" y="2" width="16" height="20" rx="2"/>
112
+ <line x1="8" y1="6" x2="16" y2="6"/>
113
+ <circle cx="12" cy="14" r="3"/>
114
+ </svg>
115
+ SmartPort
116
+ </button>
117
+ <button data-section="file-explorer">
118
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
119
+ <path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"/>
120
+ </svg>
121
+ File Explorer
122
+ </button>
123
+ <button data-section="state">
124
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
125
+ <path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/>
126
+ <polyline points="17 21 17 13 7 13 7 21"/>
127
+ <polyline points="7 3 7 8 15 8"/>
128
+ </svg>
129
+ State
130
+ </button>
131
+ <button data-section="sound">
132
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
133
+ <path d="M11 5L6 9H2v6h4l5 4V5z"/>
134
+ <path d="M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"/>
135
+ </svg>
136
+ Sound
137
+ </button>
138
+ <button data-section="debug">
139
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
140
+ <circle cx="12" cy="12" r="10"/>
141
+ <path d="M12 6v2M12 16v2M6 12h2M16 12h2"/>
142
+ <circle cx="12" cy="12" r="3"/>
143
+ </svg>
144
+ Debug Tools
145
+ </button>
146
+ <button data-section="dev">
147
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
148
+ <polyline points="16 18 22 12 16 6"/>
149
+ <polyline points="8 6 2 12 8 18"/>
150
+ </svg>
151
+ Dev Tools
152
+ </button>
153
+ <button data-section="agent">
154
+ <svg viewBox="0 0 24 24" fill="currentColor">
155
+ <path d="M12 2l1.5 4.5L18 8l-4.5 1.5L12 14l-1.5-4.5L6 8l4.5-1.5L12 2zM6 16l.75 2.25L9 19l-2.25.75L6 22l-.75-2.25L3 19l2.25-.75L6 16zM18 16l.75 2.25L21 19l-2.25.75L18 22l-.75-2.25L15 19l2.25-.75L18 16z"/>
156
+ </svg>
157
+ AI Agent
158
+ </button>
159
+ <button data-section="tips">
160
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
161
+ <path d="M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"/>
162
+ </svg>
163
+ Tips
164
+ </button>
165
+ </nav>
166
+ <div class="documentation-body">
167
+ ${this.renderSections()}
168
+ </div>
169
+ </div>
170
+ `;
171
+ }
172
+
173
+ /**
174
+ * Render all documentation sections
175
+ */
176
+ renderSections() {
177
+ return `
178
+ <!-- Getting Started Section -->
179
+ <section id="doc-getting-started" class="documentation-section active">
180
+ <h3>Getting Started</h3>
181
+ <p>Welcome to the Apple //e Emulator! This web-based emulator faithfully recreates the Apple //e Enhanced computer from 1983, allowing you to run classic Apple II software directly in your browser.</p>
182
+
183
+ <h4>Quick Start</h4>
184
+ <ol class="quick-start-list">
185
+ <li>Click the <strong>Power</strong> button to turn on the emulator</li>
186
+ <li>Click on the screen to give it keyboard focus</li>
187
+ <li>Insert a disk image using the <strong>Insert</strong> button on either drive</li>
188
+ <li>Type <kbd>PR#6</kbd> and press <kbd>Return</kbd> to boot from drive 1</li>
189
+ </ol>
190
+
191
+ <h4>What is the Apple //e?</h4>
192
+ <p>The Apple //e (Enhanced) was Apple's most popular Apple II model, released in 1983. It featured 128KB of RAM with auxiliary memory, 80-column text display, double hi-res graphics (560x192), and ran thousands of educational, productivity, and entertainment programs.</p>
193
+
194
+ <h4>Emulated Hardware</h4>
195
+ <ul>
196
+ <li><strong>CPU:</strong> 65C02 processor at 1.023 MHz (cycle-accurate)</li>
197
+ <li><strong>Memory:</strong> 128KB RAM (64KB main + 64KB auxiliary)</li>
198
+ <li><strong>Video:</strong> All Apple //e display modes including Double Hi-Res</li>
199
+ <li><strong>Storage:</strong> Two Disk II floppy drives, SmartPort hard drives</li>
200
+ <li><strong>Audio:</strong> Speaker with accurate timing, Mockingboard (dual AY-3-8910)</li>
201
+ <li><strong>Expansion:</strong> Mockingboard, Mouse Card, Thunderclock Plus, SmartPort</li>
202
+ <li><strong>ROM:</strong> Apple //e Enhanced ROM set</li>
203
+ </ul>
204
+
205
+ <div class="info-box tip">
206
+ <p><strong>Tip:</strong> Press <kbd>F1</kbd> at any time to open this help window. All windows can be moved and resized.</p>
207
+ </div>
208
+ </section>
209
+
210
+ <!-- Install App Section -->
211
+ <section id="doc-install" class="documentation-section">
212
+ <h3>Install as App</h3>
213
+ <p>This emulator is a Progressive Web App (PWA) that can be installed on your device for offline use and a native app-like experience.</p>
214
+
215
+ <h4>Chrome / Edge (Desktop)</h4>
216
+ <ol class="quick-start-list">
217
+ <li>Click the <strong>install icon</strong> in the address bar (right side)</li>
218
+ <li>Or click the <strong>three dots menu</strong> (⋮) and select "Install Apple //e Emulator"</li>
219
+ <li>Click <strong>Install</strong> in the dialog</li>
220
+ <li>The app will open in its own window and appear in your applications</li>
221
+ </ol>
222
+
223
+ <h4>Chrome (Android)</h4>
224
+ <ol class="quick-start-list">
225
+ <li>Tap the <strong>three dots menu</strong> (⋮)</li>
226
+ <li>Select <strong>"Add to Home screen"</strong> or <strong>"Install app"</strong></li>
227
+ <li>Tap <strong>Install</strong> to confirm</li>
228
+ <li>The app icon will appear on your home screen</li>
229
+ </ol>
230
+
231
+ <h4>Safari (iOS / macOS)</h4>
232
+ <ol class="quick-start-list">
233
+ <li>Tap the <strong>Share button</strong> (square with arrow)</li>
234
+ <li>Scroll down and tap <strong>"Add to Home Screen"</strong></li>
235
+ <li>Tap <strong>Add</strong> to confirm</li>
236
+ <li>The app will appear on your home screen</li>
237
+ </ol>
238
+
239
+ <h4>Firefox</h4>
240
+ <p>Firefox supports PWAs on Android. On desktop, you can bookmark the page for quick access, though full PWA installation is not yet supported.</p>
241
+
242
+ <h4>Benefits of Installing</h4>
243
+ <ul>
244
+ <li><strong>Offline Use:</strong> Run the emulator without an internet connection</li>
245
+ <li><strong>Own Window:</strong> Opens in a dedicated window without browser UI</li>
246
+ <li><strong>Quick Access:</strong> Launch from your taskbar, dock, or home screen</li>
247
+ <li><strong>Auto Updates:</strong> Automatically receives updates when online</li>
248
+ <li><strong>Full Screen:</strong> Better fullscreen experience</li>
249
+ </ul>
250
+
251
+ <h4>Automatic Updates</h4>
252
+ <p>The emulator automatically checks for updates when you open it while connected to the internet. When a new version is available, you'll see a brief notification and the page will refresh with the latest version.</p>
253
+ <p>You can also manually check for updates using the <strong>refresh button</strong> in the toolbar, which clears the cache and reloads the latest version.</p>
254
+
255
+ <div class="info-box info">
256
+ <p><strong>Note:</strong> Your saved state, disk images, and settings are preserved across updates.</p>
257
+ </div>
258
+ </section>
259
+
260
+ <!-- Keyboard Reference Section -->
261
+ <section id="doc-keyboard" class="documentation-section">
262
+ <h3>Keyboard Reference</h3>
263
+ <p>The Apple //e keyboard is mapped to your modern keyboard. Some keys have special mappings to match the original layout.</p>
264
+
265
+ <h4>Basic Keys</h4>
266
+ <table class="key-table">
267
+ <thead>
268
+ <tr><th>Your Keyboard</th><th>Apple //e Key</th><th>Notes</th></tr>
269
+ </thead>
270
+ <tbody>
271
+ <tr><td><kbd>Enter</kbd></td><td>Return</td><td>Confirm input, run commands</td></tr>
272
+ <tr><td><kbd>Backspace</kbd></td><td>Delete</td><td>Delete character left</td></tr>
273
+ <tr><td><kbd>Esc</kbd></td><td>Escape</td><td>Cancel, exit menus</td></tr>
274
+ <tr><td><kbd>Tab</kbd></td><td>Tab</td><td>Tab character</td></tr>
275
+ <tr><td><kbd>&#8592;</kbd> <kbd>&#8594;</kbd> <kbd>&#8593;</kbd> <kbd>&#8595;</kbd></td><td>Arrow Keys</td><td>Cursor movement, game controls</td></tr>
276
+ </tbody>
277
+ </table>
278
+
279
+ <h4>Special Keys</h4>
280
+ <table class="key-table">
281
+ <thead>
282
+ <tr><th>Your Keyboard</th><th>Apple //e Key</th><th>Notes</th></tr>
283
+ </thead>
284
+ <tbody>
285
+ <tr><td><kbd>Alt</kbd> (Left)</td><td>Open Apple (&#63743;)</td><td>Modifier key, joystick button 0</td></tr>
286
+ <tr><td><kbd>Alt</kbd> (Right) / <kbd>Win</kbd></td><td>Closed Apple</td><td>Modifier key, joystick button 1</td></tr>
287
+ <tr><td><kbd>Ctrl</kbd></td><td>Control</td><td>Control key modifier</td></tr>
288
+ <tr><td><kbd>Ctrl</kbd>+<kbd>Pause/Break</kbd></td><td>Reset</td><td>Warm reset (Ctrl+Reset)</td></tr>
289
+ </tbody>
290
+ </table>
291
+
292
+ <h4>Control Key Combinations</h4>
293
+ <table class="key-table">
294
+ <thead>
295
+ <tr><th>Combination</th><th>Function</th></tr>
296
+ </thead>
297
+ <tbody>
298
+ <tr><td><kbd>Ctrl</kbd>+<kbd>C</kbd></td><td>Break - stop running program</td></tr>
299
+ <tr><td><kbd>Ctrl</kbd>+<kbd>S</kbd></td><td>Pause output (Ctrl+Q to resume)</td></tr>
300
+ <tr><td><kbd>Ctrl</kbd>+<kbd>G</kbd></td><td>Bell (beep)</td></tr>
301
+ <tr><td><kbd>Ctrl</kbd>+<kbd>Reset</kbd></td><td>Warm reset (keeps memory)</td></tr>
302
+ </tbody>
303
+ </table>
304
+
305
+ <h4>Emulator Shortcuts</h4>
306
+ <table class="key-table">
307
+ <thead>
308
+ <tr><th>Shortcut</th><th>Function</th></tr>
309
+ </thead>
310
+ <tbody>
311
+ <tr><td><kbd>F1</kbd></td><td>Open/close this Help window</td></tr>
312
+ <tr><td><kbd>Ctrl</kbd>+<kbd>Escape</kbd></td><td>Exit full page mode</td></tr>
313
+ <tr><td><kbd>Ctrl</kbd>+<kbd>V</kbd></td><td>Paste text into emulator</td></tr>
314
+ <tr><td><kbd>Ctrl</kbd>+<kbd>\`</kbd></td><td>Open window switcher</td></tr>
315
+ <tr><td><kbd>Option</kbd>+<kbd>Tab</kbd></td><td>Cycle to next window</td></tr>
316
+ <tr><td><kbd>Option</kbd>+<kbd>Shift</kbd>+<kbd>Tab</kbd></td><td>Cycle to previous window</td></tr>
317
+ </tbody>
318
+ </table>
319
+
320
+ <h4>Debugger Shortcuts</h4>
321
+ <table class="key-table">
322
+ <thead>
323
+ <tr><th>Shortcut</th><th>Function</th></tr>
324
+ </thead>
325
+ <tbody>
326
+ <tr><td><kbd>F5</kbd></td><td>Run / Continue execution</td></tr>
327
+ <tr><td><kbd>F10</kbd></td><td>Step Over (skip subroutine calls)</td></tr>
328
+ <tr><td><kbd>F11</kbd></td><td>Step Into (single instruction)</td></tr>
329
+ <tr><td><kbd>Shift</kbd>+<kbd>F11</kbd></td><td>Step Out (run until current subroutine returns)</td></tr>
330
+ </tbody>
331
+ </table>
332
+
333
+ <h4>Text Selection & Copy</h4>
334
+ <p>You can select and copy text directly from the emulator screen:</p>
335
+ <ul>
336
+ <li>Click and drag on the screen to select text</li>
337
+ <li>Selected text is automatically copied when you release the mouse</li>
338
+ <li>Use <kbd>Ctrl</kbd>+<kbd>C</kbd> (or <kbd>Cmd</kbd>+<kbd>C</kbd> on Mac) while selecting</li>
339
+ </ul>
340
+
341
+ <h4>Paste Support</h4>
342
+ <p>You can paste text into the emulator using <kbd>Ctrl</kbd>+<kbd>V</kbd>. The emulator will type the text character by character at the appropriate speed. This is useful for entering BASIC programs.</p>
343
+ </section>
344
+
345
+ <!-- Display Settings Section -->
346
+ <section id="doc-display" class="documentation-section">
347
+ <h3>Display Settings</h3>
348
+ <p>Open from <strong>View &gt; Display</strong> to access extensive CRT simulation options.</p>
349
+
350
+ <h4>Display Modes</h4>
351
+ <ul>
352
+ <li><strong>Color:</strong> Full NTSC artifact color rendering</li>
353
+ <li><strong>Green:</strong> Classic green phosphor monochrome</li>
354
+ <li><strong>Amber:</strong> Amber phosphor monochrome</li>
355
+ <li><strong>White:</strong> White phosphor monochrome</li>
356
+ </ul>
357
+
358
+ <h4>CRT Effects</h4>
359
+ <ul>
360
+ <li><strong>Screen Curvature:</strong> Simulate curved CRT glass</li>
361
+ <li><strong>Overscan:</strong> Add border/overscan area</li>
362
+ <li><strong>Scanlines:</strong> Horizontal CRT scanline effect</li>
363
+ <li><strong>Shadow Mask:</strong> RGB phosphor dot pattern</li>
364
+ <li><strong>Phosphor Glow:</strong> Bloom/glow around bright pixels</li>
365
+ <li><strong>Vignette:</strong> Darker corners effect</li>
366
+ <li><strong>RGB Offset:</strong> Chromatic aberration</li>
367
+ <li><strong>Flicker:</strong> CRT refresh flicker simulation</li>
368
+ </ul>
369
+
370
+ <h4>Analog Effects</h4>
371
+ <ul>
372
+ <li><strong>Static:</strong> Random noise/grain</li>
373
+ <li><strong>Jitter:</strong> Random pixel displacement</li>
374
+ <li><strong>H-Sync:</strong> Horizontal sync distortion</li>
375
+ <li><strong>Scan Beam:</strong> Moving scan line effect</li>
376
+ <li><strong>Ambient:</strong> Screen surface reflection</li>
377
+ <li><strong>Burn-in:</strong> Phosphor persistence</li>
378
+ </ul>
379
+
380
+ <h4>Image Quality</h4>
381
+ <ul>
382
+ <li><strong>Brightness:</strong> Overall brightness level</li>
383
+ <li><strong>Contrast:</strong> Contrast adjustment</li>
384
+ <li><strong>Saturation:</strong> Color saturation (color mode only)</li>
385
+ </ul>
386
+
387
+ <h4>Rendering Options</h4>
388
+ <ul>
389
+ <li><strong>Sharp Pixels:</strong> Nearest-neighbor scaling (crisp pixels)</li>
390
+ <li><strong>NTSC Fringing:</strong> Color fringing on hi-res graphics edges</li>
391
+ </ul>
392
+
393
+ <h4>Resizing the Display</h4>
394
+ <p>Drag any corner of the monitor frame to resize. The 4:3 aspect ratio is maintained. A lock icon appears when using custom sizing - click it to return to auto-fit mode.</p>
395
+
396
+ <h4>Full Page Mode</h4>
397
+ <p>Click the <strong>fullscreen button</strong> for an immersive experience. Press <kbd>Ctrl</kbd>+<kbd>Escape</kbd> to exit.</p>
398
+
399
+ <h4>Character Set</h4>
400
+ <p>Toggle between US and UK character sets using the switch in the screen window header. The UK set replaces some symbols with British variants.</p>
401
+ </section>
402
+
403
+ <!-- Disk Drives Section -->
404
+ <section id="doc-disks" class="documentation-section">
405
+ <h3>Disk Drives</h3>
406
+ <p>The emulator includes two Disk II floppy drives, just like a real Apple //e system. Open from <strong>View &gt; Disk Drives</strong>.</p>
407
+
408
+ <h4>Supported Formats</h4>
409
+ <div class="format-list">
410
+ <div class="format-item"><code>.DSK</code><span>DOS 3.3 sector order (140KB)</span></div>
411
+ <div class="format-item"><code>.DO</code><span>DOS order (same as .DSK)</span></div>
412
+ <div class="format-item"><code>.PO</code><span>ProDOS sector order (140KB)</span></div>
413
+ <div class="format-item"><code>.WOZ</code><span>WOZ format with copy protection</span></div>
414
+ </div>
415
+
416
+ <h4>Drive Controls</h4>
417
+ <ul>
418
+ <li><strong>Insert:</strong> Load a disk image from your computer</li>
419
+ <li><strong>Recent:</strong> Quick access to recently used disks (per drive)</li>
420
+ <li><strong>Blank:</strong> Create a new formatted blank disk</li>
421
+ <li><strong>Eject:</strong> Remove the disk (prompts to save if modified)</li>
422
+ <li><strong>Browse:</strong> Open the file explorer to view disk contents</li>
423
+ </ul>
424
+
425
+ <h4>Drive Information</h4>
426
+ <ul>
427
+ <li><strong>Filename:</strong> Shown on the drive (scrolls if long)</li>
428
+ <li><strong>Track:</strong> Current head position (T00-T34)</li>
429
+ <li><strong>LED:</strong> Glows when drive is active</li>
430
+ </ul>
431
+
432
+ <h4>Drag and Drop</h4>
433
+ <p>You can drag disk image files directly onto a drive to insert them.</p>
434
+
435
+ <h4>Booting from Disk</h4>
436
+ <ul>
437
+ <li>Type <kbd>PR#6</kbd> and press <kbd>Return</kbd> to boot from Drive 1</li>
438
+ <li>Or use the <strong>Reboot</strong> button for a cold boot</li>
439
+ <li>Many games auto-boot when inserted and the machine is reset</li>
440
+ </ul>
441
+
442
+ <h4>Saving Modified Disks</h4>
443
+ <p>When you eject a disk that has been modified, you'll be prompted to save it. You can also use the File Explorer to export disks.</p>
444
+
445
+ <h4>Disk Persistence</h4>
446
+ <p>Disk contents are automatically saved in your browser's storage. When you return to the emulator, your disks will be exactly as you left them.</p>
447
+
448
+ <div class="info-box tip">
449
+ <p><strong>Tip:</strong> The Recent disks list is maintained separately for each drive, making it easy to quickly swap disks for multi-disk software.</p>
450
+ </div>
451
+ </section>
452
+
453
+ <!-- SmartPort Drives Section -->
454
+ <section id="doc-smartport" class="documentation-section">
455
+ <h3>SmartPort Drives</h3>
456
+ <p>The emulator supports SmartPort hard drive emulation, providing high-capacity storage. Open from <strong>View &gt; SmartPort Drives</strong>.</p>
457
+
458
+ <h4>Supported Formats</h4>
459
+ <div class="format-list">
460
+ <div class="format-item"><code>.HDV</code><span>Hard disk volume image</span></div>
461
+ <div class="format-item"><code>.PO</code><span>ProDOS order image</span></div>
462
+ <div class="format-item"><code>.2MG</code><span>Universal disk image (2IMG)</span></div>
463
+ </div>
464
+
465
+ <h4>Device Controls</h4>
466
+ <ul>
467
+ <li><strong>Insert:</strong> Load a SmartPort image from your computer</li>
468
+ <li><strong>Recent:</strong> Quick access to recently used images (per device)</li>
469
+ <li><strong>Eject:</strong> Remove the image (prompts to save if modified)</li>
470
+ <li><strong>Browse:</strong> Open the file explorer to view image contents</li>
471
+ </ul>
472
+
473
+ <h4>Setup</h4>
474
+ <p>The SmartPort card must be installed in an expansion slot before images can be loaded. Configure this in <strong>View &gt; Expansion Slots</strong>.</p>
475
+
476
+ <h4>Activity LED</h4>
477
+ <p>Each device has an LED indicator that glows green when the drive is being accessed.</p>
478
+
479
+ <div class="info-box tip">
480
+ <p><strong>Tip:</strong> SmartPort drives provide much larger storage than floppy disks and are commonly used with ProDOS.</p>
481
+ </div>
482
+ </section>
483
+
484
+ <!-- File Explorer Section -->
485
+ <section id="doc-file-explorer" class="documentation-section">
486
+ <h3>File Explorer</h3>
487
+ <p>The File Explorer lets you browse the contents of disk images and view files without running programs.</p>
488
+
489
+ <h4>Opening the File Explorer</h4>
490
+ <p>Open from <strong>View &gt; File Explorer</strong> or click the <strong>folder icon</strong> in the toolbar. Select which drive to browse using the drive selector at the top.</p>
491
+
492
+ <h4>Supported Disk Formats</h4>
493
+ <ul>
494
+ <li><strong>DOS 3.3:</strong> Standard Apple II DOS catalog browsing</li>
495
+ <li><strong>ProDOS:</strong> Full directory navigation with subdirectories</li>
496
+ <li><strong>WOZ:</strong> Catalog extraction from WOZ format disks</li>
497
+ </ul>
498
+
499
+ <h4>File Types</h4>
500
+ <ul>
501
+ <li><strong>A (Applesoft BASIC):</strong> Displayed with full detokenization, indentation, and syntax highlighting</li>
502
+ <li><strong>I (Integer BASIC):</strong> Detokenized and formatted</li>
503
+ <li><strong>B (Binary):</strong> Disassembled as 6502 machine code with:
504
+ <ul>
505
+ <li>Recursive descent flow analysis</li>
506
+ <li>Clickable jump/branch targets</li>
507
+ <li>Symbol tooltips (ROM routines, zero page, I/O)</li>
508
+ <li>Operand highlighting</li>
509
+ </ul>
510
+ </li>
511
+ <li><strong>T (Text):</strong> Plain text display</li>
512
+ <li><strong>Other:</strong> Hex dump view</li>
513
+ </ul>
514
+
515
+ <h4>Navigation</h4>
516
+ <ul>
517
+ <li>Click file/folder names to open them</li>
518
+ <li>Use the breadcrumb path for ProDOS directory navigation</li>
519
+ <li>Click addresses in disassembly to jump to targets</li>
520
+ <li>Use the back button to return to the catalog</li>
521
+ </ul>
522
+
523
+ <h4>Disk Information</h4>
524
+ <p>The header shows disk format, volume name, and free space (for ProDOS disks).</p>
525
+
526
+ <div class="info-box tip">
527
+ <p><strong>Tip:</strong> The File Explorer uses virtual scrolling for large files, so even massive disassemblies load instantly.</p>
528
+ </div>
529
+ </section>
530
+
531
+ <!-- State Management Section -->
532
+ <section id="doc-state" class="documentation-section">
533
+ <h3>State Management</h3>
534
+ <p>The emulator automatically saves your session so you can pick up exactly where you left off. You also have 5 manual save slots for organizing different states.</p>
535
+
536
+ <h4>What Gets Saved</h4>
537
+ <ul>
538
+ <li><strong>CPU State:</strong> All registers (A, X, Y, SP, PC) and flags</li>
539
+ <li><strong>Memory:</strong> Full 128KB RAM (main + auxiliary)</li>
540
+ <li><strong>Language Card:</strong> 16KB Language Card RAM</li>
541
+ <li><strong>Soft Switches:</strong> All memory banking and display modes</li>
542
+ <li><strong>Disk Drives:</strong> Complete disk images with modifications</li>
543
+ <li><strong>Settings:</strong> Display, sound, and window positions</li>
544
+ </ul>
545
+
546
+ <h4>Auto-Save</h4>
547
+ <p>When enabled (default), state is saved every 5 seconds while the emulator is running. Auto-save also triggers when:</p>
548
+ <ul>
549
+ <li>You switch to another tab or window</li>
550
+ <li>You close the browser</li>
551
+ <li>You power off the emulator</li>
552
+ </ul>
553
+ <p>Toggle auto-save on or off from the <strong>File</strong> menu.</p>
554
+
555
+ <h4>Save States Window</h4>
556
+ <p>Open the Save States window from <strong>File &gt; Save States...</strong> to manage all your saved states in one place.</p>
557
+
558
+ <h4>Autosave Slot</h4>
559
+ <p>The top row shows the current autosave with a screenshot thumbnail and timestamp. Use the <strong>Load</strong> button to restore it, or <strong>DL</strong> to download it as a file. This slot updates automatically while the window is open.</p>
560
+
561
+ <h4>Manual Slots (1&ndash;5)</h4>
562
+ <p>Below the autosave are 5 numbered slots for manual saves. Each slot has:</p>
563
+ <ul>
564
+ <li><strong>Save:</strong> Capture the current emulator state with a screenshot thumbnail</li>
565
+ <li><strong>Load:</strong> Restore the emulator to this saved state</li>
566
+ <li><strong>Clear:</strong> Delete the saved state from this slot</li>
567
+ <li><strong>DL:</strong> Download the state as an <code>.a2state</code> file</li>
568
+ </ul>
569
+
570
+ <h4>Load from File</h4>
571
+ <p>Click <strong>Load from File...</strong> at the bottom of the Save States window to restore a previously downloaded <code>.a2state</code> file. The file is validated before loading.</p>
572
+
573
+ <h4>How Restore Works</h4>
574
+ <p>Restoring any state (autosave, slot, or file) performs a complete power cycle and then loads the saved state. This ensures a clean restoration with no leftover state from the current session.</p>
575
+
576
+ <div class="info-box tip">
577
+ <p><strong>Tip:</strong> Use slots to save before difficult parts of a game, or to keep multiple program states. Download slots to back up important states or transfer them to another device.</p>
578
+ </div>
579
+ </section>
580
+
581
+ <!-- Sound Section -->
582
+ <section id="doc-sound" class="documentation-section">
583
+ <h3>Sound Settings</h3>
584
+ <p>Click the <strong>speaker icon</strong> in the toolbar to access audio controls.</p>
585
+
586
+ <h4>Audio Controls</h4>
587
+ <ul>
588
+ <li><strong>Volume Slider:</strong> Adjust master volume (0-100%)</li>
589
+ <li><strong>Mute Toggle:</strong> Quickly mute/unmute all sound</li>
590
+ <li><strong>Drive Sounds:</strong> Enable/disable disk drive sound effects</li>
591
+ </ul>
592
+
593
+ <h4>Sound Sources</h4>
594
+ <ul>
595
+ <li><strong>Speaker:</strong> The Apple II's built-in speaker for music and sound effects</li>
596
+ <li><strong>Mockingboard:</strong> Dual AY-3-8910 sound chips for rich stereo music and sound</li>
597
+ <li><strong>Disk Seek:</strong> Stepper motor sounds when the drive head moves</li>
598
+ </ul>
599
+
600
+ <h4>Audio Technology</h4>
601
+ <p>The emulator uses the Web Audio API with an AudioWorklet for real-time audio synthesis. Audio timing drives the emulator's frame rate, ensuring accurate 1.023 MHz CPU timing.</p>
602
+
603
+ <div class="info-box info">
604
+ <p><strong>Note:</strong> Some browsers require a user interaction (click) before audio can play. Click anywhere on the page if you don't hear sound initially.</p>
605
+ </div>
606
+ </section>
607
+
608
+ <!-- Debug Tools Section -->
609
+ <section id="doc-debug" class="documentation-section">
610
+ <h3>Debug Tools</h3>
611
+ <p>Professional debugging tools for software development, reverse engineering, and exploration. Access via the <strong>Debug</strong> menu in the toolbar.</p>
612
+
613
+ <h4>CPU Debugger Overview</h4>
614
+ <p>The CPU Debugger provides full control over 65C02 execution with registers, disassembly, breakpoints, watch expressions, and beam position breakpoints. Open it from <strong>Debug &gt; CPU Debugger</strong>.</p>
615
+
616
+ <h4>Execution Controls</h4>
617
+ <table class="key-table">
618
+ <thead>
619
+ <tr><th>Button</th><th>Shortcut</th><th>Function</th></tr>
620
+ </thead>
621
+ <tbody>
622
+ <tr><td>Run</td><td><kbd>F5</kbd></td><td>Resume execution (or continue from breakpoint)</td></tr>
623
+ <tr><td>Pause</td><td></td><td>Pause execution immediately</td></tr>
624
+ <tr><td>Step</td><td><kbd>F11</kbd></td><td>Execute one instruction, stepping into subroutines</td></tr>
625
+ <tr><td>Step Over</td><td><kbd>F10</kbd></td><td>Execute one instruction, skipping over JSR calls</td></tr>
626
+ <tr><td>Step Out</td><td><kbd>Shift</kbd>+<kbd>F11</kbd></td><td>Run until the current subroutine returns (RTS/RTI)</td></tr>
627
+ </tbody>
628
+ </table>
629
+
630
+ <h4>Registers &amp; Flags</h4>
631
+ <p>The top panel displays all CPU registers and status flags in real time.</p>
632
+ <ul>
633
+ <li><strong>Registers:</strong> A, X, Y (accumulator and index), SP (stack pointer), PC (program counter) &mdash; all shown in hexadecimal</li>
634
+ <li><strong>Flags:</strong> N (negative), V (overflow), B (break), D (decimal), I (interrupt disable), Z (zero), C (carry) &mdash; active flags are highlighted</li>
635
+ <li><strong>Editing:</strong> Double-click any register value while paused to enter a new hex value</li>
636
+ </ul>
637
+
638
+ <h4>Cycle &amp; Beam Position</h4>
639
+ <ul>
640
+ <li><strong>CYC:</strong> Total CPU cycle count since power-on</li>
641
+ <li><strong>IRQ / NMI / EDGE:</strong> Indicators for pending interrupt requests</li>
642
+ <li><strong>SCAN:</strong> Current scanline (0&ndash;261), <strong>H:</strong> horizontal position, <strong>COL:</strong> column (0&ndash;39)</li>
643
+ <li><strong>FCYC:</strong> Cycle within the current frame</li>
644
+ <li>A badge shows the beam region: <strong>VISIBLE</strong>, <strong>HBLANK</strong>, or <strong>VBL</strong></li>
645
+ </ul>
646
+
647
+ <h4>Disassembly View</h4>
648
+ <p>The scrollable disassembly view shows decoded 65C02 instructions around the current PC.</p>
649
+ <ul>
650
+ <li><strong>Go to Address:</strong> Enter a hex address or symbol name in the input field and click <strong>Go</strong> to jump the disassembly view</li>
651
+ <li><strong>Follow PC:</strong> Click <strong>Follow PC</strong> to re-center the view on the current program counter. When the CPU is running, the view automatically follows PC</li>
652
+ <li><strong>Click a line:</strong> Toggle an execution breakpoint at that address</li>
653
+ <li><strong>Ctrl+Click</strong> (or <strong>Cmd+Click</strong>): Toggle a bookmark on that line (highlighted in yellow)</li>
654
+ <li><strong>Double-click a line:</strong> Add or edit an inline comment that appears next to the instruction</li>
655
+ <li><strong>Right-click a line:</strong> Context menu with <em>Run to Cursor</em>, <em>Go to Address</em>, and <em>Toggle Breakpoint</em></li>
656
+ </ul>
657
+ <p>Branch and jump instructions are color-coded. When symbols are loaded, known addresses are annotated with their symbol names.</p>
658
+
659
+ <h4>Symbol Import</h4>
660
+ <p>Click <strong>Import Symbols</strong> in the disassembly toolbar to load a symbol file. Supported formats:</p>
661
+ <ul>
662
+ <li><code>.dbg</code> &mdash; cc65 debug info files</li>
663
+ <li><code>.sym</code> &mdash; Symbol table files (label = address)</li>
664
+ <li><code>.labels</code> &mdash; Label files (address label)</li>
665
+ <li><code>.map</code> &mdash; Map files</li>
666
+ <li><code>.txt</code> &mdash; Plain text symbol lists</li>
667
+ </ul>
668
+ <p>Once imported, symbols appear in the disassembly as annotations and can be used in the address input field.</p>
669
+
670
+ <h4>Breakpoints Tab</h4>
671
+ <p>The Breakpoints tab lets you manage all breakpoints. Click <strong>Add</strong> to create a new breakpoint.</p>
672
+ <ul>
673
+ <li><strong>Type:</strong> Choose from <em>Exec</em> (execution), <em>Read</em> (memory read), <em>Write</em> (memory write), or <em>R/W</em> (read or write)</li>
674
+ <li><strong>Address:</strong> Enter a hex address (e.g., <code>FF69</code>) or a symbol name if symbols are loaded</li>
675
+ <li><strong>Conditions:</strong> Optionally add a condition expression. Click the condition cell to open the Rule Builder, or type expressions directly:
676
+ <ul>
677
+ <li><code>A==#$FF</code> &mdash; break when accumulator equals $FF</li>
678
+ <li><code>X&gt;#$10</code> &mdash; break when X register exceeds $10</li>
679
+ <li><code>PEEK($00)==#$42</code> &mdash; break when zero page location $00 equals $42</li>
680
+ </ul>
681
+ </li>
682
+ <li><strong>Hit Count:</strong> Set a hit count target &mdash; the breakpoint only fires after being hit that many times</li>
683
+ <li><strong>Enable/Disable:</strong> Use the checkbox to temporarily disable a breakpoint without deleting it</li>
684
+ <li><strong>Remove:</strong> Click the &times; button to delete a breakpoint</li>
685
+ </ul>
686
+ <p>Breakpoints are persisted to localStorage and survive page reloads.</p>
687
+
688
+ <h4>Watch Tab</h4>
689
+ <p>The Watch tab monitors values in real time, highlighting changes. Click <strong>Add Watch</strong> and choose a source:</p>
690
+ <ul>
691
+ <li><strong>Register:</strong> Watch A, X, Y, SP, PC, or P (status byte)</li>
692
+ <li><strong>Flag:</strong> Watch individual status flags (N, V, B, D, I, Z, C)</li>
693
+ <li><strong>Byte:</strong> Watch a memory byte &mdash; displays as <code>PEEK($addr)</code></li>
694
+ <li><strong>Word:</strong> Watch a 16-bit value (little-endian) &mdash; displays as <code>DEEK($addr)</code></li>
695
+ </ul>
696
+ <p>When a watched value changes, it briefly highlights to draw attention. Watch entries are persisted between sessions.</p>
697
+
698
+ <h4>Beam Breakpoints Tab</h4>
699
+ <p>Beam breakpoints pause execution based on the CRT beam position rather than the program counter. This is useful for debugging display timing and raster effects.</p>
700
+ <ul>
701
+ <li><strong>VBL Start:</strong> Break at the start of vertical blanking (scanline 192)</li>
702
+ <li><strong>HBLANK:</strong> Break at the start of each horizontal blanking period</li>
703
+ <li><strong>Scanline:</strong> Break when the beam reaches a specific scanline (0&ndash;261)</li>
704
+ <li><strong>Column:</strong> Break when the beam reaches a specific column (0&ndash;39)</li>
705
+ <li><strong>Scan+Col:</strong> Break at a specific scanline <em>and</em> column combination</li>
706
+ </ul>
707
+ <p>Use the <strong>Enable</strong> checkbox to activate or deactivate beam breakpoints. When hit, the breakpoint row highlights briefly.</p>
708
+
709
+ <h4>Memory Browser</h4>
710
+ <ul>
711
+ <li>Full 64KB hex dump with ASCII column</li>
712
+ <li>Quick jump buttons for key memory regions</li>
713
+ <li>Direct address entry for navigation</li>
714
+ <li>Changed bytes highlighted with fade animation</li>
715
+ <li>Search for hex byte sequences</li>
716
+ <li>Click any byte to edit its value</li>
717
+ </ul>
718
+
719
+ <h4>Memory Heat Map</h4>
720
+ <ul>
721
+ <li>256&times;256 visualization of memory access</li>
722
+ <li>Left panel: Main RAM + ROM</li>
723
+ <li>Right panel: Auxiliary RAM</li>
724
+ <li>View modes: Combined, Reads only, Writes only</li>
725
+ <li>Click to jump to address in Memory Browser</li>
726
+ </ul>
727
+
728
+ <h4>Memory Map</h4>
729
+ <ul>
730
+ <li>Visual representation of memory bank configuration</li>
731
+ <li>Shows which banks are active for each region</li>
732
+ <li>Displays read/write bank status</li>
733
+ <li>Color-coded legend</li>
734
+ </ul>
735
+
736
+ <h4>Soft Switches</h4>
737
+ <ul>
738
+ <li><strong>Display:</strong> TEXT, MIXED, PAGE2, HIRES, 80COL, ALTCHAR, DHIRES</li>
739
+ <li><strong>Memory:</strong> 80STORE, RAMRD, RAMWRT, INTCXROM, ALTZP, SLOTC3ROM</li>
740
+ <li><strong>Language Card:</strong> LCRAM, LCBANK2, LCWRITE, LCPREWRT</li>
741
+ <li><strong>I/O:</strong> Annunciators, buttons, cassette</li>
742
+ </ul>
743
+
744
+ <h4>Stack Viewer</h4>
745
+ <p>Visual representation of the 6502 stack showing return addresses and saved values.</p>
746
+
747
+ <h4>Zero Page Watch</h4>
748
+ <ul>
749
+ <li>Predefined watch groups: BASIC, Screen, Graphics, DOS, System</li>
750
+ <li>Add custom watch addresses</li>
751
+ <li>Live value updates</li>
752
+ </ul>
753
+
754
+ <h4>Mockingboard Monitor</h4>
755
+ <p>Open from <strong>Debug &gt; Mockingboard</strong> to inspect the dual AY-3-8910 sound chips:</p>
756
+ <ul>
757
+ <li>Channel-centric view with inline waveforms</li>
758
+ <li>AY-3-8910 and VIA 6522 register states</li>
759
+ <li>Level meters for each channel</li>
760
+ <li>Per-channel mute controls</li>
761
+ </ul>
762
+
763
+ <h4>Mouse Card Monitor</h4>
764
+ <p>Open from <strong>Debug &gt; Mouse Card</strong> to inspect the Apple Mouse Interface Card:</p>
765
+ <ul>
766
+ <li>PIA registers and protocol activity</li>
767
+ <li>Position, mode, and interrupt state</li>
768
+ </ul>
769
+
770
+ <div class="info-box tip">
771
+ <p><strong>Tip:</strong> All debug windows can be moved and resized. Their positions and settings are saved between sessions.</p>
772
+ </div>
773
+ </section>
774
+
775
+ <!-- Dev Tools Section -->
776
+ <section id="doc-dev" class="documentation-section">
777
+ <h3>Dev Tools</h3>
778
+ <p>Development tools for writing and testing software. Access via the <strong>Dev</strong> menu in the toolbar.</p>
779
+
780
+ <h4>Applesoft BASIC Window</h4>
781
+ <p>Write, edit, debug, and load Applesoft BASIC programs. Open from <strong>Dev &gt; Applesoft BASIC</strong>.</p>
782
+
783
+ <h5>Editor Features</h5>
784
+ <ul>
785
+ <li><strong>New:</strong> Clear the editor and start a new program</li>
786
+ <li><strong>Syntax Highlighting:</strong> BASIC keywords, line numbers, strings, and comments are color-coded</li>
787
+ <li><strong>Autocomplete:</strong> Type to see suggestions for BASIC commands</li>
788
+ </ul>
789
+
790
+ <h5>Debugger Controls</h5>
791
+ <ul>
792
+ <li><strong>Run:</strong> Execute the BASIC program</li>
793
+ <li><strong>Pause:</strong> Pause execution</li>
794
+ <li><strong>Step:</strong> Step through one BASIC line at a time</li>
795
+ </ul>
796
+
797
+ <h5>Program Operations</h5>
798
+ <ul>
799
+ <li><strong>Read:</strong> Read the current BASIC program from emulator memory into the editor</li>
800
+ <li><strong>Write:</strong> Type the program into the running emulator</li>
801
+ <li><strong>Format:</strong> Auto-format the program text</li>
802
+ <li><strong>Renum:</strong> Renumber BASIC line numbers</li>
803
+ </ul>
804
+
805
+ <h5>File Operations</h5>
806
+ <ul>
807
+ <li><strong>New:</strong> Start a new program</li>
808
+ <li><strong>Open:</strong> Open a BASIC program file from your computer</li>
809
+ <li><strong>Save:</strong> Save the current program to a file</li>
810
+ </ul>
811
+
812
+ <div class="info-box warning">
813
+ <p><strong>Note:</strong> The Read and Write buttons require the emulator to be powered on.</p>
814
+ </div>
815
+
816
+ <h4>Assembler</h4>
817
+ <p>Write 65C02 assembly code using Merlin-style syntax. Open from <strong>Dev &gt; Assembler</strong>.</p>
818
+
819
+ <h5>Editor Features</h5>
820
+ <ul>
821
+ <li><strong>Syntax Highlighting:</strong> Opcodes, directives, labels, operands, and comments</li>
822
+ <li><strong>Column Guides:</strong> Visual guides for Merlin's column-based format (Label, Opcode, Operand, Comment)</li>
823
+ <li><strong>Tab Navigation:</strong> Press Tab to jump between columns</li>
824
+ <li><strong>Live Validation:</strong> Syntax errors shown as you type</li>
825
+ <li><strong>Breakpoints:</strong> Click the gutter or press <kbd>F9</kbd> to toggle breakpoints</li>
826
+ </ul>
827
+
828
+ <h5>File Operations</h5>
829
+ <table class="key-table">
830
+ <thead>
831
+ <tr><th>Button</th><th>Shortcut</th><th>Function</th></tr>
832
+ </thead>
833
+ <tbody>
834
+ <tr><td>New</td><td><kbd>Ctrl/⌘</kbd>+<kbd>N</kbd></td><td>Start a new file</td></tr>
835
+ <tr><td>Open</td><td><kbd>Ctrl/⌘</kbd>+<kbd>O</kbd></td><td>Open a .s, .asm, or .a65 file</td></tr>
836
+ <tr><td>Save</td><td><kbd>Ctrl/⌘</kbd>+<kbd>S</kbd></td><td>Save current file</td></tr>
837
+ </tbody>
838
+ </table>
839
+
840
+ <h5>Assembly &amp; Loading</h5>
841
+ <ul>
842
+ <li><strong>Assemble:</strong> Click or press <kbd>Ctrl/⌘</kbd>+<kbd>Enter</kbd> to assemble the code</li>
843
+ <li><strong>Write:</strong> After successful assembly, click Write to copy the machine code into emulator memory (requires emulator to be powered on)</li>
844
+ <li><strong>ORG Directive:</strong> Your code must include an <code>ORG</code> directive before any instructions</li>
845
+ </ul>
846
+
847
+ <h5>ROM Routines Reference</h5>
848
+ <p>Press <kbd>F2</kbd> or click <strong>ROM</strong> to open the ROM routines panel:</p>
849
+ <ul>
850
+ <li>Search and browse Apple II ROM routines</li>
851
+ <li>View input/output requirements and examples</li>
852
+ <li>Insert EQU definitions or JSR calls directly into your code</li>
853
+ </ul>
854
+
855
+ <h5>Output Panels</h5>
856
+ <ul>
857
+ <li><strong>Symbols:</strong> Lists all defined labels and their addresses</li>
858
+ <li><strong>Hex Output:</strong> Shows assembled machine code bytes</li>
859
+ </ul>
860
+ </section>
861
+
862
+ <!-- AI Agent Section -->
863
+ <section id="doc-agent" class="documentation-section">
864
+ <h3>AI Agent</h3>
865
+ <p>The AI Agent integration allows LLMs like Claude to control the emulator through natural language commands. The agent can show/hide windows, manage disks, read/write BASIC programs, and inspect emulator state in real time using the AG-UI protocol over an MCP server.</p>
866
+
867
+ <h4>Connection Status</h4>
868
+ <p>The agent connection status is shown by a sparkle icon in the toolbar header:</p>
869
+ <table class="key-table">
870
+ <thead>
871
+ <tr><th>Icon</th><th>Status</th><th>Description</th></tr>
872
+ </thead>
873
+ <tbody>
874
+ <tr>
875
+ <td><svg viewBox="0 0 24 24" width="20" height="20" fill="#6e7681"><path d="M12 2l1.5 4.5L18 8l-4.5 1.5L12 14l-1.5-4.5L6 8l4.5-1.5L12 2zM6 16l.75 2.25L9 19l-2.25.75L6 22l-.75-2.25L3 19l2.25-.75L6 16zM18 16l.75 2.25L21 19l-2.25.75L18 22l-.75-2.25L15 19l2.25-.75L18 16z"/></svg></td>
876
+ <td>Disconnected</td>
877
+ <td>MCP server is not running or not reachable</td>
878
+ </tr>
879
+ <tr>
880
+ <td><svg viewBox="0 0 24 24" width="20" height="20" fill="#FDBE34"><path d="M12 2l1.5 4.5L18 8l-4.5 1.5L12 14l-1.5-4.5L6 8l4.5-1.5L12 2zM6 16l.75 2.25L9 19l-2.25.75L6 22l-.75-2.25L3 19l2.25-.75L6 16zM18 16l.75 2.25L21 19l-2.25.75L18 22l-.75-2.25L15 19l2.25-.75L18 16z"/></svg></td>
881
+ <td>Connected</td>
882
+ <td>Agent is connected and ready to receive commands</td>
883
+ </tr>
884
+ <tr>
885
+ <td><svg viewBox="0 0 24 24" width="20" height="20" fill="#E5504F"><path d="M12 2l1.5 4.5L18 8l-4.5 1.5L12 14l-1.5-4.5L6 8l4.5-1.5L12 2zM6 16l.75 2.25L9 19l-2.25.75L6 22l-.75-2.25L3 19l2.25-.75L6 16zM18 16l.75 2.25L21 19l-2.25.75L18 22l-.75-2.25L15 19l2.25-.75L18 16z"/></svg></td>
886
+ <td>Interrupted</td>
887
+ <td>Connection error or server unavailable</td>
888
+ </tr>
889
+ </tbody>
890
+ </table>
891
+ <p>Click the sparkle icon to open the agent connection panel and view detailed status information.</p>
892
+
893
+ <h4>Setting Up the MCP Server</h4>
894
+ <p>The AI Agent uses the Model Context Protocol (MCP) to communicate with LLM clients like Claude Code. Configure your MCP client to connect to the emulator's agent server.</p>
895
+ <p>Add the following to your MCP configuration file (e.g., <code>~/.claude/mcp.json</code>):</p>
896
+ <pre><code>{
897
+ "mcpServers": {
898
+ "appleii-agent": {
899
+ "command": "node",
900
+ "args": [
901
+ "/path/to/mcp/appleii-agent/src/index.js"
902
+ ]
903
+ }
904
+ }
905
+ }</code></pre>
906
+ <p>The server listens on <code>http://localhost:3033</code> by default.</p>
907
+
908
+ <h4>Port Conflict Management</h4>
909
+ <p>The MCP server includes graceful port conflict handling when multiple instances attempt to use port 3033:</p>
910
+ <ul>
911
+ <li><strong>Automatic Detection:</strong> When port 3033 is already in use, the MCP server stays alive without failing</li>
912
+ <li><strong>Status Reporting:</strong> The status tool reports port conflicts and provides clear guidance</li>
913
+ <li><strong>Port Reclamation:</strong> Any instance can take over the port using a two-step process:
914
+ <ol class="quick-start-list">
915
+ <li>Ask the agent to "shutdown the remote server on port 3033"</li>
916
+ <li>Ask the agent to "start this server"</li>
917
+ </ol>
918
+ </li>
919
+ </ul>
920
+ <p>This allows multiple Claude Code sessions or MCP instances to coordinate gracefully without manual process management.</p>
921
+
922
+ <h4>Example Prompts</h4>
923
+
924
+ <h5>Window Management</h5>
925
+ <ul>
926
+ <li><strong>Show a window:</strong> "Show the CPU debugger window"</li>
927
+ <li><strong>Hide a window:</strong> "Hide the disk drives window"</li>
928
+ <li><strong>Focus a window:</strong> "Bring the BASIC program window to the front"</li>
929
+ </ul>
930
+
931
+ <h5>Disk Management</h5>
932
+ <ul>
933
+ <li><strong>Insert from filesystem:</strong> "Load ~/Documents/Apple_II/ProDOS_2_4_2.dsk into drive 1"</li>
934
+ <li><strong>List recent disks:</strong> "What disks are in the recent list for drive 1?"</li>
935
+ <li><strong>Load from recent:</strong> "Insert the disk named Zork_1.dsk from recent disks into drive 2"</li>
936
+ <li><strong>Eject a disk:</strong> "Eject the disk from drive 1"</li>
937
+ </ul>
938
+
939
+ <h5>BASIC Programs</h5>
940
+ <ul>
941
+ <li><strong>Read from memory:</strong> "Load the BASIC program from memory and show it in the editor"</li>
942
+ <li><strong>Write to memory:</strong> "Write this BASIC program to emulator memory: 10 PRINT \"HELLO\" 20 GOTO 10"</li>
943
+ <li><strong>Get listing:</strong> "What BASIC program is currently in memory?"</li>
944
+ <li><strong>Save to file:</strong> "Save the BASIC program from the editor to ~/Documents/myprogram.bas"</li>
945
+ </ul>
946
+
947
+ <h5>Assembly Programs</h5>
948
+ <ul>
949
+ <li><strong>Get status:</strong> "What's the status of the assembler?" or "Get the assembly origin address"</li>
950
+ <li><strong>Execute program:</strong> "Run the assembled program" or "Execute the code at the origin"</li>
951
+ <li><strong>Execute at address:</strong> "Execute the code at $0800" or "Run code at address 2048"</li>
952
+ <li><strong>Execute with return:</strong> "Execute $0800 and return to BASIC" or "Run $0800 and return to monitor"</li>
953
+ <li><strong>Set PC without executing:</strong> "Set PC to $0800 but don't execute yet"</li>
954
+ </ul>
955
+
956
+ <h5>Memory Operations</h5>
957
+ <ul>
958
+ <li><strong>Load binary to memory:</strong> "Load the file ~/program.bin into memory at address $2000"</li>
959
+ <li><strong>Save memory range:</strong> "Save 256 bytes from memory address $0800 to ~/output.bin"</li>
960
+ <li><strong>Save memory region:</strong> "Read 1024 bytes starting at $4000 and save them to ~/dump.bin"</li>
961
+ </ul>
962
+
963
+ <h5>SmartPort Hard Drives</h5>
964
+ <ul>
965
+ <li><strong>Insert image:</strong> "Load ~/Images/Total_Replay.hdv into SmartPort device 1"</li>
966
+ <li><strong>List recent images:</strong> "What images are in the recent list for SmartPort device 1?"</li>
967
+ <li><strong>Load from recent:</strong> "Insert Apple Pascal from recent SmartPort images"</li>
968
+ <li><strong>Clear recent:</strong> "Clear the recent images list for SmartPort device 1"</li>
969
+ </ul>
970
+
971
+ <h5>Slot Configuration</h5>
972
+ <ul>
973
+ <li><strong>List all slots:</strong> "Show me the current expansion slot configuration"</li>
974
+ <li><strong>Install a card:</strong> "Install the Mockingboard in slot 4"</li>
975
+ <li><strong>Remove a card:</strong> "Remove the card from slot 5"</li>
976
+ <li><strong>Move a card:</strong> "Move the SmartPort card from slot 7 to slot 5"</li>
977
+ </ul>
978
+
979
+ <h5>Emulator Control</h5>
980
+ <ul>
981
+ <li><strong>Power on:</strong> "Turn on the emulator" or "Power on the Apple //e"</li>
982
+ <li><strong>Power off:</strong> "Turn off the emulator" or "Power off"</li>
983
+ <li><strong>Reboot:</strong> "Reboot the emulator" or "Do a cold reset"</li>
984
+ <li><strong>Warm reset:</strong> "Send Ctrl+Reset to the emulator" or "Press Ctrl+Reset"</li>
985
+ <li><strong>Break program:</strong> "Send Ctrl+C to the emulator" or "Stop the running program"</li>
986
+ </ul>
987
+
988
+ <div class="info-box info">
989
+ <p><strong>Note:</strong> The MCP server must be running for the agent to connect. The server starts automatically when your MCP client connects.</p>
990
+ </div>
991
+ </section>
992
+
993
+ <!-- Tips Section -->
994
+ <section id="doc-tips" class="documentation-section">
995
+ <h3>Tips & Troubleshooting</h3>
996
+
997
+ <h4>Getting Software</h4>
998
+ <p>Search for "Apple II disk images" to find archives of classic software. Popular archives include:</p>
999
+ <ul>
1000
+ <li>Asimov Apple II Archive</li>
1001
+ <li>What Is The Apple IIGS?</li>
1002
+ <li>Internet Archive Apple II Library</li>
1003
+ </ul>
1004
+
1005
+ <h4>Common BASIC Commands</h4>
1006
+ <div class="info-box tip">
1007
+ <p>
1008
+ <code>CATALOG</code> - List files on disk<br>
1009
+ <code>RUN filename</code> - Run a BASIC program<br>
1010
+ <code>LOAD filename</code> - Load a program into memory<br>
1011
+ <code>LIST</code> - Show program listing<br>
1012
+ <code>NEW</code> - Clear current program<br>
1013
+ <code>PR#6</code> - Boot from disk in slot 6
1014
+ </p>
1015
+ </div>
1016
+
1017
+ <h4>Keyboard Not Working?</h4>
1018
+ <p>Click directly on the monitor screen to give it keyboard focus. The emulator needs focus to receive keyboard input.</p>
1019
+
1020
+ <h4>No Sound?</h4>
1021
+ <ul>
1022
+ <li>Check that the volume is turned up in Sound Settings</li>
1023
+ <li>Check that your system volume is not muted</li>
1024
+ <li>Click anywhere on the page - browsers require user interaction before playing audio</li>
1025
+ </ul>
1026
+
1027
+ <h4>Disk Won't Boot?</h4>
1028
+ <ul>
1029
+ <li>Make sure the emulator is powered on</li>
1030
+ <li>Try typing <kbd>PR#6</kbd> and pressing Return</li>
1031
+ <li>Try the Reboot button for a cold start</li>
1032
+ <li>Check that the disk is a bootable system disk</li>
1033
+ </ul>
1034
+
1035
+ <h4>Performance Issues?</h4>
1036
+ <ul>
1037
+ <li>Disable some CRT effects in Display Settings</li>
1038
+ <li>Close unused debug windows</li>
1039
+ <li>Try a different browser (Chrome recommended)</li>
1040
+ </ul>
1041
+
1042
+ <h4>Saving Your Work</h4>
1043
+ <ul>
1044
+ <li>State auto-saves every 5 seconds by default</li>
1045
+ <li>Use <strong>File &gt; Save States...</strong> to save to manual slots or download states</li>
1046
+ <li>Modified disks are saved when ejected</li>
1047
+ <li>Export disks via File Explorer for backup</li>
1048
+ </ul>
1049
+
1050
+ <h4>Release Notes</h4>
1051
+ <p>Click <strong>"Release Notes"</strong> in the footer to see the version history and recent changes.</p>
1052
+
1053
+ <div class="info-box info">
1054
+ <p><strong>Need more help?</strong> The Apple II has extensive documentation available online. Search for "Apple II Reference Manual" or "Applesoft BASIC Programming Guide" for detailed information.</p>
1055
+ </div>
1056
+ </section>
1057
+ `;
1058
+ }
1059
+
1060
+ /**
1061
+ * Called after content is rendered - set up nav button handlers
1062
+ */
1063
+ onContentRendered() {
1064
+ this.navButtons = this.contentElement.querySelectorAll(
1065
+ ".documentation-nav button"
1066
+ );
1067
+ this.sections = this.contentElement.querySelectorAll(
1068
+ ".documentation-section"
1069
+ );
1070
+
1071
+ // Navigation button clicks
1072
+ this.navButtons.forEach((btn) => {
1073
+ btn.addEventListener("click", () => {
1074
+ const sectionId = btn.dataset.section;
1075
+ this.showSection(sectionId);
1076
+ });
1077
+ });
1078
+ }
1079
+
1080
+ /**
1081
+ * Show a specific section by ID
1082
+ * @param {string} sectionId - The section ID to show (without 'doc-' prefix)
1083
+ */
1084
+ showSection(sectionId) {
1085
+ // Update nav button active states
1086
+ this.navButtons.forEach((btn) => {
1087
+ btn.classList.toggle("active", btn.dataset.section === sectionId);
1088
+ });
1089
+
1090
+ // Show/hide sections
1091
+ this.sections.forEach((section) => {
1092
+ const isTarget = section.id === `doc-${sectionId}`;
1093
+ section.classList.toggle("active", isTarget);
1094
+ });
1095
+ }
1096
+ }