badline 0.17.0 → 0.18.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 (166) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +153 -0
  3. data/CLAUDE.md +11 -7
  4. data/CONTRIBUTING.md +7 -1
  5. data/README.md +169 -20
  6. data/doc/pinned-behaviour.md +128 -0
  7. data/doc/snapshot-format.md +253 -18
  8. data/doc/snapshots.md +57 -23
  9. data/exe/badline-ruby +5 -0
  10. data/lib/badline/audio/terminal.rb +34 -2
  11. data/lib/badline/c128/keyed_state.rb +2 -0
  12. data/lib/badline/c128.rb +1 -0
  13. data/lib/badline/c64/keyed_state.rb +2 -0
  14. data/lib/badline/c64.rb +1 -0
  15. data/lib/badline/cbm2/keyed_state.rb +4 -0
  16. data/lib/badline/cbm2/p500.rb +5 -3
  17. data/lib/badline/cbm2.rb +6 -3
  18. data/lib/badline/chips/cia/timer.rb +2 -2
  19. data/lib/badline/chips/cpu/instruction_set.rb +1 -1
  20. data/lib/badline/chips/m6809/arithmetic.rb +140 -0
  21. data/lib/badline/chips/m6809/bus_steps.rb +223 -0
  22. data/lib/badline/chips/m6809/core.rb +149 -0
  23. data/lib/badline/chips/m6809/indexed.rb +82 -0
  24. data/lib/badline/chips/m6809/interrupts.rb +159 -0
  25. data/lib/badline/chips/m6809/keyed_state.rb +147 -0
  26. data/lib/badline/chips/m6809/opcodes.rb +159 -0
  27. data/lib/badline/chips/m6809/operations.rb +258 -0
  28. data/lib/badline/chips/m6809/plans.rb +143 -0
  29. data/lib/badline/chips/m6809/registers.rb +82 -0
  30. data/lib/badline/chips/m6809/stack.rb +140 -0
  31. data/lib/badline/chips/m6809.rb +13 -0
  32. data/lib/badline/chips/riot/timer.rb +14 -3
  33. data/lib/badline/chips/rriot.rb +4 -2
  34. data/lib/badline/chips/sid/filter.rb +4 -4
  35. data/lib/badline/chips/sid/waveform.rb +6 -6
  36. data/lib/badline/chips/vic_i/keyed_parts.rb +7 -2
  37. data/lib/badline/chips/vic_i.rb +84 -21
  38. data/lib/badline/data_path.rb +3 -3
  39. data/lib/badline/drives/ieee_models.rb +54 -0
  40. data/lib/badline/drives/model1001.rb +37 -0
  41. data/lib/badline/drives/model2031.rb +6 -0
  42. data/lib/badline/drives/model4040/disk.rb +62 -0
  43. data/lib/badline/drives/model4040/ip_bus.rb +46 -0
  44. data/lib/badline/drives/model4040/keyed_state.rb +57 -0
  45. data/lib/badline/drives/model4040/mechanism.rb +192 -0
  46. data/lib/badline/drives/model4040/parts.rb +20 -0
  47. data/lib/badline/drives/model4040.rb +179 -0
  48. data/lib/badline/drives/model8050/board.rb +77 -0
  49. data/lib/badline/drives/model8050/dos_board.rb +91 -0
  50. data/lib/badline/drives/model8050/idle.rb +11 -7
  51. data/lib/badline/drives/model8050/keyed_state.rb +5 -2
  52. data/lib/badline/drives/model8050.rb +18 -130
  53. data/lib/badline/drives/model9060/idle.rb +149 -0
  54. data/lib/badline/drives/model9060/keyed_state.rb +123 -0
  55. data/lib/badline/drives/model9060/parts.rb +98 -0
  56. data/lib/badline/drives/model9060/sasi_bus.rb +88 -0
  57. data/lib/badline/drives/model9060/sasi_commands.rb +168 -0
  58. data/lib/badline/drives/model9060/sasi_target.rb +161 -0
  59. data/lib/badline/drives/model9060.rb +195 -0
  60. data/lib/badline/frontend/app.rb +8 -0
  61. data/lib/badline/frontend/boot.rb +3 -2
  62. data/lib/badline/frontend/controls.rb +62 -6
  63. data/lib/badline/frontend/keys.rb +36 -0
  64. data/lib/badline/frontend/kim1_panel.rb +208 -0
  65. data/lib/badline/frontend/media_slots.rb +8 -1
  66. data/lib/badline/frontend/menu/drive_types.rb +56 -0
  67. data/lib/badline/frontend/menu/menu_dialogs.rb +61 -14
  68. data/lib/badline/frontend/menu/menu_media.rb +42 -12
  69. data/lib/badline/frontend/menu/menu_pages.rb +97 -2
  70. data/lib/badline/frontend/menu/menu_ports.rb +38 -1
  71. data/lib/badline/frontend/menu/pause_menu.rb +5 -1
  72. data/lib/badline/frontend/pet_keyboard.rb +23 -1
  73. data/lib/badline/frontend/screen.rb +1 -1
  74. data/lib/badline/frontend/screens.rb +40 -2
  75. data/lib/badline/frontend/teletype_pane.rb +152 -0
  76. data/lib/badline/frontend/timeline.rb +31 -2
  77. data/lib/badline/frontend.rb +3 -0
  78. data/lib/badline/kim1/bus.rb +117 -0
  79. data/lib/badline/kim1/cpu.rb +25 -0
  80. data/lib/badline/kim1/host_terminal.rb +74 -0
  81. data/lib/badline/kim1/key_entry.rb +74 -0
  82. data/lib/badline/kim1/keyed_modules.rb +53 -0
  83. data/lib/badline/kim1/keyed_state.rb +133 -0
  84. data/lib/badline/kim1/panel.rb +176 -0
  85. data/lib/badline/kim1/rriots.rb +28 -0
  86. data/lib/badline/kim1/sound.rb +29 -0
  87. data/lib/badline/kim1/tape.rb +116 -0
  88. data/lib/badline/kim1/teletype.rb +193 -0
  89. data/lib/badline/kim1.rb +190 -0
  90. data/lib/badline/machine/ieee_drives.rb +94 -117
  91. data/lib/badline/machine/keyboard_buffer.rb +20 -3
  92. data/lib/badline/machine/line_sound.rb +122 -0
  93. data/lib/badline/machine.rb +46 -15
  94. data/lib/badline/media/extensions.rb +8 -4
  95. data/lib/badline/media/kim1_media.rb +150 -0
  96. data/lib/badline/media/pet_media.rb +3 -1
  97. data/lib/badline/media/true_drive.rb +42 -45
  98. data/lib/badline/media.rb +12 -6
  99. data/lib/badline/options/family.rb +98 -8
  100. data/lib/badline/options/help.rb +44 -12
  101. data/lib/badline/options/table.rb +43 -11
  102. data/lib/badline/options/validation.rb +44 -8
  103. data/lib/badline/options.rb +27 -8
  104. data/lib/badline/pet/bus.rb +16 -2
  105. data/lib/badline/pet/keyboard_ports.rb +9 -2
  106. data/lib/badline/pet/keyed_state.rb +4 -0
  107. data/lib/badline/pet/model.rb +11 -2
  108. data/lib/badline/pet/rom_sets.rb +1 -0
  109. data/lib/badline/pet/sound.rb +5 -105
  110. data/lib/badline/pet/superpet/acia.rb +12 -0
  111. data/lib/badline/pet/superpet/board.rb +221 -0
  112. data/lib/badline/pet/superpet/dongle.rb +81 -0
  113. data/lib/badline/pet/superpet/keyed_modules.rb +63 -0
  114. data/lib/badline/pet/superpet/keyed_parts.rb +76 -0
  115. data/lib/badline/pet/superpet/m6809.rb +32 -0
  116. data/lib/badline/pet/superpet/waterloo_traps.rb +199 -0
  117. data/lib/badline/pet/superpet.rb +216 -0
  118. data/lib/badline/pet.rb +19 -3
  119. data/lib/badline/plus4/keyed_state.rb +2 -0
  120. data/lib/badline/plus4.rb +1 -0
  121. data/lib/badline/roms/1001/fdc-251257-02a.rom +0 -0
  122. data/lib/badline/roms/4040/dos-1.2.rom +0 -0
  123. data/lib/badline/roms/4040/dos-2.1-rev.rom +0 -0
  124. data/lib/badline/roms/4040/dos-2.1.rom +0 -0
  125. data/lib/badline/roms/4040/fdc-901466-02.rom +0 -0
  126. data/lib/badline/roms/4040/fdc-901466-04.rom +0 -0
  127. data/lib/badline/roms/9060/dos-3.0.rom +0 -0
  128. data/lib/badline/roms/9060/sasi-300515-revb.rom +0 -0
  129. data/lib/badline/roms/README +166 -0
  130. data/lib/badline/roms/kim1/6530-002.rom +0 -0
  131. data/lib/badline/roms/kim1/6530-003.rom +0 -0
  132. data/lib/badline/roms/pet/characters-superpet.rom +0 -0
  133. data/lib/badline/roms/pet/superpet-a000.rom +0 -0
  134. data/lib/badline/roms/pet/superpet-c000.rom +0 -0
  135. data/lib/badline/roms/pet/superpet-e000-50hz.rom +0 -0
  136. data/lib/badline/roms/pet/superpet-e000.rom +0 -0
  137. data/lib/badline/snapshot/container.rb +2 -0
  138. data/lib/badline/snapshot/field_doc/markdown.rb +1 -1
  139. data/lib/badline/snapshot/field_doc.rb +27 -6
  140. data/lib/badline/snapshot/image.rb +4 -1
  141. data/lib/badline/snapshot/kim1_setup.rb +28 -0
  142. data/lib/badline/snapshot/pet_setup.rb +27 -11
  143. data/lib/badline/snapshot/storage_setup.rb +4 -1
  144. data/lib/badline/snapshot/vic20_setup.rb +11 -7
  145. data/lib/badline/snapshot/vice/pet.rb +13 -7
  146. data/lib/badline/snapshot/vice/pet_cpu.rb +39 -5
  147. data/lib/badline/snapshot/vice/pet_crtc.rb +15 -2
  148. data/lib/badline/snapshot/vice/pet_drive8050.rb +188 -68
  149. data/lib/badline/snapshot/vice/pet_mem.rb +49 -5
  150. data/lib/badline/snapshot/vice/pet_restore.rb +40 -11
  151. data/lib/badline/snapshot.rb +4 -0
  152. data/lib/badline/status.rb +30 -30
  153. data/lib/badline/storage/d67_image.rb +55 -0
  154. data/lib/badline/storage/d90_image.rb +180 -0
  155. data/lib/badline/storage/disk_image/writing.rb +2 -2
  156. data/lib/badline/storage/kim_tape.rb +254 -0
  157. data/lib/badline/storage/papertape.rb +90 -0
  158. data/lib/badline/storage.rb +4 -0
  159. data/lib/badline/support/kim1_checkpoint.rb +41 -0
  160. data/lib/badline/support/superpet_checkpoint.rb +35 -0
  161. data/lib/badline/version.rb +1 -1
  162. data/lib/badline/vic20/keyed_modules.rb +6 -3
  163. data/lib/badline/vic20/keyed_state.rb +6 -4
  164. data/lib/badline/vic20.rb +26 -12
  165. data/lib/badline.rb +1 -0
  166. metadata +77 -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
 
