kind = sequential
size = 255
immutable_isa = true
no_score = true
unlocks_components = [com_time, com_screen, com_keyboard, com_halt, com_push_button]
copy_solution_to_level = ["symphony_9_aliases"]
unlocks_pages = ["Circuits/The screen", "Circuits/The keyboard"]
shared_data_folder = "symphony"
title = (31337_78454657849319, `IO Devices`)
dialogue = [
  (mentor_centered, (31337_67457044658869, `For this level you need to place three new IO components: the Screen, Time and Keyboard components.

Also link the screen to the RAM component named "Main Memory".
`)),
  (mentor_centered, (31337_29247683714165, `So far IO mode has had only 3 instructions, but now it is time to add several more. This is the updated list of IO instructions:
[left]

[b]Index  Name     Operands       Description[/b]
  0    nop                     Do nothing
  1    in       dest           Input
  2    out      src_A          Output
  3    keyboard dest           Read keyboard value
  4    screen   src_A, src_B   Set screen setting
  5    time_0   dest           Read lower 32 time bits
  6    time_1   dest           Read upper 32 time bits
  7    counter  dest           Read counter value

The details of each new instruction:

[b]keyboard[/b]
The keyboard component has two output pins we want to read "Key Down" and "Key Value". Merge them into one value like so:
D = Key Down
V = Key Value
[highlight]0000000D VVVVVVVV[/highlight]

[b]screen[/b]
The screen has three inputs, "Enable", "Setting index" and "Value". When executing the [highlight]screen[/highlight] instruction, "Enable" pin should be [T], "Setting index" should be the first operand and "Value" the second operand.

[b]time_0[/b] and [b]time_1[/b]
The time component outputs the time since 1st of January 1970 in nano seconds, as a 64 bit number. Since this architecture only deals with 32 bits, reading the value is split into two instructions. However combining times from two different cycles can produce weird behavior. To avoid this issue, only [highlight]time_0[/highlight] actually reads the time component. It stores the upper half for [highlight]time_1[/highlight] to read later. This means that [highlight]time_1[/highlight] should read 0 if [highlight]time_0[/highlight] has not been executed yet.

[b]counter[/b]
Read the value of the Counter custom component you built earlier.
[/left]
`))
]
