Add visual bell
This commit is contained in:
parent
f2c269d1cb
commit
8f39c10868
3 changed files with 23 additions and 5 deletions
20
chargen.c
20
chargen.c
|
|
@ -153,8 +153,11 @@ int scrnprintf(const char *fmt, ...) {
|
|||
return n;
|
||||
}
|
||||
|
||||
static uint16_t base_shade[] = {0, 0x554, 0xaa8, 0xffc, 0, 0x554,
|
||||
0xaa8, 0xffc, 0, 0, 0, 0};
|
||||
// note: not in flash (referenced from core1 generator thread)
|
||||
static uint16_t base_shade[] = {0, 0x554, 0xaa8, 0xffc, 0, 0x554,
|
||||
0xaa8, 0xffc, 0, 0, 0, 0,
|
||||
0xffc, 0xaa8, 0x554, 0x000, 0xffc, 0xaa8,
|
||||
0x554, 0x000, 0xffc, 0xffc, 0xffc, 0xffc};
|
||||
|
||||
#if !STANDALONE
|
||||
static void setup_vga_hsync(PIO pio) {
|
||||
|
|
@ -183,18 +186,22 @@ static void setup_vga(void) {
|
|||
setup_vga_hsync(pio0);
|
||||
}
|
||||
|
||||
int frameno = 0;
|
||||
int bell_frame_end = -1;
|
||||
__attribute__((noreturn, noinline)) static void
|
||||
__not_in_flash_func(core1_loop)(void) {
|
||||
int frameno = 0;
|
||||
while (true) {
|
||||
uint16_t *shade_ptr = frameno & 0x20 ? base_shade : base_shade + 4;
|
||||
if (bell_frame_end > frameno) {
|
||||
shade_ptr += 12;
|
||||
}
|
||||
for (int row = 0; row < FB_HEIGHT_CHAR; row++) {
|
||||
uint32_t *chardata =
|
||||
row == FB_HEIGHT_CHAR - 1
|
||||
? (uint32_t *)statusline
|
||||
: (uint32_t *)lw_terminal_vt100_getline(vt100, row);
|
||||
for (int j = 0; j < CHAR_Y; j++) {
|
||||
scan_convert(chardata, &chargen[256 * j],
|
||||
frameno & 0x20 ? base_shade : base_shade + 4);
|
||||
scan_convert(chardata, &chargen[256 * j], shade_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -202,6 +209,8 @@ __not_in_flash_func(core1_loop)(void) {
|
|||
}
|
||||
}
|
||||
|
||||
static void visual_bell(void *_) { bell_frame_end = frameno + 15; }
|
||||
|
||||
static __attribute__((noreturn, noinline)) void
|
||||
__not_in_flash_func(core1_entry)(void) {
|
||||
setup_vga();
|
||||
|
|
@ -602,6 +611,7 @@ int main(void) {
|
|||
vt100 = lw_terminal_vt100_init(NULL, NULL, master_write, char_attr,
|
||||
FB_WIDTH_CHAR, FB_HEIGHT_CHAR - 1);
|
||||
vt100->map_unicode = map_unicode;
|
||||
vt100->do_bell = visual_bell;
|
||||
multicore_launch_core1(core1_entry);
|
||||
|
||||
scrnprintf(" \r");
|
||||
|
|
|
|||
|
|
@ -341,6 +341,8 @@ static int default_map_unicode(void *user_data, int c, lw_cell_t *attr) {
|
|||
return '?';
|
||||
}
|
||||
|
||||
static void do_dummy_bell(void *user_data) {}
|
||||
|
||||
static lw_cell_t default_encode_attr(void *user_data,
|
||||
const struct lw_parsed_attr *attr) {
|
||||
(void)user_data;
|
||||
|
|
@ -1001,6 +1003,10 @@ static void vt100_write_unicode(struct lw_terminal *term_emul, int c) {
|
|||
vt100->x = 0;
|
||||
return;
|
||||
}
|
||||
if (c == '\7') {
|
||||
vt100->do_bell(vt100);
|
||||
return;
|
||||
}
|
||||
if (c == '\n' || c == '\013' || c == '\014') {
|
||||
if (MODE_IS_SET(vt100, LNM))
|
||||
NEL(term_emul);
|
||||
|
|
@ -1202,6 +1208,7 @@ struct lw_terminal_vt100 *lw_terminal_vt100_init(
|
|||
this->lw_terminal->unimplemented = unimplemented;
|
||||
this->master_write = master_write;
|
||||
this->encode_attr = encode_attr ? encode_attr : default_encode_attr;
|
||||
this->do_bell = do_dummy_bell;
|
||||
this->map_unicode = default_map_unicode;
|
||||
lw_terminal_vt100_read_str(this,
|
||||
"\033[m\033[?7h"); // set default attributes
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ struct lw_terminal_vt100 {
|
|||
int cursor_saved_x, cursor_saved_y;
|
||||
const lw_cell_t *alines[80];
|
||||
void (*master_write)(void *user_data, void *buffer, size_t len);
|
||||
void (*do_bell)(void *user_data);
|
||||
lw_cell_t (*encode_attr)(void *user_data,
|
||||
const struct lw_parsed_attr *attr);
|
||||
int (*map_unicode)(void *user_data, int c, lw_cell_t *attr);
|
||||
|
|
|
|||
Loading…
Reference in a new issue