@@ -71,8 +71,8 @@ The first argument can name the machine, as in `badline c64 game.prg`.
71
71
  The C64 is the default, and `--model` picks which C64. See
72
72
  [The VIC-20](#the-vic-20) for `badline vic20`, [The C128](#the-c128)
73
73
  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`.
74
+ [The PET](#the-pet) for `badline pet`, [The CBM-II](#the-cbm-ii) for
75
+ `badline cbm2` and [The KIM-1](#the-kim-1) for `badline kim1`.
76
76
 
77
77
  `badline-ruby` takes the same media and the same options, with the
78
78
  differences noted in the table. `--help` lists the options for either.
@@ -83,11 +83,11 @@ differences noted in the table. `--help` lists the options for either.
83
83
  | --- | --- |
84
84
  | `--no-autostart` | Attach the media and stop at `READY.`, so you can type the `LOAD` yourself |
85
85
  | `--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) |
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. A `.d90` always goes in a D9060 or D9090. See [Media](#media) |
87
+ | `--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
88
  | `-s`, `--subtune N` | Pick a subtune of a `.sid` file, counting from 1 |
89
89
  | `--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` |
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, 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
91
  | `--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
92
  | `--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
93
  | `--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) |
@@ -97,7 +97,12 @@ differences noted in the table. `--help` lists the options for either.
97
97
  | `--ram-expansion NAME` | Fit a Plus/4 or C16 with a RAM expansion: `hannes256`, `hannes1m` or `csory256`. See [The Plus/4](#the-plus4) |
98
98
  | `--reu SIZE` | Plug in a RAM Expansion Unit of `SIZE` K: 128, 256, 512 (a 1750) or up to 16384 |
99
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 |
100
+ | `--ntsc` | Run an NTSC C64 or VIC-20, as `--model ntsc` does |
101
+ | `--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) |
102
+ | `--baud N` | Run the KIM-1's teletype at `110`, `300`, `1200`, `2400`, `4800` or `9600` baud (the default) |
103
+ | `--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` |
104
+ | `--load-address ADDR` | Where the KIM-1 loads a `.bin`, in hex: `0200` (the default), `$0200` or `0x0200` |
105
+ | `--start-address ADDR` | Where the KIM-1 starts its program, in hex, when that isn't where it loads |
101
106
  | `--c64` | Start a C128 in C64 mode, holding `C=` at power-on. See [The C128](#the-c128) |
102
107
  | `--no-sound` | Don't play the SID (`badline` only, where sound is on by default) |
103
108
  | `--sound` | Play the SID (`badline-ruby`, where sound is off by default) |
@@ -138,6 +143,8 @@ library, are covered in [doc/library.md](doc/library.md).
138
143
  | `.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
144
  | `.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
145
  | `.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` |
146
+ | `.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) |
147
+ | `.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
148
  | `.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
