Changeset 523


Ignore:
Timestamp:
Apr 22, 2011, 4:12:48 AM (6 years ago)
Author:
sam
Message:

imlib: remove dead code.

Location:
abuse/trunk/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/game.cpp

    r518 r523  
    12681268        pal->shift(1);
    12691269
    1270         image *gray = new image(sd.find("gray_pict"), fp);
     1270        image *gray = new image(fp, sd.find("gray_pict"));
    12711271        image *smoke[5];
    12721272
     
    12751275        {
    12761276            sprintf(nm, "smoke%04d.pcx", i + 1);
    1277             smoke[i] = new image(sd.find(nm), fp);
     1277            smoke[i] = new image(fp, sd.find(nm));
    12781278        }
    12791279
  • abuse/trunk/src/imlib/filter.cpp

    r518 r523  
    1616#include "macs.h"
    1717#include "filter.h"
    18 
    19 extern unsigned char current_background;
    2018
    2119filter::filter(palette *from, palette *to)   // creates a conversion filter from one palette to another
     
    224222            i++, source++, dest++)
    225223        {
    226             if(!transparent || *source != current_background)
     224            if (!transparent || *source)
    227225                *dest=fdat[*source];
    228226        }
  • abuse/trunk/src/imlib/image.cpp

    r522 r523  
    2626#include "system.h"
    2727
    28 extern uint8_t current_background;
    29 
    30 char const *imerr_messages[] =
    31 {
    32     "No error",
    33     "Error occurred while reading",
    34     "Incorrect file type",
    35     "File is corrupted",
    36     "File not found",
    37     "Memory allocation trouble",
    38     "Operation/file type not supported",
    39     "Error occurred while writing, (disk full?)"
    40 };
    41 
    42 
    43 int16_t imerror=0;
    44 int16_t swpfile_num=0;
    45 
    46 int16_t current_error()
    47 { return imerror; }
    48 
    49 void clear_errors()
    50 {
    51   if (imerror)
    52   { printf("Program stopped, error : ");
    53     if (imerror<=imMAX_ERROR)
    54       printf("%s\n", imerr_messages[imerror]);
    55     else
    56       printf("Unsonsponsered error code, you got trouble\n");
    57 #ifdef __DOS_ONLY
    58     sound(300);
    59     delay(100);
    60     nosound();
    61 #else
    62     printf("%c%c\n", 7, 8);
    63 #endif
    64     exit(1);
    65   }
    66 }
    67 
    68 void set_error(int16_t x)
    69 { imerror=x; }
    70 
    71 int16_t last_error()
    72 {
    73   int16_t ec;
    74   ec=imerror;
    75   imerror=0;
    76   return ec;
    77 }
    78 
    79 linked_list image_list;
    80 
     28linked_list image_list; // FIXME: only jwindow.cpp needs this
    8129
    8230image_descriptor::image_descriptor(vec2i size,
    83                    int keep_dirties, int static_memory)
     31                                   int keep_dirties, int static_memory)
    8432{
    8533    m_clipx1 = 0; m_clipy1 = 0;
     
    14593{
    14694    m_size = size;
     95    m_special = NULL;
    14796    if (create_descriptor || page_buffer)
    148     {
    149         if (create_descriptor==2)
    150             m_special=new image_descriptor(size, 1, (page_buffer!=NULL));
    151         else
    152             m_special=new image_descriptor(size, 0, (page_buffer!=NULL));
    153     }
    154     else
    155         m_special = NULL;
     97        m_special = new image_descriptor(size, create_descriptor == 2,
     98                                         (page_buffer != NULL));
    15699    MakePage(size, page_buffer);
    157100    image_list.add_end(this);
     
    159102}
    160103
    161 image::image(spec_entry *e, bFILE *fp)
    162 {
    163     fp->seek(e->offset, 0);
     104image::image(bFILE *fp, spec_entry *e /* = NULL */)
     105{
     106    if (e)
     107        fp->seek(e->offset, 0);
    164108    m_size.x = fp->read_uint16();
    165109    m_size.y = fp->read_uint16();
     
    172116}
    173117
    174 image::image(bFILE *fp)
    175 {
    176     m_size.x = fp->read_uint16();
    177     m_size.y = fp->read_uint16();
    178     m_special = NULL;
    179     MakePage(m_size, NULL);
    180     for (int i = 0; i < m_size.y; i++)
    181         fp->read(scan_line(i), m_size.x);
    182     image_list.add_end(this);
    183     m_locked = false;
    184 }
    185 
    186118void image::Lock()
    187119{
     
    204136void image_uninit()
    205137{
    206     /* FIXME: is this used at all? */
    207 /*  image *im;
    208   while (image_list.first())
    209   {
    210     im=(image *)image_list.first();
    211     image_list.unlink(im);
    212     delete im;
    213   } */
    214 }
    215 
    216 
    217 void image_cleanup(int ret, void *arg)
    218 { image_uninit(); }
     138    while (image_list.first())
     139    {
     140        image *im = (image *)image_list.first();
     141        image_list.unlink(im);
     142        delete im;
     143    }
     144}
     145
    219146
    220147void image_init()
    221148{
    222   uint8_t bt[2];
    223   uint16_t wrd, *up;
    224   bt[0]=1;
    225   bt[1]=0;
    226   up=(uint16_t *)bt;
    227   wrd=uint16_to_intel(*up);
    228   if (wrd!=0x01)
    229   { printf("compiled with wrong endianness, edit system.h and try again\n");
    230     printf("1 (intel) = %d\n", (int)wrd);
    231     exit(1);
    232   }
    233   imerror=0;
    234 }
    235 
    236 
    237 int32_t image::total_pixels(uint8_t background)
    238 {
    239     int ret = 0;
    240     Lock();
    241     for(int i = 0; i < m_size.y; i++)
    242     {
    243         uint8_t *c = scan_line(i);
    244         for (int x = 0; x < m_size.x; x++)
    245             if (c[x] != background)
    246                 ret++;
    247     }
    248     Unlock();
    249     return ret;
     149    ;
    250150}
    251151
     
    254154    Lock();
    255155    if(color == -1)
    256         color = current_background;
     156        color = 0; // transparent
    257157    if(m_special)
    258158    {
     
    474374                    i++, source++, dest++)
    475375                {
    476                     if(*source != current_background)
     376                    if (*source)
    477377                        *dest = *source;
    478378                }
     
    595495    {
    596496      for (i=0, source=&pg2[x1], dest=&pg1[x]; i<xlen; i++, source++, dest++)
    597         if (*source!=current_background) *dest=*source;
     497        if (*source) *dest=*source;
    598498      pg1=screen->next_line(y+j, pg1);
    599499      pg2=next_line(y1+j, pg2);
     
    668568      {
    669569    for (i=0, source=&pg2[x1], dest=&pg1[x+xl-1]; i<xl; i++, source++, dest--)
    670           if (*source!=current_background) *dest=*source;
     570          if (*source) *dest=*source;
    671571      }
    672572      else
     
    744644    screen->Unlock();
    745645  }
    746 }
    747 
    748 
    749 
    750 uint8_t image::brightest_color(palette *pal)
    751 { uint8_t *p, r, g, b, bri;
    752   int16_t i, j;
    753   int32_t brv;
    754   brv=0; bri=0;
    755   Lock();
    756   for (j=0; j<m_size.y; j++)
    757   {
    758     p=scan_line(j);
    759     for (i=0; i<m_size.x; i++)
    760     { pal->get(p[i], r, g, b);
    761       if ((int32_t)r*(int32_t)g*(int32_t)b>brv)
    762       { brv=(int32_t)r*(int32_t)g*(int32_t)b;
    763     bri=p[i];
    764       }
    765     }
    766   }
    767   Unlock();
    768   return bri;
    769 }
    770 
    771 uint8_t image::darkest_color(palette *pal, int16_t noblack)
    772 { uint8_t *p, r, g, b, bri;
    773   int16_t i, j;
    774   int32_t brv, x;
    775   brv=(int32_t)258*(int32_t)258*(int32_t)258; bri=0;
    776   Lock();
    777   for (j=0; j<m_size.y; j++)
    778   {
    779     p=scan_line(j);
    780     for (i=0; i<m_size.x; i++)
    781     { pal->get(p[i], r, g, b);
    782       x=(int32_t)r*(int32_t)g*(int32_t)b;
    783       if (x<brv && (x || !noblack))
    784       { brv=x;
    785     bri=p[i];
    786       }
    787     }
    788   }
    789   Unlock();
    790   return bri;
    791646}
    792647
  • abuse/trunk/src/imlib/image.h

    r521 r523  
    1919#define MAX_DIRTY 200
    2020
    21 extern char const *imerr_messages[];  // correspond to imERRORS
    22 #define imREAD_ERROR            1
    23 #define imINCORRECT_FILETYPE   2
    24 #define imFILE_CORRUPTED       3
    25 #define imFILE_NOT_FOUND       4
    26 #define imMEMORY_ERROR         5
    27 #define imNOT_SUPPORTED        6
    28 #define imWRITE_ERROR          7
    29 #define imMAX_ERROR            7
    30 
    31 int16_t current_error();
    32 void clear_errors();
    33 void set_error(int16_t x);
    34 int16_t last_error();
    3521void image_init();
    3622void image_uninit();
    3723extern linked_list image_list;
    38 
    39 typedef struct image_color_t
    40 {
    41     uint16_t r;
    42     uint16_t g;
    43     uint16_t b;
    44 } image_color;
    45 
    46 class filter;
    47 
    4824
    4925class dirty_rect : public linked_node
     
    11793    image_descriptor *m_special;
    11894
    119     image(spec_entry *e, bFILE *fp);
    120     image(bFILE *fp);
     95    image(bFILE *fp, spec_entry *e = NULL);
    12196    image(vec2i size, uint8_t *page_buffer = NULL, int create_descriptor = 0);
    12297    ~image();
     
    136111        return last_scan + m_size.x;
    137112    }
    138     int32_t total_pixels(uint8_t background=0);
    139113    image *copy(); // makes a copy of an image
    140114    void clear(int16_t color = -1); // -1 is background color
    141     void to_24bit(palette &pal);
    142115
    143116    vec2i Size() const { return m_size; }
     
    197170    image *create_smooth(int16_t smoothness = 1); // 0 no smoothness
    198171    void unpack_scanline(int16_t line, char bitsperpixel = 1);
    199     uint8_t brightest_color(palette *pal);
    200172    void flip_x();
    201173    void flip_y();
    202     uint8_t darkest_color(palette *pal, int16_t noblack = 0);
    203174};
    204175
  • abuse/trunk/src/imlib/include.cpp

    r515 r523  
    3535  else fp=fopen(filename,"wb");
    3636
    37   if (!fp)
    38     set_error(imWRITE_ERROR);
    39   else
     37  if (fp)
    4038  {
    4139    fprintf(fp,"/* File produced by Satan Paint (c) 1994 Jonathan Clark */\n\n");
     
    6967          else fprintf(fp,", ");
    7068      }
     69    fclose(fp);
    7170  }
    72   fclose(fp);
    7371}
    7472
  • abuse/trunk/src/imlib/pcxread.cpp

    r512 r523  
    5151  FILE *fp=fopen(filename,"wb");
    5252  if (!fp)
    53   {
    54     set_error(imWRITE_ERROR);
    5553    return ;
    56   }
    5754
    5855  PCX_header.manufactururer=10;
     
    7471  if (!write_PCX_header(fp))
    7572  {
    76     set_error( imWRITE_ERROR);
    77     return ;
     73    fclose(fp);
     74    return;
    7875  }
    7976
  • abuse/trunk/src/imlib/video.h

    r494 r523  
    2424
    2525
    26 extern unsigned char current_background;
    2726extern int xres,yres;
    2827extern int xoff,yoff;
  • abuse/trunk/src/loader2.cpp

    r513 r523  
    7575image *load_image(spec_entry *e, bFILE *fp)
    7676{
    77     image *im = new image(e, fp);
     77    image *im = new image(fp, e);
    7878    if (scale_mult != 1 || scale_div != 1)
    7979        im->Scale(im->Size() * scale_mult / scale_div);
  • abuse/trunk/src/loadgame.cpp

    r513 r523  
    180180            if (se && se->type==SPEC_IMAGE)
    181181            {
    182                 thumb_nails[start_num]=new image(se,fp);
     182                thumb_nails[start_num] = new image(fp, se);
    183183                if (thumb_nails[start_num]->Size().x>max_w) max_w=thumb_nails[start_num]->Size().x;
    184184                if (thumb_nails[start_num]->Size().y>max_h) max_h=thumb_nails[start_num]->Size().y;
  • abuse/trunk/src/sdlport/video.cpp

    r519 r523  
    4444SDL_Surface *window = NULL, *surface = NULL;
    4545image *screen = NULL;
    46 unsigned char current_background;
    4746int win_xscale, win_yscale, mouse_xscale, mouse_yscale;
    4847int xres, yres;
Note: See TracChangeset for help on using the changeset viewer.