Backup - Adding AxWin0 to git, just so it's backed up
authorJohn Hodge <[email protected]>
Fri, 3 Jun 2011 07:44:19 +0000 (15:44 +0800)
committerJohn Hodge <[email protected]>
Fri, 3 Jun 2011 07:44:19 +0000 (15:44 +0800)
12 files changed:
Usermode/Applications/axwin0_src/Makefile [new file with mode: 0644]
Usermode/Applications/axwin0_src/axwin.h [new file with mode: 0644]
Usermode/Applications/axwin0_src/bitmaps.h [new file with mode: 0644]
Usermode/Applications/axwin0_src/desktop.c [new file with mode: 0644]
Usermode/Applications/axwin0_src/desktop_font.h [new file with mode: 0644]
Usermode/Applications/axwin0_src/graphics.c [new file with mode: 0644]
Usermode/Applications/axwin0_src/header.h [new file with mode: 0644]
Usermode/Applications/axwin0_src/heap.c [new file with mode: 0644]
Usermode/Applications/axwin0_src/import.asm [new file with mode: 0644]
Usermode/Applications/axwin0_src/main.c [new file with mode: 0644]
Usermode/Applications/axwin0_src/start.asm [new file with mode: 0644]
Usermode/Applications/axwin0_src/wm.c [new file with mode: 0644]

