Class: TermEMU
- Inherits:
-
Object
- Object
- TermEMU
- Includes:
- Curses
- Defined in:
- lib/HDLRuby/hdr_samples/ruby_program/sw_cpu_terminal.rb,
lib/HDLRuby/hdr_samples/ruby_program/sw_cpu_terminal.rb
Instance Attribute Summary collapse
-
#cols ⇒ Object
readonly
The dimensions of the screen in pixels.
-
#lines ⇒ Object
readonly
The dimensions of the screen in pixels.
Instance Method Summary collapse
-
#getch ⇒ Object
Get a keyboard input.
-
#put_pixel(x, y, val) ⇒ Object
Draw a pixel.
-
#refresh ⇒ Object
Refresh the screen.
-
#startup ⇒ Object
Initializes the screen.
-
#terminate ⇒ Object
Closes the screen.
Instance Attribute Details
#cols ⇒ Object (readonly)
The dimensions of the screen in pixels.
78 79 80 |
# File 'lib/HDLRuby/hdr_samples/ruby_program/sw_cpu_terminal.rb', line 78 def cols @cols end |
#lines ⇒ Object (readonly)
The dimensions of the screen in pixels.
78 79 80 |
# File 'lib/HDLRuby/hdr_samples/ruby_program/sw_cpu_terminal.rb', line 78 def lines @lines end |
Instance Method Details
#getch ⇒ Object
Get a keyboard input.
119 120 121 |
# File 'lib/HDLRuby/hdr_samples/ruby_program/sw_cpu_terminal.rb', line 119 def getch return @crt.getch end |
#put_pixel(x, y, val) ⇒ Object
Draw a pixel.
110 111 112 113 114 115 116 |
# File 'lib/HDLRuby/hdr_samples/ruby_program/sw_cpu_terminal.rb', line 110 def put_pixel(x,y,val) if val == @px_black then @crt.put_pixel(x,y,Gosu::Color::BLACK) else @crt.put_pixel(x,y,Gosu::Color::WHITE) end end |
#refresh ⇒ Object
Refresh the screen.
104 105 106 107 |
# File 'lib/HDLRuby/hdr_samples/ruby_program/sw_cpu_terminal.rb', line 104 def refresh # In case of GOSU, it is not required to do anything here. @crt.tick end |
#startup ⇒ Object
Initializes the screen.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/HDLRuby/hdr_samples/ruby_program/sw_cpu_terminal.rb', line 81 def startup(width = 320, height = 240) # Set the size of the screen and create it. @width = width @height = height # Set the size of a pixel. @px_width = 4 @px_height = 4 # Set the number of columns and lines. @cols = @width / @px_width @lines = @height / @px_height # Create the screen. @crt = CRT.new(width,height,@px_width,@px_height) @crt.tick # Sets the color black @px_black = " ".ord end |
#terminate ⇒ Object
Closes the screen.
99 100 101 |
# File 'lib/HDLRuby/hdr_samples/ruby_program/sw_cpu_terminal.rb', line 99 def terminate exit end |