Class: Badline::ControlPorts

Inherits:
Object
  • Object
show all
Defined in:
lib/badline/control_ports.rb

Overview

CIA 1 peripheral combining the keyboard matrix with the control ports.

Joystick switches share the same lines as the keyboard matrix and are wired-AND with it (active low). Port 2 sits on Port A.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(keyboard:, joystick2:) ⇒ ControlPorts

Returns a new instance of ControlPorts.



11
12
13
14
# File 'lib/badline/control_ports.rb', line 11

def initialize(keyboard:, joystick2:)
  @keyboard = keyboard
  @joystick2 = joystick2
end

Instance Attribute Details

#joystick2Object (readonly)

Returns the value of attribute joystick2.



9
10
11
# File 'lib/badline/control_ports.rb', line 9

def joystick2
  @joystick2
end

#keyboardObject (readonly)

Returns the value of attribute keyboard.



9
10
11
# File 'lib/badline/control_ports.rb', line 9

def keyboard
  @keyboard
end

Instance Method Details

#read_a(port_a, port_b) ⇒ Object



16
17
18
# File 'lib/badline/control_ports.rb', line 16

def read_a(port_a, port_b)
  keyboard.read_a(port_a, port_b) & joystick2.port_bits
end

#read_b(port_a, port_b) ⇒ Object



20
21
22
# File 'lib/badline/control_ports.rb', line 20

def read_b(port_a, port_b)
  keyboard.read_b(port_a, port_b)
end