badline 0.17.0 → 0.19.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 (195) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +193 -0
  3. data/CLAUDE.md +19 -7
  4. data/CONTRIBUTING.md +11 -1
  5. data/README.md +178 -26
  6. data/doc/library.md +5 -1
  7. data/doc/media.md +3 -2
  8. data/doc/pinned-behaviour.md +169 -1
  9. data/doc/snapshot-format.md +302 -35
  10. data/doc/snapshots.md +97 -26
  11. data/doc/vice.md +344 -0
  12. data/exe/badline-ruby +5 -0
  13. data/lib/badline/audio/renderer.rb +4 -8
  14. data/lib/badline/audio/terminal.rb +34 -2
  15. data/lib/badline/c128/keyed_state.rb +2 -0
  16. data/lib/badline/c128.rb +5 -0
  17. data/lib/badline/c64/bus/fittings.rb +6 -0
  18. data/lib/badline/c64/keyed_state.rb +2 -0
  19. data/lib/badline/c64.rb +7 -0
  20. data/lib/badline/cbm2/keyed_state.rb +4 -0
  21. data/lib/badline/cbm2/p500.rb +9 -3
  22. data/lib/badline/cbm2.rb +10 -3
  23. data/lib/badline/chips/cia/timer.rb +2 -2
  24. data/lib/badline/chips/cpu/core.rb +29 -4
  25. data/lib/badline/chips/cpu/instruction_set.rb +1 -1
  26. data/lib/badline/chips/cpu/interrupts.rb +9 -0
  27. data/lib/badline/chips/cpu/keyed_state.rb +15 -9
  28. data/lib/badline/chips/cpu/microcode.rb +10 -0
  29. data/lib/badline/chips/m6809/arithmetic.rb +140 -0
  30. data/lib/badline/chips/m6809/bus_steps.rb +223 -0
  31. data/lib/badline/chips/m6809/core.rb +149 -0
  32. data/lib/badline/chips/m6809/indexed.rb +82 -0
  33. data/lib/badline/chips/m6809/interrupts.rb +159 -0
  34. data/lib/badline/chips/m6809/keyed_state.rb +147 -0
  35. data/lib/badline/chips/m6809/opcodes.rb +159 -0
  36. data/lib/badline/chips/m6809/operations.rb +258 -0
  37. data/lib/badline/chips/m6809/plans.rb +143 -0
  38. data/lib/badline/chips/m6809/registers.rb +82 -0
  39. data/lib/badline/chips/m6809/stack.rb +140 -0
  40. data/lib/badline/chips/m6809.rb +13 -0
  41. data/lib/badline/chips/riot/timer.rb +14 -3
  42. data/lib/badline/chips/rriot.rb +8 -3
  43. data/lib/badline/chips/sid/decimator.rb +1 -1
  44. data/lib/badline/chips/sid/filter.rb +4 -4
  45. data/lib/badline/chips/sid/keyed_parts.rb +51 -18
  46. data/lib/badline/chips/sid/waveform.rb +6 -6
  47. data/lib/badline/chips/sid.rb +6 -2
  48. data/lib/badline/chips/vic_i/keyed_parts.rb +12 -2
  49. data/lib/badline/chips/vic_i/light_pen.rb +89 -0
  50. data/lib/badline/chips/vic_i.rb +91 -23
  51. data/lib/badline/data_path.rb +3 -3
  52. data/lib/badline/drives/ieee_models.rb +54 -0
  53. data/lib/badline/drives/model1001.rb +37 -0
  54. data/lib/badline/drives/model1541/sector_reader.rb +20 -3
  55. data/lib/badline/drives/model1541.rb +1 -0
  56. data/lib/badline/drives/model1551.rb +1 -0
  57. data/lib/badline/drives/model1571.rb +1 -0
  58. data/lib/badline/drives/model1581.rb +1 -0
  59. data/lib/badline/drives/model2031.rb +7 -0
  60. data/lib/badline/drives/model4040/disk.rb +62 -0
  61. data/lib/badline/drives/model4040/ip_bus.rb +46 -0
  62. data/lib/badline/drives/model4040/keyed_state.rb +57 -0
  63. data/lib/badline/drives/model4040/mechanism.rb +195 -0
  64. data/lib/badline/drives/model4040/parts.rb +20 -0
  65. data/lib/badline/drives/model4040.rb +195 -0
  66. data/lib/badline/drives/model8050/board.rb +79 -0
  67. data/lib/badline/drives/model8050/dos_board.rb +134 -0
  68. data/lib/badline/drives/model8050/fdc_bus.rb +7 -0
  69. data/lib/badline/drives/model8050/idle.rb +148 -31
  70. data/lib/badline/drives/model8050/keyed_state.rb +5 -2
  71. data/lib/badline/drives/model8050.rb +32 -130
  72. data/lib/badline/drives/model9060/idle.rb +169 -0
  73. data/lib/badline/drives/model9060/keyed_state.rb +123 -0
  74. data/lib/badline/drives/model9060/parts.rb +98 -0
  75. data/lib/badline/drives/model9060/sasi_bus.rb +88 -0
  76. data/lib/badline/drives/model9060/sasi_commands.rb +168 -0
  77. data/lib/badline/drives/model9060/sasi_target.rb +161 -0
  78. data/lib/badline/drives/model9060.rb +197 -0
  79. data/lib/badline/frontend/app.rb +8 -0
  80. data/lib/badline/frontend/boot.rb +3 -2
  81. data/lib/badline/frontend/controls.rb +62 -6
  82. data/lib/badline/frontend/keys.rb +36 -0
  83. data/lib/badline/frontend/kim1_panel.rb +208 -0
  84. data/lib/badline/frontend/media_slots.rb +8 -1
  85. data/lib/badline/frontend/menu/drive_types.rb +56 -0
  86. data/lib/badline/frontend/menu/menu_dialogs.rb +61 -14
  87. data/lib/badline/frontend/menu/menu_media.rb +42 -12
  88. data/lib/badline/frontend/menu/menu_pages.rb +97 -2
  89. data/lib/badline/frontend/menu/menu_ports.rb +38 -1
  90. data/lib/badline/frontend/menu/pause_menu.rb +5 -1
  91. data/lib/badline/frontend/pet_keyboard.rb +23 -1
  92. data/lib/badline/frontend/screen.rb +1 -1
  93. data/lib/badline/frontend/screens.rb +40 -2
  94. data/lib/badline/frontend/teletype_pane.rb +152 -0
  95. data/lib/badline/frontend/timeline.rb +31 -2
  96. data/lib/badline/frontend.rb +3 -0
  97. data/lib/badline/input/joystick.rb +15 -2
  98. data/lib/badline/kim1/bus.rb +117 -0
  99. data/lib/badline/kim1/cpu.rb +25 -0
  100. data/lib/badline/kim1/host_terminal.rb +74 -0
  101. data/lib/badline/kim1/key_entry.rb +74 -0
  102. data/lib/badline/kim1/keyed_modules.rb +53 -0
  103. data/lib/badline/kim1/keyed_state.rb +133 -0
  104. data/lib/badline/kim1/panel.rb +176 -0
  105. data/lib/badline/kim1/rriots.rb +28 -0
  106. data/lib/badline/kim1/sound.rb +29 -0
  107. data/lib/badline/kim1/tape.rb +118 -0
  108. data/lib/badline/kim1/teletype.rb +193 -0
  109. data/lib/badline/kim1.rb +194 -0
  110. data/lib/badline/machine/ieee_drives.rb +94 -117
  111. data/lib/badline/machine/keyboard_buffer.rb +20 -3
  112. data/lib/badline/machine/line_sound.rb +122 -0
  113. data/lib/badline/machine.rb +49 -15
  114. data/lib/badline/media/extensions.rb +8 -4
  115. data/lib/badline/media/kim1_media.rb +150 -0
  116. data/lib/badline/media/pet_media.rb +3 -1
  117. data/lib/badline/media/true_drive.rb +52 -45
  118. data/lib/badline/media/vic20_media.rb +4 -2
  119. data/lib/badline/media.rb +16 -6
  120. data/lib/badline/memory.rb +2 -4
  121. data/lib/badline/options/family.rb +98 -8
  122. data/lib/badline/options/help.rb +44 -12
  123. data/lib/badline/options/table.rb +44 -12
  124. data/lib/badline/options/validation.rb +44 -8
  125. data/lib/badline/options.rb +27 -8
  126. data/lib/badline/pet/bus.rb +16 -2
  127. data/lib/badline/pet/keyboard_ports.rb +9 -2
  128. data/lib/badline/pet/keyed_state.rb +4 -0
  129. data/lib/badline/pet/model.rb +11 -2
  130. data/lib/badline/pet/rom_sets.rb +1 -0
  131. data/lib/badline/pet/sound.rb +5 -105
  132. data/lib/badline/pet/superpet/acia.rb +12 -0
  133. data/lib/badline/pet/superpet/board.rb +221 -0
  134. data/lib/badline/pet/superpet/dongle.rb +92 -0
  135. data/lib/badline/pet/superpet/keyed_modules.rb +63 -0
  136. data/lib/badline/pet/superpet/keyed_parts.rb +76 -0
  137. data/lib/badline/pet/superpet/m6809.rb +32 -0
  138. data/lib/badline/pet/superpet/waterloo_traps.rb +199 -0
  139. data/lib/badline/pet/superpet.rb +221 -0
  140. data/lib/badline/pet.rb +23 -3
  141. data/lib/badline/plus4/keyed_state.rb +2 -0
  142. data/lib/badline/plus4.rb +5 -0
  143. data/lib/badline/roms/1001/fdc-251257-02a.rom +0 -0
  144. data/lib/badline/roms/4040/dos-1.2.rom +0 -0
  145. data/lib/badline/roms/4040/dos-2.1-rev.rom +0 -0
  146. data/lib/badline/roms/4040/dos-2.1.rom +0 -0
  147. data/lib/badline/roms/4040/fdc-901466-02.rom +0 -0
  148. data/lib/badline/roms/4040/fdc-901466-04.rom +0 -0
  149. data/lib/badline/roms/9060/dos-3.0.rom +0 -0
  150. data/lib/badline/roms/9060/sasi-300515-revb.rom +0 -0
  151. data/lib/badline/roms/README +176 -0
  152. data/lib/badline/roms/kim1/6530-002.rom +0 -0
  153. data/lib/badline/roms/kim1/6530-003.rom +0 -0
  154. data/lib/badline/roms/pet/characters-superpet.rom +0 -0
  155. data/lib/badline/roms/pet/superpet-a000.rom +0 -0
  156. data/lib/badline/roms/pet/superpet-c000.rom +0 -0
  157. data/lib/badline/roms/pet/superpet-e000-50hz.rom +0 -0
  158. data/lib/badline/roms/pet/superpet-e000.rom +0 -0
  159. data/lib/badline/snapshot/container.rb +8 -4
  160. data/lib/badline/snapshot/field_doc/markdown.rb +1 -1
  161. data/lib/badline/snapshot/field_doc.rb +35 -10
  162. data/lib/badline/snapshot/image.rb +19 -7
  163. data/lib/badline/snapshot/kim1_setup.rb +28 -0
  164. data/lib/badline/snapshot/pet_setup.rb +27 -11
  165. data/lib/badline/snapshot/storage_setup.rb +4 -1
  166. data/lib/badline/snapshot/vic20_setup.rb +11 -7
  167. data/lib/badline/snapshot/vice/pet.rb +14 -7
  168. data/lib/badline/snapshot/vice/pet_cpu.rb +39 -5
  169. data/lib/badline/snapshot/vice/pet_crtc.rb +15 -2
  170. data/lib/badline/snapshot/vice/pet_dongle.rb +72 -0
  171. data/lib/badline/snapshot/vice/pet_drive8050.rb +188 -68
  172. data/lib/badline/snapshot/vice/pet_mem.rb +55 -5
  173. data/lib/badline/snapshot/vice/pet_restore.rb +40 -11
  174. data/lib/badline/snapshot/vice/vic20.rb +70 -0
  175. data/lib/badline/snapshot/vice/vic20_cpu.rb +61 -0
  176. data/lib/badline/snapshot/vice/vic20_mem.rb +85 -0
  177. data/lib/badline/snapshot/vice/vic20_restore.rb +124 -0
  178. data/lib/badline/snapshot/vice/vic20_vici.rb +200 -0
  179. data/lib/badline/snapshot/vice.rb +1 -0
  180. data/lib/badline/snapshot.rb +8 -4
  181. data/lib/badline/status.rb +30 -30
  182. data/lib/badline/storage/d67_image.rb +55 -0
  183. data/lib/badline/storage/d90_image.rb +180 -0
  184. data/lib/badline/storage/kim_tape.rb +254 -0
  185. data/lib/badline/storage/papertape.rb +90 -0
  186. data/lib/badline/storage.rb +4 -0
  187. data/lib/badline/support/kim1_checkpoint.rb +41 -0
  188. data/lib/badline/support/superpet_checkpoint.rb +35 -0
  189. data/lib/badline/version.rb +1 -1
  190. data/lib/badline/vic20/keyed_modules.rb +6 -3
  191. data/lib/badline/vic20/keyed_state.rb +6 -4
  192. data/lib/badline/vic20/port_wiring.rb +11 -0
  193. data/lib/badline/vic20.rb +30 -12
  194. data/lib/badline.rb +1 -0
  195. metadata +85 -1
