diff --git a/ka/main.k b/ka/main.k index 5a9aabf..06a3c8e 100644 --- a/ka/main.k +++ b/ka/main.k @@ -14,6 +14,12 @@ main: test rdx, rdx j.nz .1 + mov rcx, 80 + prn.rep '&' + + mov rcx, 80 + prn.rep '%' + call showoff hlt diff --git a/vm/Makefile b/vm/Makefile index d07358a..c4d782f 100644 --- a/vm/Makefile +++ b/vm/Makefile @@ -10,17 +10,14 @@ FLAGS=-O2 -g -Wall -fno-builtin-log -I. dv_src = $(shell ls dv/*.c) in_src = $(shell ls in/*.c) pc_src = $(shell ls pc/*.c) -cn_src = $(shell ls cn/*.c) obj = $(patsubst %.c,$(OBJDIR)/%.o,$(dv_src)) obj += $(patsubst %.c,$(OBJDIR)/%.o,$(in_src)) obj += $(patsubst %.c,$(OBJDIR)/%.o,$(pc_src)) -obj += $(patsubst %.c,$(OBJDIR)/%.o,$(cn_src)) dep = $(patsubst %.c,$(OBJDIR)/%.d,$(dv_src)) dep += $(patsubst %.c,$(OBJDIR)/%.d,$(in_src)) dep += $(patsubst %.c,$(OBJDIR)/%.d,$(pc_src)) -dep += $(patsubst %.c,$(OBJDIR)/%.d,$(cn_src)) # Color codes CL='\033[0;32m' diff --git a/vm/in/instrs.c b/vm/in/instrs.c index 55947a7..19e1363 100644 --- a/vm/in/instrs.c +++ b/vm/in/instrs.c @@ -4,7 +4,7 @@ #include #include -#include +#include #define _NEED_ARCH_I #include diff --git a/vm/in/super.c b/vm/in/super.c index 5de4f53..8660e6a 100644 --- a/vm/in/super.c +++ b/vm/in/super.c @@ -3,7 +3,7 @@ #include #include -#include +#include IMPL_START_0(hlt) { diff --git a/vm/cn/console.c b/vm/pc/console.c similarity index 79% rename from vm/cn/console.c rename to vm/pc/console.c index a5c2737..ade6f79 100644 --- a/vm/cn/console.c +++ b/vm/pc/console.c @@ -1,7 +1,7 @@ // The OS/K Team licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#include +#include #define CONSOLE_WIDTH 80 #define CONSOLE_HEIGHT 25 @@ -91,7 +91,7 @@ void console_render(ctx_t *ctx) SDL_RenderClear(scr_rend); for (y = 0; y < CONSOLE_HEIGHT; y++) - if (scr_texts[y] != NULL) + if (scr_texts[y] != NULL && scr_rects[y] != NULL) SDL_RenderCopy(scr_rend, scr_texts[y], NULL, scr_rects[y]); @@ -104,7 +104,7 @@ void console_putat(ctx_t *ctx, char ch, int x, int y) { SDL_Surface *surf; - trace("putat: %c %d %d\n", ch, x, y); + //trace("putat: %c %d %d\n", ch, x, y); if (y >= CONSOLE_HEIGHT || x >= CONSOLE_WIDTH) { @@ -167,6 +167,8 @@ int csn_y = 0; void console_putc(ctx_t *ctx, char ch) { + size_t y; + if (ch < ' ' && ch != '\n') ch = 127; @@ -186,7 +188,42 @@ void console_putc(ctx_t *ctx, char ch) } if (csn_y == CONSOLE_HEIGHT) - csn_y = 0; + { + csn_y--; + memmove(scr_lines, &scr_lines[1], + (CONSOLE_HEIGHT - 1) * CONSOLE_WIDTH); + + memset(&scr_lines[CONSOLE_HEIGHT-1], ' ', CONSOLE_WIDTH); + scr_lines[CONSOLE_HEIGHT-1][CONSOLE_WIDTH] = 0; + + if (scr_texts[0] != NULL) + { + SDL_DestroyTexture(scr_texts[0]); + scr_texts[0] = NULL; + } + + memmove(scr_texts, &scr_texts[1], + (CONSOLE_HEIGHT - 1) * sizeof(SDL_Texture *)); + + scr_texts[CONSOLE_HEIGHT-1] = NULL; + + if (scr_rects[0] != NULL) + { + free(scr_rects[0]); + scr_rects[0] = NULL; + } + + memmove(scr_rects, &scr_rects[1], + (CONSOLE_HEIGHT - 1) * sizeof(SDL_Rect *)); + + scr_rects[CONSOLE_HEIGHT-1] = NULL; + + for (y = 0; y < CONSOLE_HEIGHT-1; y++) + if (scr_rects[y] != NULL) + { + scr_rects[y]->y -= 16; // surf->h + } + } } //----------------------------------------------------------------------------// diff --git a/vm/cn/console.h b/vm/pc/console.h similarity index 100% rename from vm/cn/console.h rename to vm/pc/console.h diff --git a/vm/pc/die.c b/vm/pc/die.c index bab8bfb..fa04c7a 100644 --- a/vm/pc/die.c +++ b/vm/pc/die.c @@ -2,7 +2,7 @@ // See the LICENSE file in the project root for more information. #include -#include +#include void die(int code) { diff --git a/vm/pc/main.c b/vm/pc/main.c index 2e7eda0..a642734 100644 --- a/vm/pc/main.c +++ b/vm/pc/main.c @@ -5,7 +5,7 @@ #include #include -#include +#include #define FWPROGSIZE (1024 * 1024 * 1024) static ssize_t fwsize;