Class: TermEMU

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Instance Attribute Details

#colsObject (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

#linesObject (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

#getchObject

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

#refreshObject

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

#startupObject

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

#terminateObject

Closes the screen.



99
100
101
# File 'lib/HDLRuby/hdr_samples/ruby_program/sw_cpu_terminal.rb', line 99

def terminate
  exit
end