data/README.md CHANGED
@@ -12,8 +12,8 @@ are modelled at the cycle level.
12
12
 
13
13
  It runs programs, disk and tape images, cartridges and SID tunes, and
14
14
  the SDL2 front end supports the keyboard, joysticks, game controllers,
15
- paddles and a 1351 mouse. It also runs a PAL VIC-20, as
16
- `badline vic20`, the C128, in C128 mode on 40 or 80 columns and in C64 mode, as `badline c128`, the Plus/4, the C16 and the C116, as `badline plus4`, the PET and CBM, as `badline pet`, and the CBM-II, the B series and the P500, as `badline cbm2`. See [What's emulated](#whats-emulated) for the details.
15
+ paddles and a 1351 mouse. It also runs the VIC-20, PAL or NTSC, as
16
+ `badline vic20`, the C128, in C128 mode on 40 or 80 columns and in C64 mode, as `badline c128`, the Plus/4, the C16 and the C116, as `badline plus4`, the PET and CBM, as `badline pet`, the CBM-II, the B series and the P500, as `badline cbm2`, and the MOS KIM-1, as `badline kim1`. See [What's emulated](#whats-emulated) for the details.
17
17
 
18
18
  It comes in two builds of the same emulator:
19
19
 
@@ -33,8 +33,10 @@ The native `badline`, with Homebrew:
33
33
  brew install elektronaut/tap/badline
34
34
  ```
35
35
 
36
- The formula builds it from the release's generated C, so it needs no
37
- Spinel or Ruby. To build it from a checkout instead, see
36
+ It installs a prebuilt bottle on macOS 15 or newer on Apple Silicon and
37
+ on x86_64 Linux. Elsewhere the formula builds it from the release's
38
+ generated C, so it needs no Spinel or Ruby. To build it from a checkout
39
+ instead, see
38
40
  [native/README.md](native/README.md).
39
41
 
40
42
  The gem needs Ruby 4.0 or newer and the SDL2 library:
@@ -71,8 +73,8 @@ The first argument can name the machine, as in `badline c64 game.prg`.
71
73
  The C64 is the default, and `--model` picks which C64. See
72
74
  [The VIC-20](#the-vic-20) for `badline vic20`, [The C128](#the-c128)
73
75
  for `badline c128`, [The Plus/4](#the-plus4) for `badline plus4`,
74
- [The PET](#the-pet) for `badline pet` and [The CBM-II](#the-cbm-ii) for
75
- `badline cbm2`.
76
+ [The PET](#the-pet) for `badline pet`, [The CBM-II](#the-cbm-ii) for
77
+ `badline cbm2` and [The KIM-1](#the-kim-1) for `badline kim1`.
76
78
 
77
79
  `badline-ruby` takes the same media and the same options, with the
78
80
  differences noted in the table. `--help` lists the options for either.
@@ -83,11 +85,11 @@ differences noted in the table. `--help` lists the options for either.
83
85
  | --- | --- |
84
86
  | `--no-autostart` | Attach the media and stop at `READY.`, so you can type the `LOAD` yourself |
85
87
  | `--writable` | Let the machine write to disk images. Without it, a disk goes in write-protected: the drive reports `26,WRITE PROTECT ON` for any write and the image file stays as it was |
86
- | `--true-drive` | Put an emulated 1541 on device 8 instead of the KERNAL traps, a 1551 on the Plus/4, or a 2031 on the PET or the CBM-II, or for a `.d80` or `.d82` an 8050 or 8250. See [Media](#media) |
87
- | `--drive-type 1541` | On the Plus/4, make the true drive on device 8 an emulated 1541 on the serial bus in place of the 1551. It implies `--true-drive`. See [The Plus/4](#the-plus4) |
88
+ | `--true-drive` | Put an emulated 1541 on device 8 instead of the KERNAL traps, a 1551 on the Plus/4, or a 2031 on the PET or the CBM-II, or for a `.d80` or `.d82` an 8050 or 8250. A `.d90` always goes in a D9060 or D9090. See [Media](#media) |
89
+ | `--drive-type MODEL` | On the Plus/4, `1541` makes the true drive on device 8 an emulated 1541 on the serial bus in place of the 1551. On the PET and the CBM-II, `2031` (the default), `8050`, `8250`, `1001` (an SFD-1001, which reads `.d82` images), `4040` or `3040` (two drives reading `.d64` images, with DOS 2.1), `2040` (DOS 1.2's `.d67` images), `9060` or `9090` names the drive `--true-drive` puts on the IEEE-488 bus. It implies `--true-drive`. See [The Plus/4](#the-plus4) and [The PET](#the-pet) |
88
90
  | `-s`, `--subtune N` | Pick a subtune of a `.sid` file, counting from 1 |
89
91
  | `--sid 6581`, `--sid 8580` | Fit the older or newer SID. `--sid auto`, the default, takes a `.sid` tune's own |
90
- | `--ram SIZE` | Give a VIC-20 the RAM expansion `SIZE`: `unexpanded`, `3k`, `8k`, `16k`, `24k`, `32k` or `all`. Without it, the VIC-20 gets the expansion its media needs. See [The VIC-20](#the-vic-20). On the Plus/4, `16k`, `32k` or `64k` of RAM in place of the model's own, and on the PET `4k`, `8k`, `16k` or `32k` |
92
+ | `--ram SIZE` | Give a VIC-20 the RAM expansion `SIZE`: `unexpanded`, `3k`, `8k`, `16k`, `24k`, `32k` or `all`. Without it, the VIC-20 gets the expansion its media needs. See [The VIC-20](#the-vic-20). On the Plus/4, `16k`, `32k` or `64k` of RAM in place of the model's own, on the PET `4k`, `8k`, `16k` or `32k`, and on the KIM-1 `1k` (the default), `5k` or `expanded`. See [The KIM-1](#the-kim-1) |
91
93
  | `--60hz` | Run a CRTC PET's 60 Hz editor in place of its 50 Hz one, or a CBM-II on 60 Hz mains. See [The PET](#the-pet) and [The CBM-II](#the-cbm-ii) |
92
94
  | `--kernal 04a`, `--kernal 03b` | Fit a B series CBM-II with KERNAL 901244-04a (the default) or 901244-03b. The P500 takes its own, `02`. See [The CBM-II](#the-cbm-ii) |
93
95
  | `--basic VERSION`, `--editor NAME` | Fit a PET with an upgrade ROM its board takes: BASIC `1`, `2` or `4`, or an editor. See [The PET](#the-pet) |
@@ -96,8 +98,13 @@ differences noted in the table. `--help` lists the options for either.
96
98
  | `--sid-card-address fd40`, `--sid-card-address fe80` | Put the SID card at `$FD40` (the default) or at `$FE80` |
97
99
  | `--ram-expansion NAME` | Fit a Plus/4 or C16 with a RAM expansion: `hannes256`, `hannes1m` or `csory256`. See [The Plus/4](#the-plus4) |
98
100
  | `--reu SIZE` | Plug in a RAM Expansion Unit of `SIZE` K: 128, 256, 512 (a 1750) or up to 16384 |
99
- | `--model NAME` | Run another model of the machine, named as in VICE. For the C64: `c64` (the default, a PAL C64 with the 6569 VIC-II, 6526 CIAs and the 6581 SID), `c64c` (the PAL C64C, with the 8565, 6526As and the 8580), `ntsc` (the 6567R8), `newntsc` (the NTSC C64C, with the 8562, 6526As and the 8580), `oldntsc` (the first NTSC C64s' 6567R56A), `drean` (the Drean C64 of Argentina, PAL-N with the 6572), `sx64` (the portable SX-64, with its own KERNAL and no datasette), `pet64` (the PET 64 or Educator 64, a PAL C64 in a PET's case with its own KERNAL and a green monochrome monitor) `c64gs` (the C64GS games console, a PAL C64C with its own BASIC and KERNAL, and no keyboard or datasette) or `ultimax` (the MAX Machine of Japan, NTSC with 2K of RAM, one CIA and no ROMs, which runs only a cartridge). `--sid` or a `.sid` tune's own SID takes the model's place. The VIC-20, the C128, the Plus/4, the PET and the CBM-II have models of their own: see their sections |
100
- | `--ntsc` | Run an NTSC C64, as `--model ntsc` does |
101
+ | `--model NAME` | Run another model of the machine, named as in VICE. For the C64: `c64` (the default, a PAL C64 with the 6569 VIC-II, 6526 CIAs and the 6581 SID), `c64c` (the PAL C64C, with the 8565, 6526As and the 8580), `ntsc` (the 6567R8), `newntsc` (the NTSC C64C, with the 8562, 6526As and the 8580), `oldntsc` (the first NTSC C64s' 6567R56A), `drean` (the Drean C64 of Argentina, PAL-N with the 6572), `sx64` (the portable SX-64, with its own KERNAL and no datasette), `pet64` (the PET 64 or Educator 64, a PAL C64 in a PET's case with its own KERNAL and a green monochrome monitor) `c64gs` (the C64GS games console, a PAL C64C with its own BASIC and KERNAL, and no keyboard, datasette or disk drive) or `ultimax` (the MAX Machine of Japan, NTSC with 2K of RAM, one CIA, no ROMs and no disk drive, which runs only a cartridge). `--sid` or a `.sid` tune's own SID takes the model's place. The VIC-20, the C128, the Plus/4, the PET and the CBM-II have models of their own: see their sections |
102
+ | `--ntsc` | Run an NTSC C64 or VIC-20, as `--model ntsc` does |
103
+ | `--tty` | Fit the KIM-1's TTY/KB jumper, so its monitor talks to a teletype: a page in the window, or the terminal with `--headless`. See [The KIM-1](#the-kim-1) |
104
+ | `--baud N` | Run the KIM-1's teletype at `110`, `300`, `1200`, `2400`, `4800` or `9600` baud (the default) |
105
+ | `--tty-load` | Load the KIM-1's `.ptp` or `.pap` through its monitor's `L` command on the teletype, in real time, instead of straight into RAM. It implies `--tty` |
106
+ | `--load-address ADDR` | Where the KIM-1 loads a `.bin`, in hex: `0200` (the default), `$0200` or `0x0200` |
107
+ | `--start-address ADDR` | Where the KIM-1 starts its program, in hex, when that isn't where it loads |
101
108
  | `--c64` | Start a C128 in C64 mode, holding `C=` at power-on. See [The C128](#the-c128) |
102
109
  | `--no-sound` | Don't play the SID (`badline` only, where sound is on by default) |
103
110
  | `--sound` | Play the SID (`badline-ruby`, where sound is off by default) |
@@ -117,7 +124,7 @@ differences noted in the table. `--help` lists the options for either.
117
124
  | `--script FILE` | Run the events in `FILE`, one `FRAME:EVENT` a line |
118
125
  | `--screenshot FILE` | Save the last frame as a `.bmp` |
119
126
  | `--save-snapshot FILE` | Save the machine as a `.vsf` snapshot after the last frame |
120
- | `--vice` | Add VICE's modules to `--save-snapshot`'s C64, PET or CBM-II snapshot, so x64sc, xpet, xcbm2 or xcbm5x0 opens it too |
127
+ | `--vice` | Add VICE's modules to `--save-snapshot`'s C64, VIC-20, PET or CBM-II snapshot, so x64sc, xvic, xpet, xcbm2 or xcbm5x0 opens it too |
121
128
 
122
129
  ```sh
123
130
  badline --unpaced --frames 12000 --true-drive disk1.d64 \
@@ -138,6 +145,8 @@ library, are covered in [doc/library.md](doc/library.md).
138
145
  | `.prg`, `.p00` | Loaded into memory after boot. A program at the BASIC start (`$0801`) is `RUN`, anything else is left for you to `SYS` |
139
146
  | `.d64`, `.d71`, `.d81` | Mounted as device 8, then `LOAD"*",8,1` and `RUN`. On a C128 in C128 mode a boot disk goes in a true drive instead and boots at power-on. See [Media](doc/media.md#c128-boot-disks). Write-protected unless `--writable` |
140
147
  | `.g64` | Put in a true 1541, then `LOAD"*",8,1` and `RUN`. It holds the disk's raw GCR, so copy protection that reads it works. Write-protected unless `--writable` |
148
+ | `.d80`, `.d82`, `.d67` | A PET's or a CBM-II's disk: an 8050's, an 8250's or SFD-1001's, or a 2040's with DOS 1. It starts a PET, and is mounted as device 8 or put in the true drive that reads it. See [The PET](#the-pet) |
149
+ | `.d90` | A D9060's or D9090's hard disk. It starts a PET, and always goes in the true drive, the D9060 or the D9090 by its size. See [The PET](#the-pet) |
141
150
  | `.m3u`, `.vfl` | A list of disk images, one path a line, relative to the list: an `.m3u` playlist, or a VICE flip list, which only unit 8's entries are taken from. Its first disk goes in as above, and the list is its set for the pause menu |
142
151
  | `.t64` | Mounted read-only as device 8 and loaded like a disk image. The files load by name, and no tape is involved |
143
152
  | `.tap` | Inserted in the datasette with PLAY pressed, then `LOAD` and `RUN`. It loads at the speed of a real tape |
@@ -158,11 +167,14 @@ from Ruby.
158
167
 
159
168
  ## The VIC-20
160
169
 
161
- `badline vic20` runs a PAL VIC-20, and takes the same media as the C64
162
- apart from SID tunes:
170
+ `badline vic20` runs a PAL VIC-20, with the 6561 VIC-I, and
171
+ `badline vic20 --ntsc` (or `--model ntsc`) an NTSC one, with the 6560 and
172
+ the NTSC KERNAL, at 1,022,727 Hz and 60 frames a second. Either takes the
173
+ same media as the C64 apart from SID tunes:
163
174
 
164
175
  ```sh
165
176
  badline vic20 # READY.
177
+ badline vic20 --ntsc # READY., on an NTSC VIC-20
166
178
  badline vic20 game.prg # Load and run a program
167
179
  badline vic20 game.d64 # Mount a disk image as device 8 and load it
168
180
  badline vic20 game.tap # Insert a tape and load it
@@ -175,8 +187,8 @@ its start of BASIC comes with, and more of BLK1 to BLK3 when it runs
175
187
  past `$3FFF`. A program that loads at `$A000` is a cartridge's ROM, and
176
188
  goes in as a `.crt` does. Disks go through the KERNAL traps or, with
177
189
  `--true-drive`, a 1541, as on the C64. `F11`, `F12` and the pause menu
178
- save and load the VIC-20 too, in badline's own snapshots: xvic's `.vsf`
179
- files don't load.
190
+ save and load the VIC-20 too, and xvic's `.vsf` files load, as
191
+ [doc/snapshots.md](doc/snapshots.md#xvic) describes.
180
192
 
181
193
  ## The C128
182
194
 
@@ -307,7 +319,8 @@ the business keyboard), `8096` (an 8032 with the 64K board at `$FFF0`),
307
319
  `8296` (128K on one board, below), `4032` (40 columns on a CRTC and the
308
320
  graphics keyboard), `3032` (the
309
321
  discrete 40-column board with BASIC 2), `3032b` (the same with the
310
- business keyboard) and `2001` (8K, BASIC 1 and the chiclet keyboard).
322
+ business keyboard), `2001` (8K, BASIC 1 and the chiclet keyboard) and
323
+ `superpet` (an 8032 with the Waterloo board, below).
311
324
  `--ram 4k`, `8k` or `16k` fits less RAM in place of the model's own, as
312
325
  the 3008, 3016 and 4016 had.
313
326
 
@@ -341,6 +354,44 @@ runs its own 50 Hz editor, `4-80-b-50hz-8296`, with lines of 59 cycles,
341
354
  fits the German boards' 4K character ROM, whose two halves R12's bit 5
342
355
  picks between.
343
356
 
357
+ The SuperPET, the SP9000 or MMF 9000, is an 8032 with the University of
358
+ Waterloo's board: 64K of RAM in 16 banks of 4K, one at a time at `$9000`
359
+ through the bank latch at `$EFFC`, the system latch at `$EFF8`, a 6551
360
+ ACIA at `$EFF0` with nothing on its RS-232 port, the 6702 protection
361
+ chip at `$EFE0`, and the 901640-01 character ROM, whose first half is the
362
+ 8032's and whose second half holds an ASCII and an APL set. It starts in
363
+ 6502 mode, as an 8032 with the board, and `--cpu 6809` sets its CPU switch
364
+ to the 6809, which runs the Waterloo ROMs to their microSystems menu. The
365
+ menu loads its languages from disk: a language disk given with `--cpu
366
+ 6809` goes in device 8, which answers the Waterloo ROM's IEEE-488
367
+ routines through traps as it answers the KERNAL's, so typing `basic` at
368
+ the menu loads microBASIC in about 20 seconds of the machine's time. The
369
+ menu loads from drive 1 of a dual drive, and the traps' one disk answers
370
+ as drive 1 too. With `--true-drive` the disk goes in a true drive
371
+ instead: a `.d80` or `.d82` in drive 1 of an 8050 or 8250, where typing
372
+ `basic` loads microBASIC in about twice the time, and a `.d64` in a
373
+ 2031's only drive, where `disk/0.BASIC` does. In 6502 mode a disk goes in
374
+ drive 0, as on the 8032. The original language
375
+ disks' copy protection finds its 6702, so they run unpatched. `--cpu
376
+ prog` leaves the CPU to bit 0 of the system latch, and `--bank-ram read`
377
+ write-protects the 64K bank RAM, or `prog` leaves it to bit 1, R/W by
378
+ default. The pause menu's power page has both switches: moving the CPU
379
+ switch resets the machine onto the CPU it picks, and the RAM switch
380
+ takes effect at once. While a Waterloo language shows its APL
381
+ characters, as microAPL does, the keys go by position: each presses the
382
+ SuperPET key that types its unshifted character, with the host's SHIFT,
383
+ so it types the APL symbol on that keycap. The menu's KEYBOARD page
384
+ says which set is up. It takes the 8032's editors and `--60hz`,
385
+ which picks the Waterloo ROM with the 60 Hz CRTC table, and no `--ram`.
386
+ Its snapshots save and load in both modes, and xpet's `-model SuperPET`
387
+ opens those saved with `--vice`.
388
+
389
+ ```sh
390
+ badline pet --model superpet --cpu 6809 # The SuperPET's Waterloo menu
391
+ badline pet --model superpet --cpu 6809 sp9000lang.d80 # The same with the language disk
392
+ badline pet --model superpet --bank-ram read # The bank RAM write-protected
393
+ ```
394
+
344
395
  ```sh
345
396
  badline pet --model 8296 --jumpers ram9,rama # An 8296 with RAM at $9000 and $A000
346
397
  badline pet --model 2001 --basic 2 # A 2001 with BASIC 2
@@ -356,11 +407,26 @@ goes into memory as a program file does. `--basic 2`, the upgrade
356
407
  Commodore sold, loads from disk.
357
408
 
358
409
  A program loads at the start of BASIC, `$0401`, and runs. A `.d80`, a
359
- `.d82` or a tape made for the PET starts a PET without `pet`, but a
410
+ `.d82`, a `.d67`, a `.d90` or a tape made for the PET starts a PET
411
+ without `pet`, but a
360
412
  program that loads at `$0401` starts a C64, since a VIC-20 with 3K loads
361
413
  there too. Disks go through the KERNAL traps on the IEEE-488 bus as
362
414
  device 8, or with `--true-drive` an emulated 2031 on the bus, which
363
- reads `.d64` and `.g64` images, and tapes play on cassette port 1. The keys type what the host's
415
+ reads `.d64` and `.g64` images, and an 8050 for a `.d80` or an 8250 for
416
+ a `.d82`. `--drive-type 8050` or `8250` plugs either in from the start,
417
+ and `--drive-type 1001` an SFD-1001, the single drive that takes the
418
+ 8250's disks, for a `.d82`. `--drive-type 4040` or `3040` puts a `.d64`
419
+ in a 4040 or a 3040 with DOS 2.1 in place of the 2031. A `.d67`, a DOS 1
420
+ disk, goes in a 2040 running DOS 1.2, the only DOS 1 there is an image
421
+ of, which takes `I0` before it reads a disk and `0:` before a file name,
422
+ and works from BASIC 2. The traps mount a `.d67` as they do the others.
423
+ A `.d90` hard disk image always goes in an emulated D9060 or D9090, by
424
+ its size, since the traps don't read one; `--drive-type 9060` or `9090`
425
+ picks the drive whatever the image's size. Its `N` skips the test
426
+ patterns the DOS writes over the whole disk, an hour on the hardware.
427
+ The pause menu's Drive 8 page lists the drive types under DRIVE TYPE,
428
+ and the one picked goes on the bus as device 8, with the disk device 8
429
+ had if it reads it. Tapes play on cassette port 1. The keys type what the host's
364
430
  keys type, on either keyboard, and `Alt` adds the PET's `SHIFT`:
365
431
  [Input](#input) lists the rest. The pause
366
432
  menu's Power page names the model, its RAM and its frame rate, and its
@@ -396,7 +462,8 @@ A program loads at the start of BASIC, `$0003` in segment 1, and runs.
396
462
  Disks of every kind, `.d80` and `.d82` among them, go through the
397
463
  KERNAL traps on the IEEE-488 bus as device 8, or with `--true-drive` an
398
464
  emulated 2031 on the bus, which reads `.d64` and `.g64` images, and an
399
- 8050 for a `.d80` or an 8250 for a `.d82`. A 610's first `LOAD` from a
465
+ 8050 for a `.d80` or an 8250 for a `.d82`, and `--drive-type` names the
466
+ drive to start with, as on the PET. A 610's first `LOAD` from a
400
467
  2031 after power-on finds no file, as on xcbm2, and the second loads.
401
468
  A `.d80` or `.d82` on its own starts a PET, so `cbm2` names the machine
402
469
  for one, but a cartridge made for the CBM-II starts it without `cbm2`.
@@ -420,6 +487,81 @@ controllers drive them. The pause menu's Ports page plugs a 1351 mouse
420
487
  or a pair of paddles into either port, as on the C64, and while the
421
488
  keys type, says where its keys are.
422
489
 
490
+ ## The KIM-1
491
+
492
+ `badline kim1` runs a MOS KIM-1, the single-board computer of 1976,
493
+ with its 1K of RAM and the monitor in its 6530-002. The window shows its
494
+ six LED digits and its keypad, and the monitor starts on address 0000:
495
+
496
+ ```sh
497
+ badline kim1 # The monitor, on the keypad and display
498
+ badline kim1 --tty # The monitor on a teletype, in the window
499
+ badline kim1 --headless # The monitor on a teletype, in the terminal
500
+ badline game.ptp # Load a papertape and run it
501
+ badline kim1 --ram 5k game.bin # Load a .bin at $0200 on a board with 5K
502
+ ```
503
+
504
+ | Host key | KIM-1 key |
505
+ |----------|-----------|
506
+ | `0`-`9`, `A`-`F`, the keypad's digits | The hex keys |
507
+ | `,` | AD, address mode |
508
+ | `.` | DA, data mode |
509
+ | `Space`, `+`, the keypad's `+` | +, the next address |
510
+ | `G`, `Return`, `Enter` | GO |
511
+ | `P` | PC |
512
+ | `S`, `Esc` | ST, which stops a program |
513
+ | `R` | RS, reset |
514
+ | `T` | The SST switch, which steps a program an instruction at a time |
515
+
516
+ A click on a key the window draws presses it too. Each digit is lit
517
+ only while a program scans it, as on the board, so the monitor's
518
+ display is steady, a program that scans more slowly shows dimmer, and
519
+ one that doesn't scan leaves it dark. ST and SST work once the NMI
520
+ vector at `$17FA` holds `$1C00`, as the User Manual's section 4.1 sets
521
+ it up. The sound is U2's PB7, the tape output music programs toggle.
522
+ The pause menu's Panel page sets SST and the TTY/KB jumper, wires U3's
523
+ PB7, its timer's interrupt, to IRQ, and plays a speaker on U3's PA0 in
524
+ place of PB7.
525
+
526
+ With `--tty`, or the jumper on the Panel page, the monitor talks to a
527
+ teletype on its 20 mA loop instead, as the User Manual's section 2.6
528
+ describes, at `--baud`'s rate, 9600 by default. The window shows the
529
+ teletype's page, the host keys type on it, `Backspace` sends RUBOUT and
530
+ `Down` LINE FEED, and the board echoes what's typed, as its hardware
531
+ does. `--headless` puts the teletype on the terminal, until `Ctrl-C`.
532
+ After a reset the teletype sends RUBOUT for the monitor to time, and
533
+ then each character once the monitor has had time to take the last.
534
+
535
+ The KIM-1 loads MOS papertapes, `.ptp` and `.pap` files as the
536
+ monitor's `Q` command punches them, which start a KIM-1 without
537
+ `kim1`, and `.bin` files of bare bytes, at `--load-address`. The
538
+ program goes straight into RAM once the monitor runs, the NMI and IRQ
539
+ vectors at `$17FA` and `$17FE` are set to `$1C00`, so ST and `BRK`
540
+ stop it in the monitor, and the monitor starts it as you would: `AD`,
541
+ the address and `GO` on the keypad, or the address, a space and `G` on
542
+ the teletype. It starts where it loads unless `--start-address` says
543
+ otherwise, and with `--no-autostart` the monitor stops at that address.
544
+ `--tty-load` feeds a papertape through the monitor's `L` command
545
+ instead, as a teletype's tape reader would. A program that loads over
546
+ the monitor's own bytes at `$00EF`-`$00FF`, `$01F8`-`$01FF` or
547
+ `$17E7`-`$17FF` can't load that way on the board either.
548
+
549
+ The stock board has 1K of RAM at `$0000`-`$03FF`. `--ram 5k` fills
550
+ `$0400`-`$13FF` with RAM, as a board on the expansion connector does,
551
+ and `--ram expanded` adds `$2000`-`$DFFF` too, with the first 8K
552
+ repeated at `$E000`-`$FFFF` for the vectors, as most software beyond
553
+ the First Book of KIM needs. The KIM-1 saves snapshots as the others
554
+ do, without VICE's modules.
555
+
556
+ The pause menu's Datasette page is the KIM-1's cassette deck. INSERT,
557
+ Quick open, a drop or `badline kim1 tape.wav` puts a `.wav` recording of a
558
+ KIM tape in it, 8-bit or 16-bit, without starting anything, and DECK presses
559
+ PLAY, RECORD or STOP. The monitor's LOADT, at `$1873`, reads the tape
560
+ while it plays, and DUMPT, at `$1800`, writes it while it records, as the
561
+ User Manual's appendix E describes. A recording goes over the tape from
562
+ where the deck is, and STOP writes it to its `.wav`. With no tape in,
563
+ RECORD puts a new one in the `tapes` folder in badline's data folder.
564
+
423
565
  ## Snapshots
424
566
 
425
567
  `F11` quicksaves the whole machine to the next of five slots in
@@ -577,9 +719,9 @@ too.
577
719
  |------|---------------|
578
720
  | Snapshots | Quicksave, save under a name, load a named save, and the latest quicksaves and autosaves |
579
721
  | Drive 8 | The disk: insert, eject, the previous or next disk of its set, and whether it's writable |
580
- | Datasette | The tape: insert, eject, PLAY and REWIND |
722
+ | Datasette | The tape: insert, eject, PLAY and REWIND. On the KIM-1, its deck's PLAY, RECORD and STOP too |
581
723
  | Expansion port | The cartridge's name: a `.crt`'s own, or a raw image's file name. Insert, remove, and its freeze button if it has one. On the VIC-20, the cartridge and the RAM expansion |
582
- | Ports | The device in each control port, and where the keys go. On the PET and the CBM-II's B series, Keyboard: where its keys are, and on the P500 also where its keys are while they type |
724
+ | Ports | The device in each control port, and where the keys go. On the PET and the CBM-II's B series, Keyboard: where its keys are, and on the P500 also where its keys are while they type. On the KIM-1, Panel: SST, the TTY/KB jumper and U3's wiring |
583
725
  | Sound | Mute, and the SID's model |
584
726
  | Power | Reset, power cycle and quit, on a C128 its model and mode, on a Plus/4 or a PET its model and RAM, and on a CBM-II its model, RAM, mains and KERNAL |
585
727
 
@@ -615,8 +757,10 @@ in cartridge 1 as it does from the command line.
615
757
  - **REU**: the 1700, 1764 and 1750 and bigger units up to 16M
616
758
  (`--reu`), with DMA timed against the VIC's bad lines and sprites.
617
759
  - **Datasette**: `.tap` playback.
618
- - **VIC-20**: the 6502, the PAL 6561 VIC-I with its picture and sound,
619
- both 6522 VIAs, the keyboard, the joystick and RESTORE, RAM
760
+ - **VIC-20**: the 6502, the PAL 6561 and NTSC 6560 VIC-I with its
761
+ picture, sound and light pen latch and the 6560's interlaced fields'
762
+ timing, both 6522
763
+ VIAs, the keyboard, the joystick and RESTORE, RAM
620
764
  expansions up to 35K (`--ram`), cartridges, the datasette and the
621
765
  serial bus to device 8 (`badline vic20`).
622
766
  - **C128**: C128 mode with BASIC 7.0 and C64 mode, on the 8502 with its
@@ -635,9 +779,12 @@ in cartridge 1 as it does from the command line.
635
779
  with BASIC 1, 2 or 4, the discrete video and the 6545 CRTC on 40 and 80
636
780
  columns, both 6520 PIAs and the 6522 VIA, the graphics and business
637
781
  keyboards, the sound on the VIA's CB2, the 8096's 64K board, the
638
- 8296's 128K with its jumpers, RA4 and 4K character ROM, both
782
+ 8296's 128K with its jumpers, RA4 and 4K character ROM, the
783
+ SuperPET's bank RAM, latches, ACIA, 6702 and 6809 with the Waterloo
784
+ languages loading from disk, both
639
785
  cassette ports and device 8 on the IEEE-488 bus through the KERNAL
640
- traps, `.d80` and `.d82` among its disks (`badline pet`).
786
+ traps, `.d80` and `.d82` among its disks, and the D9060 and D9090
787
+ hard disks on `.d90` images (`badline pet`).
641
788
  - **CBM-II**: the B series' 610, 620, 710 and 720, with the 6509 at
642
789
  2 MHz and its sixteen segments, 128K or 256K of RAM, BASIC 128 or 256
643
790
  with KERNAL 04a or 03b, the 6845 CRTC on 80 columns, the SID, the
@@ -650,6 +797,11 @@ in cartridge 1 as it does from the command line.
650
797
  paddles on either port, and device 8
651
798
  on the IEEE-488 bus through the KERNAL traps
652
799
  (`badline cbm2 --model 510`).
800
+ - **KIM-1**: the 6502 at 1 MHz, 1K, 5K or 53K of RAM, the two 6530 RRIOTs with
801
+ the monitor's and the tape routines' ROMs, the keypad and the six
802
+ multiplexed LED digits, the SST switch, ST and RS, PB7's sound, the
803
+ teletype on its 20 mA loop, papertape and `.bin` programs, and the
804
+ cassette as `.wav` (`badline kim1`).
653
805
  - **2031**: the PET's single drive, the 1541's board and DOS 2.6 on the
654
806
  IEEE-488 bus, with the bus's handshake on every line
655
807
  (`badline pet --true-drive`).
data/doc/library.md CHANGED
@@ -49,12 +49,16 @@ model (`Badline::Model::ALL`):
49
49
  - `kernal: :gs` fits the C64GS's BASIC and KERNAL, and `board: :gs` its
50
50
  case, which has no keyboard: `computer.keyboard` takes no keys. The
51
51
  C64GS has both, and no datasette.
52
+ - `board: :gs` and `board: :max` have no serial port, so
53
+ `Badline::Media.attach` and `Media.insert_disk` raise
54
+ `Badline::Machine::Unsupported` for a disk image, a `.t64` or a host
55
+ directory, and `Media::TrueDrive.plug` for a true drive.
52
56
  - `board: :max` builds the MAX Machine's board: 2K of RAM at
53
57
  `$0000-$07FF`, no ROMs mapped, CIA 1 alone, answering all through
54
58
  `$DC00-$DFFF` but for the I/O 1 page a cartridge takes, and Ultimax
55
59
  mode with or without a cartridge. CIA 2 is never on the bus, so the
56
60
  VIC stays in bank 0. `Badline::Model::ULTIMAX` runs it on
57
- `Badline::Region::NTSC_OLD`.
61
+ `Badline::Region::NTSC_OLD`, with a datasette at its cassette port.
58
62
 
59
63
  ## Cartridges
60
64
 
data/doc/media.md CHANGED
@@ -127,11 +127,12 @@ of half waves.
127
127
 
128
128
  A program SAVEd that way on the C64 loads and runs in VICE's x64sc, on
129
129
  the VIC-20 in xvic, and on the Plus/4 or the C16 in xplus4 as a Plus/4.
130
- Neither the Plus/4's tape nor the C16's ran on xplus4's C16 model.
130
+ xplus4's C16 model loads no tape, its own included (#704).
131
131
  Checked with VICE 3.10.
132
132
 
133
133
  ## The light pen
134
134
 
135
135
  Control port 1's fire line is also the VIC-II's light pen input, so
136
136
  joystick 1's fire button and the 1351's left button in port 1 latch the
137
- light pen registers.
137
+ light pen registers. On the VIC-20 the joystick's fire line is the
138
+ VIC-I's light pen input, and the fire button latches `$9006` and `$9007`.
@@ -37,6 +37,7 @@ only catches the rows that happen to move.
37
37
  - [RAM power-on pattern](#ram-power-on-pattern)
38
38
  - [VIC-20 RAM power-on pattern](#vic-20-ram-power-on-pattern)
39
39
  - [VIC-I fetches and the V-bus](#vic-i-fetches-and-the-v-bus)
40
+ - [VIC-I light pen](#vic-i-light-pen)
40
41
  - [VIC-I sound](#vic-i-sound)
41
42
  - [TED beam and the 7501 port](#ted-beam-and-the-7501-port)
42
43
  - [TED sound](#ted-sound)
@@ -52,6 +53,10 @@ only catches the rows that happen to move.
52
53
  - [PET CRTC](#pet-crtc)
53
54
  - [CBM-II DRAM refresh](#cbm-ii-dram-refresh)
54
55
  - [6509 indirection segment](#6509-indirection-segment)
56
+ - [KIM-1 single step](#kim-1-single-step)
57
+ - [6809 dead cycles](#6809-dead-cycles)
58
+ - [6809 interrupts, SYNC, CWAI, HALT and reset](#6809-interrupts-sync-cwai-halt-and-reset)
59
+ - [6809 undocumented opcodes](#6809-undocumented-opcodes)
55
60
 
56
61
  ## CPU interrupt recognition
57
62
 
@@ -1420,11 +1425,24 @@ and each was knocked out: removing it fails the rows named.
1420
1425
  - Pinned by `VIC20/split-tests/timing`: all 1,024 bytes of its readings
1421
1426
  of `$9003`, `$9004`, `$9100` and `$9200` over 256 cycles match
1422
1427
  `dumps/dump6561e.prg`, a real 6561E. The later 6561-101's dump reads
1423
- `$20` in the idle cycles instead; badline follows the 6561E.
1428
+ `$20` in the idle cycles instead; badline follows the 6561E. On the
1429
+ 6560, `timing_ntsc` matches `dumps/dump6560-101.prg` byte for byte
1430
+ from `$17E0`, and `dumps/dump6560.prg`, from another NTSC machine,
1431
+ reads `$20` in the idle cycles as the 6561-101 does.
1424
1432
  - Spec guard:
1425
1433
  [`chips/vic_i_split_tests_timing_spec.rb`](../spec/badline/chips/vic_i_split_tests_timing_spec.rb)
1426
1434
  (`:slow`), and *the fetches* in
1427
1435
  [`chips/vic_i_video_spec.rb`](../spec/badline/chips/vic_i_video_spec.rb).
1436
+ - The 6560's raster count, which `$9003` bit 7 and `$9004` read, moves
1437
+ on to the next line 28 cycles into a line, and on the last line wraps
1438
+ to 0 at column 61 (`Chips::VICI::NTSC`), measured on xvic as a black
1439
+ box.
1440
+ - Pinned by `VIC20/split-tests/timing`'s `timing_ntsc`, whose `$9003`
1441
+ and `$9004` readings match `dumps/dump6560-101.prg`, and by
1442
+ `VIC20/vic_line0/raster-ntsc`, whose effect starts 33 cycles later
1443
+ for `$9004` at 0 than for 1, as its readme reports from a real
1444
+ machine, and in one field 33 later and in the other on time with
1445
+ interlace (`testbench-vic20-ntsc`).
1428
1446
  - A write to `$900F` or `$900E` takes hold from the second of the four
1429
1447
  pixels of the cycle it lands in, the reverse bit two pixels later, and
1430
1448
  a character's pixels come out in the two cycles after its pattern
@@ -1433,6 +1451,32 @@ and each was knocked out: removing it fails the rows named.
1433
1451
  - Spec guard: *a colour write* in
1434
1452
  [`chips/vic_i_video_spec.rb`](../spec/badline/chips/vic_i_video_spec.rb).
1435
1453
 
1454
+ ## VIC-I light pen
1455
+
1456
+ - A falling edge on the light pen line, VIA 1's PA5 on the VIC-20,
1457
+ latches `$9006` = 2h + 1, where h is the edge's column plus two,
1458
+ wrapping at the line's end, and `$9007` = the raster count of the next
1459
+ cycle, bits 8-1, the 6560's early count included
1460
+ (`Chips::VICI::LightPen`). The column is badline's, the VIC's at the
1461
+ cycle of the VIA write.
1462
+ - Around the cycle where the count turns to 0 (the 6561's frame start,
1463
+ the 6560's column 61 of its last line): an edge from 8 cycles before it
1464
+ to 1 after it latches as an edge in the cycle after it would, with
1465
+ `$9007` at 0, but an edge 2 cycles before it latches an even `$9006`,
1466
+ one less. Earlier, an edge latches nothing while the count read its
1467
+ last value of the frame in the cycle before the edge: 311 on the 6561,
1468
+ 261 on the 6560.
1469
+ - A second edge in a frame latches again. The test drives one edge a
1470
+ measurement, so no dump checks it.
1471
+ - Pinned by `VIC20/split-tests/lightpen`: `lightpen.prg`'s 1,024
1472
+ readings of `$9003`, `$9004`, `$9006` and `$9007` match
1473
+ `dumps/dump6561e.prg`, and `lightpen_ntsc.prg`'s match
1474
+ `dumps/dump6560.prg`, both from `$17E0` (`testbench-vic20` and
1475
+ `testbench-vic20-ntsc`). The even `$9006` shows in both dumps; the
1476
+ readme says the 6561E's was verified with 3 more dumps.
1477
+ - Spec guard:
1478
+ [`chips/vic_i_light_pen_spec.rb`](../spec/badline/chips/vic_i_light_pen_spec.rb).
1479
+
1436
1480
  ## VIC-I sound
1437
1481
 
1438
1482
  No testprog checks the VIC-I's sound, so these rules are pinned by xvic
@@ -2290,3 +2334,127 @@ testprogs named.
2290
2334
  through. A write to the tenths that released the latch fails it.
2291
2335
  - Spec guard: *makes STA (zp),Y's dummy read in the indirection
2292
2336
  segment* in [`cbm2/cpu_spec.rb`](../spec/badline/cbm2/cpu_spec.rb).
2337
+
2338
+ ## KIM-1 single step
2339
+
2340
+ - With the SST switch on, the board pulls NMI through each opcode fetch
2341
+ outside K7 ($1C00-$1FFF and its mirrors), and the CPU takes it at the
2342
+ end of the instruction that fetch starts, a 2-cycle one included: the
2343
+ board raises the NMI latch ahead of the fetch cycle's poll, so the
2344
+ sample the boundary commits, the one from the second-to-last cycle,
2345
+ holds it. The pull on the cycle that starts the interrupt sequence is
2346
+ taken up by the same NMI.
2347
+ - Pinned by the KIM-1 User Manual's figure 5.6, which single-steps the
2348
+ sample program of figure 5.4 from $0200: the display shows 0202 after
2349
+ the first GO, the 2-cycle LDA #$01, and 020F after TAX. With the
2350
+ latch raised a cycle later, after the fetch cycle has polled, NMI
2351
+ waits an instruction more and the first GO shows 0205.
2352
+ - The monitor's display scan, SCANDS ($1F1F) and the key scan AK
2353
+ ($1EFE) in its idle loop, repeats every 4,258 cycles, and lights the
2354
+ six digits 676, 687, 676, 687, 676 and 657 cycles each. That follows
2355
+ from the ROM and the 6502 core's cycle counts, which SingleStepTests
2356
+ checks, not from a test of the board.
2357
+ - Spec guards: *takes the NMI single-step pulls right after a 2-cycle
2358
+ instruction* in [`kim1/cpu_spec.rb`](../spec/badline/kim1/cpu_spec.rb),
2359
+ and *figure 5.6* and *scans the six digits every 4,258 cycles* in
2360
+ [`kim1_spec.rb`](../spec/badline/kim1_spec.rb).
2361
+
2362
+ ## 6809 dead cycles
2363
+
2364
+ 6809 dead cycles follow the MC6809E flowcharts, not MAME. The
2365
+ neetandev/m6809 vectors (`rake test`) are MAME's, and on these dead
2366
+ ("Don't Care") cycles they read another address than Figure 17 of the
2367
+ MC6809E datasheet gives. The core reads the datasheet's address, and the
2368
+ runner checks each of these cycles against it, through the rules in
2369
+ [`m6809_divergences.rb`](../test/support/m6809_divergences.rb). Every
2370
+ other cycle, and every cycle count but X18's, is the vectors'.
2371
+
2372
+ - A read-modify-write (NEG, COM, LSR, ROR, ASR, ASL, ROL, DEC, INC, CLR
2373
+ and the undocumented aliases, in memory) reads `$FFFF` between its read
2374
+ and its write, where the vectors read PC. Pinned by MC6809E Fig. 17
2375
+ sheet 5 and the datasheet's DEC extended example.
2376
+ - ADDD, SUBD, CMPD, CMPX, CMPY, CMPU, CMPS and the undocumented XADDD and
2377
+ XADDU end on a dead read of `$FFFF`, where the vectors read PC. Pinned
2378
+ by MC6809E Fig. 17 sheet 5.
2379
+ - JSR's first dead cycle after its address reads the subroutine's
2380
+ address, where the vectors read PC. BSR and LBSR read it on the dead
2381
+ cycle before their last `$FFFF`, where the vectors read `$FFFF`. Pinned
2382
+ by MC6809E Fig. 17 sheets 1 and 5 and the datasheet's LBSR example.
2383
+ - RTS ends on a dead read of `$FFFF`, where the vectors read the stack.
2384
+ Pinned by MC6809E Fig. 17 sheet 2.
2385
+ - TSTA and TSTB read NNNN+1 after the opcode, as every one-byte inherent
2386
+ opcode does, where the vectors read `$FFFF`. Pinned by MC6809E Fig. 17
2387
+ sheet 2.
2388
+ - Indexed: an 8-bit offset from R is followed by a dead read of `$FFFF`,
2389
+ where the vectors read PC. A 16-bit offset from R or PC, a D offset and
2390
+ extended indirect read NNNN+4 (NNNN+5 after a prefix) on the cycle
2391
+ after the offset, where the vectors read `$FFFF`. Pinned by MC6809E
2392
+ Fig. 17 sheet 4.
2393
+ - Spec guard: *dead cycles* in
2394
+ [`m6809_spec.rb`](../spec/badline/chips/m6809_spec.rb).
2395
+
2396
+ ## 6809 interrupts, SYNC, CWAI, HALT and reset
2397
+
2398
+ The vectors leave these out. The core follows the MC6809E datasheet, and
2399
+ reyco2000's `6809_interrupt_test` and `6809_cycle_test`
2400
+ (`rake test`) pass on it.
2401
+
2402
+ - The lines are sampled once a cycle, and an instruction boundary sees the
2403
+ sample of two cycles before: IRQ or FIRQ asserted on an instruction's
2404
+ next-to-last cycle is taken once it ends, and on its last cycle only
2405
+ after the next instruction. NMI is an edge, latched until taken, and
2406
+ ignored until a program loads S after reset (LDS, LEAS, TFR or EXG
2407
+ into S, PULU S). Pinned by MC6809E Figs. 8 and 9.
2408
+ - IRQ and NMI take 19 cycles from the cycle that would have fetched the
2409
+ opcode: PC twice, `$FFFF`, the 12 bytes from PC low to CC with E set,
2410
+ `$FFFF`, the vector, `$FFFF`. FIRQ takes 10, stacking PC and CC with E
2411
+ clear. The masks take effect as the vector's first byte is read. Pinned
2412
+ by MC6809E Figs. 8 and 9.
2413
+ - SYNC reads NNNN+1 and then leaves the bus alone until any interrupt line
2414
+ is asserted, masked or not, and for one cycle more. A masked interrupt
2415
+ goes on to the next instruction; an unmasked one runs its usual
2416
+ sequence. Pinned by MC6809E Fig. 16 and Fig. 17 sheet 2.
2417
+ - CWAI reads its operand, NNNN+2 and `$FFFF`, ANDs CC with the operand,
2418
+ sets E, stacks all 12 bytes, then reads `$FFFF` until an interrupt it
2419
+ may take comes, and reads that interrupt's vector and `$FFFF`: 20
2420
+ cycles when the interrupt is already there. Pinned by MC6809E Fig. 17
2421
+ sheet 2.
2422
+ - HALT stops the CPU at the next instruction boundary, sampled as IRQ is,
2423
+ and leaves the bus alone until it is released.
2424
+ - After RESET the CPU reads `$FFFE` twice, the vector at `$FFFE` and
2425
+ `$FFFF`, and `$FFFF`, and fetches its first opcode on the sixth cycle.
2426
+ It masks FIRQ and IRQ and clears DP. Pinned by MC6809E Fig. 6.
2427
+ - Spec guard: [`m6809_spec.rb`](../spec/badline/chips/m6809_spec.rb).
2428
+
2429
+ ## 6809 undocumented opcodes
2430
+
2431
+ The undocumented opcodes follow David Banks' "Undocumented 6809
2432
+ Behaviours" (github.com/hoglet67/6809Decoder/wiki), which was checked on
2433
+ real chips, where it and the vectors (MAME's) disagree. The runner checks
2434
+ these cases against the rules in
2435
+ [`m6809_divergences.rb`](../test/support/m6809_divergences.rb).
2436
+
2437
+ - X18 (`$18`) takes 3 cycles, where the vectors take 2, and sets V to
2438
+ (C AND bit 0) OR (Z AND bit 2) of the byte after the opcode, where the
2439
+ vectors take Z alone. Banks doesn't give the third cycle's address; the
2440
+ core reads `$FFFF`. Pinned by Banks, X18.
2441
+ - XADDU adds the operand to U OR `$FF00`, where the vectors add U. Pinned
2442
+ by Banks, XADDU.
2443
+ - DAA sets V to C XOR bit 7 of the result, where the vectors (and the
2444
+ datasheet) clear it. Pinned by Banks, Undefined values of the Overflow
2445
+ Flag.
2446
+ - The stores immediate set N and clear Z and V when prefixed. Unprefixed,
2447
+ N, Z and V hang on the group of the instruction before (CMPA and BITA;
2448
+ LDA and LDD; the A arithmetic and logic; the A shifts, DEC, INC, NEG,
2449
+ COM, TSTA, DAA and SUBD; SEX; the 16-bit compares and XADDD/XADDU; LEA;
2450
+ anything else). The 16-bit ones also clear Z unless the register's low
2451
+ byte is 0. The vectors set N and Z from the register and clear V. The
2452
+ vectors start every case after no instruction, the "anything else"
2453
+ group: N set, Z and V clear. Pinned by Banks, Store Immediate and Flags
2454
+ for unprefixed Store Immediate.
2455
+ - What the vectors leave out also comes from Banks: `$14`, `$15` and `$CD`
2456
+ read on from PC, a byte a cycle, until reset; a chain of `$10` and `$11`
2457
+ prefixes takes the first, a cycle for each; an opcode page 2 or 3
2458
+ doesn't define runs as on page 1, a cycle later.
2459
+ - Spec guard: *the flags of the unprefixed stores immediate* in
2460
+ [`m6809_spec.rb`](../spec/badline/chips/m6809_spec.rb).