Class: MicroCisc::Vm::TermDevice
- Inherits:
-
Device
- Object
- Device
- MicroCisc::Vm::TermDevice
show all
- Defined in:
- lib/micro_cisc/vm/term_device.rb
Instance Attribute Summary
Attributes inherited from Device
#id
Instance Method Summary
collapse
Methods inherited from Device
#bank_index=, #banked?, #devices=, #read_control, #read_mem, #source_halted, #write_control, #write_mem
Constructor Details
#initialize(device_id) ⇒ TermDevice
Returns a new instance of TermDevice.
4
5
6
7
8
9
|
# File 'lib/micro_cisc/vm/term_device.rb', line 4
def initialize(device_id)
super(device_id, 9, 1)
@privileged_read = @privileged_read | 0xE0
@privileged_write = @privileged_write | 0x20
end
|
Instance Method Details
#handle_control_read(address) ⇒ Object
15
16
17
18
19
20
21
22
|
# File 'lib/micro_cisc/vm/term_device.rb', line 15
def handle_control_read(address)
case(address)
when 7
@control_mem[7] = TTY::Screen.width
when 8
@control_mem[8] = TTY::Screen.height
end
end
|
#handle_control_update(address, value) ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'lib/micro_cisc/vm/term_device.rb', line 24
def handle_control_update(address, value)
if address == 5
words = (value + 1) / 2
string = @local_mem[0][0...words].pack("S>*")[0...value]
$stdout.write(string)
$stdout.flush
end
end
|
#host_device=(device_id) ⇒ Object
11
12
13
|
# File 'lib/micro_cisc/vm/term_device.rb', line 11
def host_device=(device_id)
@control_mem[2] = device_id
end
|