]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/bitmap.c
too tired to continue
[16.git] / src / lib / bitmap.c
index 19af31f5386846af026278b88df3d0ca94e697b6..b42204aac9ac5ce22d0503df11a8b2839875827f 100755 (executable)
@@ -1,5 +1,5 @@
 /* Project 16 Source Code~\r
- * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669\r
+ * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
  *\r
  * This file is part of Project 16.\r
  *\r
 #include <stdlib.h>\r
 #include <malloc.h>\r
 #include "src/lib/bitmap.h"\r
-#include "src/lib/modex16.h"\r
+#include "src/lib/16_mm.h"\r
+#include "src/lib/16_pm.h"\r
+#include "src/lib/16_ca.h"\r
 \r
-#ifndef PCXHEADER_H\r
-#define PCXHEADER_H\r
 static struct pcxHeader {\r
        byte id;\r
        byte version;\r
@@ -47,14 +47,12 @@ static struct pcxHeader {
        word vScreenSize;\r
        byte padding[54];\r
 } head;\r
-#endif /*PCXHEADER_H*/\r
-\r
 \r
 static void loadPcxStage1(FILE *file, bitmap_t *result) {\r
-       long bufSize;\r
-       int index;\r
-       byte count, val;\r
-       long int pos;\r
+       //long bufSize;\r
+       //int index;\r
+       //byte count, val;\r
+       //long int pos;\r
 \r
        /* read the header */\r
        fread(&head, sizeof(char), sizeof(struct pcxHeader), file);\r
@@ -96,7 +94,7 @@ static void loadPcxPalette(FILE *file, bitmap_t *result) {
 \r
 \r
 bitmap_t\r
-bitmapLoadPcx(char *filename) {\r
+bitmapLoadPcx(char *filename, global_game_variables_t *gv) {\r
        FILE *file;\r
        bitmap_t result;\r
        dword bufSize;\r
@@ -107,7 +105,7 @@ bitmapLoadPcx(char *filename) {
        file = fopen(filename, "rb");\r
        if(!file) {\r
                printf("Could not open %s for reading.\n", filename);\r
-               exit(-2);\r
+               //exit(-2);\r
        }\r
 \r
        /* load the first part of the pcx file */\r
@@ -116,7 +114,9 @@ bitmapLoadPcx(char *filename) {
        /* allocate the buffer */\r
        //printf("%zu\n", _memmax());\r
        bufSize = (/*(dword)*/result.width * result.height);\r
+       //CA_LoadFile(filename, (memptr *)(result.data), gv);\r
        result.data = malloc(bufSize);\r
+\r
 //     result.data = (byte far *)_fmalloc(bufSize);\r
 //     result.data = (byte __huge *)halloc(bufSize, sizeof(byte));\r
        /*printf("&bufSize=%p\n", &bufSize);\r
@@ -126,11 +126,10 @@ bitmapLoadPcx(char *filename) {
        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.data) {\r
                fprintf(stderr, "Could not allocate memory for bitmap data.");\r
                fclose(file);\r
-               exit(-1);\r
+               //exit(-1);\r
        }\r
 \r
        /*  read the buffer in */\r
@@ -151,6 +150,7 @@ bitmapLoadPcx(char *filename) {
                result.data[index] = val;\r
        }\r
        } while(index < bufSize);\r
+       //printf("index=%d\n", index);\r
 \r
        loadPcxPalette(file, &result);\r
 \r
@@ -160,6 +160,7 @@ bitmapLoadPcx(char *filename) {
 }\r
 \r
 //TODO: update!!\r
+/*\r
 tileset_t\r
 bitmapLoadPcxTiles(char *filename, word twidth, word theight) {\r
        tileset_t ts;\r
@@ -167,33 +168,33 @@ bitmapLoadPcxTiles(char *filename, word twidth, word theight) {
        bitmap_t result;\r
        int i;\r
 \r
-       /* open the PCX file for reading */\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
 \r
-       /* load the first part of the pcx file */\r
+       // load the first part of the pcx file\r
        loadPcxStage1(file, &result);\r
 \r
-       /* get the number of tiles and set up the result structure */\r
+       // get the number of tiles and set up the result structure\r
        ts.twidth = twidth;\r
        ts.theight = theight;\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
+       // allocate the pixel storage for the tiles\r
+       ts.data = _fmalloc(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
+       // finish off the file\r
        loadPcxPalette(file, &result);\r
 \r
        fclose(file);\r
 \r
        return ts;\r
-}\r
+}*/\r