]> 4ch.mooo.com Git - 16.git/commitdiff
Merge branch 'master' of github.com:sparky4/16
authorsparky4 <sparky4@lappy4.4ch.mooo.com>
Wed, 21 Jan 2015 02:36:39 +0000 (20:36 -0600)
committersparky4 <sparky4@lappy4.4ch.mooo.com>
Wed, 21 Jan 2015 02:36:39 +0000 (20:36 -0600)
13 files changed:
16/Q.BAT [deleted file]
16/lib/TYPES.H [deleted file]
makefile
pcxtest.exe
planarNotes.txt [new file with mode: 0644]
scroll.exe
src/lib/PLANAR.C [new file with mode: 0644]
src/lib/modex16.c
src/lib/modex16.h
src/lib/planar.h [new file with mode: 0644]
src/test2.c
test.exe
test2.exe

diff --git a/16/Q.BAT b/16/Q.BAT
deleted file mode 100644 (file)
index 5d1b584..0000000
--- a/16/Q.BAT
+++ /dev/null
@@ -1,5 +0,0 @@
-call hres\r
-vi dos_gfx.cpp\r
-call x\r
-pause\r
-dos_gfx.exe\r
diff --git a/16/lib/TYPES.H b/16/lib/TYPES.H
deleted file mode 100644 (file)
index 039653f..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-/*\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
index 0a47caf606ba3574f6ae846644e425ea71b4324f..ebc15e33d99e7d58c12f71d971d4518333f5e284 100644 (file)
--- a/makefile
+++ b/makefile
@@ -10,8 +10,8 @@ scroll.obj: $(SRC)scroll.c
 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
@@ -33,6 +33,9 @@ dos_kb.obj: $(SRCLIB)dos_kb.h $(SRCLIB)dos_kb.c
 \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
index 1a99ead2f9f3f8199f08031f468fe6ac2dd72c12..e13ada6699a6998caf703c0c328fb26139e7b2ce 100644 (file)
Binary files a/pcxtest.exe and b/pcxtest.exe differ
diff --git a/planarNotes.txt b/planarNotes.txt
new file mode 100644 (file)
index 0000000..f929393
--- /dev/null
@@ -0,0 +1,26 @@
+The first case to consider is that where the image width is divisible
+by 4.  This case is shown below:
+
+Planar Format     Normal Raster order
+=============    ===================
+0 0 1 2 3                PI
+  4 5 6 7        00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33
+  8 9 A B         04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37
+                         08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B
+1 0 1 2 3
+  4 5 6 7
+  8 9 A B
+
+2 0 1 2 3
+  4 5 6 7
+  8 9 A B
+
+3 0 1 2 3
+  4 5 6 7
+  8 9 A B
+
+Suppose we would like to render the image from (1,0) to (3,1), we
+would render the coordinates:
+
+  10 20 30
+  14 24 34
index ba9037f20a99eeb8e3d5d2acffd28b5a9ecde875..05fc5f4ee122f71674ef41b6d0c4e8b5d238845d 100644 (file)
Binary files a/scroll.exe and b/scroll.exe differ
diff --git a/src/lib/PLANAR.C b/src/lib/PLANAR.C
new file mode 100644 (file)
index 0000000..8b9f004
--- /dev/null
@@ -0,0 +1,78 @@
+/*\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
index bde6b1fe47b89604ce2547e6f9d9ef45a1fa8616..0137b625e95302afa459d1020a63ca1786ebb5c7 100644 (file)
@@ -286,6 +286,12 @@ modexDrawBmpRegion(page_t *page, int x, int y,
 }\r
 \r
 \r
+void\r
+modexDrawPlanarBuf(page_t *page, int x, int y, planar_buf_t *bmp) {\r
+    /* TODO - adapt from test code */\r
+}\r
+\r
+\r
 void\r
 modexDrawSprite(page_t *page, int x, int y, bitmap_t *bmp) {\r
     /* draw the whole sprite */\r
index 1a5debdf26d44a927230dfb5593ec9c2f757c588..7cb278205e7115db68c7146a12a7a3d60432b327 100644 (file)
@@ -6,6 +6,7 @@
 #include <conio.h>\r
 #include "src\lib\types.h"\r
 #include "src\lib\bitmap.h"\r
+#include "src\lib\planar.h"\r
 \r
 /* -========================== Types & Macros ==========================- */\r
 #define PAGE_OFFSET(x,y) (((y)<<6)+((y)<<4)+((x)>>2))\r
@@ -29,11 +30,12 @@ page_t modexNextPage(page_t *p);
 void modexShowPage(page_t *page);\r
 void modexPanPage(page_t *page, int dx, int dy);\r
 void modexSelectPlane(byte plane);\r
-void modexClearRegion(page_t *page, int x, int y, int w, int h, byte color);
+void modexClearRegion(page_t *page, int x, int y, int w, int h, byte color);\r
 void modexDrawBmp(page_t *page, int x, int y, bitmap_t *bmp);\r
 void modexDrawBmpRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, bitmap_t *bmp);\r
+void modexDrawPlanarBuf(page_t *page, int x, int y, planar_buf_t *bmp);\r
 void modexDrawSprite(page_t *page, int x, int y, bitmap_t *bmp);\r
-void modexDrawSpriteRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, bitmap_t *bmp);
+void modexDrawSpriteRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, bitmap_t *bmp);\r
 void modexCopyPageRegion(page_t *dest, page_t *src, word sx, word sy, word dx, word dy, word width, word height);\r
 \r
 /* Palette fade and flash effects */\r
diff --git a/src/lib/planar.h b/src/lib/planar.h
new file mode 100644 (file)
index 0000000..6aa8e26
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * 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
index 5b3d32c0c962afe65d9857a1fb2c8751d7719d74..ac939e573a2ef62a4506be253cb0f11d6868d335 100644 (file)
@@ -1,19 +1,46 @@
+#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
index fcccbf075c9f2b7adc20c381566b5532724c4caa..4dae76db4bea4ee902435dc7d92efcac58b7faff 100644 (file)
Binary files a/test.exe and b/test.exe differ
index ca41644c5c0b27095806d15eecc48bb4064cc5ed..7878dbc4e243afe8c483edcb264dd4e3221ea4f1 100644 (file)
Binary files a/test2.exe and b/test2.exe differ