badline 0.14.0 → 0.15.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 (82) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +23 -0
  3. data/CLAUDE.md +15 -5
  4. data/README.md +68 -8
  5. data/doc/pinned-behaviour.md +145 -0
  6. data/doc/snapshot-format.md +188 -38
  7. data/doc/snapshots.md +18 -1
  8. data/lib/badline/audio/bare_player.rb +4 -8
  9. data/lib/badline/audio/machine_player.rb +2 -12
  10. data/lib/badline/c128/banks.rb +1 -3
  11. data/lib/badline/c128/bus.rb +19 -1
  12. data/lib/badline/c128/mmu_pages.rb +7 -0
  13. data/lib/badline/c64/bus/extra_sids.rb +80 -0
  14. data/lib/badline/c64/bus.rb +1 -0
  15. data/lib/badline/c64/cartridge/action_replay.rb +6 -2
  16. data/lib/badline/c64/cartridge/comal80.rb +1 -0
  17. data/lib/badline/c64/cartridge/dinamic.rb +3 -1
  18. data/lib/badline/c64/cartridge/final_cartridge3.rb +1 -0
  19. data/lib/badline/c64/cartridge/fun_play.rb +2 -1
  20. data/lib/badline/c64/cartridge/game_system.rb +2 -1
  21. data/lib/badline/c64/cartridge/keyed_state.rb +155 -34
  22. data/lib/badline/c64/cartridge/magic_desk.rb +2 -1
  23. data/lib/badline/c64/cartridge/ocean.rb +1 -0
  24. data/lib/badline/c64/cartridge/pagefox.rb +1 -0
  25. data/lib/badline/c64/cartridge/rgcd.rb +2 -1
  26. data/lib/badline/c64/cartridge/super_games.rb +3 -2
  27. data/lib/badline/c64/cartridge/zaxxon.rb +1 -0
  28. data/lib/badline/c64/cartridge.rb +3 -3
  29. data/lib/badline/c64/keyed_modules.rb +6 -2
  30. data/lib/badline/chips/ted/beam.rb +13 -14
  31. data/lib/badline/chips/ted/fetches.rb +199 -0
  32. data/lib/badline/chips/ted/keyed_state.rb +156 -0
  33. data/lib/badline/chips/ted/modes.rb +134 -0
  34. data/lib/badline/chips/ted/palette.rb +43 -0
  35. data/lib/badline/chips/ted/picture.rb +182 -0
  36. data/lib/badline/chips/ted/sound/output.rb +86 -0
  37. data/lib/badline/chips/ted/sound.rb +284 -0
  38. data/lib/badline/chips/ted.rb +53 -6
  39. data/lib/badline/chips/tia.rb +12 -0
  40. data/lib/badline/drives/datasette/keyed_state.rb +7 -2
  41. data/lib/badline/drives/datasette.rb +22 -5
  42. data/lib/badline/frontend/boot.rb +3 -1
  43. data/lib/badline/frontend/controls.rb +7 -3
  44. data/lib/badline/frontend/keys.rb +14 -2
  45. data/lib/badline/frontend/media_slots.rb +11 -1
  46. data/lib/badline/frontend/menu/menu_dialogs.rb +2 -1
  47. data/lib/badline/frontend/menu/menu_media.rb +13 -3
  48. data/lib/badline/frontend/menu/menu_pages.rb +8 -8
  49. data/lib/badline/frontend/menu/menu_ports.rb +13 -1
  50. data/lib/badline/frontend/screen.rb +33 -12
  51. data/lib/badline/frontend/screens.rb +2 -1
  52. data/lib/badline/frontend/sound.rb +4 -4
  53. data/lib/badline/frontend/timeline.rb +19 -6
  54. data/lib/badline/machine/settling.rb +1 -1
  55. data/lib/badline/machine.rb +26 -6
  56. data/lib/badline/media/plus4_media.rb +68 -0
  57. data/lib/badline/media/program.rb +20 -6
  58. data/lib/badline/media.rb +33 -12
  59. data/lib/badline/options/family.rb +1 -0
  60. data/lib/badline/options/help.rb +30 -6
  61. data/lib/badline/options/table.rb +15 -2
  62. data/lib/badline/options/validation.rb +26 -4
  63. data/lib/badline/options.rb +37 -9
  64. data/lib/badline/plus4/bus.rb +77 -14
  65. data/lib/badline/plus4/cassette_sense.rb +21 -0
  66. data/lib/badline/plus4/keyboard_port.rb +35 -10
  67. data/lib/badline/plus4/keyed_modules.rb +99 -0
  68. data/lib/badline/plus4/keyed_parts.rb +143 -0
  69. data/lib/badline/plus4/keyed_state.rb +41 -0
  70. data/lib/badline/plus4.rb +92 -16
  71. data/lib/badline/snapshot/container.rb +2 -0
  72. data/lib/badline/snapshot/field_doc/markdown.rb +7 -6
  73. data/lib/badline/snapshot/field_doc.rb +46 -7
  74. data/lib/badline/snapshot/image.rb +12 -3
  75. data/lib/badline/snapshot/plus4_setup.rb +39 -0
  76. data/lib/badline/snapshot.rb +9 -4
  77. data/lib/badline/storage/g64_image.rb +1 -1
  78. data/lib/badline/storage/tap.rb +21 -12
  79. data/lib/badline/support/checkpoint.rb +3 -2
  80. data/lib/badline/support/plus4_checkpoint.rb +42 -0
  81. data/lib/badline/version.rb +1 -1
  82. metadata +15 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 320b4659e6c9945509741f928989b2378d38ae18a51c1dd5bbca706e3b3ada54