diff --git a/Usermode/Applications/axwin0_src/Makefile b/Usermode/Applications/axwin0_src/Makefile
new file mode 100644 (file)
index 0000000..fb51b2d
--- /dev/null
@@ -0,0 +1,11 @@
+# Project: Acess GUI Window Manager
+
+-include ../Makefile.cfg
+
+CPPFLAGS += -I../include
+
+DIR := Apps/AxWin/0.1
+BIN := ../AxWin0
+OBJ := main.o wm.o graphics.o desktop.o
+
+-include ../Makefile.tpl
diff --git a/Usermode/Applications/axwin0_src/axwin.h b/Usermode/Applications/axwin0_src/axwin.h
new file mode 100644 (file)
index 0000000..6259f0f
--- /dev/null
@@ -0,0 +1,48 @@
+/*\r
+AxWin API\r
+*/\r
+\r
+#ifndef NULL\r
+# define NULL  ((void*)0)\r
+#endif\r
+\r
+#ifndef _AXWIN_HEADER_H\r
+typedef unsigned char  Uint8;\r
+typedef unsigned long  Uint32;\r
+typedef unsigned int   Uint;\r
+#endif\r
+\r
+typedef int (*wndproc_t)(void *handle, int message, int arg1, int arg2);\r
+\r
+typedef struct {\r
+       short   width, height;\r
+       int             bpp;\r
+       void    *data;\r
+} BITMAP;\r
+typedef struct {\r
+       int x1, y1;\r
+       int x2, y2;\r
+} RECT;\r
+\r
+\r
+//Flag Values\r
+#define WNDFLAG_SHOW           0x0001\r
+#define WNDFLAG_NOBORDER       0x0010\r
+\r
+//Window Messages\r
+enum MESSAGES {\r
+       WM_NULL,\r
+       WM_REPAINT,\r
+       WM_GETTEXT,\r
+       WM_SETTEXT,\r
+       WM_SETTITLE,\r
+       WM_GETTITLE\r
+};\r
+\r
+// === EXTERNAL FUNCTIONS ===\r
+extern void*   WM_CreateWindow(int x, int y, int w, int h, wndproc_t wndProc, Uint flags);\r
+extern int     WM_SendMessage(void *hwnd, int msg, int a1, int a2);\r
+\r
+// === DEFINES ===\r
+#define WM_SetText(hwnd, text) WM_SendMessage((hwnd), WM_SETTEXT, (int)((char*)(text)), 0)\r
+#define WM_SetTitle(hwnd, text)        WM_SendMessage((hwnd), WM_SETTITLE, (int)((char*)(text)), 0)\r
diff --git a/Usermode/Applications/axwin0_src/bitmaps.h b/Usermode/Applications/axwin0_src/bitmaps.h
new file mode 100644 (file)
index 0000000..6ed6355
--- /dev/null
@@ -0,0 +1,34 @@
+/*\r
+AcessOS Window Manager\r
+Bitmaps\r
+HEADER\r
+*/\r
+\r
+Uint32 bmpCursor[] = { //16x32\r
+       0xF0000000,0x00000000,\r
+       0xFF000000,0x00000000,\r
+       0xF1F00000,0x00000000,\r
+       0xF11F0000,0x00000000,\r
+       0xF111F000,0x00000000,\r
+       0xF1111F00,0x00000000,\r
+       0xF11111F0,0x00000000,\r
+       0xF111111F,0x00000000,\r
+       0xF1111111,0xF0000000,\r
+       0xF1111111,0x1F000000,\r
+       0xF1111111,0x11F00000,\r
+       0xF111111F,0xFFFF0000,\r
+       0xF111F11F,0x00000000,\r
+       0xF11FF11F,0x00000000,\r
+       0xF1F00F11,0xF0000000,\r
+       0xFF000F11,0xF0000000,\r
+       0xF00000F1,0x1F000000,\r
+       0x000000F1,0x1F000000,\r
+       0x0000000F,0x11F00000,\r
+       0x0000000F,0x11F00000,\r
+       0x00000000,0xFF000000,\r
+       0x00000000,0x00000000,\r
+       0x00000000,0x00000000,\r
+       0x00000000,0x00000000,\r
+       0x00000000,0x00000000,\r
+       0x00000000,0x00000000,\r
+};\r
diff --git a/Usermode/Applications/axwin0_src/desktop.c b/Usermode/Applications/axwin0_src/desktop.c
new file mode 100644 (file)
index 0000000..e474f75
--- /dev/null
@@ -0,0 +1,80 @@
+/*\r
+AcessOS Window Manager\r
+Desktop Window\r
+*/\r
+#include "axwin.h"\r
+#include "desktop_font.h"\r
+#include <string.h>\r
+\r
+#define        DEBUG   0\r
+\r
+#define        FGC     0xFFFFFFFF\r
+#define        BGC     0xFF000000\r
+\r
+// === GLOBALS ===\r
+ void* gHwnd = NULL;\r
+ int   gW = 640;\r
+ int   gH = 480;\r
\r
+// === PROTOTYPES ===\r
+void   Desktop_Init();\r
+ int   Desktop_WndProc(void *handle, int message, int arg1, int arg2);\r
+void   Desktop_PrintAt(BITMAP *bmp, int x, int y, char *text);\r
+\r
+// === CODE ===\r
+void Desktop_Init()\r
+{\r
+       gHwnd = WM_CreateWindow(0, 0, -1, -1, Desktop_WndProc, WNDFLAG_NOBORDER|WNDFLAG_SHOW);\r
+       if(gHwnd == 0)\r
+       {\r
+               //write(giConsoleFP, 32, "Unable to create desktop window\n");\r
+               return;\r
+       }\r
+       WM_SetTitle(gHwnd, "Desktop");\r
+}\r
+\r
+int    Desktop_WndProc(void *handle, int message, int arg1, int arg2)\r
+{\r
+       switch(message)\r
+       {\r
+       case WM_REPAINT:\r
+               {\r
+               BITMAP  *bmp = (BITMAP*)arg1;\r
+               memset( bmp->data, BGC, bmp->width*bmp->height*4 );\r
+               Desktop_PrintAt( bmp, 0, 0, "CAB@1337!" );\r
+               }\r
+               break;\r
+               \r
+       default:\r
+               return 0;\r
+       }\r
+       return 1;       // Handled\r
+}\r
+\r
+void Desktop_PrintAt(BITMAP *bmp, int x, int y, char *text)\r
+{\r
+       int j,k,w;\r
+       Uint32  *buf;\r
+       \r
+       if( bmp == NULL || text == NULL )\r
+          return;\r
+\r
+       buf = bmp->data;\r
+       w = bmp->width;\r
+       buf += y*w+x;\r
+       while(*text)\r
+       {\r
+               for(j=0;j<9;j++)\r
+               {\r
+                       int     c = cFONT_ASCII[(int)*text][j];\r
+                       for(k=0;k<8;k++)\r
+                       {\r
+                               if(c&(1<<(7-k)))        buf[j*w+k] = FGC;\r
+                               else                            buf[j*w+k] = BGC;\r
+                       }\r
+                       buf[j*w+8] = BGC;\r
+               }\r
+               buf += 9;\r
+               text++;\r
+       }\r
+}\r
diff --git a/Usermode/Applications/axwin0_src/desktop_font.h b/Usermode/Applications/axwin0_src/desktop_font.h
new file mode 100644 (file)
index 0000000..43f338f
--- /dev/null
@@ -0,0 +1,47 @@
+/*\r
+AcessOS Window Manager\r
+Desktop Window\r
+Font\r
+HEADER\r
+*/\r
+\r
+Uint8  cFONT_ASCII[][9] = {\r
+{0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0},       //0\r
+{0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0},       //4\r
+{0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0},       //8\r
+{0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0},       //C\r
+{0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0},       //10\r
+{0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0},       //14\r
+{0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0},       //18\r
+{0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0},       //1C\r
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},        {0x08,0x08,0x08,0x08,0x08,0x00,0x00,0x08,0x08}, //20+21\r
+{0x24,0x24,0x24,0x00,0x00,0x00,0x00,0x00,0x00}, {0x24,0x24,0xFF,0x24,0x24,0x24,0xFF,0x24,0x24},        //22+23\r
+{0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00},        {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //24+25\r
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x10,0x10,0x08,0x00,0x00,0x00,0x00,0x00,0x00},        //26+27\r
+{0x00,0x04,0x08,0x10,0x20,0x20,0x10,0x08,0x04}, {0x00,0x20,0x10,0x08,0x04,0x04,0x08,0x10,0x20},        //28+29 ()\r
+{0x54,0x38,0x54,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x10,0x10,0x7C,0x10,0x10,0x00,0x00},        //2A+2B *+\r
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x08}, {0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x00},        //2C+2D ,-\r
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18}, {0x06,0x0C,0x0C,0x18,0x18,0x30,0x30,0x60,0x60},        //2E+2F ./\r
+{0x3C,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x3C}, {0x1C,0x28,0x08,0x08,0x08,0x08,0x08,0x08,0x3E}, //30+31 01\r
+{0x3C,0x42,0x04,0x08,0x10,0x10,0x20,0x40,0x7E}, {0x3C,0x42,0x02,0x02,0x3C,0x02,0x02,0x42,0x7E}, //32+33 23\r
+{0x08,0x18,0x28,0x48,0x7E,0x08,0x08,0x08,0x3C}, {0x7E,0x40,0x40,0x38,0x04,0x02,0x02,0x04,0x38}, //34+35 45\r
+{0x1E,0x20,0x40,0x40,0x7C,0x42,0x42,0x42,0x18},        {0x7E,0x02,0x04,0x08,0x08,0x10,0x10,0x20,0x20}, //36+37 67\r
+{0x3C,0x42,0x42,0x42,0x3C,0x42,0x42,0x42,0x3C},        {0x3C,0x42,0x42,0x42,0x3E,0x02,0x02,0x04,0x78}, //38+39 89\r
+{0x00,0x00,0x18,0x00,0x00,0x00,0x18,0x00,0x00},        {0x00,0x00,0x18,0x00,0x00,0x18,0x30,0x60,0x00}, //3A+3B :;\r
+{0x00,0x00,0x0C,0x30,0x40,0x30,0x0C,0x00,0x00},        {0x00,0x00,0x00,0x7E,0x00,0x7E,0x00,0x00,0x00}, //3C+3D <=\r
+{0x00,0x00,0x30,0x0C,0x02,0x0C,0x30,0x00,0x00},        {0x3C,0x42,0x02,0x0C,0x10,0x10,0x00,0x30,0x00}, //3E+3F >?\r
+{0x3C,0x42,0x4E,0x52,0x52,0x4C,0x40,0x40,0x3C},        {0x18,0x24,0x24,0x42,0x7E,0x42,0x42,0x42,0x42}, //40+41 @A\r
+{0x7C,0x22,0x22,0x22,0x3C,0x22,0x22,0x22,0x7C},        {0x3C,0x42,0x40,0x40,0x40,0x40,0x40,0x42,0x3C}, //42+43 BC\r
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},        {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //44+45 DE\r
+};\r
+#if 0\r
+00111100\r
+01000010\r
+01000000\r
+01000000\r
+01000000\r
+01000000\r
+01000000\r
+01000010\r
+00111100\r
+#endif\r
diff --git a/Usermode/Applications/axwin0_src/graphics.c b/Usermode/Applications/axwin0_src/graphics.c
new file mode 100644 (file)
index 0000000..38b06fa
--- /dev/null
@@ -0,0 +1,107 @@
+/*\r
+Acess OS Window Manager\r
+*/\r
+#include "header.h"\r
+\r
+#define ABS(x) ((x)<0?-(x):(x))\r
+#define PLOT(x,y,colour)       (gScreenBuffer[(y)*SCREEN_WIDTH+(x)] = (colour))\r
+\r
+void draw_line(int x1, int y1, int x2, int y2, Uint32 colour)\r
+{\r
+       int dy, dx;\r
+       int     i;\r
+       float   step;\r
+       \r
+       dy = ABS(y2 - y1);\r
+       dx = ABS(x2 - x1);\r
+       \r
+       if(dx == 0) {\r
+               if(y1 < y2) {\r
+                       for(i=y1;i<y2;i++)\r
+                               PLOT(x1, i, colour);\r
+               } else {\r
+                       for(i=y2;i<y1;i++)\r
+                               PLOT(x1, i, colour);\r
+               }\r
+       }\r
+       \r
+       if(x1 < x2) {\r
+               step = (dy/dx); step = (y2>y1?step:-step);\r
+               for(i=x1;i<x2;i++)      PLOT(i, y1+(int)(step*i), colour);\r
+       } else {\r
+               step = (dy/dx); step = (y2>y1?-step:step);\r
+               for(i=x2;i<x1;i++)      PLOT(i, y1+(int)(step*i), colour);\r
+       }\r
+}\r
+\r
+void draw_rect(int x, int y, int w, int h, Uint32 colour)\r
+{\r
+       Uint32  *p = gScreenBuffer+y*SCREEN_WIDTH+x;\r
+       int             i, j;\r
+       \r
+       for(j=0;j<h;j++) {\r
+               for(i=0;i<w;i++)        *(p+i) = colour;\r
+               p += SCREEN_WIDTH;\r
+       }\r
+}\r
+\r
+void draw_bmp(BITMAP *bmp, RECT *rc)\r
+{\r
+       int w, h, i, j;\r
+       Uint32  a;\r
+       int     r,g,b;\r
+       Uint32  *buf, *bi;\r
+       Uint16  *bi16;\r
+       Uint8   *bi8;\r
+       \r
+       #if DEBUG\r
+               k_printf("draw_bmp: (bmp=0x%x, rc=0x%x)\n", bmp, rc);\r
+       #endif\r
+       \r
+       buf = gScreenBuffer+rc->y1*SCREEN_WIDTH+rc->x1;\r
+       bi = bmp->data; bi16 = bmp->data;       bi8 = bmp->data;\r
+       w = bmp->width;\r
+       h = bmp->height;\r
+       \r
+       #if DEBUG\r
+               k_printf(" draw_bmp: bmp->bpp = %i\n", bmp->bpp);\r
+       #endif\r
+       \r
+       switch(bmp->bpp)\r
+       {\r
+       // === 32bit Colour ===\r
+       case 32:\r
+               for(i = 0; i < h; i++)\r
+               {\r
+                       for(j = 0; j < w; j++)\r
+                       {\r
+                               a = *bi >> 24;\r
+                               switch(a)\r
+                               {\r
+                               case 0xFF:      //Fully Visible\r
+                                       buf[j] = *bi;\r
+                                       break;\r
+                               case 0x80:      // 50/50\r
+                                       r = ((*bi>>16)&0xFF) + ((*buf>>16)&0xFF);\r
+                                       g = ((*bi>>8)&0xFF) + ((*buf>>8)&0xFF);\r
+                                       b = ((*bi)&0xFF) + ((*buf)&0xFF);\r
+                                       r >>= 1;        g >>= 1;        b >>= 1;\r
+                                       buf[j] = (r<<16) | (g<<8) | b;\r
+                                       break;\r
+                               case 0x00:      // Fully Transparent\r
+                                       break;\r
+                               default:        // Everything else\r
+                                       r = ((*bi>>16)&0xFF)*(255-a) + ((*buf>>16)&0xFF)*a;\r
+                                       g = ((*bi>>8)&0xFF)*(255-a) + ((*buf>>8)&0xFF)*a;\r
+                                       b = ((*bi)&0xFF)*(255-a) + ((*buf)&0xFF)*a;\r
+                                       r >>= 8;        g >>= 8;        b >>= 8;\r
+                                       buf[j] = (r<<16) | (g<<8) | b;\r
+                                       break;\r
+                               }\r
+                               bi++;\r
+                       }\r
+                       buf += SCREEN_WIDTH;\r
+               }\r
+               break;\r
+       }\r
+}\r
diff --git a/Usermode/Applications/axwin0_src/header.h b/Usermode/Applications/axwin0_src/header.h
new file mode 100644 (file)
index 0000000..1244f59
--- /dev/null
@@ -0,0 +1,49 @@
+/*\r
+Acess OS GUI\r
+*/\r
+#ifndef        _AXWIN_HEADER_H\r
+#define _AXWIN_HEADER_H\r
+\r
+#include <acess/sys.h>\r
+\r
+//CONSTANTS\r
+#define SCREEN_WIDTH   640\r
+#define SCREEN_HEIGHT  480\r
+#define        SCREEN_PX_COUNT (SCREEN_WIDTH*SCREEN_HEIGHT)\r
+#define        SCREEN_BUFFER_SIZE      (SCREEN_WIDTH*SCREEN_HEIGHT*4)\r
+\r
+#define NULL   ((void*)0)\r
+\r
+typedef uint32_t       Uint32;\r
+typedef uint16_t       Uint16;\r
+typedef uint8_t        Uint8;\r
+typedef uint   Uint;\r
+\r
+extern Uint32  *gScreenBuffer;\r
+\r
+#include "axwin.h"\r
+\r
+typedef struct sWINDOW{\r
+       void    *handle;\r
+       RECT    rc;\r
+       char    *title;\r
+       int             flags;\r
+       int             repaint;\r
+       \r
+       BITMAP  bmp;\r
+       \r
+       struct sWINDOW  *next, *prev;\r
+       struct sWINDOW  *first_child, *last_child;\r
+       struct sWINDOW  *parent;\r
+       \r
+       wndproc_t       wndproc;\r
+} tWINDOW;\r
+\r
+//PROTOTYPES\r
+extern void wmUpdateWindows();\r
+extern void memcpyd(void *to, void *from, int count);\r
+extern void draw_line(int x1, int y1, int x2, int y2, Uint32 colour);\r
+extern void draw_rect(int x, int y, int w, int h, Uint32 colour);\r
+extern void draw_bmp(BITMAP *bmp, RECT *rc);\r
+\r
+#endif\r
diff --git a/Usermode/Applications/axwin0_src/heap.c b/Usermode/Applications/axwin0_src/heap.c
new file mode 100644 (file)
index 0000000..e7a1e39
--- /dev/null
@@ -0,0 +1,235 @@
+/*\r
+AcessOS Basic LibC\r
+Malloc.c - Heap Manager\r
+*/\r
+\r
+#include "header.h"\r
+\r
+#define MAGIC  0xACE2ACED      //AcessOS1\r
+#define MAGIC_FREE     (~MAGIC)        //AcessOS1\r
+#define BLOCK_SIZE     16      //Minimum\r
+\r
+//Typedefs\r
+typedef struct {\r
+       Uint    magic;\r
+       Uint    size;\r
+}      heap_head;\r
+typedef struct {\r
+       heap_head       *header;\r
+       Uint    magic;\r
+}      heap_foot;\r
+\r
+//Globals\r
+void   *heap_start = NULL;\r
+void   *heap_end;\r
+Uint   endHeap;\r
+\r
+//Prototypes\r
+void *malloc(Uint bytes);\r
+void free(void *mem);\r
+void *realloc(Uint bytes, void *mem);\r
+void *extendHeap(int bytes);\r
+\r
+//Code\r
+/* Initialise Heap\r
+ */\r
+void heap_init()\r
+{\r
+       heap_start = (void*)( (gAxeHdr.loadto + gAxeHdr.length + 0xFFF) & 0xFFFFF000) ;\r
+       heap_end = heap_start;\r
+       extendHeap( gAxeHdr.maxmem );\r
+       endHeap = (Uint)heap_start + gAxeHdr.maxmem;\r
+}\r
+\r
+void *malloc(Uint bytes)\r
+{\r
+       Uint    bestSize;\r
+       Uint    closestMatch = 0;\r
+       Uint    bestMatchAddr = 0;\r
+       heap_head       *curBlock = heap_start;\r
+       \r
+       if(heap_start == NULL) {\r
+               heap_init();\r
+               curBlock = heap_start;\r
+       }\r
+       \r
+       bestSize = ((bytes+sizeof(heap_head)+sizeof(heap_foot))/BLOCK_SIZE+1)*BLOCK_SIZE;       //Round up to block size\r
+       \r
+       while((Uint)curBlock < (Uint)heap_end)\r
+       {\r
+               if(curBlock->magic == MAGIC_FREE)\r
+               {\r
+                       //foundFree = 1;\r
+                       if(curBlock->size == bestSize)\r
+                               break;\r
+                       if(bestSize < curBlock->size && (curBlock->size < closestMatch || closestMatch == 0)) {\r
+                               closestMatch = curBlock->size;\r
+                               bestMatchAddr = (Uint)curBlock;\r
+                       }\r
+               } else if(curBlock->magic != MAGIC) {\r
+                       //Corrupt Heap\r
+                       return NULL;\r
+               }\r
+               curBlock = (heap_head*)((Uint)curBlock + curBlock->size);\r
+       }\r
+       \r
+       if((Uint)curBlock < (Uint)heap_start) {\r
+               //panic("malloc: Heap underrun for some reason\n");\r
+               return NULL;\r
+       }\r
+       \r
+       //Found a perfect match\r
+       if((Uint)curBlock < (Uint)heap_end) {\r
+               curBlock->magic = MAGIC;\r
+               return (void*)((Uint)curBlock + sizeof(heap_head));\r
+       }\r
+       \r
+       //Out of Heap Space\r
+       if(!closestMatch)\r
+       {\r
+               #if 0\r
+               curBlock = extendHeap(bestSize);        //Allocate more\r
+               if(curBlock == NULL) {\r
+                       //panic("malloc: Out of kernel heap memory\n");\r
+                       return NULL;\r
+               }\r
+               curBlock->magic = MAGIC;\r
+               return (void*)((Uint)curBlock + sizeof(heap_head));\r
+               #else\r
+               return NULL;\r
+               #endif\r
+       }\r
+       \r
+       //Split Block?\r
+       if(closestMatch - bestSize > BLOCK_SIZE) {\r
+               heap_foot       *foot;\r
+               curBlock = (heap_head*)bestMatchAddr;\r
+               curBlock->magic = MAGIC;\r
+               curBlock->size = bestSize;\r
+               foot = (heap_foot*)(bestMatchAddr + bestSize - sizeof(heap_foot));\r
+               foot->header = curBlock;\r
+               foot->magic = MAGIC;\r
+\r
+               curBlock = (heap_head*)(bestMatchAddr + bestSize);\r
+               curBlock->magic = MAGIC_FREE;\r
+               curBlock->size = closestMatch - bestSize;\r
+               \r
+               foot = (heap_foot*)(bestMatchAddr + closestMatch - sizeof(heap_foot));\r
+               foot->header = curBlock;\r
+               \r
+               ((heap_head*)bestMatchAddr)->magic = MAGIC;     //mark as used\r
+               return (void*)(bestMatchAddr + sizeof(heap_head));\r
+       }\r
+       \r
+       //Don't Split the block\r
+       ((heap_head*)bestMatchAddr)->magic = MAGIC;\r
+       return (void*)(bestMatchAddr+sizeof(heap_head));\r
+}\r
+\r
+/* Free previously allocated memory\r
+ */\r
+void free(void *mem)\r
+{\r
+       heap_head       *head = mem;\r
+       \r
+       if(head->magic != MAGIC)        //Valid Heap Address\r
+               return;\r
+       \r
+       head->magic = MAGIC_FREE;\r
+       \r
+       //Unify Right\r
+       if((Uint)head + head->size < (Uint)heap_end)\r
+       {\r
+               heap_head       *nextHead = (heap_head*)((Uint)head + head->size);\r
+               if(nextHead->magic == MAGIC_FREE) {     //Is the next block free\r
+                       head->size += nextHead->size;   //Amalgamate\r
+                       nextHead->magic = 0;    //For Security\r
+               }\r
+       }\r
+       //Unify Left\r
+       if((Uint)head - sizeof(heap_foot) > (Uint)heap_start)\r
+       {\r
+               heap_head       *prevHead;\r
+               heap_foot       *prevFoot = (heap_foot *)((Uint)head - sizeof(heap_foot));\r
+               if(prevFoot->magic == MAGIC) {\r
+                       prevHead = prevFoot->header;\r
+                       if(prevHead->magic == MAGIC_FREE) {\r
+                               prevHead->size += head->size;   //Amalgamate\r
+                               head->magic = 0;        //For Security\r
+                       }\r
+               }\r
+       }\r
+}\r
+\r
+/* Create a new block at the end of the heap area\r
+ */\r
+void *extendHeap(int bytes)\r
+{\r
+       heap_head       *head = heap_end;\r
+       heap_foot       *foot = (heap_foot*)(((Uint)heap_end) + bytes-sizeof(heap_foot));\r
+       \r
+       //Create New Block\r
+       head->magic = MAGIC_FREE;       //Unallocated\r
+       head->size = bytes;\r
+       \r
+       foot->header = head;\r
+       foot->magic = MAGIC;\r
+       \r
+       //Combine with previous block if nessasary\r
+       if(heap_end != heap_start && ((heap_foot*)((Uint)heap_end-sizeof(heap_foot)))->magic == MAGIC) {\r
+               heap_head       *tmpHead = ((heap_foot*)((Uint)heap_end-sizeof(heap_foot)))->header;\r
+               if(tmpHead->magic == MAGIC_FREE) {\r
+                       tmpHead->size += bytes;\r
+                       foot->header = tmpHead;\r
+                       head = tmpHead;\r
+               }\r
+       }\r
+       \r
+       heap_end = (void*) ((Uint)foot+sizeof(heap_foot));\r
+       return head;\r
+}\r
+\r
+/* Reallocate a block of memory\r
+ */\r
+void *realloc(Uint bytes, void *oldPos)\r
+{\r
+       void *ret;\r
+       heap_head       *head;\r
+       \r
+       if(oldPos == NULL) {\r
+               return malloc(bytes);\r
+       }\r
+       \r
+       //Check for free space after block\r
+       head = (heap_head*)((Uint)oldPos-sizeof(heap_head));\r
+       \r
+       //Hack to used free's amagamating algorithym and malloc's splitting\r
+       free(oldPos);\r
+       \r
+       //Allocate new memory\r
+       ret = malloc(bytes);\r
+       if(ret == NULL)\r
+               return NULL;\r
+       \r
+       //Copy Old Data\r
+       if((Uint)ret != (Uint)oldPos)\r
+       {\r
+               Uint    *in, *out;\r
+               Uint    count;\r
+               count = head->size - sizeof(heap_head) - sizeof(heap_foot);\r
+               if((Uint)ret < (Uint)out)\r
+               {\r
+                       out = ret;              in = oldPos;\r
+                       while(count--)  *out++ = *in++;\r
+               }\r
+               else\r
+               {\r
+                       out = ret;              in = oldPos;\r
+                       out += count;   in += count;\r
+                       while(count--)  *--out = *--in;\r
+               }\r
+       }\r
+       \r
+       //Return\r
+       return ret;\r
+}\r
diff --git a/Usermode/Applications/axwin0_src/import.asm b/Usermode/Applications/axwin0_src/import.asm
new file mode 100644 (file)
index 0000000..81a1b67
--- /dev/null
@@ -0,0 +1,117 @@
+\r
+global _k_fopen\r
+global _k_fclose\r
+global _k_ftell\r
+global _k_fseek\r
+global _k_fread\r
+global _k_fwrite\r
+global _k_fstat\r
+;global _k_printf\r
+global _k_puts\r
+global _k_opendir\r
+global _k_readdir\r
+global _k_exec\r
+global _k_ioctl\r
+\r
+%macro START_FRAME 0\r
+       push ebp\r
+       mov ebp, esp\r
+       push ebx\r
+       push ecx\r
+       push edx\r
+%endmacro\r
+%macro END_FRAME 0\r
+       pop edx\r
+       pop ecx\r
+       pop ebx\r
+       pop ebp\r
+%endmacro\r
+\r
+_k_fopen:\r
+       START_FRAME\r
+       mov eax, 2      ;SYS_OPEN\r
+       mov ebx, DWORD [ebp+8]\r
+       mov ecx, DWORD [ebp+12]\r
+       mov edx, 0\r
+       int 0xAC\r
+       END_FRAME\r
+       ret\r
+       ;jmp    0x0010001c\r
+_k_fclose:\r
+       START_FRAME\r
+       mov eax, 3      ;SYS_CLOSE\r
+       mov ebx, DWORD [ebp+8]\r
+       int     0xAC\r
+       END_FRAME       ;Restore Stack Frame\r
+       ret\r
+       ;jmp    0x00100022\r
+_k_ftell:\r
+       jmp     0x0010002e\r
+_k_fseek:\r
+       jmp     0x001000a9\r
+_k_fread:\r
+       START_FRAME\r
+       mov eax, 4      ;SYS_READ\r
+       mov ebx, DWORD [ebp+8]\r
+       mov ecx, DWORD [ebp+12]\r
+       mov edx, DWORD [ebp+16]\r
+       int 0xAC\r
+       END_FRAME\r
+       ret\r
+_k_fwrite:\r
+       START_FRAME\r
+       mov eax, 5      ;SYS_WRITE\r
+       mov ebx, DWORD [ebp+8]\r
+       mov ecx, DWORD [ebp+12]\r
+       mov edx, DWORD [ebp+16]\r
+       int 0xAC\r
+       END_FRAME\r
+       ret\r
+_k_fstat:\r
+       START_FRAME\r
+       mov eax, 10     ;SYS_FSTAT\r
+       mov ebx, DWORD [ebp+8]\r
+       mov ecx, DWORD [ebp+12]\r
+       int 0xAC\r
+       END_FRAME\r
+       ret\r
+;_k_printf:\r
+;              jmp     0x1000a4\r
+_k_puts:\r
+               jmp     0x105418\r
+_k_opendir:\r
+       START_FRAME\r
+       mov eax, 2      ;SYS_OPEN\r
+       mov ebx, DWORD [ebp+8]\r
+       mov ecx, 0\r
+       mov edx, 0\r
+       int 0xAC\r
+       END_FRAME\r
+       ret\r
+       ;jmp    0x00100050\r
+_k_readdir:\r
+       START_FRAME\r
+       mov eax, 11     ;SYS_READDIR\r
+       mov ebx, DWORD [ebp+8]\r
+       mov ecx, DWORD [ebp+12]\r
+       int 0xAC\r
+       END_FRAME\r
+       ret\r
+\r
+_k_exec:\r
+       START_FRAME\r
+       mov eax, 14     ;SYS_EXEC\r
+       mov ebx, DWORD [ebp+8]\r
+       int 0xAC\r
+       END_FRAME\r
+       ret\r
+\r
+_k_ioctl:\r
+       START_FRAME\r
+       mov eax, 12     ;SYS_IOCTL\r
+       mov ebx, DWORD [ebp+8]\r
+       mov ecx, DWORD [ebp+12]\r
+       mov edx, DWORD [ebp+16]\r
+       int 0xAC\r
+       END_FRAME\r
+       ret\r
diff --git a/Usermode/Applications/axwin0_src/main.c b/Usermode/Applications/axwin0_src/main.c
new file mode 100644 (file)
index 0000000..a2ed61a
--- /dev/null
@@ -0,0 +1,183 @@
+/*\r
+Acess OS Window Manager\r
+*/\r
+#include "header.h"\r
+#include "bitmaps.h"\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <string.h>\r
+\r
+#define        USE_MOUSE       1\r
+\r
+//GLOBALS\r
+ int   giConsoleFP = -1;\r
+ int   giScreenFP = -1;\r
+ int   giScreenMode = 1;\r
+ int   giScreenWidth = SCREEN_WIDTH;\r
+ int   giScreenHeight = SCREEN_HEIGHT;\r
+ int   giScreenDepth = 32;\r
+ int   giScreenSize = SCREEN_WIDTH*SCREEN_HEIGHT*32/8;\r
+Uint32 *gScreenBuffer;\r
+#if USE_MOUSE\r
+int    giMouseFP = -1;\r
+Uint32         gCursorBMP[sizeof(bmpCursor)*2] = {0};\r
+int            mouseX=0, mouseY=0;\r
+Uint8  buttonState;\r
+#endif\r
+\r
+//PROTOTYPES\r
+extern void Desktop_Init();\r
+extern void heap_init();\r
+void UpdateScreen();\r
+#if USE_MOUSE\r
+void UpdateMouse();\r
+void BuildCursor();\r
+void DrawCursor();\r
+#endif\r
+void memsetd(void *to, long val, int count);\r
+\r
+//CODE\r
+int main(void)\r
+{\r
+        int    tmp;\r
+       \r
+       giConsoleFP = open("/Devices/vterm/1", OPENFLAG_WRITE);\r
+       \r
+       printf("AcessOS GUI version 1\n");\r
+       printf("Opening and Initialising Video and Mouse...");\r
+       \r
+       #if USE_MOUSE\r
+       giMouseFP = open("/Devices/ps2mouse", OPENFLAG_READ);\r
+       #endif\r
+       \r
+       tmp = giScreenWidth;    ioctl(giConsoleFP, 4, &tmp);    // Width\r
+       tmp = giScreenHeight;   ioctl(giConsoleFP, 5, &tmp);    // Height\r
+       tmp = 1;        ioctl(giConsoleFP, 6, &tmp);    // Buffer Mode\r
+       \r
+       giScreenSize = giScreenWidth*giScreenHeight*giScreenDepth/8;\r
+       \r
+       #if USE_MOUSE\r
+       ioctl(giMouseFP, 2, &giScreenWidth);    //Set Max X\r
+       ioctl(giMouseFP, 3, &giScreenHeight);   //Set Max Y\r
+       #endif\r
+       printf("Done.\n");\r
+       \r
+       // Allocate Screen Buffer\r
+       gScreenBuffer = malloc(giScreenSize);\r
+       if(gScreenBuffer == NULL)\r
+               printf("Unable to allocate double buffer (gScreenBuffer)\n");\r
+       \r
+       UpdateScreen();\r
+       Desktop_Init();\r
+       #if USE_MOUSE\r
+       BuildCursor();  //Create Cursor\r
+       #endif\r
+       \r
+       for(;;) {\r
+               memset(gScreenBuffer, 0x6666FF, giScreenSize);  // Set Background Colour\r
+               wmUpdateWindows();\r
+               #if USE_MOUSE\r
+               UpdateMouse();\r
+               DrawCursor();\r
+               #endif\r
+               UpdateScreen();\r
+       }\r
+       \r
+       return 1;\r
+}\r
+\r
+/* Copy from the buffer to the screen\r
+ */\r
+void UpdateScreen()\r
+{\r
+       printf("Updating Framebuffer.\n");\r
+       seek(giScreenFP, 0, 1); //SEEK SET\r
+       write(giScreenFP, giScreenSize, gScreenBuffer);\r
+}\r
+\r
+#if USE_MOUSE\r
+void UpdateMouse()\r
+{\r
+       struct {\r
+               int     x, y, scroll;\r
+               Uint8   buttons;\r
+       } data;\r
+       //k_printf("Updating Mouse State...");\r
+       \r
+       seek(giMouseFP, 0, 1);\r
+       read(giMouseFP, sizeof(data), &data);\r
+       \r
+       mouseX = data.x;        mouseY = data.y;\r
+       //Button Press\r
+       if(data.buttons & ~buttonState) {\r
+               //wmMessageButtonDown();\r
+       }\r
+       //Button Release\r
+       if(~data.buttons & buttonState) {\r
+               //wmMessageButtonUp();\r
+       }\r
+       \r
+       buttonState = data.buttons;     //Update Button State\r
+       //k_printf("Done.\n");\r
+}\r
+\r
+void DrawCursor()\r
+{\r
+       int i,j;\r
+       Uint32  *buf, *bi;\r
+       bi = gCursorBMP;\r
+       buf = gScreenBuffer + mouseY*giScreenWidth + mouseX;\r
+       for(i=0;i<24;i++)\r
+       {\r
+               for(j=0;j<16;j++)\r
+               {\r
+                       if(*bi&0xFF000000)\r
+                       {\r
+                               buf[j] = *bi&0xFFFFFF;\r
+                       }\r
+                       bi++;\r
+               }\r
+               buf += giScreenWidth;\r
+       }\r
+}\r
+\r
+void BuildCursor()\r
+{\r
+       int i,j;\r
+       Uint32  px;\r
+       Uint32  *buf, *bi;\r
+       bi = bmpCursor;\r
+       buf = gCursorBMP;\r
+       for(i=0;i<sizeof(bmpCursor)/8;i++)\r
+       {\r
+               for(j=0;j<8;j++)\r
+               {\r
+                       px = (*bi & (0xF << ((7-j)*4) )) >> ((7-j)*4);\r
+                       if( px & 0x1 )\r
+                       {\r
+                               if(px & 8)      *buf = 0xFF000000;      //Black (100% Alpha)\r
+                               else            *buf = 0xFFFFFFFF;      //White (100% Alpha)\r
+                       }\r
+                       else\r
+                               *buf = 0;       // 0% Alpha\r
+                       buf++;\r
+               }\r
+               bi++;\r
+               for(j=0;j<8;j++)\r
+               {\r
+                       px = (*bi & (0xF << ((7-j)*4) )) >> ((7-j)*4);\r
+                       if( px & 0x1 )\r
+                       {\r
+                               if(px & 8)      *buf = 0xFF000000;      // Black (100% Alpha)\r
+                               else            *buf = 0xFFFFFFFF;      // White (100% Alpha)\r
+                       }\r
+                       else\r
+                       {\r
+                               *buf = 0; // 0% Alpha\r
+                       }\r
+                       buf++;\r
+               }\r
+               bi++;\r
+       }\r
+}\r
+#endif\r
diff --git a/Usermode/Applications/axwin0_src/start.asm b/Usermode/Applications/axwin0_src/start.asm
new file mode 100644 (file)
index 0000000..c45e419
--- /dev/null
@@ -0,0 +1,98 @@
+; AcessBasic Test Command Prompt\r
+; Assembler Stub\r
+\r
+[BITS 32]\r
+\r
+extern _main\r
+extern codeLength\r
+extern loadTo\r
+extern entrypoint\r
+extern magic\r
+\r
+global start\r
+global _gAxeHdr\r
+\r
+FLAGS equ 0\r
+MAXMEM equ     0x400000        ; 4Mb\r
+\r
+;Header\r
+db     'A'\r
+db     'X'\r
+db     'E'\r
+db     0\r
+;Size\r
+_gAxeHdr:\r
+dd codeLength  ;Code Size\r
+dd loadTo              ;Load Address\r
+dd entrypoint  ;Entrypoint\r
+dd MAXMEM      ;Maximum Used Memory\r
+dd FLAGS       ;Flags\r
+dd magic+FLAGS+MAXMEM\r
+\r
+;Code\r
+start:\r
+       push eax\r
+       call _main\r
+       \r
+       ret\r
+       ret\r
+       \r
+;String Compare\r
+_strcmp:\r
+       push ebp\r
+       mov ebp, esp\r
+       push ebx\r
+       push ecx\r
+       \r
+       mov ebx, [ebp+8]\r
+       mov ecx, [ebp+12]\r
+.cmp:\r
+       mov al, BYTE [ecx]\r
+       cmp BYTE [ebx], al\r
+       jnz     .out\r
+       cmp BYTE [ecx],0\r
+       jnz     .out\r
+       inc ebx\r
+       inc edx\r
+       jmp     .cmp\r
+.out:\r
+       mov eax, DWORD 0\r
+       mov al, BYTE [ebx]\r
+       sub al, BYTE [ecx]\r
+       ;Cleanup\r
+       pop     ecx\r
+       pop ebx\r
+       pop ebp\r
+       ret\r
+       \r
+;String Copy\r
+_strcpy:\r
+       push ebp\r
+       mov ebp, esp\r
+       push ebx\r
+       push ecx\r
+       push edx\r
+       mov ebx, [ebp+8]        ;Src\r
+       mov ecx, [ebp+12]       ;Dest\r
+.cmp:\r
+       cmp BYTE [ebx], 0\r
+       jnz .out\r
+       mov dl, BYTE [ebx]\r
+       mov BYTE [ecx], dl\r
+       inc ebx\r
+       inc ecx\r
+       jmp .cmp\r
+.out:  ;Cleanup\r
+       pop edx\r
+       pop ecx\r
+       pop ebx\r
+       pop ebp\r
+       ret\r
+\r
+       \r
+[section .bss]\r
+[global _startHeap]\r
+[global _endHeap]\r
+_startHeap:\r
+resb 0x4000    ;Heap Space\r
+_endHeap:\r
diff --git a/Usermode/Applications/axwin0_src/wm.c b/Usermode/Applications/axwin0_src/wm.c
new file mode 100644 (file)
index 0000000..2885984
--- /dev/null
@@ -0,0 +1,184 @@
+/*\r
+Acess OS GUI\r
+Window Manager\r
+*/\r
+#include "header.h"\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+\r
+#define        DEBUG   0\r
+#define EXPORT \r
+\r
+// === STRUCTURES ===\r
+typedef struct sWINDOW_LIST {\r
+       struct sWINDOW_LIST     *next;\r
+       tWINDOW *wnd;\r
+}      tWINDOW_LIST;\r
+\r
+// === IMPORTS ===\r
+extern int     giScreenWidth,giScreenHeight;\r
+\r
+//GLOBALS\r
+static tWINDOW         *hwndRootWindow = NULL;\r
+static tWINDOW_LIST    *windowList = NULL;\r
+\r
+//PROTOTYPES\r
+void wmDrawWindow(tWINDOW *wnd);\r
+void wmRepaintWindow(tWINDOW *wnd);\r
+void wmRepaintScreen(tWINDOW_LIST *ent);\r
+void wmInvalidateWindow(tWINDOW        *wnd);\r
+\r
+//CODE\r
+void wmUpdateWindows()\r
+{\r
+       if(windowList == NULL)  return;\r
+       wmRepaintScreen(windowList);\r
+       //wmRepaintWindow(hwndRootWindow);\r
+}\r
+\r
+EXPORT void    *WM_CreateWindow(int x, int y, int w, int h, wndproc_t wndProc, Uint flags)\r
+{\r
+       tWINDOW *tmpWindow;\r
+       tWINDOW_LIST    *tmpListEnt;\r
+       \r
+       \r
+       #if DEBUG\r
+               //k_printf("WM_CreateWindow: (x=%i,y=%i,w=%i,h=%i,wndProc=0x%x,flags=0x%x)\n", x,y,w,h,wndProc,flags);\r
+       #endif\r
+       \r
+       if(x < 0 || y < 0 || wndProc == NULL)\r
+               return 0;\r
+       \r
+       tmpWindow = (tWINDOW*)malloc(sizeof(tWINDOW));\r
+       if(tmpWindow == NULL)\r
+               return NULL;\r
+       \r
+       #if DEBUG\r
+               //k_printf(" WM_CreateWindow: tmpWindow = 0x%x\n", tmpWindow);\r
+       #endif\r
+       \r
+       tmpWindow->handle = tmpWindow;\r
+       tmpWindow->flags = flags;\r
+       tmpWindow->wndproc = wndProc;\r
+       tmpWindow->bmp.bpp = 32;\r
+       tmpWindow->bmp.width = (w==-1?giScreenWidth:w);\r
+       tmpWindow->bmp.height = (h==-1?giScreenHeight:h);\r
+       tmpWindow->bmp.data = (void *) malloc(4*tmpWindow->bmp.width*tmpWindow->bmp.height);\r
+       if(tmpWindow->bmp.data == NULL)\r
+       {\r
+               free(tmpWindow);\r
+               return NULL;\r
+       }\r
+       tmpWindow->rc.x1 = x;\r
+       tmpWindow->rc.y1 = y;\r
+       tmpWindow->rc.x2 = x + tmpWindow->bmp.width;\r
+       tmpWindow->rc.y2 = y + tmpWindow->bmp.height;\r
+       tmpWindow->next = NULL;\r
+       tmpWindow->prev = NULL;\r
+       tmpWindow->first_child = NULL;\r
+       tmpWindow->last_child = NULL;\r
+       tmpWindow->parent = NULL;\r
+       \r
+       if(flags & WNDFLAG_SHOW)\r
+       {\r
+               tmpListEnt = malloc(sizeof(tWINDOW_LIST));\r
+               tmpListEnt->wnd = tmpWindow;\r
+               tmpListEnt->next = windowList;\r
+               windowList = tmpListEnt;\r
+       }\r
+       \r
+       if(hwndRootWindow == NULL)\r
+       {\r
+               hwndRootWindow = tmpWindow;\r
+       }\r
+       else\r
+       {\r
+               if(hwndRootWindow->first_child == NULL)\r
+               {\r
+                       hwndRootWindow->last_child = tmpWindow;\r
+                       hwndRootWindow->first_child = tmpWindow;\r
+               }\r
+               else\r
+               {\r
+                       hwndRootWindow->last_child->next = tmpWindow;\r
+                       tmpWindow->prev = hwndRootWindow->last_child;\r
+                       tmpWindow->prev->next = tmpWindow;\r
+                       hwndRootWindow->last_child = tmpWindow;\r
+               }\r
+               tmpWindow->parent = hwndRootWindow;\r
+       }\r
+       \r
+       wmInvalidateWindow(tmpWindow);\r
+       \r
+       return tmpWindow;\r
+}\r
+\r
+EXPORT int     WM_SendMessage(void *hwnd, int msg, int a1, int a2)\r
+{\r
+       if(hwnd == NULL || ((tWINDOW*)hwnd)->wndproc == NULL)\r
+       {\r
+               //k_printf("WM_SendMessage: ERROR - Window is undefined\n");\r
+               return -1;\r
+       }\r
+       return ((tWINDOW*)hwnd)->wndproc( ((tWINDOW*)hwnd)->handle, msg, a1, a2 );\r
+}\r
+\r
+void wmRepaintWindow(tWINDOW *wnd)\r
+{\r
+       tWINDOW *child;\r
+       \r
+       if(wnd->repaint == 1)\r
+       {\r
+               for(child = wnd->first_child; child != NULL; child = child->next) {\r
+                       wmRepaintWindow(child);\r
+               }\r
+               WM_SendMessage(wnd, WM_REPAINT, (Uint)&wnd->bmp, 0);\r
+               wmDrawWindow(wnd);\r
+       }\r
+}\r
+\r
+void wmRepaintScreen(tWINDOW_LIST *ent)\r
+{\r
+       #if DEBUG\r
+               //k_printf("wmRepaintScreen: (ent=0x%x)\n", ent);\r
+       #endif\r
+       if(ent == NULL)\r
+               return;\r
+       if(ent->wnd->repaint == 1)\r
+       {\r
+               #if DEBUG\r
+                       //k_printf("wmRepaintScreen: ent->wnd=0x%x\n", ent->wnd);\r
+               #endif\r
+               WM_SendMessage(ent->wnd, WM_REPAINT, (Uint)&ent->wnd->bmp, 0);\r
+               #if DEBUG\r
+                       //k_printf("wmRepaintScreen: ent->wnd=0x%x\n", ent->wnd);\r
+               #endif\r
+               wmDrawWindow(ent->wnd);\r
+       }\r
+       if(ent->next != NULL)\r
+       {\r
+               wmRepaintScreen(ent->next);\r
+       }\r
+}\r
+\r
+void wmDrawWindow(tWINDOW *wnd)\r
+{\r
+       #if DEBUG\r
+               //k_printf("wmDrawWindow: (wnd = 0x%x)\n", wnd);\r
+       #endif\r
+       if(wnd->flags & WNDFLAG_SHOW) {\r
+               #if DEBUG\r
+                       //k_printf(" wmDrawWindow: Drawing Window\n");\r
+               #endif\r
+               draw_bmp(&wnd->bmp, &wnd->rc);\r
+       }\r
+}\r
+\r
+void wmInvalidateWindow(tWINDOW        *wnd)\r
+{\r
+       tWINDOW *parent;\r
+       wnd->repaint = 1;\r
+       \r
+       while( (parent = wnd->parent) )\r
+               parent->repaint = 1;\r
+}\r

UCC git Repository :: git.ucc.asn.au