badline 0.14.0 → 0.15.1

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 (116) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +86 -0
  3. data/CLAUDE.md +22 -5
  4. data/README.md +101 -11
  5. data/doc/media.md +19 -0
  6. data/doc/pinned-behaviour.md +145 -0
  7. data/doc/snapshot-format.md +244 -46
  8. data/doc/snapshots.md +18 -1
  9. data/exe/badline-ruby +1 -1
  10. data/lib/badline/audio/bare_player.rb +4 -8
  11. data/lib/badline/audio/machine_player.rb +4 -26
  12. data/lib/badline/c128/banks.rb +1 -3
  13. data/lib/badline/c128/bus.rb +19 -1
  14. data/lib/badline/c128/mmu_pages.rb +7 -0
  15. data/lib/badline/c64/bus/extra_sids.rb +80 -0
  16. data/lib/badline/c64/bus.rb +1 -0
  17. data/lib/badline/c64/cartridge/action_replay.rb +6 -2
  18. data/lib/badline/c64/cartridge/comal80.rb +1 -0
  19. data/lib/badline/c64/cartridge/dinamic.rb +3 -1
  20. data/lib/badline/c64/cartridge/final_cartridge3.rb +1 -0
  21. data/lib/badline/c64/cartridge/fun_play.rb +2 -1
  22. data/lib/badline/c64/cartridge/game_system.rb +2 -1
  23. data/lib/badline/c64/cartridge/keyed_state.rb +155 -34
  24. data/lib/badline/c64/cartridge/magic_desk.rb +2 -1
  25. data/lib/badline/c64/cartridge/ocean.rb +1 -0
  26. data/lib/badline/c64/cartridge/pagefox.rb +1 -0
  27. data/lib/badline/c64/cartridge/rgcd.rb +2 -1
  28. data/lib/badline/c64/cartridge/super_games.rb +3 -2
  29. data/lib/badline/c64/cartridge/zaxxon.rb +1 -0
  30. data/lib/badline/c64/cartridge.rb +3 -3
  31. data/lib/badline/c64/keyed_modules.rb +6 -2
  32. data/lib/badline/c64/true_drives.rb +13 -1
  33. data/lib/badline/c64.rb +6 -0
  34. data/lib/badline/chips/ted/beam.rb +13 -14
  35. data/lib/badline/chips/ted/fetches.rb +199 -0
  36. data/lib/badline/chips/ted/keyed_state.rb +156 -0
  37. data/lib/badline/chips/ted/modes.rb +134 -0
  38. data/lib/badline/chips/ted/palette.rb +43 -0
  39. data/lib/badline/chips/ted/picture.rb +182 -0
  40. data/lib/badline/chips/ted/sound/output.rb +86 -0
  41. data/lib/badline/chips/ted/sound.rb +284 -0
  42. data/lib/badline/chips/ted.rb +53 -6
  43. data/lib/badline/chips/tia.rb +28 -0
  44. data/lib/badline/chips/vic/register_log.rb +4 -1
  45. data/lib/badline/drives/datasette/keyed_state.rb +14 -4
  46. data/lib/badline/drives/datasette.rb +22 -5
  47. data/lib/badline/drives/engine/core.rb +6 -14
  48. data/lib/badline/drives/engine/idle.rb +42 -4
  49. data/lib/badline/drives/engine/idle_cpu.rb +18 -0
  50. data/lib/badline/drives/engine/serial_connection.rb +25 -0
  51. data/lib/badline/drives/engine/sleep.rb +1 -0
  52. data/lib/badline/drives/engine.rb +1 -0
  53. data/lib/badline/drives/model1541/byte_ready.rb +19 -3
  54. data/lib/badline/drives/model1541/mechanism.rb +10 -1
  55. data/lib/badline/drives/model1541.rb +1 -0
  56. data/lib/badline/drives/model1551/bus.rb +138 -0
  57. data/lib/badline/drives/model1551/cable.rb +104 -0
  58. data/lib/badline/drives/model1551/cpu.rb +14 -0
  59. data/lib/badline/drives/model1551/keyed_state.rb +65 -0
  60. data/lib/badline/drives/model1551/port.rb +74 -0
  61. data/lib/badline/drives/model1551/tia.rb +92 -0
  62. data/lib/badline/drives/model1551.rb +170 -0
  63. data/lib/badline/drives/model1571.rb +1 -0
  64. data/lib/badline/drives/model1581.rb +1 -0
  65. data/lib/badline/frontend/boot.rb +23 -2
  66. data/lib/badline/frontend/controls.rb +7 -3
  67. data/lib/badline/frontend/keys.rb +14 -2
  68. data/lib/badline/frontend/media_slots.rb +11 -1
  69. data/lib/badline/frontend/menu/menu_dialogs.rb +14 -5
  70. data/lib/badline/frontend/menu/menu_media.rb +102 -14
  71. data/lib/badline/frontend/menu/menu_pages.rb +16 -11
  72. data/lib/badline/frontend/menu/menu_ports.rb +13 -1
  73. data/lib/badline/frontend/player/player_controller.rb +11 -4
  74. data/lib/badline/frontend/screen.rb +33 -12
  75. data/lib/badline/frontend/screens.rb +2 -1
  76. data/lib/badline/frontend/sound.rb +4 -4
  77. data/lib/badline/frontend/timeline.rb +19 -6
  78. data/lib/badline/machine/settling.rb +1 -1
  79. data/lib/badline/machine.rb +30 -6
  80. data/lib/badline/media/plus4_media.rb +68 -0
  81. data/lib/badline/media/program.rb +20 -6
  82. data/lib/badline/media/true_drive.rb +7 -5
  83. data/lib/badline/media.rb +33 -12
  84. data/lib/badline/options/family.rb +1 -0
  85. data/lib/badline/options/help.rb +32 -6
  86. data/lib/badline/options/option.rb +2 -1
  87. data/lib/badline/options/table.rb +29 -4
  88. data/lib/badline/options/validation.rb +66 -4
  89. data/lib/badline/options.rb +71 -11
  90. data/lib/badline/plus4/acia/frames.rb +55 -0
  91. data/lib/badline/plus4/acia.rb +276 -16
  92. data/lib/badline/plus4/bus.rb +245 -46
  93. data/lib/badline/plus4/cassette_sense.rb +21 -0
  94. data/lib/badline/plus4/keyboard_port.rb +35 -10
  95. data/lib/badline/plus4/keyed_modules.rb +116 -0
  96. data/lib/badline/plus4/keyed_parts.rb +172 -0
  97. data/lib/badline/plus4/keyed_state.rb +44 -0
  98. data/lib/badline/plus4/ram_expansion.rb +145 -0
  99. data/lib/badline/plus4/sid_card.rb +95 -0
  100. data/lib/badline/plus4/sound_mix.rb +51 -0
  101. data/lib/badline/plus4/tcbm_drive.rb +120 -0
  102. data/lib/badline/plus4/user_port.rb +11 -2
  103. data/lib/badline/plus4.rb +184 -26
  104. data/lib/badline/roms/README +9 -0
  105. data/lib/badline/roms/dos1551.rom +0 -0
  106. data/lib/badline/snapshot/container.rb +2 -0
  107. data/lib/badline/snapshot/field_doc/markdown.rb +7 -6
  108. data/lib/badline/snapshot/field_doc.rb +48 -7
  109. data/lib/badline/snapshot/image.rb +12 -3
  110. data/lib/badline/snapshot/plus4_setup.rb +81 -0
  111. data/lib/badline/snapshot.rb +9 -4
  112. data/lib/badline/storage/tap.rb +21 -12
  113. data/lib/badline/support/checkpoint.rb +3 -2
  114. data/lib/badline/support/plus4_checkpoint.rb +42 -0
  115. data/lib/badline/version.rb +1 -1
  116. metadata +29 -1
