+++ /dev/null
-call hres\r
-vi dos_gfx.cpp\r
-call x\r
-pause\r
-dos_gfx.exe\r
+++ /dev/null
-/*\r
- * Just some handy typedefs that make it easier to think about the low\r
- * level code\r
- */\r
-\r
-typedef unsigned char byte;\r
-typedef unsigned short word;\r
-typedef unsigned long dword;\r
-typedef signed char sbyte;\r
-typedef signed short sword;\r
-typedef signed long sdword;\r
test.exe: test.obj modex16.obj bitmap.obj\r
wcl $(FLAGS) test.obj modex16.obj bitmap.obj\r
\r
-test2.exe: test2.obj modex16.obj bitmap.obj\r
- wcl $(FLAGS) test2.obj modex16.obj bitmap.obj\r
+test2.exe: test2.obj modex16.obj bitmap.obj planar.obj\r
+ wcl $(FLAGS) test2.obj modex16.obj bitmap.obj planar.obj\r
\r
pcxtest.exe: pcxtest.obj modex16.obj bitmap.obj\r
wcl $(FLAGS) pcxtest.obj modex16.obj bitmap.obj\r
\r
bitmap.obj: $(SRCLIB)bitmap.h $(SRCLIB)bitmap.c\r
wcl $(FLAGS) -c $(SRCLIB)bitmap.c\r
+\r
+planar.obj: $(SRCLIB)planar.h $(SRCLIB)planar.c\r
+ wcl $(FLAGS) -c $(SRCLIB)planar.c\r
\r
clean: \r
del *.obj\r
--- /dev/null
+/*\r
+ * Implimentation of the planar buffer files.\r
+ */\r
+#include <stdlib.h>\r
+#include "planar.h"\r
+\r
+/* creates a planar buffer from the bitmap data.\r
+ The planar buffer is dynamically allocated, and should\r
+ be destroyed with the planar_buf_free function when no longer\r
+ needed.\r
+ */\r
+planar_buf_t *\r
+planar_buf_from_bitmap(bitmap_t *b) {\r
+ planar_buf_t *p;\r
+ int plane, bi, pi, x, y;\r
+\r
+ /* allocate the buffer */\r
+ p = planar_buf_alloc(b->width, b->height);\r
+\r
+ /* copy the bitmap data into the planar format */\r
+ bi=0;\r
+ pi=0;\r
+ for(y=0; y < b->height; y++) {\r
+ /* start on the first plane */\r
+ plane=0;\r
+ for(x=0; x < b->width; x++) {\r
+ /* copy to each plane */\r
+ p->plane[plane++][pi]=b->data[bi++];\r
+\r
+ /* handle the completion of 4 planes. */\r
+ if(plane==4) {\r
+ plane=0;\r
+ pi++;\r
+ }\r
+ }\r
+\r
+ /* correct for images not divisible by 4 */\r
+ if(plane) pi++;\r
+ }\r
+\r
+ return p;\r
+}\r
+\r
+\r
+/* allocates a planar buffer with specified dimensions */\r
+planar_buf_t *\r
+planar_buf_alloc(word width, word height) {\r
+ planar_buf_t *p;\r
+ int i;\r
+\r
+ /* allocate the structure and populate sizes */\r
+ p=malloc(sizeof(planar_buf_t));\r
+ p->width = width;\r
+ p->height = height;\r
+ p->pwidth = width / 4 + (width%4 ? 1 : 0);\r
+\r
+ /* allocate the planes */\r
+ for(i=0; i<4; i++) {\r
+ p->plane[i] = malloc(p->height * p->pwidth);\r
+ }\r
+\r
+ return p;\r
+}\r
+\r
+\r
+/* deallocates a planar buffer */\r
+void\r
+planar_buf_free(planar_buf_t *p) {\r
+ int i;\r
+\r
+ /* free the planes */\r
+ for(i=0; i<4; i++) {\r
+ free(p->plane[i]);\r
+ }\r
+\r
+ /* free the structure */\r
+ free(p);\r
+}\r
--- /dev/null
+/*
+ * Functions and types for a planar image buffer.
+ * This is meant to be able to load into video memory faster.
+ */
+#include "bitmap.h"
+
+#ifndef PLANAR_H
+#define PLANAR_H
+typedef struct {
+ byte *plane[4]; /* 4 planes of image data */
+ word width; /* width of the image (spread across 4 planes) */
+ word height; /* height of the image (spread across 4 planes) */
+ word pwidth; /* the number of bytes in each plane */
+} planar_buf_t;
+
+
+/* creates a planar buffer from the bitmap data.
+ The planar buffer is dynamically allocated, and should
+ be destroyed with the planar_buf_free function when no longer
+ needed.
+ */
+planar_buf_t *planar_buf_from_bitmap(bitmap_t *b);
+
+
+/* allocates a planar buffer with specified dimensions */
+planar_buf_t *planar_buf_alloc(word width, word height);
+
+
+/* deallocates a planar buffer */
+void planar_buf_free(planar_buf_t *p);
+#endif
+#include <stdio.h>\r
#include "src\lib\modex16.h"\r
+#include "src\lib\planar.h"\r
+#include "src\lib\bitmap.h"\r
\r
word far* clock= (word far*) 0x046C; /* 18.2hz clock */\r
\r
void main() {\r
+ bitmap_t bmp;\r
+ planar_buf_t *p;\r
+ word size;\r
int i;\r
- word start;\r
- page_t page;\r
+ int plane;\r
+ int x,y;\r
+ byte color;\r
\r
- page=modexDefaultPage();\r
+ /* get the size we want */\r
+ printf("Width: ");\r
+ scanf("%d", &bmp.width);\r
+ printf("Height: ");\r
+ scanf("%d", &bmp.height);\r
+ printf("Color: ");\r
+ scanf("%x", &color);\r
\r
- modexEnter();\r
- start = *clock;\r
- for(i=0; i<500; i++) {\r
- modexShowPage(&page);\r
+ /* allocate the bmp and fill it with 42 */\r
+ size = bmp.width * bmp.height;\r
+ bmp.data = malloc(size);\r
+ for(i=0; i<size; i++) {\r
+ bmp.data[i] = color;\r
}\r
- modexLeave();\r
\r
+ /* create the planar buffer */\r
+ p = planar_buf_from_bitmap(&bmp);\r
+\r
+ /* print out the contents of each plane */\r
+ for(plane=0; plane < 4; plane++) {\r
+ i=0;\r
+ printf("Plane %d\n", plane);\r
+ for(y=0; y < p->height; y++) {\r
+ for(x=0; x < p->pwidth; x++) {\r
+ printf("%02X ", (int) p->plane[plane][i++]);\r
+ }\r
+ printf("\n");\r
+ }\r
+ }\r
}\r