Spaces:
Runtime error
Runtime error
File size: 2,804 Bytes
8df6da4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
import { dbg_assert } from "../log.js";
import { get_charmap } from "../lib.js";
/**
* @constructor
* @param {Object=} options
*/
export function DummyScreenAdapter(options)
{
var
graphic_image_data,
/** @type {number} */
cursor_row = 0,
/** @type {number} */
cursor_col = 0,
graphical_mode_width = 0,
graphical_mode_height = 0,
// are we in graphical mode now?
is_graphical = false,
// Index 0: ASCII code
// Index 1: Blinking
// Index 2: Background color
// Index 3: Foreground color
text_mode_data,
// number of columns
text_mode_width = 0,
// number of rows
text_mode_height = 0,
// 8-bit-text to Unicode character map
charmap = get_charmap(options?.encoding);
this.put_char = function(row, col, chr, blinking, bg_color, fg_color)
{
dbg_assert(row >= 0 && row < text_mode_height);
dbg_assert(col >= 0 && col < text_mode_width);
text_mode_data[row * text_mode_width + col] = chr;
};
this.destroy = function() {};
this.pause = function() {};
this.continue = function() {};
this.set_mode = function(graphical)
{
is_graphical = graphical;
};
this.set_font_bitmap = function(height, width_9px, width_dbl, copy_8th_col, bitmap, bitmap_changed)
{
};
this.set_font_page = function(page_a, page_b)
{
};
this.clear_screen = function()
{
};
/**
* @param {number} cols
* @param {number} rows
*/
this.set_size_text = function(cols, rows)
{
if(cols === text_mode_width && rows === text_mode_height)
{
return;
}
text_mode_data = new Uint8Array(cols * rows);
text_mode_width = cols;
text_mode_height = rows;
};
this.set_size_graphical = function(width, height)
{
graphical_mode_width = width;
graphical_mode_height = height;
};
this.set_scale = function(s_x, s_y)
{
};
this.update_cursor_scanline = function(start, end, max)
{
};
this.update_cursor = function(row, col)
{
cursor_row = row;
cursor_col = col;
};
this.update_buffer = function(layers)
{
};
this.get_text_screen = function()
{
var screen = [];
for(var i = 0; i < text_mode_height; i++)
{
screen.push(this.get_text_row(i));
}
return screen;
};
this.get_text_row = function(y)
{
const begin = y * text_mode_width;
const end = begin + text_mode_width;
return Array.from(text_mode_data.subarray(begin, end), chr => charmap[chr]).join("");
};
this.set_size_text(80, 25);
}
|