@@ -19,10 +19,12 @@ module Badline
19
19
  # The file it was read from, expanded, and the file's bytes.
20
20
  attr_reader :version, :platform, :path, :bytes
21
21
 
22
- # A blank version 1 tape for `platform` (0 C64, 1 VIC-20) at `path`,
23
- # written to the host file.
22
+ # A blank tape for `platform` at `path`, written to the host file: a
23
+ # version 1 tape for the C64 (0) or the VIC-20 (1), and a version 2
24
+ # C16 tape for the 264 series (2).
24
25
  def self.create(path, platform:)
25
- File.binwrite(path, (SIGNATURE + [1, platform, 0, 0, 0, 0, 0, 0]).pack("C*"))
26
+ header = platform == 2 ? C16_SIGNATURE + [2] : SIGNATURE + [1]
27
+ File.binwrite(path, (header + [platform, 0, 0, 0, 0, 0, 0]).pack("C*"))
26
28
  new(path)
27
29
  end
28
30
 
@@ -61,15 +63,16 @@ module Badline
61
63
  # cycle count for a long one (a lone zero, an overflow, on a version 0
62
64
  # tape). A version 2 tape records it as two equal halves.
63
65
  def record_pulse(cycles)
64
- @bytes.slice!(@pos..)
65
- if version == 2
66
- half = cycles / 2
67
- @bytes.concat(encode(cycles - half))
68
- @bytes.concat(encode(half))
69
- else
70
- @bytes.concat(encode(cycles))
71
- end
72
- @pos = @end = @bytes.length
66
+ return record(encode(cycles)) unless version == 2
67
+
68
+ half = cycles / 2
69
+ record(encode(cycles - half) + encode(half))
70
+ end
71
+
72
+ # Records a half wave `cycles` long at the position, in place of the
73
+ # rest of the tape, as a version 2 tape times them.
74
+ def record_half_wave(cycles)
75
+ record(encode(cycles))
73
76
  end
