16FLAGS=-fh=16.hed
BAKAPIFLAGS=-fh=bakapi.hed
-SFLAGS=-sg -st -of+ -zu -zdf -zff -zgf -k56000#60000#32768
+SFLAGS=-sg -st -of+ -zu -zdf -zff -zgf -k56832#60000#32768
DFLAGS=-DTARGET_MSDOS=16 -DMSDOS=1 $(SFLAGS)
ZFLAGS=-zk0 -zq -zc -zp8# -zm
CFLAGS=$(IFLAGS) -mh -lr -l=dos -wo# -d2##wwww
16LIBOBJS = 16_in.$(OBJ) 16_mm.$(OBJ) wcpu.$(OBJ) 16_head.$(OBJ) 16_ca.$(OBJ) kitten.$(OBJ) 16_hc.$(OBJ) timer.$(OBJ)
#
#3812intf.$(OBJ)
-GFXLIBOBJS = modex16.$(OBJ) bitmap.$(OBJ) planar.$(OBJ) 16planar.$(OBJ) 16text.$(OBJ) bakapee.$(OBJ) scroll16.$(OBJ) 16render.$(OBJ)
+GFXLIBOBJS = modex16.$(OBJ) bitmap.$(OBJ) planar.$(OBJ) 16text.$(OBJ) bakapee.$(OBJ) scroll16.$(OBJ) 16render.$(OBJ) 16planar.$(OBJ)
TESTEXEC = exmmtest.exe test.exe pcxtest.exe pcxtest2.exe test2.exe palettec.exe maptest.exe fmemtest.exe fonttest.exe fontgfx.exe scroll.exe vgmtest.exe inputest.exe palettel.exe planrpcx.exe
# tsthimem.exe
#include <malloc.h>\r
#include "src/lib/bitmap.h"\r
\r
-#ifndef PCXHEADER_H\r
-#define PCXHEADER_H\r
-static struct pcxHeader {\r
- byte id;\r
- byte version;\r
- byte encoding;\r
- byte bpp;\r
- word xmin;\r
- word ymin;\r
- word xmax;\r
- word ymax;\r
- word hres;\r
- word vres;\r
- byte pal16[48];\r
- byte res1;\r
- word bpplane;\r
- word palType;\r
- word hScreenSize;\r
- word vScreenSize;\r
- byte padding[54];\r
-} head;\r
-#endif /*PCXHEADER_H*/\r
-\r
static void loadPcxStage1(FILE *file, bitmap_t *result) {\r
long bufSize;\r
int index;\r
result.data[index] = val;\r
}\r
} while(index < bufSize);\r
+ printf("index=%d\n", index);\r
\r
loadPcxPalette(file, &result);\r
\r
#define MODEX16_H
//#include <conio.h>
-#include "src/lib/types.h"
#include "src/lib/16_head.h"
#include "src/lib/bitmap.h"
#include "src/lib/planar.h"
#include "src/lib/modex16/192x144_.h"
#include "src/lib/modex16/160x120.h"
+static struct pcxHeader {
+ byte id;
+ byte version;
+ byte encoding;
+ byte bpp;
+ word xmin;
+ word ymin;
+ word xmax;
+ word ymax;
+ word hres;
+ word vres;
+ byte pal16[48];
+ byte res1;
+ word bpplane;
+ word palType;
+ word hScreenSize;
+ word vScreenSize;
+ byte padding[54];
+} head;
+
//320x240 = 20x15
//192x144 = 12x9
#include <malloc.h>\r
#include "src/lib/modex16/16planar.h"\r
\r
-#ifndef PCXHEADER_H\r
-#define PCXHEADER_H\r
-static struct pcxHeader {\r
- byte id;\r
- byte version;\r
- byte encoding;\r
- byte bpp;\r
- word xmin;\r
- word ymin;\r
- word xmax;\r
- word ymax;\r
- word hres;\r
- word vres;\r
- byte pal16[48];\r
- byte res1;\r
- word bpplane;\r
- word palType;\r
- word hScreenSize;\r
- word vScreenSize;\r
- byte padding[54];\r
-} head;\r
-#endif /*PCXHEADER_H*/\r
+/*\r
+ *============================================================================\r
+ */\r
\r
static void loadPcxpbufStage1(FILE *file, planar_buf_t *result) {\r
int index;\r
byte count, val;\r
long int pos;\r
\r
+//word w=0;\r
+//fprintf(stderr, "\nplanarLoadPcx: ");\r
+//fprintf(stderr, "%u ", w++);\r
/* read the header */\r
fread(&head, sizeof(char), sizeof(struct pcxHeader), file);\r
-\r
+//fprintf(stderr, "%u ", w++);\r
/* get the width and height */\r
result->width = head.xmax - head.xmin + 1;\r
result->height = head.ymax - head.ymin + 1;\r
-\r
+ result->pwidth = result->width / 4 + (result->width%4 ? 1 : 0);\r
+//fprintf(stderr, "%u ", w++);\r
/* make sure this is 8bpp */\r
if(head.bpp != 8) {\r
fprintf(stderr, "I only know how to handle 8bpp pcx files!\n");\r
fclose(file);\r
- //exit(-2);\r
+ exit(-2);\r
}\r
}\r
\r
}\r
}\r
\r
+/* allocates a planar buffer with specified dimensions */\r
+planar_buf_t\r
+pbuf_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
+ //p.pwidth = width / 4 + (width%4 ? 1 : 0);\r
+\r
+ /* allocate the planes */\r
+ for(i=0; i<4; i++) {\r
+ p.plane[i] = _fmalloc(p.height * p.pwidth);\r
+ }\r
+\r
+ return p;\r
+}\r
+\r
+/* allocates a planar buffer with specified dimensions */\r
+void\r
+pbuf_alloc0(planar_buf_t *p, word width, word height) {\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
+ //p.pwidth = width / 4 + (width%4 ? 1 : 0);\r
+\r
+ /* allocate the planes */\r
+ for(i=0; i<4; i++) {\r
+ p->plane[i] = _fmalloc(p->height * p->pwidth);\r
+ }\r
+}\r
+\r
/* sparky4's functions~ */\r
planar_buf_t planarLoadPcx(char *filename)\r
{\r
FILE *file;\r
planar_buf_t result;\r
dword bufSize;\r
- int index, plane, x, y;\r
+ int index[4], plane;\r
byte count, val;\r
- word q;\r
\r
+word w=0;\r
+fprintf(stderr, "\nplanarLoadPcx: ");\r
+fprintf(stderr, "%u ", w++);\r
/* open the PCX file for reading */\r
file = fopen(filename, "rb");\r
+//fprintf(stderr, "%u ", w++);\r
if(!file) {\r
fprintf(stderr, "Could not open %s for reading.\n", filename);\r
- //exit(-2);\r
+ exit(-2);\r
}\r
-\r
+//fprintf(stderr, "%u ", w++);\r
/* load the first part of the pcx file */\r
loadPcxpbufStage1(file, &result);\r
-\r
+//fprintf(stderr, "%u ", w++);\r
/* allocate the buffer */\r
bufSize = (/*(dword)*/result.width * result.height);\r
- //result = pbuf_alloc(result.width, result.height);\r
- if(!result.plane[0]) {\r
+ result = pbuf_alloc(result.width, result.height);\r
+ //pbuf_alloc0(&result, result.width, result.height);\r
+//fprintf(stderr, "%u ", w++);\r
+ printf("&bufSize=%p\n", &bufSize);\r
+ printf("&result.data=%p\n", result.plane);\r
+ printf("Size of block is %zu bytes\n", _msize(result.plane));\r
+ printf("Size of bufSize is %zu bytes\n", bufSize);\r
+ printf("Size of result.width is %zu \n", result.width);\r
+ printf("Size of result.height is %zu \n", result.height);\r
+ printf("Dimensions of result is %lu\n", (dword)result.width*result.height);\r
+ //exit(0);\r
+ if(!result.plane) {\r
fprintf(stderr, "Could not allocate memory for bitmap data.");\r
fclose(file);\r
- //exit(-1);\r
+ exit(-1);\r
}\r
-\r
+fprintf(stderr, "read the buffer? %u ", w++);\r
+getch();\r
/* read the buffer in */\r
- index = 0;\r
+ index[0] = 0,index[1]=0,index[2]=0,index[3]=0;\r
+ /* start on the first plane */\r
+ plane=0;\r
do {\r
/* get the run length and the value */\r
count = fgetc(file);\r
count = 1;\r
}\r
\r
- // start on the first plane\r
- plane=0;\r
/* write the pixel the specified number of times */\r
- for(; count && index < bufSize; count--,index++) {\r
+//fprintf(stderr, "\nputting in memory~ %u\n", w++);\r
+//if(index>=49152) getch();\r
+ for(; count && (index[0]+index[1]+index[2]+index[3]) < bufSize; count--,index[plane]++) {\r
+//fprintf(stderr, "count=%d index=%d plane=%d\n", count, index, plane);\r
switch (plane)\r
{\r
case 4:\r
plane=0;\r
break;\r
+ case 0:\r
+ case 1:\r
+ case 2:\r
+ plane++;\r
+ break;\r
}\r
+ //fprintf(stderr, "%d ", result.plane[plane][(index[0]+index[1]+index[2]+index[3])]);\r
// copy to each plane\r
- result.plane[plane++][index]=val;\r
+ result.plane[plane++][index[plane]]=val;\r
}\r
- } while(index < bufSize);\r
-\r
+ } while((index[0]+index[1]+index[2]+index[3]) < bufSize);\r
+ getch();\r
//++++loadPcxpbufPalette(file, &result);\r
fclose(file);\r
return result;\r
\r
/* allocate the planes */\r
for(i=0; i<4; i++) {\r
- p->plane[i] = malloc(p->height * p->pwidth);\r
+ p->plane[i] = malloc(p->height * p->pwidth);\r
}\r
\r
return p;\r
#include "src/lib/modex16.h"
-extern byte *modexNewPal();
-
/* 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
/* deallocates a planar buffer */
void planar_buf_free(planar_buf_t *p);
-
#endif
} tileset_t;\r
\r
typedef struct {\r
- byte huge *plane[4]; /* 4 planes of image data */\r
+ byte far *plane[4]; /* 4 planes of image data */\r
word width; /* width of the image (spread across 4 planes) */\r
word height; /* height of the image (spread across 4 planes) */\r
word pwidth; /* the number of bytes in each plane */\r
#include "src/lib/modex16.h"\r
\r
global_game_variables_t gvar;\r
-planar_buf_t huge p, ptmp;\r
+planar_buf_t p, ptmp;\r
+int i;\r
+word start;//, w;\r
+int plane;\r
+float t1, t2, tpee;\r
+int x,y;\r
+word px,py;\r
+sword baka;\r
+char *bakapeee;\r
\r
void main(int argc, char *argv[])\r
{\r
- int i;\r
- word start;\r
- int plane;\r
- float t1, t2, tpee;\r
- int x,y;\r
- word px,py;\r
- sword baka;\r
- char *bakapeee;\r
\r
- byte l[1024];\r
+ //byte l[1024];\r
word j,chw,xp,col,bgcol;\r
\r
-\r
+//w=0;\r
+//printf("%u ", w++);\r
bakapeee = malloc(64);\r
\r
if(argv[1]) bakapeee = argv[1];\r
// if(argv[2]) baka = atoi(argv[2]);\r
// else\r
baka = 1;\r
-\r
+//fprintf(stderr, "%u ", w++);\r
p = planarLoadPcx(bakapeee);\r
- ptmp = planarLoadPcx("data/ptmp.pcx");\r
-/* VGAmodeX(baka, &gvar);\r
+//fprintf(stderr, "%u ", w++);\r
+// ptmp = planarLoadPcx("data/ptmp.pcx");\r
+//fprintf(stderr, "%u ", w++);\r
+//fprintf(stderr, "^^;", w++);\r
+//getch();\r
+\r
+ VGAmodeX(baka, &gvar);\r
gvar.video.page[0]=modexDefaultPage(&gvar.video.page[0]);\r
\r
//fix up the palette and everything\r
while(!kbhit())\r
{\r
}\r
- VGAmodeX(0, &gvar);*/\r
+ VGAmodeX(0, &gvar);\r
\r
//print out the contents of each plane\r
for(plane=0; plane < 4; plane++) {\r
}\r
}\r
col=0x0d, bgcol=0;\r
- /*for(i=0; i<8; i++)\r
+ /*\r
+ for(i=0; i<8; i++)\r
{\r
//modexSelectPlane(PLANE(x));\r
//j=1<<8;\r
chw += xp;\r
fprintf(stderr,"Project 16 planrpcx.exe. This is just a test file!\n");\r
fprintf(stderr,"version %s\n", VERSION);\r
- fprintf(stderr,"%d\n", sizeof(p.plane));\r
- fprintf(stderr,"pw=%d\n", p.width);\r
- fprintf(stderr,"ph=%d\n", p.height);\r
- fprintf(stderr,"ppw=%d\n", p.pwidth);\r
- fprintf(stderr,"%d\n", sizeof(p));\r
- fprintf(stderr,"%dx%d\n", gvar.video.page[0].sw-(p.width), gvar.video.page[0].sh-(p.height));\r
- //planar_buf_free(p);\r
+ //fprintf(stderr,"%d\n", sizeof(p.plane));\r
+ //fprintf(stderr,"pw=%d\n", p.width);\r
+ //fprintf(stderr,"ph=%d\n", p.height);\r
+ //fprintf(stderr,"ppw=%d\n", p.pwidth);\r
+ //fprintf(stderr,"%d\n", sizeof(p));\r
+ //fprintf(stderr,"%dx%d\n", gvar.video.page[0].sw-(p.width), gvar.video.page[0].sh-(p.height));\r
free(bakapeee);\r
- fprintf(stderr, "modexDrawBmpPBuf: %f\n", t1);\r
- fprintf(stderr, "modexDrawPBuf: %f\n", t2);\r
- fprintf(stderr, "speed difference %f\n", t2/t1);\r
- fprintf(stderr, "gvar.video.page[0].width: %u\n", gvar.video.page[0].width);\r
- fprintf(stderr, "gvar.video.page[0].height: %u\n", gvar.video.page[0].height);\r
- return;\r
+ //fprintf(stderr, "modexDrawBmpPBuf: %f\n", t1);\r
+ //fprintf(stderr, "modexDrawPBuf: %f\n", t2);\r
+ //fprintf(stderr, "speed difference %f\n", t2/t1);\r
+ //fprintf(stderr, "gvar.video.page[0].width: %u\n", gvar.video.page[0].width);\r
+ //fprintf(stderr, "gvar.video.page[0].height: %u\n", gvar.video.page[0].height);\r
}\r