X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fbitmap.c;h=e8ad461c2a22bcaef0cda0d30db469ec0040385e;hb=968b6bcf1d7f19f8902e1ae00f2a80ab78d399cc;hp=d2480bafafd96b759a2cd0e5987f0e3ed450419b;hpb=47cdc66151d973d975d0e31fb8a786eb639bebdb;p=16.git diff --git a/src/lib/bitmap.c b/src/lib/bitmap.c index d2480baf..e8ad461c 100755 --- a/src/lib/bitmap.c +++ b/src/lib/bitmap.c @@ -1,5 +1,5 @@ /* Project 16 Source Code~ - * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 + * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover * * This file is part of Project 16. * @@ -24,12 +24,35 @@ #include #include #include "src/lib/bitmap.h" +#include "src/lib/16_mm.h" +#include "src/lib/16_pm.h" +#include "src/lib/16_ca.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; static void loadPcxStage1(FILE *file, bitmap_t *result) { - long bufSize; - int index; - byte count, val; - long int pos; + //long bufSize; + //int index; + //byte count, val; + //long int pos; /* read the header */ fread(&head, sizeof(char), sizeof(struct pcxHeader), file); @@ -71,7 +94,7 @@ static void loadPcxPalette(FILE *file, bitmap_t *result) { bitmap_t -bitmapLoadPcx(char *filename) { +bitmapLoadPcx(char *filename, global_game_variables_t *gv) { FILE *file; bitmap_t result; dword bufSize; @@ -82,7 +105,7 @@ bitmapLoadPcx(char *filename) { file = fopen(filename, "rb"); if(!file) { printf("Could not open %s for reading.\n", filename); - exit(-2); + //exit(-2); } /* load the first part of the pcx file */ @@ -91,7 +114,9 @@ bitmapLoadPcx(char *filename) { /* allocate the buffer */ //printf("%zu\n", _memmax()); bufSize = (/*(dword)*/result.width * result.height); + //CA_LoadFile(filename, (memptr *)(result.data), gv); result.data = malloc(bufSize); + // result.data = (byte far *)_fmalloc(bufSize); // result.data = (byte __huge *)halloc(bufSize, sizeof(byte)); /*printf("&bufSize=%p\n", &bufSize); @@ -101,11 +126,10 @@ bitmapLoadPcx(char *filename) { printf("Size of result.width is %zu \n", result.width); printf("Size of result.height is %zu \n", result.height); printf("Dimensions of result is %lu\n", (dword)result.width*result.height);*/ - //exit(0); if(!result.data) { fprintf(stderr, "Could not allocate memory for bitmap data."); fclose(file); - exit(-1); + //exit(-1); } /* read the buffer in */ @@ -160,7 +184,7 @@ bitmapLoadPcxTiles(char *filename, word twidth, word theight) { ts.palette = result.palette; /* allocate the pixel storage for the tiles */ - ts.data = malloc(sizeof(byte*) * ts.ntiles); + ts.data = _fmalloc(sizeof(byte*) * ts.ntiles); //ts.data[0] = malloc(sizeof(byte) * ts.ntiles * twidth * theight); for(i=1; i < ts.ntiles; i++) { ts.data[i] = ts.data[i-1] + twidth * theight;