module BBS::Petscii::Canvas::Output
The bytes that send a Canvas to a C64: the whole screen (frame), a stretch of a row (span), scattered cells (patch), the cursor alone (cursor). Each is raw PETSCII, a binary String for session.write_raw.
Public Instance Methods
Source
# File lib/bbs/petscii/canvas/output.rb, line 54 def cursor(row, col) = moves_to(row, col).pack('C*')
The cursor moves to row, col, with nothing printed: HOME, then down and right. A binary String.
Source
# File lib/bbs/petscii/canvas/output.rb, line 13 def frame out = [UPPERCASE, CLEAR] pen = Pen.new last = last_visible_row (0..last).each do |row| len = visible_end(row) pen.emit(out, @cells[row].first(len)) next if len == COLS || row == last out << CR pen.rvs = false end out.pack('C*') end
The whole screen: the graphics set, a clear screen, then the rows, each cut after its last visible cell, as a binary String.
Source
# File lib/bbs/petscii/canvas/output.rb, line 41 def patch(positions) out = [HOME, RVS_OFF] pen = Pen.new at = [0, 0] nearest_first(positions.uniq).each do |row, col| at = step_to(out, at, row, col) pen.emit(out, [@cells[row][col]]) end pen.close(out).pack('C*') end
The cells at positions, [row, col] each, the cursor stepping to the nearest one left instead of from the top left each time: the cheap repaint of a few cells scattered over the screen. A binary String.
Source
# File lib/bbs/petscii/canvas/output.rb, line 30 def span(row, col, width) out = moves_to(row, col) << RVS_OFF pen = Pen.new pen.emit(out, @cells[row][col, width]) pen.close(out).pack('C*') end
The cells of row from col, width long, with the cursor moves that put them in place, as a binary String.