aboutsummaryrefslogtreecommitdiff
path: root/engines/avalanche/chunker.cpp
blob: 6d48054a2e13c88295ff39aa2a257282543e2801 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include "ptoc.h"



enum flavourtype {ch_ega,ch_bgi, last_flavourtype};

struct chunkblocktype {
                  flavourtype flavour;
                  integer x,y;
                  integer xl,yl;
                  longint size;
                  boolean natural;

                  boolean memorise; /* Hold it in memory? */
};

untyped_file f;
string fn;
byte num_chunks,fv;
longint offset;
chunkblocktype ch;

int main(int argc, const char* argv[])
{
   pio_initialize(argc, argv);
   output << NL;
   output << "CHUNKER 12/3/1995 TT" << NL;
   output << NL;

   if (paramcount!=1) 
   {
      output << "which chunk file?" << NL;
      exit(0);
   }

   fn=paramstr(1);
   assign(f,fn);
   reset(f,1);
   output << "----- In chunk file " << fn << ", there are: -----" << NL;

   seek(f,44);
   blockread(f,num_chunks,1);
   output << format(num_chunks,4) << " chunks:" << NL;

   output << "  No  Hdr    Offset  Flvr  Mem Nat      X      Y  Width Height Size of image" << NL;

   for( fv=1; fv <= num_chunks; fv ++)
   {

      output << "Ch" << format(fv,2) << ':';

      seek(f,41+fv*4);

      output << format(41+fv*4,4);
      blockread(f,offset,4);
      output << format(offset,10);

      seek(f,offset);
      blockread(f,ch,sizeof(ch));
      {
         if (ch.flavour==ch_bgi) 
            output << " ch_BGI";
         else
            output << " ch_EGA";

         if (ch.memorise) 
            output << " yes";
         else
            output << " no ";

         if (ch.natural) 
            output << " yes";
         else
            output << " no ";

         output << format(ch.x,7) << format(ch.y,7) << format(ch.xl,7) << format(ch.yl,7) << format(ch.size,10);
      }

      output << NL;
   }

   output << "---ENDS---" << NL;

   close(f);
   return EXIT_SUCCESS;
}