~ubuntu-branches/ubuntu/feisty/alevt/feisty

« back to all changes in this revision

Viewing changes to contrib/paul.fmt_page.c

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Schoepf
  • Date: 2002-03-17 15:09:36 UTC
  • Revision ID: james.westby@ubuntu.com-20020317150936-yglzziwcc0luz55k
Tags: upstream-1.6.0
ImportĀ upstreamĀ versionĀ 1.6.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
static void
 
2
fmt_page(struct export *e, struct fmt_page *pg, struct vt_page *vtp)
 
3
{
 
4
    char buf[16];
 
5
    int x, y;
 
6
    u8 c, *p = vtp->data[0];
 
7
    pg->dbl = 0;
 
8
    sprintf(buf, "\2%3x.%02x\7", vtp->pgno, vtp->subno & 0xff);
 
9
    strncpy(p,buf,8);
 
10
    for (y = 0; y < H; y++)
 
11
    {
 
12
      /* two variables for each attribute 
 
13
       * new_attr  -- information got from the latest char
 
14
       * here_attr -- value of the attribute for this xy position
 
15
       * So, if the attribute char is "Set-At" 
 
16
       *        then  
 
17
       *            {
 
18
       *              here_attr=new_attr=attribute(latest_char);
 
19
       *              ... processing ... (use here_attr !!!)
 
20
       *              here_attr=new_attr; // <-- unneeded, 
 
21
       *                                  // but doesn't break the code
 
22
       *            }
 
23
       *        else   // Set-After 
 
24
       *            {
 
25
       *              new_attr=attribute(latest_char);
 
26
       *              ... processing ... (use here_attr !!!)
 
27
       *              here_attr=new_attr;
 
28
       *            }
 
29
       * Attributes persist until changed by another attribute
 
30
       *   or end of row
 
31
       */
 
32
      u8 held_mosaic_char=' ';
 
33
      u8 dbl=0; /* set to 1 for double height page 
 
34
                  * (is used at the end of row processing) */
 
35
      
 
36
      u8 new_gfx=0, here_gfx=0; // Start-of-row default condition
 
37
      u8 new_bg=0, here_bg=0;   // Start-of-row default condition
 
38
      u8 new_fg=7, here_fg=7;   // Start-of-row default condition
 
39
      u8 new_bln=0, here_bln=0;   // Start-of-row default condition
 
40
      u8 new_dbl=0, here_dbl=0;   // Start-of-row default condition
 
41
      u8 new_con=0, here_con=0;   // Start-of-row default condition
 
42
      u8 here_sep=0;  /*  Start-of-row default condition
 
43
                        *  set/reset by 0x19,0x1a chars
 
44
                        *  Both (0x19,0x1a) are Set-At
 
45
                        *  so anyway (here_sep==new_sep) all the time
 
46
                        */
 
47
      u8 new_hld=0, here_hld=0;  
 
48
        
 
49
      //hold attribute:
 
50
      u8 held_sep=0;
 
51
 
 
52
      for (x = 0; x < W; ++x)
 
53
        {
 
54
          pg->data[y][x].ch=' ';  // case 0x00 ... 0x1f
 
55
          switch (c=*p++)
 
56
            {
 
57
            case 0x00 ... 0x07:      
 
58
              //Alpha Colour Codes (foreground)
 
59
              //Set-After
 
60
              new_gfx=0;
 
61
              new_fg=c;  // in this case (c == (c & 0x07))
 
62
              new_con=0;
 
63
              break;
 
64
            case 0x08:
 
65
              //Flash
 
66
              //Set-After
 
67
              new_bln=EA_BLINK;
 
68
              break;
 
69
            case 0x09:
 
70
              //Steady
 
71
              //Set-At
 
72
              new_bln=here_bln=0;
 
73
              break;
 
74
            case 0x0a:
 
75
              //End Box
 
76
              //Set-After
 
77
              //!!! not processed
 
78
              break;
 
79
            case 0x0b:
 
80
              //Start Box  (used with End Box to mark visible 
 
81
              //            part of page on transparent ones
 
82
              //            eg. newsflash or subtitle )
 
83
              //Set-After
 
84
              //!!! not processed
 
85
              break;
 
86
            case 0x0c:
 
87
              //Normal Size
 
88
              //Set-At
 
89
              new_dbl=here_dbl=0;
 
90
              break;
 
91
            case 0x0d:
 
92
              //Double Height
 
93
              //Set-After
 
94
              dbl=1;
 
95
              new_dbl=EA_DOUBLE;
 
96
              break;
 
97
            case 0x0e:
 
98
              //Double Width (for Presentation Level 2.5 and 3.5)
 
99
              //Set-After
 
100
              //!!! not processed
 
101
              break;
 
102
            case 0x0f:
 
103
              //Double Size (for Presentation Level 2.5 and 3.5)
 
104
              //Set-After
 
105
              //!!! not processed
 
106
              break;
 
107
            case 0x10 ... 0x17:
 
108
              //Mosaic Colour Codes
 
109
              //Set-After
 
110
              new_gfx=EA_GRAPHIC;
 
111
              new_fg= c & 0x07;
 
112
              new_con=0;
 
113
              break;
 
114
            case 0x18:
 
115
              //Conceal
 
116
              //Set-At
 
117
              here_con=new_con=EA_CONCEALED;
 
118
              break;
 
119
            case 0x19:
 
120
              //Contiguous Mosaic Graphics
 
121
              //Set-At
 
122
              here_sep=0;
 
123
              break;
 
124
            case 0x1a:
 
125
              //Separated Mosaic Graphics
 
126
              //Set-At
 
127
              here_sep=EA_SEPARATED;
 
128
              break;
 
129
            case 0x1b:
 
130
              //ESC (or Switch) 
 
131
              //Set-After
 
132
              //!!! not processed
 
133
              break;
 
134
            case 0x1c:
 
135
              //Black Background
 
136
              //Set-At
 
137
              here_bg=new_bg=0;
 
138
              break;
 
139
            case 0x1d:
 
140
              //New Background
 
141
              //Set-At
 
142
              here_bg=new_bg=here_fg;
 
143
              break;
 
144
            case 0x1e:
 
145
              //Hold Mosaics
 
146
              //Set-At
 
147
              here_hld=new_hld=1;
 
148
              break;
 
149
            case 0x1f:
 
150
              //Release Mosaics
 
151
              //Set-After
 
152
              new_hld=0;
 
153
              break;
 
154
 
 
155
          // start of "... processing ..."
 
156
              
 
157
            default: //noncontrol characters 
 
158
              pg->data[y][x].ch=c;
 
159
              /* **************************** */
 
160
              /* special treating of sep
 
161
               * when in Hold-Mosaics mode 
 
162
               * see the specs for details...
 
163
               */
 
164
              if (c & (1<<5))  //why "6" bit set is (1<<5) ????????
 
165
                {
 
166
                  held_mosaic_char=c;
 
167
                  held_sep=here_sep;
 
168
                }
 
169
              if (here_hld) //when in "hold" set 'here_sep' here:
 
170
                pg->data[y][x].attr|=here_sep;
 
171
              /* **************************** */
 
172
            } //end of switch
 
173
          
 
174
          if (here_hld)  c=held_mosaic_char;
 
175
          
 
176
          if ((here_gfx) && ((c & 0xa0) == 0x20))
 
177
            pg->data[y][x].ch= c + ((c & 0x40) ? 32 : -32);
 
178
          
 
179
          if ((here_con) && (not e->reveal))
 
180
            pg->data[y][x].ch=' ';        
 
181
          
 
182
          pg->data[y][x].fg=here_fg;
 
183
          pg->data[y][x].bg=here_bg;
 
184
          
 
185
          if (here_hld) // special treating again...
 
186
            pg->data[y][x].attr=(here_dbl|here_gfx|
 
187
                                 here_bln|here_con);
 
188
          else  // when not in "hold" set 'here_sep' here
 
189
            pg->data[y][x].attr=(here_dbl|here_gfx|
 
190
                                 here_bln|here_con|here_sep);
 
191
          
 
192
          // end of "... processing ..."
 
193
          here_gfx=new_gfx;
 
194
          here_fg=new_fg;
 
195
          here_bg=new_bg;
 
196
          here_bln=new_bln;
 
197
          here_dbl=new_dbl;
 
198
          here_con=new_con;
 
199
          here_hld=new_hld;
 
200
        }
 
201
      if (dbl)
 
202
        {
 
203
          pg->dbl |= 1 << y;
 
204
          for (x = 0; x < W; ++x)
 
205
            {
 
206
              if (~pg->data[y][x].attr & EA_DOUBLE)
 
207
                pg->data[y][x].attr |= EA_HDOUBLE;
 
208
              pg->data[y+1][x] = pg->data[y][x];
 
209
              pg->data[y+1][x].ch = ' ';
 
210
            }
 
211
          y++;p+=40;
 
212
        }
 
213
    }
 
214
    
 
215
}