OSDN Git Service

huge memory model fucks up everything! wwww
authorsparky4 <sparky4@cock.li>
Sun, 24 May 2015 05:48:12 +0000 (00:48 -0500)
committersparky4 <sparky4@cock.li>
Sun, 24 May 2015 05:48:12 +0000 (00:48 -0500)
modified:   makefile
modified:   maptest.exe
modified:   pcxtest.exe
modified:   scroll.exe
modified:   src/lib/bitmap.c
modified:   src/lib/bitmap.h
modified:   src/lib/lib_head.c
modified:   src/lib/lib_head.h
modified:   src/lib/mapread.h
modified:   src/lib/modex16.h
modified:   src/maptest.c
modified:   src/pcxtest.c
modified:   src/test.c
modified:   src/test2.c
modified:   test.exe
modified:   test2.exe

16 files changed:
makefile
maptest.exe
pcxtest.exe
scroll.exe
src/lib/bitmap.c
src/lib/bitmap.h
src/lib/lib_head.c
src/lib/lib_head.h
src/lib/mapread.h
src/lib/modex16.h
src/maptest.c
src/pcxtest.c
src/test.c
src/test2.c
test.exe
test2.exe

index cba8978..c108e70 100644 (file)
--- a/makefile
+++ b/makefile
@@ -1,5 +1,5 @@
 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)
@@ -20,8 +20,8 @@ test2.exe: test2.obj modex16.obj bitmap.obj planar.obj
 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
@@ -49,15 +49,15 @@ bitmap.obj: $(SRCLIB)bitmap.h $(SRCLIB)bitmap.c
 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
index e08e7d4..8c75a73 100644 (file)
Binary files a/maptest.exe and b/maptest.exe differ
index 2b66334..2c9959a 100644 (file)
Binary files a/pcxtest.exe and b/pcxtest.exe differ
index f6d853d..74b3f6c 100644 (file)
Binary files a/scroll.exe and b/scroll.exe differ
index a5a4394..3777c3d 100644 (file)
@@ -1,5 +1,6 @@
 #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
@@ -39,9 +40,9 @@ static void loadPcxStage1(FILE *file, bitmap_t *result) {
 \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
@@ -73,28 +74,34 @@ bitmap_t
 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
@@ -102,16 +109,16 @@ bitmapLoadPcx(char *filename) {
        /* 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
@@ -122,7 +129,7 @@ bitmapLoadPcx(char *filename) {
     return result;\r
 }\r
 \r
-\r
+//update!!\r
 tileset_t\r
 bitmapLoadPcxTiles(char *filename, word twidth, word theight) {\r
     tileset_t ts;\r
@@ -132,10 +139,10 @@ bitmapLoadPcxTiles(char *filename, word twidth, word theight) {
 \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
@@ -146,12 +153,12 @@ bitmapLoadPcxTiles(char *filename, word twidth, word theight) {
     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
index 19ae2f0..f1b126e 100644 (file)
@@ -3,22 +3,23 @@
  */\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
index e9004d5..0053446 100644 (file)
@@ -3,7 +3,8 @@
 /* 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
@@ -93,3 +94,15 @@ size_t GetFreeSize(void)
 
   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
+}
index 34fcb3a..5bc441a 100644 (file)
 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);
index 1ce7b01..eaca256 100644 (file)
@@ -9,6 +9,7 @@
 #include "src/lib/modex16.h"
 #include "src/lib/lib_head.h"
 
+//---- temp!
 static char *js_sv;
 
 typedef struct {\r
index fa9e54e..755a11c 100644 (file)
@@ -3,7 +3,7 @@
  */
 #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"
index dfcd300..48c022d 100644 (file)
@@ -4,6 +4,6 @@ void
 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
index be8dcc7..3901c23 100644 (file)
@@ -5,7 +5,7 @@
 #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
@@ -55,7 +55,8 @@ DrawPBuf(page_t *page, int x, int y, planar_buf_t *p, byte sprite)
 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
@@ -65,6 +66,8 @@ void main() {
 \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
@@ -75,47 +78,53 @@ void main() {
        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
index 24520a5..3e2b1e6 100644 (file)
@@ -1,7 +1,7 @@
 #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
@@ -39,7 +39,7 @@ void main() {
     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
@@ -64,7 +64,7 @@ void main() {
        }\r
     }\r
 \r
-    end = *clock;\r
+    end = *clockw;\r
 \r
     /* fade back to text mode */\r
     modexFadeOff(1, pal2);\r
index 8926372..2f76a02 100644 (file)
@@ -2,9 +2,9 @@
 #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
index 38fef80..f79cea4 100644 (file)
Binary files a/test.exe and b/test.exe differ
index d1a35e5..a289dfd 100644 (file)
Binary files a/test2.exe and b/test2.exe differ