badline 0.16.1 → 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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +213 -0
- data/CLAUDE.md +11 -7
- data/CONTRIBUTING.md +7 -1
- data/README.md +265 -26
- data/doc/media.md +5 -2
- data/doc/pinned-behaviour.md +189 -0
- data/doc/snapshot-format.md +616 -74
- data/doc/snapshots.md +192 -24
- data/exe/badline-ruby +5 -0
- data/lib/badline/audio/terminal.rb +34 -2
- data/lib/badline/c128/keyed_state.rb +2 -0
- data/lib/badline/c128.rb +1 -0
- data/lib/badline/c64/keyed_state.rb +2 -0
- data/lib/badline/c64.rb +1 -0
- data/lib/badline/cbm2/acia.rb +10 -0
- data/lib/badline/cbm2/bus.rb +263 -0
- data/lib/badline/cbm2/cpu.rb +58 -0
- data/lib/badline/cbm2/crtc_video.rb +133 -0
- data/lib/badline/cbm2/ieee_drive.rb +18 -0
- data/lib/badline/cbm2/ieee_layout.rb +69 -0
- data/lib/badline/cbm2/ieee_ports.rb +104 -0
- data/lib/badline/cbm2/ieee_traps.rb +81 -0
- data/lib/badline/cbm2/keyboard_ports.rb +60 -0
- data/lib/badline/cbm2/keyed_modules.rb +67 -0
- data/lib/badline/cbm2/keyed_state.rb +95 -0
- data/lib/badline/cbm2/model.rb +44 -0
- data/lib/badline/cbm2/p500/control_ports.rb +80 -0
- data/lib/badline/cbm2/p500/ieee_layout.rb +41 -0
- data/lib/badline/cbm2/p500/keyed_state.rb +85 -0
- data/lib/badline/cbm2/p500/model.rb +39 -0
- data/lib/badline/cbm2/p500/pages.rb +57 -0
- data/lib/badline/cbm2/p500.rb +264 -0
- data/lib/badline/cbm2/sid_page.rb +19 -0
- data/lib/badline/cbm2.rb +270 -0
- data/lib/badline/{plus4 → chips}/acia/frames.rb +1 -1
- data/lib/badline/chips/acia/keyed_state.rb +47 -0
- data/lib/badline/chips/acia.rb +307 -0
- data/lib/badline/chips/cia/timer.rb +2 -2
- data/lib/badline/chips/cpu/instruction_set.rb +1 -1
- data/lib/badline/chips/crtc.rb +3 -2
- data/lib/badline/chips/m6809/arithmetic.rb +140 -0
- data/lib/badline/chips/m6809/bus_steps.rb +223 -0
- data/lib/badline/chips/m6809/core.rb +149 -0
- data/lib/badline/chips/m6809/indexed.rb +82 -0
- data/lib/badline/chips/m6809/interrupts.rb +159 -0
- data/lib/badline/chips/m6809/keyed_state.rb +147 -0
- data/lib/badline/chips/m6809/opcodes.rb +159 -0
- data/lib/badline/chips/m6809/operations.rb +258 -0
- data/lib/badline/chips/m6809/plans.rb +143 -0
- data/lib/badline/chips/m6809/registers.rb +82 -0
- data/lib/badline/chips/m6809/stack.rb +140 -0
- data/lib/badline/chips/m6809.rb +13 -0
- data/lib/badline/chips/riot/fast_forward.rb +72 -0
- data/lib/badline/chips/riot/keyed_parts.rb +69 -0
- data/lib/badline/chips/riot/timer.rb +91 -0
- data/lib/badline/chips/riot.rb +162 -0
- data/lib/badline/chips/rriot/keyed_state.rb +30 -0
- data/lib/badline/chips/rriot.rb +134 -0
- data/lib/badline/chips/sid/filter.rb +4 -4
- data/lib/badline/chips/sid/waveform.rb +6 -6
- data/lib/badline/chips/tpi/keyed_state.rb +38 -0
- data/lib/badline/chips/tpi.rb +233 -0
- data/lib/badline/chips/vic/bank.rb +60 -5
- data/lib/badline/chips/vic/sprite.rb +4 -3
- data/lib/badline/chips/vic_i/keyed_parts.rb +7 -2
- data/lib/badline/chips/vic_i.rb +84 -21
- data/lib/badline/data_path.rb +3 -3
- data/lib/badline/drives/datasette/keyed_state.rb +9 -1
- data/lib/badline/drives/datasette.rb +27 -3
- data/lib/badline/drives/ieee_models.rb +54 -0
- data/lib/badline/drives/model1001.rb +37 -0
- data/lib/badline/drives/model2031.rb +6 -0
- data/lib/badline/drives/model4040/disk.rb +62 -0
- data/lib/badline/drives/model4040/ip_bus.rb +46 -0
- data/lib/badline/drives/model4040/keyed_state.rb +57 -0
- data/lib/badline/drives/model4040/mechanism.rb +192 -0
- data/lib/badline/drives/model4040/parts.rb +20 -0
- data/lib/badline/drives/model4040.rb +179 -0
- data/lib/badline/drives/model8050/board.rb +77 -0
- data/lib/badline/drives/model8050/disk.rb +163 -0
- data/lib/badline/drives/model8050/dos_board.rb +91 -0
- data/lib/badline/drives/model8050/fdc_bus.rb +102 -0
- data/lib/badline/drives/model8050/idle.rb +181 -0
- data/lib/badline/drives/model8050/ieee_port.rb +147 -0
- data/lib/badline/drives/model8050/ip_bus.rb +93 -0
- data/lib/badline/drives/model8050/keyed_state.rb +163 -0
- data/lib/badline/drives/model8050/mechanism.rb +230 -0
- data/lib/badline/drives/model8050/parts.rb +37 -0
- data/lib/badline/drives/model8050.rb +131 -0
- data/lib/badline/drives/model9060/idle.rb +149 -0
- data/lib/badline/drives/model9060/keyed_state.rb +123 -0
- data/lib/badline/drives/model9060/parts.rb +98 -0
- data/lib/badline/drives/model9060/sasi_bus.rb +88 -0
- data/lib/badline/drives/model9060/sasi_commands.rb +168 -0
- data/lib/badline/drives/model9060/sasi_target.rb +161 -0
- data/lib/badline/drives/model9060.rb +195 -0
- data/lib/badline/frontend/app.rb +18 -3
- data/lib/badline/frontend/boot.rb +4 -3
- data/lib/badline/frontend/controls.rb +107 -15
- data/lib/badline/frontend/gamepads.rb +3 -3
- data/lib/badline/frontend/keys.rb +97 -2
- data/lib/badline/frontend/kim1_panel.rb +208 -0
- data/lib/badline/frontend/media_slots.rb +8 -1
- data/lib/badline/frontend/menu/drive_types.rb +56 -0
- data/lib/badline/frontend/menu/menu_dialogs.rb +61 -14
- data/lib/badline/frontend/menu/menu_media.rb +47 -14
- data/lib/badline/frontend/menu/menu_pages.rb +113 -4
- data/lib/badline/frontend/menu/menu_ports.rb +77 -4
- data/lib/badline/frontend/menu/pause_menu.rb +6 -2
- data/lib/badline/frontend/pet_keyboard.rb +45 -7
- data/lib/badline/frontend/screen.rb +1 -1
- data/lib/badline/frontend/screens.rb +40 -2
- data/lib/badline/frontend/teletype_pane.rb +152 -0
- data/lib/badline/frontend/timeline.rb +49 -11
- data/lib/badline/frontend.rb +3 -0
- data/lib/badline/kernal_trap/dos/disk_commands.rb +80 -0
- data/lib/badline/kernal_trap/dos/status.rb +3 -0
- data/lib/badline/kernal_trap/dos.rb +18 -5
- data/lib/badline/kernal_trap/ieee.rb +4 -2
- data/lib/badline/kernal_trap/ieee_layout.rb +95 -43
- data/lib/badline/kim1/bus.rb +117 -0
- data/lib/badline/kim1/cpu.rb +25 -0
- data/lib/badline/kim1/host_terminal.rb +74 -0
- data/lib/badline/kim1/key_entry.rb +74 -0
- data/lib/badline/kim1/keyed_modules.rb +53 -0
- data/lib/badline/kim1/keyed_state.rb +133 -0
- data/lib/badline/kim1/panel.rb +176 -0
- data/lib/badline/kim1/rriots.rb +28 -0
- data/lib/badline/kim1/sound.rb +29 -0
- data/lib/badline/kim1/tape.rb +116 -0
- data/lib/badline/kim1/teletype.rb +193 -0
- data/lib/badline/kim1.rb +190 -0
- data/lib/badline/machine/ieee_drives.rb +171 -0
- data/lib/badline/machine/keyboard_buffer.rb +20 -3
- data/lib/badline/machine/line_sound.rb +122 -0
- data/lib/badline/machine/settling.rb +4 -0
- data/lib/badline/machine.rb +62 -14
- data/lib/badline/media/cbm2_media.rb +29 -0
- data/lib/badline/media/extensions.rb +8 -4
- data/lib/badline/media/kim1_media.rb +150 -0
- data/lib/badline/media/pet_media.rb +3 -1
- data/lib/badline/media/program.rb +6 -3
- data/lib/badline/media/true_drive.rb +51 -25
- data/lib/badline/media.rb +23 -8
- data/lib/badline/options/family.rb +108 -6
- data/lib/badline/options/help.rb +58 -12
- data/lib/badline/options/table.rb +60 -14
- data/lib/badline/options/validation.rb +71 -11
- data/lib/badline/options.rb +46 -13
- data/lib/badline/pet/bus.rb +16 -2
- data/lib/badline/pet/cassettes.rb +22 -1
- data/lib/badline/pet/ieee_drive.rb +5 -64
- data/lib/badline/pet/ieee_ports.rb +7 -0
- data/lib/badline/pet/keyboard_ports.rb +9 -2
- data/lib/badline/pet/keyed_state.rb +4 -0
- data/lib/badline/pet/model.rb +11 -2
- data/lib/badline/pet/rom_sets.rb +1 -0
- data/lib/badline/pet/sound.rb +5 -105
- data/lib/badline/pet/superpet/acia.rb +12 -0
- data/lib/badline/pet/superpet/board.rb +221 -0
- data/lib/badline/pet/superpet/dongle.rb +81 -0
- data/lib/badline/pet/superpet/keyed_modules.rb +63 -0
- data/lib/badline/pet/superpet/keyed_parts.rb +76 -0
- data/lib/badline/pet/superpet/m6809.rb +32 -0
- data/lib/badline/pet/superpet/waterloo_traps.rb +199 -0
- data/lib/badline/pet/superpet.rb +216 -0
- data/lib/badline/pet.rb +33 -6
- data/lib/badline/plus4/acia.rb +4 -298
- data/lib/badline/plus4/keyed_parts.rb +0 -44
- data/lib/badline/plus4/keyed_state.rb +2 -0
- data/lib/badline/plus4.rb +2 -0
- data/lib/badline/roms/1001/fdc-251257-02a.rom +0 -0
- data/lib/badline/roms/4040/dos-1.2.rom +0 -0
- data/lib/badline/roms/4040/dos-2.1-rev.rom +0 -0
- data/lib/badline/roms/4040/dos-2.1.rom +0 -0
- data/lib/badline/roms/4040/fdc-901466-02.rom +0 -0
- data/lib/badline/roms/4040/fdc-901466-04.rom +0 -0
- data/lib/badline/roms/8050/dos-2.7.rom +0 -0
- data/lib/badline/roms/8050/fdc-901869-01.rom +0 -0
- data/lib/badline/roms/8050/fdc-901885-04.rom +0 -0
- data/lib/badline/roms/9060/dos-3.0.rom +0 -0
- data/lib/badline/roms/9060/sasi-300515-revb.rom +0 -0
- data/lib/badline/roms/README +277 -0
- data/lib/badline/roms/cbm2/basic128-02b.rom +0 -0
- data/lib/badline/roms/cbm2/basic128.rom +0 -0
- data/lib/badline/roms/cbm2/basic256.rom +0 -0
- data/lib/badline/roms/cbm2/characters-600.rom +0 -0
- data/lib/badline/roms/cbm2/characters-700.rom +0 -0
- data/lib/badline/roms/cbm2/kernal-03b.rom +0 -0
- data/lib/badline/roms/cbm2/kernal-04a.rom +0 -0
- data/lib/badline/roms/cbm2/p500-basic.rom +0 -0
- data/lib/badline/roms/cbm2/p500-kernal.rom +0 -0
- data/lib/badline/roms/kim1/6530-002.rom +0 -0
- data/lib/badline/roms/kim1/6530-003.rom +0 -0
- data/lib/badline/roms/pet/characters-superpet.rom +0 -0
- data/lib/badline/roms/pet/superpet-a000.rom +0 -0
- data/lib/badline/roms/pet/superpet-c000.rom +0 -0
- data/lib/badline/roms/pet/superpet-e000-50hz.rom +0 -0
- data/lib/badline/roms/pet/superpet-e000.rom +0 -0
- data/lib/badline/snapshot/cbm2_setup.rb +53 -0
- data/lib/badline/snapshot/container.rb +9 -2
- data/lib/badline/snapshot/field_doc/markdown.rb +4 -2
- data/lib/badline/snapshot/field_doc.rb +59 -3
- data/lib/badline/snapshot/image.rb +65 -9
- data/lib/badline/snapshot/kim1_setup.rb +28 -0
- data/lib/badline/snapshot/pet_setup.rb +27 -11
- data/lib/badline/snapshot/storage_setup.rb +4 -1
- data/lib/badline/snapshot/vic20_setup.rb +11 -7
- data/lib/badline/snapshot/vice/cbm2.rb +93 -0
- data/lib/badline/snapshot/vice/cbm2_acia.rb +75 -0
- data/lib/badline/snapshot/vice/cbm2_crtc.rb +127 -0
- data/lib/badline/snapshot/vice/cbm2_mains.rb +49 -0
- data/lib/badline/snapshot/vice/cbm2_mem.rb +75 -0
- data/lib/badline/snapshot/vice/cbm2_restore.rb +204 -0
- data/lib/badline/snapshot/vice/cbm2_tpi.rb +58 -0
- data/lib/badline/snapshot/vice/cias.rb +13 -9
- data/lib/badline/snapshot/vice/p500.rb +96 -0
- data/lib/badline/snapshot/vice/p500_restore.rb +130 -0
- data/lib/badline/snapshot/vice/p500_vicii.rb +166 -0
- data/lib/badline/snapshot/vice/pet.rb +20 -10
- data/lib/badline/snapshot/vice/pet_cpu.rb +42 -5
- data/lib/badline/snapshot/vice/pet_crtc.rb +25 -17
- data/lib/badline/snapshot/vice/pet_drive.rb +180 -0
- data/lib/badline/snapshot/vice/pet_drive8050.rb +336 -0
- data/lib/badline/snapshot/vice/pet_mem.rb +49 -5
- data/lib/badline/snapshot/vice/pet_restore.rb +100 -7
- data/lib/badline/snapshot/vice/pet_via.rb +6 -5
- data/lib/badline/snapshot/vice/sid_registers.rb +2 -1
- data/lib/badline/snapshot/vice/vicii_import.rb +10 -6
- data/lib/badline/snapshot/vice.rb +3 -0
- data/lib/badline/snapshot.rb +15 -3
- data/lib/badline/status.rb +30 -30
- data/lib/badline/storage/crt_file.rb +7 -1
- data/lib/badline/storage/d64_image.rb +7 -0
- data/lib/badline/storage/d67_image.rb +55 -0
- data/lib/badline/storage/d80_image.rb +17 -1
- data/lib/badline/storage/d81_image.rb +14 -0
- data/lib/badline/storage/d90_image.rb +180 -0
- data/lib/badline/storage/disk_image/bam.rb +18 -3
- data/lib/badline/storage/disk_image/formatting.rb +69 -0
- data/lib/badline/storage/disk_image/writing.rb +37 -2
- data/lib/badline/storage/disk_image.rb +2 -0
- data/lib/badline/storage/kim_tape.rb +254 -0
- data/lib/badline/storage/papertape.rb +90 -0
- data/lib/badline/storage.rb +5 -0
- data/lib/badline/support/cbm2_checkpoint.rb +48 -0
- data/lib/badline/support/kim1_checkpoint.rb +41 -0
- data/lib/badline/support/p500_checkpoint.rb +35 -0
- data/lib/badline/support/superpet_checkpoint.rb +35 -0
- data/lib/badline/version.rb +1 -1
- data/lib/badline/vic20/keyed_modules.rb +6 -3
- data/lib/badline/vic20/keyed_state.rb +6 -4
- data/lib/badline/vic20.rb +26 -12
- data/lib/badline.rb +2 -0
- metadata +148 -2
data/lib/badline/plus4/acia.rb
CHANGED
|
@@ -1,305 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "badline/plus4/acia/frames"
|
|
4
|
-
|
|
5
3
|
module Badline
|
|
6
4
|
class Plus4
|
|
7
|
-
# The Plus/4's 6551
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
|
|
11
|
-
# $FD02 - the command register
|
|
12
|
-
# $FD03 - the control register
|
|
13
|
-
#
|
|
14
|
-
# Status: bit 0 a parity error, 1 a framing error, 2 an overrun, 3 the
|
|
15
|
-
# receiver full, 4 the transmitter empty, 5 DCD and 6 DSR as their pins
|
|
16
|
-
# read (1 high, not asserted), 7 an interrupt. Reading it clears bit 7.
|
|
17
|
-
#
|
|
18
|
-
# Command: bit 0 DTR, which also enables the receiver and every
|
|
19
|
-
# interrupt, bit 1 set disables the receiver's interrupt, bits 2-3 the
|
|
20
|
-
# transmitter (00 off with RTS high, 01 on with its interrupt, 10 on
|
|
21
|
-
# without, 11 sending a break), bit 4 echoes what is received, bits 5-7
|
|
22
|
-
# the parity.
|
|
23
|
-
#
|
|
24
|
-
# Control: bits 0-3 the baud rate from the 1.8432 MHz crystal (0, the
|
|
25
|
-
# 16x external clock, runs straight from the crystal, 115,200 baud),
|
|
26
|
-
# bit 4 the receiver's clock (0 the RxC pin, which nothing drives on the
|
|
27
|
-
# Plus/4, so the receiver hears nothing), bits 5-6 the word length (8
|
|
28
|
-
# down to 5 bits) and bit 7 the stop bits (Frames).
|
|
29
|
-
#
|
|
30
|
-
# The transmitter runs in whole characters while it is on: at the end
|
|
31
|
-
# of each it hands the character it shifted out to the line, moves a
|
|
32
|
-
# waiting byte from the data register into the shift register and sets
|
|
33
|
-
# the transmitter empty, and with its interrupt on interrupts while the
|
|
34
|
-
# register is empty, every character until a byte comes. The first
|
|
35
|
-
# character ends a character's time after the transmitter comes on.
|
|
36
|
-
# The receiver takes a character's time for each byte the line sends,
|
|
37
|
-
# and a byte that arrives while the last is unread is lost to an
|
|
38
|
-
# overrun. The receiver full, and DCD or DSR changing, interrupt unless
|
|
39
|
-
# bit 1 disables it.
|
|
40
|
-
#
|
|
41
|
-
# The user port carries no CTS, so the transmitter is always clear to
|
|
42
|
-
# send; the KERNAL takes the user port's 6529 P1 as its handshake.
|
|
43
|
-
#
|
|
44
|
-
# What is on the other end of the user port (#plug): nothing, where
|
|
45
|
-
# DCD and DSR read high and what is sent goes nowhere; a terminal,
|
|
46
|
-
# which asserts DCD and DSR, sends what the host feeds it (#feed) while
|
|
47
|
-
# DTR is asserted and keeps what it receives for the host to drain
|
|
48
|
-
# (#drain); or a loopback plug, which returns TxD to RxD and DTR to DSR
|
|
49
|
-
# and DCD.
|
|
50
|
-
#
|
|
51
|
-
# The machine runs the ACIA at the cycle it next has something to do
|
|
52
|
-
# (#due) through #run!, and learns its IRQ line and that cycle from
|
|
53
|
-
# `clock`'s #acia_changed, whose #cycles is the time.
|
|
54
|
-
class ACIA
|
|
55
|
-
include Frames
|
|
56
|
-
|
|
57
|
-
PARITY_ERROR = 0x01
|
|
58
|
-
FRAMING_ERROR = 0x02
|
|
59
|
-
OVERRUN = 0x04
|
|
60
|
-
RECEIVER_FULL = 0x08
|
|
61
|
-
TRANSMITTER_EMPTY = 0x10
|
|
62
|
-
DCD = 0x20
|
|
63
|
-
DSR = 0x40
|
|
64
|
-
IRQ = 0x80
|
|
65
|
-
|
|
66
|
-
NOTHING = 0
|
|
67
|
-
TERMINAL = 1
|
|
68
|
-
LOOPBACK = 2
|
|
69
|
-
|
|
70
|
-
# No shift in progress.
|
|
71
|
-
IDLE = -1
|
|
72
|
-
|
|
73
|
-
# Far enough ahead that it never comes.
|
|
74
|
-
NEVER = 1 << 60
|
|
75
|
-
|
|
76
|
-
attr_reader :command, :control, :device, :due
|
|
77
|
-
|
|
78
|
-
def initialize(clock, clock_hz)
|
|
79
|
-
@clock = clock
|
|
80
|
-
@clock_hz = clock_hz
|
|
81
|
-
@device = NOTHING
|
|
82
|
-
@incoming = []
|
|
83
|
-
@received = []
|
|
84
|
-
reset!
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
# The RES line: every register cleared, the transmitter empty and
|
|
88
|
-
# both shift registers stopped.
|
|
89
|
-
def reset!
|
|
90
|
-
@command = 0
|
|
91
|
-
@control = 0
|
|
92
|
-
@errors = 0
|
|
93
|
-
@receiver_full = false
|
|
94
|
-
@transmitter_empty = true
|
|
95
|
-
@irq = false
|
|
96
|
-
@receive_data = 0
|
|
97
|
-
@transmit_data = 0
|
|
98
|
-
@shifting = IDLE
|
|
99
|
-
@transmit_at = NEVER
|
|
100
|
-
@transmit_remainder = 0
|
|
101
|
-
@receive_at = NEVER
|
|
102
|
-
@receive_remainder = 0
|
|
103
|
-
@clock_lost = false
|
|
104
|
-
@lines = modem_lines
|
|
105
|
-
changed
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
def irq? = @irq
|
|
109
|
-
|
|
110
|
-
# DTR and RTS as asserted, low on the pins.
|
|
111
|
-
def dtr? = @command.anybits?(0x01)
|
|
112
|
-
|
|
113
|
-
def rts? = @command.anybits?(0x0c)
|
|
114
|
-
|
|
115
|
-
# Whether the transmitter sends a break, holding TxD low.
|
|
116
|
-
def break? = @command & 0x0c == 0x0c
|
|
117
|
-
|
|
118
|
-
# Plugs NOTHING, a TERMINAL or a LOOPBACK plug into the user port.
|
|
119
|
-
def plug(device)
|
|
120
|
-
@device = device
|
|
121
|
-
@incoming.clear
|
|
122
|
-
lines_changed
|
|
123
|
-
start_receiving
|
|
124
|
-
changed
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
# Bytes the terminal sends, one a character's time while DTR is
|
|
128
|
-
# asserted.
|
|
129
|
-
def feed(bytes)
|
|
130
|
-
return unless @device == TERMINAL
|
|
131
|
-
|
|
132
|
-
@incoming.concat(bytes)
|
|
133
|
-
start_receiving
|
|
134
|
-
changed
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
# What the terminal has received since the last drain.
|
|
138
|
-
def drain
|
|
139
|
-
received = @received
|
|
140
|
-
@received = []
|
|
141
|
-
received
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
# Runs what falls due up to cycle `now`: the transmitter's character
|
|
145
|
-
# ends, then the receiver's.
|
|
146
|
-
def run!(now)
|
|
147
|
-
end_character while @transmit_at <= now
|
|
148
|
-
receive_character while @receive_at <= now
|
|
149
|
-
changed
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
def peek(addr)
|
|
153
|
-
case addr & 0x03
|
|
154
|
-
when 0
|
|
155
|
-
@receiver_full = false
|
|
156
|
-
@receive_data
|
|
157
|
-
when 1 then read_status
|
|
158
|
-
when 2 then @command
|
|
159
|
-
else @control
|
|
160
|
-
end
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
def poke(addr, value)
|
|
164
|
-
case addr & 0x03
|
|
165
|
-
when 0 then write_data(value)
|
|
166
|
-
when 1 then write_command(@command & 0xe0, clear_overrun: true)
|
|
167
|
-
when 2 then write_command(value)
|
|
168
|
-
else @control = value
|
|
169
|
-
end
|
|
170
|
-
changed
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
# The status as a read finds it, without clearing the interrupt.
|
|
174
|
-
def status
|
|
175
|
-
status = @errors | (@lines & (DCD | DSR))
|
|
176
|
-
status |= RECEIVER_FULL if @receiver_full
|
|
177
|
-
status |= TRANSMITTER_EMPTY if @transmitter_empty
|
|
178
|
-
@irq ? status | IRQ : status
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
private
|
|
182
|
-
|
|
183
|
-
def read_status
|
|
184
|
-
value = status
|
|
185
|
-
@irq = false
|
|
186
|
-
changed
|
|
187
|
-
value
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
def write_data(value)
|
|
191
|
-
@transmit_data = value
|
|
192
|
-
@transmitter_empty = false
|
|
193
|
-
end
|
|
194
|
-
|
|
195
|
-
def write_command(value, clear_overrun: false)
|
|
196
|
-
was_on = transmitter_on?
|
|
197
|
-
@command = value
|
|
198
|
-
@errors &= ~OVERRUN if clear_overrun
|
|
199
|
-
start_transmitting if transmitter_on? && !was_on
|
|
200
|
-
stop_transmitting unless transmitter_on? || @shifting != IDLE
|
|
201
|
-
lines_changed
|
|
202
|
-
start_receiving
|
|
203
|
-
end
|
|
204
|
-
|
|
205
|
-
def transmitter_on?
|
|
206
|
-
control = @command & 0x0c
|
|
207
|
-
control != 0 && control != 0x0c
|
|
208
|
-
end
|
|
209
|
-
|
|
210
|
-
def interrupts? = @command.anybits?(0x01)
|
|
211
|
-
|
|
212
|
-
def receiver_interrupts? = @command & 0x03 == 0x01
|
|
213
|
-
|
|
214
|
-
def transmitter_interrupts? = @command & 0x0d == 0x05
|
|
215
|
-
|
|
216
|
-
def receiving? = dtr? && @control.anybits?(0x10)
|
|
217
|
-
|
|
218
|
-
def start_transmitting
|
|
219
|
-
@transmit_remainder = 0
|
|
220
|
-
@transmit_at = after(@clock.cycles, true)
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
def stop_transmitting
|
|
224
|
-
@transmit_at = NEVER
|
|
225
|
-
end
|
|
226
|
-
|
|
227
|
-
# A character's end: the character shifted out goes to the line, and
|
|
228
|
-
# the transmitter takes the next byte or interrupts while it has none.
|
|
229
|
-
def end_character
|
|
230
|
-
sent = @shifting
|
|
231
|
-
@shifting = IDLE
|
|
232
|
-
deliver(sent) unless sent == IDLE
|
|
233
|
-
on = transmitter_on?
|
|
234
|
-
if on && !@transmitter_empty
|
|
235
|
-
@shifting = @transmit_data & word_mask
|
|
236
|
-
@transmitter_empty = true
|
|
237
|
-
end
|
|
238
|
-
@irq = true if on && @transmitter_empty && transmitter_interrupts?
|
|
239
|
-
if on || @shifting != IDLE
|
|
240
|
-
@transmit_at = after(@transmit_at, true)
|
|
241
|
-
else
|
|
242
|
-
stop_transmitting
|
|
243
|
-
end
|
|
244
|
-
end
|
|
245
|
-
|
|
246
|
-
def deliver(byte)
|
|
247
|
-
case @device
|
|
248
|
-
when TERMINAL then @received << byte
|
|
249
|
-
when LOOPBACK then take(byte) if receiving?
|
|
250
|
-
end
|
|
251
|
-
end
|
|
252
|
-
|
|
253
|
-
def start_receiving
|
|
254
|
-
return unless @receive_at == NEVER && !@incoming.empty? && receiving?
|
|
255
|
-
|
|
256
|
-
@receive_remainder = 0
|
|
257
|
-
@receive_at = after(@clock.cycles, false)
|
|
258
|
-
end
|
|
259
|
-
|
|
260
|
-
def receive_character
|
|
261
|
-
byte = @incoming[0]
|
|
262
|
-
@incoming.delete_at(0)
|
|
263
|
-
take(byte)
|
|
264
|
-
@receive_at = !@incoming.empty? && receiving? ? after(@receive_at, false) : NEVER
|
|
265
|
-
end
|
|
266
|
-
|
|
267
|
-
# A whole character in from RxD: into the data register, or lost to
|
|
268
|
-
# an overrun while the last is unread. In echo mode it goes back out
|
|
269
|
-
# to the terminal.
|
|
270
|
-
def take(byte)
|
|
271
|
-
if @receiver_full
|
|
272
|
-
@errors |= OVERRUN
|
|
273
|
-
else
|
|
274
|
-
@receive_data = byte & word_mask
|
|
275
|
-
@receiver_full = true
|
|
276
|
-
@errors = 0
|
|
277
|
-
end
|
|
278
|
-
@received << byte if @device == TERMINAL && @command & 0x1c == 0x10
|
|
279
|
-
@irq = true if receiver_interrupts?
|
|
280
|
-
end
|
|
281
|
-
|
|
282
|
-
# DCD and DSR as the device drives them, interrupting on a change.
|
|
283
|
-
def lines_changed
|
|
284
|
-
lines = modem_lines
|
|
285
|
-
return if lines == @lines
|
|
286
|
-
|
|
287
|
-
@lines = lines
|
|
288
|
-
@irq = true if receiver_interrupts?
|
|
289
|
-
end
|
|
290
|
-
|
|
291
|
-
def modem_lines
|
|
292
|
-
case @device
|
|
293
|
-
when TERMINAL then 0
|
|
294
|
-
when LOOPBACK then dtr? ? 0 : DCD | DSR
|
|
295
|
-
else DCD | DSR
|
|
296
|
-
end
|
|
297
|
-
end
|
|
298
|
-
|
|
299
|
-
def changed
|
|
300
|
-
@due = [@transmit_at, @receive_at].min
|
|
301
|
-
@clock.acia_changed(@irq && interrupts?, @due)
|
|
302
|
-
end
|
|
5
|
+
# The Plus/4's 6551 at $FD00-$FD0F, on the user port. Nothing drives
|
|
6
|
+
# its RxC pin, and the user port carries no CTS; the KERNAL takes the
|
|
7
|
+
# user port's 6529 P1 as its handshake.
|
|
8
|
+
class ACIA < Chips::ACIA
|
|
303
9
|
end
|
|
304
10
|
end
|
|
305
11
|
end
|
|
@@ -52,50 +52,6 @@ module Badline
|
|
|
52
52
|
include KeyedState
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
-
class ACIA
|
|
56
|
-
# The registers, the status, the shift register and when the
|
|
57
|
-
# transmitter's character ends, in a keyed snapshot module (BL-ACIA).
|
|
58
|
-
# What the device on the user port has still to send stays with the
|
|
59
|
-
# host, and the receiver starts on it again once loaded (#restored!).
|
|
60
|
-
# A snapshot from before the transmitter's timing was saved starts
|
|
61
|
-
# its character clock on load.
|
|
62
|
-
module KeyedState
|
|
63
|
-
def save_fields(out)
|
|
64
|
-
out.int("command", @command).int("control", @control).int("errors", @errors)
|
|
65
|
-
out.bool("receiver_full", @receiver_full).bool("transmitter_empty", @transmitter_empty).bool("irq", @irq)
|
|
66
|
-
out.int("receive_data", @receive_data).int("transmit_data", @transmit_data).int("shifting", @shifting)
|
|
67
|
-
out.int("transmit_at", @transmit_at).int("transmit_remainder", @transmit_remainder)
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def load_fields(input)
|
|
71
|
-
@command = input.byte("command", @command)
|
|
72
|
-
@control = input.byte("control", @control)
|
|
73
|
-
@errors = input.masked("errors", 0, PARITY_ERROR | FRAMING_ERROR | OVERRUN)
|
|
74
|
-
@receiver_full = input.bool("receiver_full", false)
|
|
75
|
-
@transmitter_empty = input.bool("transmitter_empty", true)
|
|
76
|
-
@irq = input.bool("irq", false)
|
|
77
|
-
@receive_data = input.byte("receive_data", 0)
|
|
78
|
-
@transmit_data = input.byte("transmit_data", 0)
|
|
79
|
-
@shifting = input.int("shifting", IDLE)
|
|
80
|
-
@transmit_remainder = input.int("transmit_remainder", 0)
|
|
81
|
-
transmit_at = input.optional_int("transmit_at")
|
|
82
|
-
@transmit_at = transmit_at || NEVER
|
|
83
|
-
@clock_lost = transmit_at.nil?
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def restored!
|
|
87
|
-
@receive_at = NEVER
|
|
88
|
-
@lines = modem_lines
|
|
89
|
-
start_transmitting if @clock_lost && transmitter_on?
|
|
90
|
-
@clock_lost = false
|
|
91
|
-
start_receiving
|
|
92
|
-
changed
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
include KeyedState
|
|
97
|
-
end
|
|
98
|
-
|
|
99
55
|
class Bus
|
|
100
56
|
# The ROM bank latch, whether ROM is selected and the last byte on the
|
|
101
57
|
# bus, under `prefix`, and the cartridges' ROMs by slot (#save_slot_fields),
|
|
@@ -28,6 +28,7 @@ module Badline
|
|
|
28
28
|
out.int("cycles", @cycles)
|
|
29
29
|
pending = @pending_keys
|
|
30
30
|
out.ints("host.pending_keys", pending) if pending
|
|
31
|
+
save_init_keys(out)
|
|
31
32
|
out.int("host.init_pending", booting? ? @init_handlers.length : 0)
|
|
32
33
|
out.text("host.true_drive_model", @true_drive_model)
|
|
33
34
|
end
|
|
@@ -36,6 +37,7 @@ module Badline
|
|
|
36
37
|
@cycles = input.int("cycles", @cycles)
|
|
37
38
|
pending = input.ints("host.pending_keys", [])
|
|
38
39
|
@pending_keys = pending.empty? ? nil : pending.dup
|
|
40
|
+
load_init_keys(input)
|
|
39
41
|
@init_handlers_lost = [input.int("host.init_pending", 0) - @init_handlers.length, 0].max
|
|
40
42
|
@true_drive_model = input.choice("host.true_drive_model", TCBMDrive::TRUE_DRIVE_MODELS, @true_drive_model)
|
|
41
43
|
end
|
data/lib/badline/plus4.rb
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "badline/chips/ted"
|
|
4
4
|
require "badline/chips/tia"
|
|
5
|
+
require "badline/chips/acia"
|
|
5
6
|
require "badline/drives/model1551"
|
|
6
7
|
require "badline/plus4/model"
|
|
7
8
|
require "badline/plus4/cpu"
|
|
@@ -143,6 +144,7 @@ module Badline
|
|
|
143
144
|
@sound_mix = @sid_card ? SoundMix.new(@sound, @sid_card) : nil
|
|
144
145
|
@init_handlers = []
|
|
145
146
|
@pending_keys = nil
|
|
147
|
+
@init_keys = nil
|
|
146
148
|
@dos = nil
|
|
147
149
|
@serial_trap = nil
|
|
148
150
|
@save_trap = nil
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|