Metropoli BBS
VIEWER: gfxconv.cpp MODE: TEXT (CP437)
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <dir.h>
#include <string.h>

// Own headers
#include <saidin.h>
#include "gfxio.h"

char far data[64000];
char near buffer[255];

int res;


void showimages(void);

main()
{
    textmode(3);
    int quit=0,res;
    char ch;
    char far*screen=(char far*)0xa0000000;
    while(!quit)
    {
        clrscr();
        window(1,1,80,25);
        SetRGB(2,10,5,32);
        SetRGB(1,20,10,63);
        SetRGB(9,32,15,63);
        SetRGB(3,10,45,63);
        textcolor(1);
        textbackground(3);
        cprintf("≡GFXConv v1.5                                                1996(C) Hypothermia\r");
        textcolor(1);
        textbackground(0);
        cprintf("▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀\r\n\n");
        window(1,3,80,25);
        textbackground(0);
        textcolor(9);
        gotoxy(10, 5);cprintf("▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄\r\n");
        textcolor(15);
        textbackground(1);
        gotoxy(10, 6);cprintf(" 1) Load PCX Image    \n\r");
        gotoxy(10, 7);cprintf(" 2) Load Raw Image    \n\r");
        gotoxy(10, 8);cprintf(" 3) Load GDT Image    \n\r");
        gotoxy(10, 9);cprintf(" 4) Load GDZ Image    \n\r");
        gotoxy(10,10);cprintf(" 5) Save Raw Image    \n\r");
        gotoxy(10,11);cprintf(" 6) Save GDT Image    \n\r");
        gotoxy(10,12);cprintf(" 7) Save GDZ Image    \r\n");
        gotoxy(10,13);cprintf(" 8) Show Loaded Image \r\n");
        gotoxy(10,14);cprintf(" 9) Show Directory    \r\n");
        gotoxy(10,15);cprintf(" 0) Quit              \r\n");
        textcolor(2);
        textbackground(0);
        gotoxy(10,16);cprintf("▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀\n\r");
        textcolor(15);
        cprintf("\n\n>");
        ch=getche();
        printf("\r\n");
        if (ch=='0') {quit=1;res=255;}
        if (ch>='1'&&ch<='7') {
           textcolor(14);
           cprintf("Filename:");
           cscanf("%s",buffer);
           textcolor(4);
           cprintf("\r\n\nPlease wait\r");
           res=255;
        }
        if (ch=='1') res=load_pcx(buffer,data);
        if (ch=='2') res=load_raw(buffer,data);
        if (ch=='3') res=load_gdt(buffer,data);
        if (ch=='4') res=load_gdz(buffer,data);
        if (ch=='5') res=save_raw(buffer,data);
        if (ch=='6') res=save_gdt(buffer,data);
        if (ch=='7') res=save_gdz(buffer,data);
        if (ch=='8')
        {
            startgraph();
            setpal(255);
            copyscreen(FP_SEG(data));
            getch();
            endgraph();
        }
        if (ch=='9') {showimages();res=255;}
        if (res!=255) {
           if (res!=0) {
              textattr((1<<8)+4);
              cprintf("!!Error code: %i!!\r\n",res);
              getch();
           }
        }
    }
    clrscr();
    textmode(19);
    textmode(3);
}

void showimages()
{
    char path[MAXPATH],drive[MAXDRIVE],dir[MAXDIR],file[MAXFILE],ext[MAXEXT];
    struct ffblk ffblk;
    int done,count;
    window(1,3,80,18);
    clrscr();
    textcolor(7);
    SetRGB(7,20,20,30);
    SetRGB(5,63,10,50);
    SetRGB(2,5,63,10);
    cprintf("IMAGES IN CURRENT DIRECTORY %s\n\n\r");
    done = findfirst("*.*",&ffblk,0);
    count=0;
    gotoxy(1,4);
    while (!done)
    {
       fnsplit(ffblk.ff_name,drive,dir,file,ext);
       if (strcmpi(ext,".PCX")==0||strcmpi(ext,".GDT")==0||strcmpi(ext,".GDZ")==0||strcmpi(ext,".RAW")==0)
       {
            if (strcmpi(ext,".PCX")==0) textcolor(2);
            if (strcmpi(ext,".GDT")==0) textcolor(5);
            if (strcmpi(ext,".GDZ")==0) textcolor(11);
            if (strcmpi(ext,".RAW")==0) textcolor(7);
            gotoxy(3+(count&1)*40,wherey());
            cprintf("%s",ffblk.ff_name);
            gotoxy(20+(count&1)*40,wherey());
            cprintf("%likb",ffblk.ff_fsize>>10);
            if (count&1) cprintf("\r\n");
            count++;
       }
       done = findnext(&ffblk);
       if (count==30)
       {
            textcolor(15);
            cprintf("\rPress a key...\r");
            textcolor(7);
            getch();
            cprintf("(More)        \n");
            count=0;
       }
    }
    textcolor(15);
    cprintf("\r\nPress a key...\r");
    textcolor(7);
    getch();
    cprintf("              ");
    return;
}



[ RETURN TO DIRECTORY ]