Class: MicroCisc::Vm::TermDevice
- Defined in:
- lib/micro_cisc/vm/term_device.rb
Constant Summary
Constants inherited from Device
Device::TYPE_BLOCK_IO, Device::TYPE_BLOCK_MEMORY, Device::TYPE_HID, Device::TYPE_INVALID, Device::TYPE_PROCESSOR, Device::TYPE_SERIAL, Device::TYPE_TERMINAL
Instance Attribute Summary
Attributes inherited from Device
Instance Method Summary collapse
- #handle_control_read(address) ⇒ Object
- #handle_control_update(address, value) ⇒ Object
-
#initialize(device_id) ⇒ TermDevice
constructor
A new instance of TermDevice.
Methods inherited from Device
#bank_index=, #banked?, #devices=, #read_control, #read_mem, #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, Device::TYPE_TERMINAL, 1) # Init device specific read/write controls @privileged_read = @privileged_read | 0x1C0 @privileged_write = @privileged_write | 0x40 end |
Instance Method Details
#handle_control_read(address) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/micro_cisc/vm/term_device.rb', line 11 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
20 21 22 23 24 25 26 27 28 |
# File 'lib/micro_cisc/vm/term_device.rb', line 20 def handle_control_update(address, value) if address == 6 # value is number of bytes to send words = (value + 1) / 2 string = @local_mem[0][0...words].pack("S>*")[0...value] $stdout.write(string) $stdout.flush end end |