]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/modex16/16planar.c
fixed ^^ still buggy but it works better now~
[16.git] / src / lib / modex16 / 16planar.c
index 4c167597c292b135026234d81b4719598aa9bdb0..c8d3b54e5dd19e88c4df1f6b6ddc7f6b9ba49030 100755 (executable)
@@ -90,7 +90,7 @@ pbuf_alloc(word width, word height) {
 \r
        /* allocate the planes */\r
        for(i=0; i<4; i++) {\r
-               p.plane[i] = _fmalloc(p.height * p.pwidth);\r
+               p.plane[i] = _fmalloc((p.height * p.pwidth)+1);\r
        }\r
 \r
        return p;\r
@@ -180,6 +180,9 @@ fprintf(stderr, "%u ", w++);*/
        /* write the pixel the specified number of times */\r
 //fprintf(stderr, "\nputting in memory~ %u\n", w++);\r
        for(; count && (index[0]+index[1]+index[2]+index[3]) < bufSize; count--,index[plane]++)  {\r
+               // copy to each plane\r
+               result.plane[plane][index[plane]]=(word)val;\r
+//fprintf(stdout, "plane=%u    index val=%02X  val=%02X\n", plane, result.plane[plane][index[plane]], val);\r
                switch (plane)\r
                {\r
                        case 4:\r
@@ -194,17 +197,14 @@ fprintf(stderr, "%u ", w++);*/
                                plane=0;\r
                        break;\r
                }\r
-               // copy to each plane\r
-               result.plane[plane][index[plane]]=val;\r
 //fprintf(stdout, "count=%02X  index=%u        plane=%u        ", count, index[plane], plane);\r
-//fprintf(stdout, "index val=%02X      val=%02X\n", result.plane[plane][index[plane]], val);\r
        }\r
+       //val++;\r
 // fprintf(stdout, "\nindex=%lu                bufsize=%lu\n\n", (dword)(index[0]+index[1]+index[2]+index[3]),  bufSize);\r
        } while((index[0]+index[1]+index[2]+index[3]) < bufSize);\r
        loadPcxpbufPalette(file, &result);\r
        fclose(file);\r
 // fprintf(stderr, "\n\n%s     count=%d        index=%d        plane=%d\n", filename, count, (dword)(index[0]+index[1]+index[2]+index[3]), pla);\r
-// exit(0);\r
        return result;\r
 \r
 }\r