4
- data.tar.gz: 9a6ce80ab26e74e325c8fb660f4ed1fabc64a6e3c1859b723b3816aebe3f4b55
3
+ metadata.gz: dcc4aea1603a5dac88787b701529e7019573fa5bd3b66cdd31a6d4f071fb3ecf
4
+ data.tar.gz: bc8de62e989822edd15ff2d59002a034c361c176e50a0e064a3482ff820b150a
5
5
  SHA512:
6
- metadata.gz: 0f4e3b6c6bc7c35eec18ea3a81165050183e92eeebab3c04b12472970b5b0a87d8ad860ceac81e411a39836c601239b3e708bcffbcb7f4eb6561599c1cda1522
7
- data.tar.gz: 61d6698127237a45d99febd816088da06d227519b34455188babc7dafebb977613a61c1472ed348c691433a8c02f4dcbab0346f48083b71fc02035f64f7c8549
6
+ metadata.gz: 88c53ecfb3d2322c4f2ed6cc99c58e3e5cdb9b135b9afaae85a183f95d23d1546c0c7d245547dfe968574849689508e0669dda8648c3a0cb123251672895d442
7
+ data.tar.gz: 2d2d289ef46a002ff548fb7a219805a8c6fcbd555f469f4f8bb8eb87bc6895df48e83d8694ec262251d87997a2f2d325120f608f491df76ef9c47f83be1cc0e2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.15.0](https://github.com/elektronaut/badline/compare/v0.14.0...v0.15.0) (2026-10-12)
4
+
5
+
6
+ ### Features
7
+
8
+ * run the Plus/4 and the C16 in the window with badline plus4 ([935bcf1](https://github.com/elektronaut/badline/commit/935bcf11b986c65f01024515d7c98ac1efa46530))
9
+ * paint the TED's picture ([ede7805](https://github.com/elektronaut/badline/commit/ede7805b8113cb6321fbfdffedcb6b7a79e95983))
10
+ * play the TED's sound ([a34efd6](https://github.com/elektronaut/badline/commit/a34efd67dbec995f246781452bce7c9c070ed10b))
11
+ * read the Plus/4's joysticks through the keyboard latch and map its keys ([6a1f7cb](https://github.com/elektronaut/badline/commit/6a1f7cb5a9a9426562fe5b3c9106a245bc23d287))
12
+ * attach programs, disks and cartridges to a Plus/4 ([84a86f4](https://github.com/elektronaut/badline/commit/84a86f43e97e08fdb4ea21ef909adf54bc09540c))
13
+ * put a true 1541 or 1581 on the Plus/4's serial bus ([bd068ff](https://github.com/elektronaut/badline/commit/bd068ffd1b337915ad70ed9e96f10df6ca770c05))
14
+ * put Plus/4 cartridges in both slots, from .crt or raw .bin ([42ae7c0](https://github.com/elektronaut/badline/commit/42ae7c0f66dd200bc1787ad3a9bd62c4f57719eb))
15
+ * play and record Plus/4 and C16 tapes ([cd19fa9](https://github.com/elektronaut/badline/commit/cd19fa920a4e2b8a488011872ca98f6bd95cb43a))
16
+ * show the Plus/4's picture, play its sound and drive its joysticks in the front end ([4213c26](https://github.com/elektronaut/badline/commit/4213c26ffeaafe46bc6ec42433e2dc763b70aa6a))
17
+ * keyed snapshots for the Plus/4 and the C16 ([c7a1ace](https://github.com/elektronaut/badline/commit/c7a1ace2c3c94064bb14841773e109c56e49f1d6))
18
+ * save the Plus/4 from F11 and the Snapshots page ([853085f](https://github.com/elektronaut/badline/commit/853085f0c177fcbf305c1fd60cd1a800dfcbc266))
19
+ * save cartridge mappers' registers in snapshots ([9ea6e0b](https://github.com/elektronaut/badline/commit/9ea6e0b2669c4ae9ed8270cf3de345787c76dcb3))
20
+ * save the extra SIDs in snapshots ([bf7f142](https://github.com/elektronaut/badline/commit/bf7f1426472620b6168352ba3bf74e4780d29e89))
21
+
22
+ ### Bug Fixes
23
+
24
+ * store a C128 bank LOAD into the I/O that bank maps ([58672c2](https://github.com/elektronaut/badline/commit/58672c2bb7b9a5fed8d75d72007d00444eebb696))
25
+
3
26
  ## [0.14.0](https://github.com/elektronaut/badline/compare/v0.13.0...v0.14.0) (2026-10-11)
4
27
 
5
28
 
data/CLAUDE.md CHANGED
@@ -69,10 +69,10 @@ file: `core.rb` requires their members one by one.
69
69
  | rspec (`spec/`) | `bundle exec rspec` | Unit behaviour, all of `lib/` |
70
70
  | SingleStepTests 65x02 | `rake test` (100 sampled cases per opcode) | CPU, per-cycle bus traces |
71
71
  | SingleStepTests z80 | `rake test` (the first 100 cases per opcode, `Z80_SAMPLE=all` for all 1,604,000) | `Z80`: registers, flags, ports and the bus pins on every T-state |
72
- | Wolfgang Lorenz suite | `bin/lorenz` | CPU, CIA, interrupts |
73
- | VICE testbench | `bin/testbench <subtree>` | `VICII/`, `CIA/`, `interrupts/`, `CPU/`, cartridges with `--carts`, the true 1541 drive with `--drive`, the VIC-20 with `--vic20`, the C128 in C64 mode with `--c128c64`, in C128 mode with `--c128`, and its Z80 with `--c128-z80` |
72
+ | Wolfgang Lorenz suite | `bin/lorenz` | CPU, CIA, interrupts; its plus4 build with `--plus4`: the CPU on the 264's bus, the TED's clock, DMA, timers and interrupt |
73
+ | VICE testbench | `bin/testbench <subtree>` | `VICII/`, `CIA/`, `interrupts/`, `CPU/`, cartridges with `--carts`, the true 1541 drive with `--drive`, the VIC-20 with `--vic20`, the C128 in C64 mode with `--c128c64`, in C128 mode with `--c128`, and its Z80 with `--c128-z80`, the Plus/4 with `--plus4` and the C16 with `--c16` |
74
74
  | VICE SID testprogs | `bin/sidtests` | SID |
75
- | Drive scenarios | `bin/drive_scenarios` | The true 1541 running the DOS ROM: save, format, the error channel, idle, write protect and autostart |
75
+ | Drive scenarios | `bin/drive_scenarios` | The true 1541 running the DOS ROM: save, format, the error channel, idle, write protect and autostart; the `plus4-*` rows on the Plus/4 and C16, with the 1541 and 1581 on their serial bus and a tape saved and loaded back on the datasette |
76
76
  | CIA offline grids | `bundle exec rspec --tag slow spec/badline/chips/cia` | CIA timers and shift register, against a bare CIA in about 2 min |
77
77
 
78
78
  The CIA offline grids replay Lorenz's `cia1ta` and `cia1tb` sweeps (about
@@ -190,7 +190,7 @@ overrides that, capped by the core count, but keep the default, because
190
190
  other worktrees share the machine. Whole runs at 4 shards on an M-series
191
191
  laptop take 15 min for `testbench` (`VICII/`), 11 for `testbench-cia`, 1 for
192
192
  `testbench-interrupts`, 37 for `testbench-irqdma`, 11 for
193
- `testbench-cpu`, 2 for `testbench-carts`, about 25 for `testbench-expansions`, under 1 for `testbench-vic20` and about 30 for `testbench-c128c64`. `sid` takes about 12 min. `lorenz` chains itself and takes
193
+ `testbench-cpu`, 2 for `testbench-carts`, about 25 for `testbench-expansions`, under 1 for `testbench-vic20`, `testbench-plus4`, `testbench-c16` and `testbench-plus4-ntsc`, and about 30 for `testbench-c128c64`. `lorenz-plus4` takes about 21 min whole on the Spinel build. `rake regression:lorenz-plus4-1` to `lorenz-plus4-4` run it as four stretches, cut where `lorenz` is, and the last, through the trap tests the chain resumes past, is about half of it. `sid` takes about 12 min. `lorenz` chains itself and takes
194
194
  about 2.5 h on CI whole. `rake regression:lorenz-1` to `lorenz-4` run it as
195
195
  four stretches of about 40 min each, and they can run side by side.
196
196
  `test/baselines/README.md` has the full table. A killed `bin/testbench` run
@@ -255,7 +255,17 @@ the 6526A) for anything the interrupt register or the CIA model reaches; cartrid
255
255
  `testbench-carts`, plus `testbench-expansions` for banking; GEO-RAM, +60K,
256
256
  +256K, the REU or the VIC's BA line the REU follows → `testbench-expansions`; the 1541 drive, VIA or IEC bus →
257
257
  `testbench-drive` (`bin/testbench --drive`) and `drive-scenarios` (`bin/drive_scenarios <filter>`), plus `testbench-vic20` for the VIA; the VIC-20 (`vic20/`) →
258
- `testbench-vic20` (`bin/testbench --vic20`); the C128 (`c128.rb`, `c128/`), or
258
+ `testbench-vic20` (`bin/testbench --vic20`); the 264 series (`plus4.rb`,
259
+ `plus4/`), the TED (`chips/ted.rb`, `chips/ted/`) or the TIA (`chips/tia.rb`)
260
+ → `testbench-plus4` (`bin/testbench --plus4`) and `testbench-c16`
261
+ (`bin/testbench --c16`), plus `testbench-plus4-ntsc`
262
+ (`bin/testbench --plus4 --ntsc`) for anything NTSC timing or the picture
263
+ reaches, `lorenz-plus4` (`bin/lorenz --plus4`) for
264
+ anything the CPU's clock, the TED's DMA, its timers or its interrupt reach,
265
+ and the `plus4-*` drive scenarios (`bin/drive_scenarios plus4`) for its
266
+ serial bus, its media, the CPU port or the datasette.
267
+ Its tests run one at a time as the C64's do, with
268
+ `ruby --yjit bin/lorenz --plus4 --resume <test> --stop-after <test>`; the C128 (`c128.rb`, `c128/`), or
259
269
  the VIC-IIe, CPU or PLA code it shares with the C64 → `testbench-c128c64`
260
270
  (`bin/testbench --c128c64`); the C128's Z80, MMU or hand-over → `testbench-c128-z80` (`bin/testbench --c128-z80`) and `testbench-c128`; SID → `sid`, plus `sid-8580` for anything the 8580
261
271
  model reaches (`bin/sidtests --sid 8580`). Leave the Lorenz chain to CI,
data/README.md CHANGED
@@ -13,7 +13,7 @@ are modelled at the cycle level.
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
15
  paddles and a 1351 mouse. It also runs a PAL VIC-20, as
16
- `badline vic20`, and the C128, in C128 mode on 40 or 80 columns and in C64 mode, as `badline c128`. See [What's emulated](#whats-emulated) for the details.
16
+ `badline vic20`, the C128, in C128 mode on 40 or 80 columns and in C64 mode, as `badline c128`, and the Plus/4, the C16 and the C116, as `badline plus4`. See [What's emulated](#whats-emulated) for the details.
17
17
 
18
18
  It comes in two builds of the same emulator:
19
19
 
@@ -69,8 +69,8 @@ from it.
69
69
 
70
70
  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
- [The VIC-20](#the-vic-20) for `badline vic20` and [The C128](#the-c128)
73
- for `badline c128`.
72
+ [The VIC-20](#the-vic-20) for `badline vic20`, [The C128](#the-c128)
73
+ for `badline c128` and [The Plus/4](#the-plus4) for `badline plus4`.
74
74
 
75
75
  `badline-ruby` takes the same media and the same options, with the
76
76
  differences noted in the table. `--help` lists the options for either.
@@ -84,9 +84,10 @@ differences noted in the table. `--help` lists the options for either.
84
84
  | `--true-drive` | Put an emulated 1541 on device 8 instead of the KERNAL traps. See [Media](#media) |
85
85
  | `-s`, `--subtune N` | Pick a subtune of a `.sid` file, counting from 1 |
86
86
  | `--sid 6581`, `--sid 8580` | Fit the older or newer SID. `--sid auto`, the default, takes a `.sid` tune's own |
87
- | `--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) |
87
+ | `--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 |
88
+ | `--c1lo FILE`, `--c1hi FILE`, `--c2lo FILE`, `--c2hi FILE` | Put a raw `.bin` ROM image in one of the Plus/4's cartridge slots: cartridge 1 or 2, low (`$8000`) or high (`$C000`). See [The Plus/4](#the-plus4) |
88
89
  | `--reu SIZE` | Plug in a RAM Expansion Unit of `SIZE` K: 128, 256, 512 (a 1750) or up to 16384 |
89
- | `--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 |
90
+ | `--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 and the Plus/4 have models of their own: see their sections |
90
91
  | `--ntsc` | Run an NTSC C64, as `--model ntsc` does |
91
92
  | `--c64` | Start a C128 in C64 mode, holding `C=` at power-on. See [The C128](#the-c128) |
92
93
  | `--no-sound` | Don't play the SID (`badline` only, where sound is on by default) |
@@ -221,6 +222,44 @@ no host key yet: `Tab` and the arrows keep their C64 uses.
221
222
  `F11`, `F12` and the pause menu save and load the C128 in badline's own
222
223
  snapshots, and x128's `.vsf` files don't load.
223
224
 
225
+ ## The Plus/4
226
+
227
+ `badline plus4` runs a PAL Plus/4, with BASIC 3.5 and the 3-plus-1
228
+ function ROMs, and takes the same media as the C64 apart from SID tunes:
229
+
230
+ ```sh
231
+ badline plus4 # READY., in BASIC 3.5
232
+ badline plus4 game.prg # Load and run a program
233
+ badline plus4 game.d64 # Mount a disk image as device 8 and load it
234
+ badline plus4 game.tap # Insert a tape and load it
235
+ badline plus4 game.crt # Attach a cartridge
236
+ badline plus4 --model c16 game.bin # A C16 with a cartridge's ROM image
237
+ ```
238
+
239
+ `--model` picks the machine: `plus4` (the default, PAL with 64K of RAM),
240
+ `c16` (PAL with 16K, without the function ROMs, the ACIA and the user
241
+ port), `c116`, which is the C16 in another case, and `plus4ntsc` and
242
+ `c16ntsc` for their NTSC versions. `--ram 16k`, `32k` or `64k` fits other
243
+ RAM in place of the model's own.
244
+
245
+ A program loads at the start of BASIC 3.5, `$1001`, and runs. A tape's
246
+ `LOAD` reads the datasette, as the 264 KERNAL's does by default. A
247
+ cartridge is a `.crt` or a raw `.bin` ROM image. A `.bin` goes in
248
+ cartridge 1, its low slot for up to 16K and both slots for 32K, and
249
+ `--c1lo`, `--c1hi`, `--c2lo` and `--c2hi` put one in the slot they name,
250
+ as xplus4's options do:
251
+
252
+ ```sh
253
+ badline plus4 --c1lo game-low.bin --c1hi game-high.bin
254
+ ```
255
+
256
+ Disks go through the KERNAL traps or, with `--true-drive`, a 1541 or a
257
+ 1581 on the serial bus. There is no 1551 yet. The pause menu's Power
258
+ page names the model and its RAM, and its Expansion port page shows the
259
+ slots that hold a cartridge and takes them all out. `F11` and the
260
+ Snapshots page save it as they do the others, but not for VICE.
261
+ [Input](#input) lists its keys.
262
+
224
263
  ## Snapshots
225
264
 
226
265
  `F11` quicksaves the whole machine to the next of five slots in
@@ -272,6 +311,21 @@ types `"`. These keys have no same-named host key:
272
311
  | `+` / `*` | Keypad `+` / Keypad `*` |
273
312
  | `RESTORE` | `Page Up` |
274
313
 
314
+ The Plus/4 and the C16 keep the C64's host keys for the keys they share,
315
+ and put their own here:
316
+
317
+ | Plus/4 | Host |
318
+ |--------|------|
319
+ | `ESC` | `Escape` |
320
+ | `RUN/STOP` | `Page Down` |
321
+ | `F1` / `F2` / `F3` | `F1` / `F2` / `F3` |
322
+ | `HELP` | `F4`, `Insert` or `Help` |
323
+ | `CRSR ←` / `→` / `↑` / `↓` | `Left` / `Right` / `Up` / `Down` |
324
+ | `SHIFT` | `Left Shift` or `Right Shift` |
325
+
326
+ They have no `RESTORE`, `←` or `↑` key, so `Page Up`, `` ` `` and `]`
327
+ press nothing.
328
+
275
329
  `Tab` switches the keys between the C64 keyboard and the joysticks. The
276
330
  window title shows where they go, and any device plugged into a control
277
331
  port:
@@ -314,10 +368,10 @@ too.
314
368
  | Snapshots | Quicksave, save under a name, load a named save, and the latest quicksaves and autosaves |
315
369
  | Drive 8 | The disk: insert, eject, the previous or next disk of its set, and whether it's writable |
316
370
  | Datasette | The tape: insert, eject, PLAY and REWIND |
317
- | Expansion port | The cartridge: insert, remove, and its freeze button if it has one |
371
+ | Expansion port | The cartridge: insert, remove, and its freeze button if it has one. On the Plus/4, the slots that hold one |
318
372
  | Ports | The device in each control port, and where the keys go |
319
373
  | Sound | Mute, and the SID's model |
320
- | Power | Reset, power cycle and quit, and on a C128 its model and mode |
374
+ | Power | Reset, power cycle and quit, on a C128 its model and mode, and on a Plus/4 its model and RAM |
321
375
 
322
376
  INSERT opens a file browser. A disk's set is the `.m3u` or `.vfl` list it
323
377
  was opened from, or one in its folder that lists it. Without one, it comes
@@ -357,12 +411,18 @@ program or `.sid` dropped on it opens the menu to ask first.
357
411
  port, FAST mode, the VIC-IIe with its extra keyboard lines, the 8722
358
412
  MMU, the 8563 or 8568 VDC with its 80 column display, and 128K of RAM
359
413
  (`badline c128`), and the Z80, which boots the machine.
414
+ - **Plus/4, C16 and C116**: the 7501, the TED with its picture, sound,
415
+ timers and the CPU's single and double clock, 16K to 64K of RAM, ROM
416
+ banking with the 3-plus-1 function ROMs, the keyboard and both
417
+ joysticks, cartridges in both slots, the datasette and the serial bus
418
+ to device 8, PAL and NTSC (`badline plus4`). The ACIA's registers are
419
+ there but send and receive nothing.
360
420
  - **1541**: an emulated drive running its own DOS (`--true-drive`).
361
421
  - **1571**: the C128D's drive running DOS 3.0, in 1541 mode and in 1571
362
422
  mode at 2 MHz with both sides of a `.d71` or `.g71`, and fast serial
363
423
  (burst) to a C128 in C128 mode (`badline c128 --true-drive`).
364
424
  - **1581**: the 3.5" drive running its own DOS on its WD1772 and 8520,
365
- reading and writing `.d81` images, on the C64, the VIC-20 and the C128
425
+ reading and writing `.d81` images, on the C64, the VIC-20, the C128 and the Plus/4
366
426
  (`--true-drive` with a `.d81`).
367
427
  - **Cartridges**: standard 8K, 16K and Ultimax, Simons' BASIC, Ocean,
368
428
  Fun Play / Power Play, Super Games, Epyx FastLoad, Westermann
@@ -39,6 +39,7 @@ only catches the rows that happen to move.
39
39
  - [VIC-I fetches and the V-bus](#vic-i-fetches-and-the-v-bus)
40
40
  - [VIC-I sound](#vic-i-sound)
41
41
  - [TED beam and the 7501 port](#ted-beam-and-the-7501-port)
42
+ - [TED sound](#ted-sound)
42
43
  - [1541 serial port](#1541-serial-port)
43
44
  - [1541 disk mechanism](#1541-disk-mechanism)
44
45
  - [REU DMA](#reu-dma)
@@ -1519,6 +1520,150 @@ finds one should start here.
1519
1520
  - Pinned by `lorenz-plus4`'s rows for those tests. The xplus4 verdicts
1520
1521
  are its exit codes with `-debugcart`, one program at a time.
1521
1522
 
1523
+ The TED's fetch counters (`Chips::TED::Fetches`) follow xplus4 where the
1524
+ datasheet is silent, and the datasheet where the two disagree. Each was
1525
+ checked with probes that sample `$FF1A`, `$FF1B`, `$FF1D`, `$FF1E` and
1526
+ `$FF1F` through a frame, run on badline and xplus4 r45942 alike.
1527
+
1528
+ - The row's line (`$FF1F` bits 0-2) steps with the line count only on the
1529
+ display window's lines, so it holds 7 from line 204 to the end of the
1530
+ frame, and the character position reload holds 1000 there. The frame's
1531
+ end clears both.
1532
+ - The blink counter (`$FF1F` bits 3-6) counts at horizontal count 336, the
1533
+ datasheet's "Increment Blink", on line 256 of a PAL frame and line 228
1534
+ of an NTSC one, the lines xplus4 counts on. The datasheet gives no line.
1535
+ - A row's last line keeps its own attributes, although the line fetches
1536
+ the next row's, as xplus4 shows it: the attributes take hold as each
1537
+ character's pointer is fetched.
1538
+ - The attribute line reads the row the reload will point to after its own
1539
+ latch: 40 on from it on a row's eighth line, and the reload itself on any
1540
+ other line, as on the first row of a frame or after a scroll change
1541
+ stretched a row past eight lines.
1542
+ - The pointer line is the line after an attribute line, whatever the
1543
+ scroll says by then (the datasheet's DMA timing, step 8). A line whose
1544
+ scroll alone asks for pointers fetches none, so a scroll of 7 starts the
1545
+ first row on line 8, not line 0.
1546
+ - The row's line runs on from the frame's first row, wrapping from 7 to
1547
+ 0, and a pointer line doesn't reset it. After a scroll change moves the
1548
+ DMA lines, a row starts on whatever line the counter has reached.
1549
+ - Both pinned by xplus4 screenshots of scroll changes inside a text row,
1550
+ on lines 20, 100 and 101.
1551
+ - `$FF1A` reads back both bits written to it, the datasheet's two MSBs of
1552
+ the reload. xplus4 reads bit 1 as 0.
1553
+ - xplus4 reads the reload 40 higher for a few cycles around the line step
1554
+ on some lines. badline reads the register as it stands.
1555
+
1556
+ The TED's picture (`Chips::TED::Picture` and `Modes`) matches xplus4's
1557
+ screenshots pixel for pixel, by palette index, on probes for every mode,
1558
+ both column widths, both row counts, each horizontal and vertical scroll,
1559
+ the idle lines before the first row, cursor and flash, and scroll changes
1560
+ mid-frame. Where it follows xplus4 over the datasheet:
1561
+
1562
+ - The 38-column window is pixels 39-342 of the 384, 7 in on the left and
1563
+ 9 on the right. The datasheet's counts (3 and 307 against 451 and 315)
1564
+ would make it 8 and 8.
1565
+ - A multicolour bitmap's 01 takes the luminance of the attribute's bits
1566
+ 0-2, as the hires bitmap's 1 does. The datasheet gives it bits 4-6.
1567
+ - A register write takes hold 19 dots after its cycle starts
1568
+ (`Picture::WRITE_DELAY`), on a character cell's boundary with no scroll.
1569
+ That puts a raster interrupt's colour change within a cycle or two of
1570
+ where xplus4 puts it. Code timed from `$FF1E` or a DMA stall lands 3
1571
+ cycles later than in xplus4, the other side of the line-step difference
1572
+ above. Pinned by probes that change `$FF15` and `$FF19` every 6 cycles,
1573
+ timed both ways, and the spec guard *shows a register written mid-line
1574
+ from the pixel the write lands on* in
1575
+ [`chips/ted_spec.rb`](../spec/badline/chips/ted_spec.rb).
1576
+ - The picture's lines are scanlines as they go out. They follow the line
1577
+ count until a write to `$FF1C`-`$FF1D` moves it, start over where the
1578
+ count wraps to 0 at the end of the frame, and step with each line
1579
+ otherwise. The vertical border is a flip-flop: the window opens when
1580
+ the count reaches line 4 (8 with 24 rows) and shuts when it reaches 204
1581
+ (200), so a count moved past line 4 leaves the frame bordered. Pinned by
1582
+ `TED/write-scanline-coarse.prg`, which matches xplus4's screenshot pixel
1583
+ for pixel, and the spec guards *keeps the window shut through a frame
1584
+ whose line count jumps past line 4* and *paints the scanline after a
1585
+ line count write on the picture's next line*.
1586
+ - A write to `$FF1E` changes nothing: xplus4 reads the same positions
1587
+ after writes of `$00` to `$FF` on line 100, and its screenshots don't
1588
+ move. Härsfalvi says writing back a value read at the right time
1589
+ affects the screen, which no probe here reproduces.
1590
+ - Freezing the TED (`$FF07` bit 5) for about 100 cycles on line 100
1591
+ leaves the picture as xplus4 shows it.
1592
+ - The blink counter's carry turns cursor and flash over together: in one
1593
+ turn flashing characters show the background and the cursor is off, in
1594
+ the other both show, the cursor as reverse.
1595
+
1596
+ ## TED sound
1597
+
1598
+ No testprog checks the TED's sound, so these rules are pinned by xplus4
1599
+ (VICE 3.10) recordings, run as a black box: `-sounddev wav` at 96 kHz of
1600
+ probe programs that set the registers, the same programs run on badline
1601
+ with the sound's level sampled at the same rate, and the two compared by
1602
+ period, level and noise bits. xplus4 records the raw level, with no
1603
+ filter, so its samples read off as levels. xplus4's own source wasn't
1604
+ read.
1605
+
1606
+ - A voice counts once every 4 cycles and toggles its output every
1607
+ 1023 - x counts, so its frequency is the clock over 8 * (1023 - x).
1608
+ `$3FF` counts 1,024. The datasheet's formula has 1024 - x, and its PAL
1609
+ constant, 111,840.45, is 1,000 above the clock over 8.
1610
+ - Pinned by xplus4: voice 1 at `$000`, `$200`, `$300`, `$3F0` and `$3FF`
1611
+ measures 108.344, 216.900, 434.653, 7389.08 and 108.239 Hz. Their
1612
+ ratios are 1023 : 511 : 255 : 15 : 1024 to 5 digits, which 1024 - x
1613
+ can't give, and badline's recordings measure the same within 0.005%.
1614
+ - Spec guard: *a voice's counter* in
1615
+ [`chips/ted/sound_spec.rb`](../spec/badline/chips/ted/sound_spec.rb).
1616
+ - `$3FE` stops a voice after its next toggle, its output high whatever
1617
+ the phase, square wave or noise, and stops the noise's shifts.
1618
+ - Pinned by xplus4: `$3FE` written while voice 1 plays at `$200`, after
1619
+ 21, 22, 23 and 24 frames, holds the level high each time, and noise
1620
+ at `$3FE` holds high too. Noise held at `$3FE` for 20, 21 or 23
1621
+ frames plays on with the same bits once it leaves, one shift on from
1622
+ where it would be if the pending toggle were dropped.
1623
+ - Spec guard: *$3FE* in
1624
+ [`chips/ted/sound_spec.rb`](../spec/badline/chips/ted/sound_spec.rb).
1625
+ - The noise is an 8-bit shift register that shifts at each of voice 2's
1626
+ toggles, taking in the XOR of bits 1, 4, 5 and 7 at bit 0. Bit 1 is the
1627
+ output. Voice 2's counter and the noise run whether voice 2 plays the
1628
+ square wave, the noise or nothing, and the square wins when bits 5 and
1629
+ 6 of `$FF11` are both set.
1630
+ - Pinned by xplus4: 21,306 bits of noise at `$3D7` after a reload,
1631
+ decoded from a recording, satisfy s(n) = s(n-2) ^ s(n-5) ^ s(n-6) ^
1632
+ s(n-8) (Berlekamp-Massey gives linear complexity 8), with period 255,
1633
+ starting 1100110111101110. Run back from there, the register held all
1634
+ ones with the first two output bits already in it, so the output is
1635
+ bit 1. Released from the reload into the square wave, into nothing or
1636
+ into noise, voice 2 plays the same bits once switched to noise.
1637
+ badline's recordings decode to the same first 64 bits in each of
1638
+ these runs and in the `$3FE` ones above.
1639
+ - Spec guard: *the noise* in
1640
+ [`chips/ted/sound_spec.rb`](../spec/badline/chips/ted/sound_spec.rb).
1641
+ - While `$FF11` bit 7 is set, the voices that are on hold high, the noise
1642
+ is silent and its register holds all ones. Written clear, each voice
1643
+ starts on a whole high half-wave. With the voices held high, the volume
1644
+ plays 9-level samples.
1645
+ - Pinned by xplus4: voice 1, voice 2's square wave and both hold the
1646
+ level high under bit 7, noise holds it at 0, and the half-wave after
1647
+ the release is 221 samples at `$200`, a whole one.
1648
+ - Spec guard: *the reload bit* in
1649
+ [`chips/ted/sound_spec.rb`](../spec/badline/chips/ted/sound_spec.rb).
1650
+ - The level comes from the volume and how many voices are on and high.
1651
+ One voice measures 586, 1610, 2634, 3658, 4682, 5706, 6730 and 7754 at
1652
+ volumes 1-8, and both 1172, 3284, 5526, 7984, 10658, 13548, 16654 and
1653
+ 19976. Volumes 9-15 are 8, and volume 0 or no voice on is silent.
1654
+ - Pinned by xplus4: those are its sample values, read off recordings
1655
+ that step the volume with one voice and with both held high.
1656
+ - Not pinned: that the hardware's levels are these. Nothing here says
1657
+ why two voices come out above twice one.
1658
+ - Spec guard: *the levels* in
1659
+ [`chips/ted/sound_spec.rb`](../spec/badline/chips/ted/sound_spec.rb).
1660
+ - The output stage is the level averaged over each sample, then a one-pole
1661
+ high-pass at 2.7 Hz. The Plus/4 schematic (310164, sheet 2) couples SND
1662
+ through R10 (1K) and C18 (10 uF) into R11 (12K) and R12 (10K), with C19
1663
+ (2,700 pF) as a low-pass at about 70 kHz, above any audio rate.
1664
+ - Not pinned: xplus4 records no output stage, and there is no hardware
1665
+ recording.
1666
+
1522
1667
  ## 1541 serial port
1523
1668
 
1524
1669
  - The drive sees the C64's side of the serial bus a host cycle late. The