X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=16%2Fmodex16%2Fmodex16.c;h=f01116b5257fbab4c24267157af17adc0b73ff20;hb=2fc6c650cc91ba3a4447630286d9aa4bb92bbfda;hp=71537b6672a3a37f2cb7561003365f380aafb52c;hpb=067c2ee7341922ae714b4ce18e520aab7c7b5b5f;p=16.git diff --git a/16/modex16/modex16.c b/16/modex16/modex16.c old mode 100644 new mode 100755 index 71537b66..f01116b5 --- a/16/modex16/modex16.c +++ b/16/modex16/modex16.c @@ -11,26 +11,6 @@ byte far* VGA=(byte far*) 0xA0000000; /* this points to video memory. */ static void fadePalette(sbyte fade, sbyte start, word iter, byte *palette); static byte tmppal[PAL_SIZE]; -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]; -}; - static void vgaSetMode(byte mode) @@ -623,82 +603,3 @@ modexWaitBorder() { /* spin */ } } - - -bitmap_t -modexLoadPcx(char *filename) { - FILE *file; - bitmap_t result; - struct pcxHeader head; - long bufSize; - int index; - byte count, val; - - /* open the PCX file for reading */ - file = fopen(filename, "rb"); - if(!file) { - printf("Could not open %s for reading.\n", filename); - exit(-2); - } - - /* read the header */ - fread(&head, sizeof(char), sizeof(struct pcxHeader), file); - - /* make sure this is 8bpp */ - if(head.bpp != 8) { - printf("I only know how to handle 8bpp pcx files!\n"); - fclose(file); - exit(-2); - } - - /* allocate the buffer */ - result.width = head.xmax - head.xmin + 1; - result.height = head.ymax - head.ymin + 1; - bufSize = result.width * result.height; - result.data = malloc(bufSize); - if(!result.data) { - printf("Could not allocate memory for bitmap data."); - fclose(file); - exit(-1); - } - - /* read the buffer in */ - index = 0; - do { - /* get the run length and the value */ - count = fgetc(file); - if(0xC0 == (count & 0xC0)) { /* this is the run count */ - count &= 0x3f; - val = fgetc(file); - } else { - val = count; - count = 1; - } - - /* write the pixel the specified number of times */ - for(; count && index < bufSize; count--,index++) { - result.data[index] = val; - } - } while(index < bufSize); - - /* handle the palette */ - fseek(file, -769, SEEK_END); - val = fgetc(file); - result.palette = modexNewPal(); - if(head.version == 5 && val == 12) { - /* use the vga palette */ - for(index=0; !feof(file) && index < PAL_SIZE; index++) { - val = fgetc(file); - result.palette[index] = val >> 2; - } - } else { - /* use the 16 color palette */ - for(index=0; index<48; index++) { - result.palette[index] = head.pal16[index]; - } - } - - fclose(file); - - return result; -}