]> Joshua Wise's Git repositories - netwatch.git/blobdiff - aseg/vga-overlay.c
move packet to aseg-paging in preparation for aseg's deletion
[netwatch.git] / aseg / vga-overlay.c
index e5414cadaad81a953a7a045be2e6a96e32743c38..7d107d71264f20d9ae430f2dd99bbb40b1f5c21d 100644 (file)
@@ -2,8 +2,15 @@
 #include <smram.h>
 #include <video_defines.h>
 #include <minilib.h>
+#include <stdarg.h>
+#include <output.h>
 
-static char logents[4][41] = {{0}};
+#define LOGLEN 96
+#define LOG_ONSCREEN 4
+
+static char logents[LOGLEN][41] = {{0}};
+static int prodptr = 0;
+static int flush_imm = 0;
 
 #define VRAM_BASE              0xA0000UL
 #define TEXT_CONSOLE_OFFSET    0x18000UL 
@@ -12,6 +19,11 @@ static char logents[4][41] = {{0}};
 
 #define COLOR                  0x1F
 
+void vga_flush_imm(int imm)
+{
+       flush_imm = imm;
+}
+
 static unsigned char vga_read(unsigned char idx)
 {
        outb(CRTC_IDX_REG, idx);
@@ -22,8 +34,8 @@ static char * vga_base()
 {
        return (char *) (
                TEXT_CONSOLE_BASE
-               | (((unsigned int) vga_read(CRTC_START_ADDR_LSB_IDX)) << 9)
-               | (((unsigned int) vga_read(CRTC_START_ADDR_MSB_IDX)) << 1)
+               + (((unsigned int) vga_read(CRTC_START_ADDR_MSB_IDX)) << 9)
+               + (((unsigned int) vga_read(CRTC_START_ADDR_LSB_IDX)) << 1)
        );
 }
 
@@ -33,7 +45,7 @@ void strblit(char *src, int row, int col)
        smram_state_t old_state = smram_save_state();
 
        smram_aseg_set_state(SMRAM_ASEG_SMMCODE);
-       
+
        while (*src)
        {
                *(destp++) = *(src++);
@@ -52,7 +64,7 @@ void outlog()
 
        smram_aseg_set_state(SMRAM_ASEG_SMMCODE);
 
-       for (y = 0; y < 4; y++)
+       for (y = 0; y < LOG_ONSCREEN; y++)
                for (x = 40; x < 80; x++)
                {
                        basep[y*80*2+x*2] = ' ';
@@ -60,13 +72,33 @@ void outlog()
                }
 
        smram_restore_state(old_state);
+       
+       for (y = -LOG_ONSCREEN; y < 0; y++)
+               strblit(logents[(y + prodptr) % LOGLEN], y + LOG_ONSCREEN, 40);
+}
 
-       for (y = 0; y < 4; y++)
-               strblit(logents[y], y, 40);
+void dolog(const char *s)
+{
+       strcpy(logents[prodptr], s);
+       prodptr = (prodptr + 1) % LOGLEN;
+       if (flush_imm)
+               outlog();
 }
+void (*output)(const char *s) = dolog;
 
-void dolog(char *s)
+void dologf(const char *fmt, ...)
 {
-       memmove(logents[0], logents[1], sizeof(logents[0])*3);
-       strcpy(logents[3], s);
+       va_list va;
+       
+       va_start(va, fmt);
+       vsnprintf(logents[prodptr], 40, fmt, va);
+       va_end(va);
+       prodptr = (prodptr + 1) % LOGLEN;
+       if (flush_imm)
+               outlog();
+}
+void (*outputf)(const char *s, ...) = dologf;
+
+void dump_log (char * target) {
+       memcpy(target, logents, sizeof(logents));
 }
This page took 0.02418 seconds and 4 git commands to generate.