74
77
 
75
78
  # Writes the tape back to its host file, with the data size the
@@ -111,6 +114,12 @@ module Badline
111
114
  version.zero? ? OVERFLOW : long_pulse
112
115
  end
113
116
 
117
+ def record(times)
118
+ @bytes.slice!(@pos..)
119
+ @bytes.concat(times)
120
+ @pos = @end = @bytes.length
121
+ end
122
+
114
123
  def encode(cycles)
115
124
  units = (cycles + 4) / 8
116
125
  return [units] if units.between?(1, 0xff)
@@ -9,8 +9,9 @@ module Badline
9
9
  # interface, so taking a checkpoint leaves the machine as it was.
10
10
  #
11
11
  # Checkpoint.take digests a C64's components, COMPONENTS.
12
- # Vic20Checkpoint and C128Checkpoint digest the other families', each
13
- # with a list of its own, which a checkpoint carries as +components+.
12
+ # Vic20Checkpoint, C128Checkpoint and Plus4Checkpoint digest the other
13
+ # families', each with a list of its own, which a checkpoint carries as
14
+ # +components+.
14
15
  #
15
16
  # Colour RAM is digested as the four bits each cell stores: the upper
16
17
  # nibble a CPU read sees comes off the open bus.
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Badline
4
+ module Support
5
+ # A Checkpoint of a 264 series machine: its CPU, its RAM, the TED's
6
+ # picture, the TED's registers, timers and beam, its sound, and the
7
+ # CPU's port with the ROM banks. The sound's voices are run up to the
8
+ # cycle to read them, which changes nothing they do.
9
+ module Plus4Checkpoint
10
+ COMPONENTS = %w[cpu ram display ted sound port].freeze
11
+
12
+ def self.take(machine)
13
+ ram = machine.ram
14
+ Checkpoint.new(machine.cycles, [
15
+ Checkpoint.fnv1a(Checkpoint.cpu_state(machine.cpu)),
16
+ Checkpoint.fnv1a(Checkpoint.ram(ram, ram.length)),
17
+ Checkpoint.fnv1a(machine.ted.display),
18
+ Checkpoint.fnv1a(ted_state(machine.ted)),
19
+ Checkpoint.fnv1a(sound_state(machine.sound)),
20
+ Checkpoint.fnv1a(port_state(machine))
21
+ ], COMPONENTS)
22
+ end
23
+
24
+ def self.parse(line) = Checkpoint.parse(line, COMPONENTS)
25
+
26
+ def self.ted_state(ted)
27
+ Array.new(0x20) { |register| ted.peek(0xff00 + register) } +
28
+ ted.timer_counts + [ted.line, ted.column, ted.interrupt_flags, ted.cpu_slots]
29
+ end
30
+
31
+ def self.sound_state(sound)
32
+ [sound.noise, sound.phase(0), sound.phase(1), sound.level, sound.volume, sound.control]
33
+ end
34
+
35
+ def self.port_state(machine)
36
+ port = machine.port
37
+ bus = machine.bus
38
+ [port.ddr, port.data, bus.low_bank, bus.high_bank, bus.rom_selected ? 1 : 0]
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Badline
4
- VERSION = "0.14.0"
4
+ VERSION = "0.15.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: badline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.15.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Inge Jørgensen
@@ -182,6 +182,13 @@ files:
182
182
  - lib/badline/chips/sid/waveform/noise_writeback.rb
183
183
  - lib/badline/chips/ted.rb
184
184
  - lib/badline/chips/ted/beam.rb
185
+ - lib/badline/chips/ted/fetches.rb
186
+ - lib/badline/chips/ted/keyed_state.rb
187
+ - lib/badline/chips/ted/modes.rb
188
+ - lib/badline/chips/ted/palette.rb
189
+ - lib/badline/chips/ted/picture.rb
190
+ - lib/badline/chips/ted/sound.rb
191
+ - lib/badline/chips/ted/sound/output.rb
185
192
  - lib/badline/chips/ted/timers.rb
