X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosdemo;a=blobdiff_plain;f=src%2Fdemo.c;h=45b889a73487fca335410817b1c7cb0f719b3b5a;hp=6abcf672b751f58424ad5c6b47415f005bc70214;hb=a5c65ceb155188c8acee31a475f8db9f5b58f4b6;hpb=9ed338a5e703fc819cede5cb797e82e08046ac17 diff --git a/src/demo.c b/src/demo.c index 6abcf67..45b889a 100644 --- a/src/demo.c +++ b/src/demo.c @@ -11,6 +11,7 @@ #include "music.h" #include "cfgopt.h" #include "tinyfps.h" +#include "util.h" int fb_width = 320; int fb_height = 240; @@ -23,6 +24,7 @@ unsigned int mouse_bmask; float sball_matrix[] = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}; static unsigned long nframes; +static int console_active; int demo_init(int argc, char **argv) { @@ -121,23 +123,48 @@ void demo_keyboard(int key, int press) demo_quit(); break; + case 127: + debug_break(); + break; + + case '`': + console_active = !console_active; + if(console_active) { + printf("> "); + fflush(stdout); + } else { + putchar('\n'); + } + break; + + case '\b': + if(console_active && wr != rd) { + printf("\b \b"); + fflush(stdout); + wr = (wr + CBUF_SIZE - 1) & CBUF_MASK; + } + break; + case '\n': case '\r': - dptr = inp; - while(rd != wr) { - *dptr++ = cbuf[rd]; - rd = (rd + 1) & CBUF_MASK; - } - *dptr = 0; - if(inp[0]) { - printf("trying to match: %s\n", inp); - nscr = scr_num_screens(); - for(i=0; iname, inp)) { - change_screen(i); - break; + if(console_active) { + dptr = inp; + while(rd != wr) { + *dptr++ = cbuf[rd]; + rd = (rd + 1) & CBUF_MASK; + } + *dptr = 0; + if(inp[0]) { + printf("\ntrying to match: %s\n", inp); + nscr = scr_num_screens(); + for(i=0; iname, inp)) { + change_screen(i); + break; + } } } + console_active = 0; } break; @@ -148,7 +175,10 @@ void demo_keyboard(int key, int press) change_screen(9); } - if(key < 256 && isprint(key)) { + if(console_active && key < 256 && isprint(key)) { + putchar(key); + fflush(stdout); + cbuf[wr] = key; wr = (wr + 1) & CBUF_MASK; if(wr == rd) { /* overflow */