Class: Badline::ChroutTrap

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

Overview

Observe-only PC trap on the KERNAL CHROUT routine ($FFD2). Records each character written while the KERNAL is banked in, then lets execution fall through to the ROM, so the screen output is unaffected. Used for headless capture of program output.

Constant Summary collapse

ADDRESS =
0xffd2

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cpu:, bus:) ⇒ ChroutTrap

Returns a new instance of ChroutTrap.



13
14
15
16
17
# File 'lib/badline/chrout_trap.rb', line 13

def initialize(cpu:, bus:)
  @cpu = cpu
  @bus = bus
  @output = +""
end

Instance Attribute Details

#outputObject (readonly)

Returns the value of attribute output.



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

def output
  @output
end

Instance Method Details

#callObject



19
20
21
# File 'lib/badline/chrout_trap.rb', line 19

def call
  @output << ascii(@cpu.a) if @bus.io_port.kernal?
end

#inspectObject



23
24
25
# File 'lib/badline/chrout_trap.rb', line 23

def inspect
  "#<#{self.class.name} output=#{@output.inspect}>"
end