OFLAGS=-ot -ox -ob -ol -oh -or
-FLAGS=-0 -d2 -mh -wo $(OFLAGS)
+FLAGS=-0 -d2 -wo $(OFLAGS)# -mh
DIRSEP=\
SRC=src$(DIRSEP)\r
SRCLIB=$(SRC)lib$(DIRSEP)
pcxtest.exe: pcxtest.obj modex16.obj bitmap.obj\r
wcl $(FLAGS) pcxtest.obj modex16.obj bitmap.obj\r
\r
-maptest.exe: maptest.obj mapread.obj jsmn.obj modex16.obj bitmap.obj\r
- wcl $(FLAGS) maptest.obj mapread.obj jsmn.obj modex16.obj bitmap.obj\r
+maptest.exe: maptest.obj mapread.obj jsmn.obj modex16.obj bitmap.obj lib_head.obj\r
+ wcl $(FLAGS) maptest.obj mapread.obj jsmn.obj modex16.obj bitmap.obj lib_head.obj\r
\r
\r
test.obj: $(SRC)test.c $(SRCLIB)modex16.h\r
planar.obj: $(SRCLIB)planar.h $(SRCLIB)planar.c\r
wcl $(FLAGS) -c $(SRCLIB)planar.c\r
\r
-mapread.obj: $(SRCLIB)mapread.h $(SRCLIB)mapread.c lib_head.obj jsmn.obj\r
+mapread.obj: $(SRCLIB)mapread.h $(SRCLIB)mapread.c# lib_head.obj jsmn.obj\r
wcl $(FLAGS) -c $(SRCLIB)mapread.c\r
\r
lib_head.obj: $(SRCLIB)lib_head.h $(SRCLIB)lib_head.c\r
wcl $(FLAGS) -c $(SRCLIB)lib_head.c\r
\r
jsmn.obj: $(JSMNLIB)jsmn.h $(JSMNLIB)jsmn.c\r
- wcl $(FLAGS) -c $(JSMNLIB)jsmn.c\r
-\r
+ wcl $(FLAGS) -c $(JSMNLIB)jsmn.c
+
clean:\r
del *.obj\r
# del *.exe\r
#include <stdio.h>\r
-#include <stdlib.h>\r
+#include <stdlib.h>
+#include <malloc.h>
#include "src/lib/bitmap.h"\r
#include "src/lib/modex16.h"\r
\r
\r
/* make sure this is 8bpp */\r
if(head.bpp != 8) {\r
- printf("I only know how to handle 8bpp pcx files!\n");\r
- fclose(file);\r
- exit(-2);\r
+ printf("I only know how to handle 8bpp pcx files!\n");\r
+ fclose(file);\r
+ exit(-2);\r
}\r
}\r
\r
bitmapLoadPcx(char *filename) {\r
FILE *file;\r
bitmap_t result;\r
- long bufSize;\r
+ dword bufSize;\r
int index;\r
byte count, val;
\r
/* open the PCX file for reading */\r
file = fopen(filename, "rb");\r
if(!file) {\r
- printf("Could not open %s for reading.\n", filename);\r
- exit(-2);\r
+ printf("Could not open %s for reading.\n", filename);\r
+ exit(-2);\r
}\r
\r
/* load the first part of the pcx file */\r
loadPcxStage1(file, &result);
\r
/* allocate the buffer */\r
- bufSize = result.width * result.height;
- result.data = malloc(bufSize); //it breaks right here~
- if(!result.data) {\r
- printf("Could not allocate memory for bitmap data.");\r
- fclose(file);\r
- exit(-1);\r
- }\r
+ bufSize = ((dword)result.width * result.height);
+ result.data = malloc((bufSize));
+ /*0000printf("Size of block is %u bytes\n", _msize(result.data));
+ printf("Size of bufSize is %lu bytes\n", bufSize);
+ printf("Size of result.width is %lu \n", result.width);
+ printf("Size of result.height is %lu \n", result.height);
+ printf("Dimensions of result is %lu\n", result.width*result.height);*/
+ //exit(0);
+ if(!result.data) {
+ fprintf(stderr, "Could not allocate memory for bitmap data.");\r
+ fclose(file);\r
+ exit(-1);\r
+ }\r
\r
/* read the buffer in */\r
index = 0;\r
/* get the run length and the value */\r
count = fgetc(file);\r
if(0xC0 == (count & 0xC0)) { /* this is the run count */\r
- count &= 0x3f;\r
- val = fgetc(file);\r
+ count &= 0x3f;\r
+ val = fgetc(file);\r
} else {\r
- val = count;\r
- count = 1;\r
+ val = count;\r
+ count = 1;\r
}\r
\r
/* write the pixel the specified number of times */\r
for(; count && index < bufSize; count--,index++) {\r
- result.data[index] = val;\r
+ result.data[index] = val;\r
}\r
} while(index < bufSize);\r
\r
return result;\r
}\r
\r
-\r
+//update!!\r
tileset_t\r
bitmapLoadPcxTiles(char *filename, word twidth, word theight) {\r
tileset_t ts;\r
\r
/* open the PCX file for reading */\r
file = fopen(filename, "rb");\r
- if(!file) {\r
- printf("Could not open %s for reading.\n", filename);\r
- exit(-2);\r
- }\r
+ if(!file) {\r
+ printf("Could not open %s for reading.\n", filename);\r
+ exit(-2);\r
+ }\r
\r
/* load the first part of the pcx file */\r
loadPcxStage1(file, &result);\r
ts.ntiles = (result.width/twidth) * (result.height/theight);\r
ts.palette = result.palette;\r
\r
- /* allocate the pixel storage for the tiles */\r
- ts.data = malloc(sizeof(byte*) * ts.ntiles);\r
- ts.data[0] = malloc(sizeof(byte) * ts.ntiles * twidth * theight);\r
- for(i=1; i < ts.ntiles; i++) {\r
- ts.data[i] = ts.data[i-1] + twidth * theight;\r
- }\r
+ /* allocate the pixel storage for the tiles */\r
+ ts.data = malloc(sizeof(byte*) * ts.ntiles);\r
+ ts.data[0] = malloc(sizeof(byte) * ts.ntiles * twidth * theight);\r
+ for(i=1; i < ts.ntiles; i++) {\r
+ ts.data[i] = ts.data[i-1] + twidth * theight;\r
+ }\r
\r
/* finish off the file */\r
loadPcxPalette(file, &result);\r
*/\r
#ifndef BITMAP_H\r
#define BITMAP_H
-//#include <malloc.h>\r
-#include "src/lib/types.h"\r
+#include "src/lib/types.h"
+#include "src/lib/lib_head.h"
+\r
typedef struct {\r
- byte *data;
- word width;\r
- word height;\r
- byte *palette;
- word offset;
+ byte *data;
+ word width;\r
+ word height;\r
+ byte *palette;
+ word offset;
} bitmap_t;\r
\r
typedef struct {\r
- byte **data;\r
- word ntiles; /* the number of tiles */\r
- word twidth; /* width of the tiles */\r
- word theight; /* height of the tiles */\r
- byte *palette; /* palette for the tile set */\r
+ byte **data;\r
+ word ntiles; /* the number of tiles */\r
+ word twidth; /* width of the tiles */\r
+ word theight; /* height of the tiles */\r
+ byte *palette; /* palette for the tile set */\r
} tileset_t;\r
\r
bitmap_t bitmapLoadPcx(char *filename);\r
/* local function */\r
void wait(clock_t wait);
void* AllocateLargestFreeBlock(size_t* Size);
-size_t GetFreeSize(void);\r
+size_t GetFreeSize(void);
+long int filesize(FILE *fp);\r
\r
/* Function: Wait **********************************************************\r
*\r
return total;
}
+
+long int
+filesize(FILE *fp)\r
+{\r
+ long int save_pos, size_of_file;\r
+\r
+ save_pos = ftell(fp);\r
+ fseek(fp, 0L, SEEK_END);\r
+ size_of_file = ftell(fp);\r
+ fseek(fp, save_pos, SEEK_SET);\r
+ return(size_of_file);\r
+}
void wait(clock_t wait);
void* AllocateLargestFreeBlock(size_t* Size);
size_t GetFreeSize(void);
+long int filesize(FILE *fp);
/* THIS FUNCTION CONVERTS A POINTER TO AN INTEL LONG */\r
//int long ptr2long(char *p);
#include "src/lib/modex16.h"
#include "src/lib/lib_head.h"
+//---- temp!
static char *js_sv;
typedef struct {\r
*/
#ifndef MODEX16_H
#define MODEX16_H
-#include <conio.h>
+//#include <conio.h>
#include "src/lib/types.h"
#include "src/lib/bitmap.h"
#include "src/lib/planar.h"
main(int argc, char *argv[])\r
{\r
map_t map;
- //loadmap("data/test.map", &map);
+ loadmap("data/test.map", &map);
fprintf(stderr, "%d\n", map.data[0]);
}\r
#include "src/lib/bitmap.h"
#include "src/lib/planar.c"\r
\r
-word far* clock= (word far*) 0x046C; /* 18.2hz clock */\r
+word far* clockw= (word far*) 0x046C; /* 18.2hz clock */\r
\r
void\r
oldDrawBmp(byte far* page, int x, int y, bitmap_t *bmp, byte sprite) {\r
void main() {\r
bitmap_t bmp;
planar_buf_t *p;\r
- int i;\r
+ //int i;
+ dword i;\r
page_t page;\r
word start;
int plane;\r
\r
//0000 bmp = bitmapLoadPcx("data/koishi~~.pcx");
bmp = bitmapLoadPcx("data/chikyuu.pcx");
+// bmp = bitmapLoadPcx("data/koishi^^.pcx");
+// bmp = bitmapLoadPcx("16/PCX_LIB/chikyuu.pcx");
//0000 p = planar_buf_from_bitmap(&bmp);\r
modexEnter();\r
\r
modexClearRegion(&page, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 1);\r
\r
/* non sprite comparison */
- /*0000start = *clock;\r
+ /*0000start = *clockw;\r
for(i=0; i<100 ;i++) {\r
oldDrawBmp(VGA, 20, 20, &bmp, 0);\r
}\r
\r
- start = *clock;\r
+ start = *clockw;\r
for(i=0; i<100 ;i++) {\r
//0000 modexDrawBmp(&page, 20, 20, &bmp);
modexDrawBmp(&page, 0, 0, &bmp);\r
}\r
- t1 = (*clock-start) /18.2;\r
+ t1 = (*clockw-start) /18.2;\r
\r
- start = *clock;\r
+ start = *clockw;\r
for(i=0; i<100; i++) {\r
//0000 modexCopyPageRegion(&page, &page, 20, 20, 128, 20, 64, 64);
modexCopyPageRegion(&page, &page, 0, 0, 0, 0, 320, 240);\r
}\r
- t2 = (*clock-start)/18.2;\r
+ t2 = (*clockw-start)/18.2;\r
\r
\r
- start = *clock;\r
+ start = *clockw;\r
for(i=0; i<100 ;i++) {\r
oldDrawBmp(VGA, 20, 20, &bmp, 1);\r
}\r
\r
\r
- start = *clock;\r
+ start = *clockw;\r
for(i=0; i<100 ;i++) {\r
//0000 modexDrawSprite(&page, 20, 20, &bmp);
modexDrawSprite(&page, 0, 0, &bmp);\r
}*/
//_fmemset(MK_FP(0xA000, 0), (int)p->plane, SCREEN_WIDTH*(SCREEN_HEIGHT*2));
+ modexDrawBmp(&page, 0, 0, &bmp);
while(!kbhit())
{
//DrawPBuf(&page, 0, 0, p, 0);
- modexDrawBmp(&page, 0, 0, &bmp);
}
modexLeave();\r
printf("\n%d\n", sizeof(p->plane));
- printf("%d\n", sizeof(bmp));\r
+ printf("%d\n", sizeof(bmp));
+
+ /*for(i=0; i<(320*240); i++)
+ {
+ fprintf(stdout, "%d", bmp.data[i]);
+ if(i%320==0) fprintf(stdout, "\n");
+ }*/\r
//0000 printf("CPU to VGA: %f\n", t1);\r
//0000 printf("VGA to VGA: %f\n", t2);\r
return;\r
#include "src/lib/modex16.h"\r
#include <stdio.h>\r
\r
-word far* clock= (word far*) 0x046C; /* 18.2hz clock */\r
+word far* clockw= (word far*) 0x046C; /* 18.2hz clock */\r
\r
void main() {\r
int i, j;\r
modexFadeOn(1, pal2);\r
\r
\r
- start = *clock;\r
+ start = *clockw;\r
for(i=0; i<5; i++) {\r
/* go right */\r
for(j=0; j<32; j++) {\r
}\r
}\r
\r
- end = *clock;\r
+ end = *clockw;\r
\r
/* fade back to text mode */\r
modexFadeOff(1, pal2);\r
#include <conio.h>
#include "src/lib/modex16.h"\r
#include "src/lib/planar.h"\r
-#include "src/lib/bitmap.h"\r
+//#include "src/lib/bitmap.h"\r
\r
-word far* clock= (word far*) 0x046C; /* 18.2hz clock */\r
+word far* clockw= (word far*) 0x046C; /* 18.2hz clock */\r
\r
void main() {
FILE *file;\r