149
  | `.t64` | Mounted read-only as device 8 and loaded like a disk image. The files load by name, and no tape is involved |
143
150
  | `.tap` | Inserted in the datasette with PLAY pressed, then `LOAD` and `RUN`. It loads at the speed of a real tape |
@@ -158,11 +165,14 @@ from Ruby.
158
165
 
159
166
  ## The VIC-20
160
167
 
161
- `badline vic20` runs a PAL VIC-20, and takes the same media as the C64
162
- apart from SID tunes:
168
+ `badline vic20` runs a PAL VIC-20, with the 6561 VIC-I, and
169
+ `badline vic20 --ntsc` (or `--model ntsc`) an NTSC one, with the 6560 and
170
+ the NTSC KERNAL, at 1,022,727 Hz and 60 frames a second. Either takes the
171
+ same media as the C64 apart from SID tunes:
163
172
 
164
173
  ```sh
165
174
  badline vic20 # READY.
175
+ badline vic20 --ntsc # READY., on an NTSC VIC-20
166
176
  badline vic20 game.prg # Load and run a program
167
177
  badline vic20 game.d64 # Mount a disk image as device 8 and load it
168
178
  badline vic20 game.tap # Insert a tape and load it
@@ -307,7 +317,8 @@ the business keyboard), `8096` (an 8032 with the 64K board at `$FFF0`),
307
317
  `8296` (128K on one board, below), `4032` (40 columns on a CRTC and the
308
318
  graphics keyboard), `3032` (the
309
319
  discrete 40-column board with BASIC 2), `3032b` (the same with the
310
- business keyboard) and `2001` (8K, BASIC 1 and the chiclet keyboard).
320
+ business keyboard), `2001` (8K, BASIC 1 and the chiclet keyboard) and
321
+ `superpet` (an 8032 with the Waterloo board, below).
311
322
  `--ram 4k`, `8k` or `16k` fits less RAM in place of the model's own, as
312
323
  the 3008, 3016 and 4016 had.
313
324
 
@@ -341,6 +352,44 @@ runs its own 50 Hz editor, `4-80-b-50hz-8296`, with lines of 59 cycles,
341
352
  fits the German boards' 4K character ROM, whose two halves R12's bit 5
342
353
  picks between.
343
354
 
355
+ The SuperPET, the SP9000 or MMF 9000, is an 8032 with the University of
356
+ Waterloo's board: 64K of RAM in 16 banks of 4K, one at a time at `$9000`
357
+ through the bank latch at `$EFFC`, the system latch at `$EFF8`, a 6551
358
+ ACIA at `$EFF0` with nothing on its RS-232 port, the 6702 protection
359
+ chip at `$EFE0`, and the 901640-01 character ROM, whose first half is the
360
+ 8032's and whose second half holds an ASCII and an APL set. It starts in
361
+ 6502 mode, as an 8032 with the board, and `--cpu 6809` sets its CPU switch
362
+ to the 6809, which runs the Waterloo ROMs to their microSystems menu. The
363
+ menu loads its languages from disk: a language disk given with `--cpu
364
+ 6809` goes in device 8, which answers the Waterloo ROM's IEEE-488
365
+ routines through traps as it answers the KERNAL's, so typing `basic` at
366
+ the menu loads microBASIC in about 20 seconds of the machine's time. The
367
+ menu loads from drive 1 of a dual drive, and the traps' one disk answers
368
+ as drive 1 too. With `--true-drive` the disk goes in a true drive
369
+ instead: a `.d80` or `.d82` in drive 1 of an 8050 or 8250, where typing
370
+ `basic` loads microBASIC in about twice the time, and a `.d64` in a
371
+ 2031's only drive, where `disk/0.BASIC` does. In 6502 mode a disk goes in
372
+ drive 0, as on the 8032. The original language
373
+ disks' copy protection finds its 6702, so they run unpatched. `--cpu
374
+ prog` leaves the CPU to bit 0 of the system latch, and `--bank-ram read`
375
+ write-protects the 64K bank RAM, or `prog` leaves it to bit 1, R/W by
376
+ default. The pause menu's power page has both switches: moving the CPU
377
+ switch resets the machine onto the CPU it picks, and the RAM switch
378
+ takes effect at once. While a Waterloo language shows its APL
379
+ characters, as microAPL does, the keys go by position: each presses the
380
+ SuperPET key that types its unshifted character, with the host's SHIFT,
381
+ so it types the APL symbol on that keycap. The menu's KEYBOARD page
382
+ says which set is up. It takes the 8032's editors and `--60hz`,
383
+ which picks the Waterloo ROM with the 60 Hz CRTC table, and no `--ram`.
384
+ Its snapshots save and load in both modes, and xpet's `-model SuperPET`
385
+ opens those saved with `--vice`.
386
+
387
+ ```sh
388
+ badline pet --model superpet --cpu 6809 # The SuperPET's Waterloo menu
389
+ badline pet --model superpet --cpu 6809 sp9000lang.d80 # The same with the language disk
390
+ badline pet --model superpet --bank-ram read # The bank RAM write-protected
391
+ ```
392
+
344
393
  ```sh