186
193
  - lib/badline/chips/tia.rb
187
194
  - lib/badline/chips/vdc.rb
@@ -252,6 +259,7 @@ files:
252
259
  - lib/badline/drives/engine/idle.rb
253
260
  - lib/badline/drives/engine/idle_cpu.rb
254
261
  - lib/badline/drives/engine/orbit.rb
262
+ - lib/badline/drives/engine/serial_connection.rb
255
263
  - lib/badline/drives/engine/serial_lines.rb
256
264
  - lib/badline/drives/engine/sleep.rb
257
265
  - lib/badline/drives/engine/vias.rb
@@ -269,6 +277,13 @@ files:
269
277
  - lib/badline/drives/model1541/sector_reader.rb
270
278
  - lib/badline/drives/model1541/serial_port.rb
271
279
  - lib/badline/drives/model1541/track.rb
280
+ - lib/badline/drives/model1551.rb
281
+ - lib/badline/drives/model1551/bus.rb
282
+ - lib/badline/drives/model1551/cable.rb
283
+ - lib/badline/drives/model1551/cpu.rb
284
+ - lib/badline/drives/model1551/keyed_state.rb
285
+ - lib/badline/drives/model1551/port.rb
286
+ - lib/badline/drives/model1551/tia.rb
272
287
  - lib/badline/drives/model1571.rb
273
288
  - lib/badline/drives/model1571/bus.rb
274
289
  - lib/badline/drives/model1571/cpu.rb
@@ -376,6 +391,7 @@ files:
376
391
  - lib/badline/media/disk_set.rb
377
392
  - lib/badline/media/extensions.rb
378
393
  - lib/badline/media/not_disk.rb
394
+ - lib/badline/media/plus4_media.rb
379
395
  - lib/badline/media/program.rb
380
396
  - lib/badline/media/true_drive.rb
381
397
  - lib/badline/media/tune.rb
@@ -393,11 +409,20 @@ files:
393
409
  - lib/badline/options/validation.rb
394
410
  - lib/badline/plus4.rb
395
411
  - lib/badline/plus4/acia.rb
412
+ - lib/badline/plus4/acia/frames.rb
396
413
  - lib/badline/plus4/bus.rb
414
+ - lib/badline/plus4/cassette_sense.rb
397
415
  - lib/badline/plus4/cpu.rb
398
416
  - lib/badline/plus4/cpu_port.rb
399
417
  - lib/badline/plus4/keyboard_port.rb
418
+ - lib/badline/plus4/keyed_modules.rb
419
+ - lib/badline/plus4/keyed_parts.rb
420
+ - lib/badline/plus4/keyed_state.rb
400
421
  - lib/badline/plus4/model.rb
422
+ - lib/badline/plus4/ram_expansion.rb
423
+ - lib/badline/plus4/sid_card.rb
424
+ - lib/badline/plus4/sound_mix.rb
425
+ - lib/badline/plus4/tcbm_drive.rb
401
426
  - lib/badline/plus4/user_port.rb
402
427
  - lib/badline/region.rb
403
428
  - lib/badline/rom.rb
@@ -409,6 +434,7 @@ files:
409
434
  - lib/badline/roms/c64gs.rom
410
435
  - lib/badline/roms/character.rom
411
436
  - lib/badline/roms/dos1541.rom
437
+ - lib/badline/roms/dos1551.rom
412
438
  - lib/badline/roms/dos1571.rom
413
439
  - lib/badline/roms/dos1581.rom
414
440
  - lib/badline/roms/eapi/LICENSE.md
@@ -448,6 +474,7 @@ files:
448
474
  - lib/badline/snapshot/keyed/report.rb
449
475
  - lib/badline/snapshot/keyed/writer.rb
450
476
  - lib/badline/snapshot/machine_state.rb
477
+ - lib/badline/snapshot/plus4_setup.rb
451
478
  - lib/badline/snapshot/storage_setup.rb
452
479
  - lib/badline/snapshot/vic20_setup.rb
453
480
  - lib/badline/snapshot/vice.rb
@@ -485,6 +512,7 @@ files:
485
512
  - lib/badline/support.rb
486
513
  - lib/badline/support/c128_checkpoint.rb
487
514
  - lib/badline/support/checkpoint.rb
515
+ - lib/badline/support/plus4_checkpoint.rb
488
516
  - lib/badline/support/vic20_checkpoint.rb
489
517
  - lib/badline/timing.rb
490
518
  - lib/badline/version.rb