345
394
  badline pet --model 8296 --jumpers ram9,rama # An 8296 with RAM at $9000 and $A000
346
395
  badline pet --model 2001 --basic 2 # A 2001 with BASIC 2
@@ -356,11 +405,26 @@ goes into memory as a program file does. `--basic 2`, the upgrade
356
405
  Commodore sold, loads from disk.
357
406
 
358
407
  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
408
+ `.d82`, a `.d67`, a `.d90` or a tape made for the PET starts a PET
409
+ without `pet`, but a
360
410
  program that loads at `$0401` starts a C64, since a VIC-20 with 3K loads
361
411
  there too. Disks go through the KERNAL traps on the IEEE-488 bus as
362
412
  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
413
+ reads `.d64` and `.g64` images, and an 8050 for a `.d80` or an 8250 for
414
+ a `.d82`. `--drive-type 8050` or `8250` plugs either in from the start,
415
+ and `--drive-type 1001` an SFD-1001, the single drive that takes the
416
+ 8250's disks, for a `.d82`. `--drive-type 4040` or `3040` puts a `.d64`
417
+ in a 4040 or a 3040 with DOS 2.1 in place of the 2031. A `.d67`, a DOS 1
418
+ disk, goes in a 2040 running DOS 1.2, the only DOS 1 there is an image
419
+ of, which takes `I0` before it reads a disk and `0:` before a file name,
420
+ and works from BASIC 2. The traps mount a `.d67` as they do the others.
421
+ A `.d90` hard disk image always goes in an emulated D9060 or D9090, by
422
+ its size, since the traps don't read one; `--drive-type 9060` or `9090`
423
+ picks the drive whatever the image's size. Its `N` skips the test
424
+ patterns the DOS writes over the whole disk, an hour on the hardware.
425
+ The pause menu's Drive 8 page lists the drive types under DRIVE TYPE,
426
+ and the one picked goes on the bus as device 8, with the disk device 8
427
+ had if it reads it. Tapes play on cassette port 1. The keys type what the host's
364
428
  keys type, on either keyboard, and `Alt` adds the PET's `SHIFT`:
365
429
  [Input](#input) lists the rest. The pause
366
430
  menu's Power page names the model, its RAM and its frame rate, and its
@@ -396,7 +460,8 @@ A program loads at the start of BASIC, `$0003` in segment 1, and runs.
396
460
  Disks of every kind, `.d80` and `.d82` among them, go through the
397
461
  KERNAL traps on the IEEE-488 bus as device 8, or with `--true-drive` an
398
462
  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
463
+ 8050 for a `.d80` or an 8250 for a `.d82`, and `--drive-type` names the
464
+ drive to start with, as on the PET. A 610's first `LOAD` from a
400
465
  2031 after power-on finds no file, as on xcbm2, and the second loads.
401
466
  A `.d80` or `.d82` on its own starts a PET, so `cbm2` names the machine
402
467
  for one, but a cartridge made for the CBM-II starts it without `cbm2`.
@@ -420,6 +485,81 @@ controllers drive them. The pause menu's Ports page plugs a 1351 mouse
420
485
  or a pair of paddles into either port, as on the C64, and while the
421
486
  keys type, says where its keys are.
422
487
 
488
+ ## The KIM-1
489
+
490
+ `badline kim1` runs a MOS KIM-1, the single-board computer of 1976,
491
+ with its 1K of RAM and the monitor in its 6530-002. The window shows its
492
+ six LED digits and its keypad, and the monitor starts on address 0000:
493
+
494
+ ```sh
495
+ badline kim1 # The monitor, on the keypad and display
496
+ badline kim1 --tty # The monitor on a teletype, in the window
497
+ badline kim1 --headless # The monitor on a teletype, in the terminal
498
+ badline game.ptp # Load a papertape and run it
499
+ badline kim1 --ram 5k game.bin # Load a .bin at $0200 on a board with 5K
500
+ ```
501
+
502
+ | Host key | KIM-1 key |
503
+ |----------|-----------|
504
+ | `0`-`9`, `A`-`F`, the keypad's digits | The hex keys |
505
+ | `,` | AD, address mode |
506
+ | `.` | DA, data mode |
507
+ | `Space`, `+`, the keypad's `+` | +, the next address |
508
+ | `G`, `Return`, `Enter` | GO |
509
+ | `P` | PC |
510
+ | `S`, `Esc` | ST, which stops a program |
511
+ | `R` | RS, reset |
512
+ | `T` | The SST switch, which steps a program an instruction at a time |
513
+
514
+ A click on a key the window draws presses it too. Each digit is lit
515
+ only while a program scans it, as on the board, so the monitor's
516
+ display is steady, a program that scans more slowly shows dimmer, and
517
+ one that doesn't scan leaves it dark. ST and SST work once the NMI
518
+ vector at `$17FA` holds `$1C00`, as the User Manual's section 4.1 sets
519
+ it up. The sound is U2's PB7, the tape output music programs toggle.
520
+ The pause menu's Panel page sets SST and the TTY/KB jumper, wires U3's
521
+ PB7, its timer's interrupt, to IRQ, and plays a speaker on U3's PA0 in
522
+ place of PB7.
523
+
524
+ With `--tty`, or the jumper on the Panel page, the monitor talks to a
525
+ teletype on its 20 mA loop instead, as the User Manual's section 2.6
526
+ describes, at `--baud`'s rate, 9600 by default. The window shows the
527
+ teletype's page, the host keys type on it, `Backspace` sends RUBOUT and
528
+ `Down` LINE FEED, and the board echoes what's typed, as its hardware
529
+ does. `--headless` puts the teletype on the terminal, until `Ctrl-C`.
530
+ After a reset the teletype sends RUBOUT for the monitor to time, and
531
+ then each character once the monitor has had time to take the last.
532
+
533
+ The KIM-1 loads MOS papertapes, `.ptp` and `.pap` files as the
534
+ monitor's `Q` command punches them, which start a KIM-1 without
535
+ `kim1`, and `.bin` files of bare bytes, at `--load-address`. The
536
+ program goes straight into RAM once the monitor runs, the NMI and IRQ
537
+ vectors at `$17FA` and `$17FE` are set to `$1C00`, so ST and `BRK`
538
+ stop it in the monitor, and the monitor starts it as you would: `AD`,
539
+ the address and `GO` on the keypad, or the address, a space and `G` on
540
+ the teletype. It starts where it loads unless `--start-address` says
541
+ otherwise, and with `--no-autostart` the monitor stops at that address.
542
+ `--tty-load` feeds a papertape through the monitor's `L` command
543
+ instead, as a teletype's tape reader would. A program that loads over
544
+ the monitor's own bytes at `$00EF`-`$00FF`, `$01F8`-`$01FF` or
545
+ `$17E7`-`$17FF` can't load that way on the board either.
546
+
547
+ The stock board has 1K of RAM at `$0000`-`$03FF`. `--ram 5k` fills
548
+ `$0400`-`$13FF` with RAM, as a board on the expansion connector does,
549
+ and `--ram expanded` adds `$2000`-`$DFFF` too, with the first 8K
550
+ repeated at `$E000`-`$FFFF` for the vectors, as most software beyond
551
+ the First Book of KIM needs. The KIM-1 saves snapshots as the others
552
+ do, without VICE's modules.
553
+
554
+ The pause menu's Datasette page is the KIM-1's cassette deck. INSERT,
555
+ Quick open, a drop or `badline kim1 tape.wav` puts a `.wav` recording of a
556
+ KIM tape in it, 8-bit or 16-bit, without starting anything, and DECK presses
557
+ PLAY, RECORD or STOP. The monitor's LOADT, at `$1873`, reads the tape
558
+ while it plays, and DUMPT, at `$1800`, writes it while it records, as the
559
+ User Manual's appendix E describes. A recording goes over the tape from
560
+ where the deck is, and STOP writes it to its `.wav`. With no tape in,
561
+ RECORD puts a new one in the `tapes` folder in badline's data folder.
562
+
423
563
  ## Snapshots
424
564
 
425
565
  `F11` quicksaves the whole machine to the next of five slots in
@@ -577,9 +717,9 @@ too.
577
717
  |------|---------------|
578
718
  | Snapshots | Quicksave, save under a name, load a named save, and the latest quicksaves and autosaves |
579
719
  | 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 |
720
+ | Datasette | The tape: insert, eject, PLAY and REWIND. On the KIM-1, its deck's PLAY, RECORD and STOP too |
581
721
  | 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 |
722
+ | 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
723
  | Sound | Mute, and the SID's model |
584
724
  | 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
725
 
@@ -615,8 +755,9 @@ in cartridge 1 as it does from the command line.
615
755
  - **REU**: the 1700, 1764 and 1750 and bigger units up to 16M
616
756
  (`--reu`), with DMA timed against the VIC's bad lines and sprites.
617
757
  - **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
758
+ - **VIC-20**: the 6502, the PAL 6561 and NTSC 6560 VIC-I with its
759
+ picture and sound and the 6560's interlaced fields' timing, both 6522
760
+ VIAs, the keyboard, the joystick and RESTORE, RAM
620
761
  expansions up to 35K (`--ram`), cartridges, the datasette and the
621
762
  serial bus to device 8 (`badline vic20`).
622
763
  - **C128**: C128 mode with BASIC 7.0 and C64 mode, on the 8502 with its
@@ -635,9 +776,12 @@ in cartridge 1 as it does from the command line.
635
776
  with BASIC 1, 2 or 4, the discrete video and the 6545 CRTC on 40 and 80
636
777
  columns, both 6520 PIAs and the 6522 VIA, the graphics and business
637
778
  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
779
+ 8296's 128K with its jumpers, RA4 and 4K character ROM, the
780
+ SuperPET's bank RAM, latches, ACIA, 6702 and 6809 with the Waterloo
781
+ languages loading from disk, both
639
782
  cassette ports and device 8 on the IEEE-488 bus through the KERNAL
640
- traps, `.d80` and `.d82` among its disks (`badline pet`).
783
+ traps, `.d80` and `.d82` among its disks, and the D9060 and D9090
784
+ hard disks on `.d90` images (`badline pet`).
641
785
  - **CBM-II**: the B series' 610, 620, 710 and 720, with the 6509 at
642
786
  2 MHz and its sixteen segments, 128K or 256K of RAM, BASIC 128 or 256
643
787
  with KERNAL 04a or 03b, the 6845 CRTC on 80 columns, the SID, the
@@ -650,6 +794,11 @@ in cartridge 1 as it does from the command line.
650
794
  paddles on either port, and device 8
651
795
  on the IEEE-488 bus through the KERNAL traps
652
796
  (`badline cbm2 --model 510`).
797
+ - **KIM-1**: the 6502 at 1 MHz, 1K, 5K or 53K of RAM, the two 6530 RRIOTs with
798
+ the monitor's and the tape routines' ROMs, the keypad and the six
799
+ multiplexed LED digits, the SST switch, ST and RS, PB7's sound, the
800
+ teletype on its 20 mA loop, papertape and `.bin` programs, and the
801
+ cassette as `.wav` (`badline kim1`).
653
802
  - **2031**: the PET's single drive, the 1541's board and DOS 2.6 on the
654
803
  IEEE-488 bus, with the bus's handshake on every line
655
804
  (`badline pet --true-drive`).
@@ -52,6 +52,10 @@ only catches the rows that happen to move.
52
52
  - [PET CRTC](#pet-crtc)
53
53
  - [CBM-II DRAM refresh](#cbm-ii-dram-refresh)
54
54
  - [6509 indirection segment](#6509-indirection-segment)
55
+ - [KIM-1 single step](#kim-1-single-step)
56
+ - [6809 dead cycles](#6809-dead-cycles)
57
+ - [6809 interrupts, SYNC, CWAI, HALT and reset](#6809-interrupts-sync-cwai-halt-and-reset)
58
+ - [6809 undocumented opcodes](#6809-undocumented-opcodes)
55
59
 
56
60
  ## CPU interrupt recognition
57
61
 
@@ -2290,3 +2294,127 @@ testprogs named.
2290
2294
  through. A write to the tenths that released the latch fails it.
2291
2295
  - Spec guard: *makes STA (zp),Y's dummy read in the indirection
2292
2296
  segment* in [`cbm2/cpu_spec.rb`](../spec/badline/cbm2/cpu_spec.rb).
2297
+
2298
+ ## KIM-1 single step
2299
+
2300
+ - With the SST switch on, the board pulls NMI through each opcode fetch
2301
+ outside K7 ($1C00-$1FFF and its mirrors), and the CPU takes it at the
2302
+ end of the instruction that fetch starts, a 2-cycle one included: the
2303
+ board raises the NMI latch ahead of the fetch cycle's poll, so the
2304
+ sample the boundary commits, the one from the second-to-last cycle,
2305
+ holds it. The pull on the cycle that starts the interrupt sequence is
2306
+ taken up by the same NMI.
2307
+ - Pinned by the KIM-1 User Manual's figure 5.6, which single-steps the
2308
+ sample program of figure 5.4 from $0200: the display shows 0202 after
2309
+ the first GO, the 2-cycle LDA #$01, and 020F after TAX. With the
2310
+ latch raised a cycle later, after the fetch cycle has polled, NMI
2311
+ waits an instruction more and the first GO shows 0205.
2312
+ - The monitor's display scan, SCANDS ($1F1F) and the key scan AK
2313
+ ($1EFE) in its idle loop, repeats every 4,258 cycles, and lights the
2314
+ six digits 676, 687, 676, 687, 676 and 657 cycles each. That follows
2315
+ from the ROM and the 6502 core's cycle counts, which SingleStepTests
2316
+ checks, not from a test of the board.
2317
+ - Spec guards: *takes the NMI single-step pulls right after a 2-cycle
2318
+ instruction* in [`kim1/cpu_spec.rb`](../spec/badline/kim1/cpu_spec.rb),
2319
+ and *figure 5.6* and *scans the six digits every 4,258 cycles* in
2320
+ [`kim1_spec.rb`](../spec/badline/kim1_spec.rb).
2321
+
2322
+ ## 6809 dead cycles
2323
+
2324
+ 6809 dead cycles follow the MC6809E flowcharts, not MAME. The
2325
+ neetandev/m6809 vectors (`rake test`) are MAME's, and on these dead
2326
+ ("Don't Care") cycles they read another address than Figure 17 of the
2327
+ MC6809E datasheet gives. The core reads the datasheet's address, and the
2328
+ runner checks each of these cycles against it, through the rules in
2329
+ [`m6809_divergences.rb`](../test/support/m6809_divergences.rb). Every
2330
+ other cycle, and every cycle count but X18's, is the vectors'.
2331
+
2332
+ - A read-modify-write (NEG, COM, LSR, ROR, ASR, ASL, ROL, DEC, INC, CLR
2333
+ and the undocumented aliases, in memory) reads `$FFFF` between its read
2334
+ and its write, where the vectors read PC. Pinned by MC6809E Fig. 17
2335
+ sheet 5 and the datasheet's DEC extended example.
2336
+ - ADDD, SUBD, CMPD, CMPX, CMPY, CMPU, CMPS and the undocumented XADDD and
2337
+ XADDU end on a dead read of `$FFFF`, where the vectors read PC. Pinned
2338
+ by MC6809E Fig. 17 sheet 5.
2339
+ - JSR's first dead cycle after its address reads the subroutine's
2340
+ address, where the vectors read PC. BSR and LBSR read it on the dead
2341
+ cycle before their last `$FFFF`, where the vectors read `$FFFF`. Pinned
2342
+ by MC6809E Fig. 17 sheets 1 and 5 and the datasheet's LBSR example.
2343
+ - RTS ends on a dead read of `$FFFF`, where the vectors read the stack.
2344
+ Pinned by MC6809E Fig. 17 sheet 2.
2345
+ - TSTA and TSTB read NNNN+1 after the opcode, as every one-byte inherent
2346
+ opcode does, where the vectors read `$FFFF`. Pinned by MC6809E Fig. 17
2347
+ sheet 2.
2348
+ - Indexed: an 8-bit offset from R is followed by a dead read of `$FFFF`,
2349
+ where the vectors read PC. A 16-bit offset from R or PC, a D offset and
2350
+ extended indirect read NNNN+4 (NNNN+5 after a prefix) on the cycle
2351
+ after the offset, where the vectors read `$FFFF`. Pinned by MC6809E
2352
+ Fig. 17 sheet 4.
2353
+ - Spec guard: *dead cycles* in
2354
+ [`m6809_spec.rb`](../spec/badline/chips/m6809_spec.rb).
2355
+
2356
+ ## 6809 interrupts, SYNC, CWAI, HALT and reset
2357
+
2358
+ The vectors leave these out. The core follows the MC6809E datasheet, and
2359
+ reyco2000's `6809_interrupt_test` and `6809_cycle_test`
2360
+ (`rake test`) pass on it.
2361
+
2362
+ - The lines are sampled once a cycle, and an instruction boundary sees the
2363
+ sample of two cycles before: IRQ or FIRQ asserted on an instruction's
2364
+ next-to-last cycle is taken once it ends, and on its last cycle only
2365
+ after the next instruction. NMI is an edge, latched until taken, and
2366
+ ignored until a program loads S after reset (LDS, LEAS, TFR or EXG
2367
+ into S, PULU S). Pinned by MC6809E Figs. 8 and 9.
2368
+ - IRQ and NMI take 19 cycles from the cycle that would have fetched the
2369
+ opcode: PC twice, `$FFFF`, the 12 bytes from PC low to CC with E set,
2370
+ `$FFFF`, the vector, `$FFFF`. FIRQ takes 10, stacking PC and CC with E
2371
+ clear. The masks take effect as the vector's first byte is read. Pinned
2372
+ by MC6809E Figs. 8 and 9.
2373
+ - SYNC reads NNNN+1 and then leaves the bus alone until any interrupt line
2374
+ is asserted, masked or not, and for one cycle more. A masked interrupt
2375
+ goes on to the next instruction; an unmasked one runs its usual
2376
+ sequence. Pinned by MC6809E Fig. 16 and Fig. 17 sheet 2.
2377
+ - CWAI reads its operand, NNNN+2 and `$FFFF`, ANDs CC with the operand,
2378
+ sets E, stacks all 12 bytes, then reads `$FFFF` until an interrupt it
2379
+ may take comes, and reads that interrupt's vector and `$FFFF`: 20
2380
+ cycles when the interrupt is already there. Pinned by MC6809E Fig. 17
2381
+ sheet 2.
2382
+ - HALT stops the CPU at the next instruction boundary, sampled as IRQ is,
2383
+ and leaves the bus alone until it is released.
2384
+ - After RESET the CPU reads `$FFFE` twice, the vector at `$FFFE` and
2385
+ `$FFFF`, and `$FFFF`, and fetches its first opcode on the sixth cycle.
2386
+ It masks FIRQ and IRQ and clears DP. Pinned by MC6809E Fig. 6.
2387
+ - Spec guard: [`m6809_spec.rb`](../spec/badline/chips/m6809_spec.rb).
2388
+
2389
+ ## 6809 undocumented opcodes
2390
+
2391
+ The undocumented opcodes follow David Banks' "Undocumented 6809
2392
+ Behaviours" (github.com/hoglet67/6809Decoder/wiki), which was checked on
2393
+ real chips, where it and the vectors (MAME's) disagree. The runner checks
2394
+ these cases against the rules in
2395
+ [`m6809_divergences.rb`](../test/support/m6809_divergences.rb).
2396
+
2397
+ - X18 (`$18`) takes 3 cycles, where the vectors take 2, and sets V to
2398
+ (C AND bit 0) OR (Z AND bit 2) of the byte after the opcode, where the
2399
+ vectors take Z alone. Banks doesn't give the third cycle's address; the
2400
+ core reads `$FFFF`. Pinned by Banks, X18.
2401
+ - XADDU adds the operand to U OR `$FF00`, where the vectors add U. Pinned
2402
+ by Banks, XADDU.
2403
+ - DAA sets V to C XOR bit 7 of the result, where the vectors (and the
2404
+ datasheet) clear it. Pinned by Banks, Undefined values of the Overflow
2405
+ Flag.
2406
+ - The stores immediate set N and clear Z and V when prefixed. Unprefixed,
2407
+ N, Z and V hang on the group of the instruction before (CMPA and BITA;
2408
+ LDA and LDD; the A arithmetic and logic; the A shifts, DEC, INC, NEG,
2409
+ COM, TSTA, DAA and SUBD; SEX; the 16-bit compares and XADDD/XADDU; LEA;
2410
+ anything else). The 16-bit ones also clear Z unless the register's low
2411
+ byte is 0. The vectors set N and Z from the register and clear V. The
2412
+ vectors start every case after no instruction, the "anything else"
2413
+ group: N set, Z and V clear. Pinned by Banks, Store Immediate and Flags
2414
+ for unprefixed Store Immediate.
2415
+ - What the vectors leave out also comes from Banks: `$14`, `$15` and `$CD`
2416
+ read on from PC, a byte a cycle, until reset; a chain of `$10` and `$11`
2417
+ prefixes takes the first, a cycle for each; an opcode page 2 or 3
2418
+ doesn't define runs as on page 1, a cycle later.
2419
+ - Spec guard: *the flags of the unprefixed stores immediate* in
2420
+ [`m6809_spec.rb`](../spec/badline/chips/m6809_spec.rb).