source: abuse/trunk/src/transp.cpp @ 494

Last change on this file since 494 was 494, checked in by Sam Hocevar, 11 years ago

style: remove trailing spaces, fix copyright statements.

File size: 1.9 KB
Line 
1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
4 *  Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net>
5 *
6 *  This software was released into the Public Domain. As with most public
7 *  domain software, no warranty is made or implied by Crack dot Com or
8 *  Jonathan Clark.
9 */
10
11#include "config.h"
12
13#include "transp.h"
14
15void transp_put(image *im, image *screen, uint8_t *table, int x, int y)
16{
17  short cx1,cy1,cx2,cy2;
18  screen->get_clip(cx1,cy1,cx2,cy2);
19  int xs=0,ys=0,xl=im->width(),yl=im->height();
20  if (x<cx1)
21  {
22    int chop=cx1-x;
23    xs+=chop;
24    xl-=chop;
25    x+=chop;
26  }
27  if (y<cy1)
28  {
29    int chop=cy1-y;
30    ys+=chop;
31    yl-=chop;
32    y+=chop;
33  }
34  if (x+xl>cx2)
35    xl=cx2-x;
36  if (y+yl>cy2)
37    yl=cy2-y;
38
39  if (xl<0 || yl<0) return ;
40  screen->add_dirty(x,y,x+xl-1,y+yl-1);
41
42  int ye=ys+yl;
43  int xe=xs+xl;
44
45  uint8_t *isl=im->scan_line(ys)+xs;
46  uint8_t *ssl=screen->scan_line(y)+x;
47  int iw=im->width(),sw=screen->width();
48
49  for (int iy=ys; iy<ye; iy++,y++,isl+=iw,ssl+=sw)
50  {
51    uint8_t *s=ssl,*i=isl;
52    for (int ix=xs; ix<xe; ix++,s++,i++)
53    {
54      if (*i)
55        *s=*i;
56      else *s=table[*s];
57    }
58  }
59}
60
61
62/*
63void transp_put(image *im, image *screen, uint8_t *table, int x, int y)
64{
65  short cx1,cy1,cx2,cy2;
66  screen->get_clip(cx1,cy1,cx2,cy2);
67  int xs=0,ys=0,xl=im->width(),yl=im->height();
68  if (x<cx1)
69  {
70    int chop=cx1-x;
71    xs+=chop;
72    xl-=chop;
73    x+=chop;
74  }
75  if (y<cy1)
76  {
77    int chop=cy1-y;
78    ys+=chop;
79    yl-=chop;
80    y+=chop;
81  }
82  if (x+xl>cx2)
83    xl=cx2-x;
84  if (y+yl>cy2)
85    yl=cy2-y;
86
87  if (xl<0 || yl<0) return ;
88  screen->add_dirty(x,y,x+xl-1,y+yl-1);
89
90  int ye=ys+yl;
91  int xe=xs+xl;
92
93  uint8_t *isl=im->scan_line(ys)+xs;
94  uint8_t *ssl=screen->scan_line(y)+x;
95  int iw=im->width(),sw=screen->width();
96
97  for (int iy=ys; iy<ye; iy++,y++,isl+=iw,ssl+=sw)
98  {
99    uint8_t *s=ssl,*i=isl;
100    for (int ix=xs; ix<xe; ix++,s++,i++)
101      *s=table[((*i)<<8)|(*s)];
102  }
103}
104
105
106*/
Note: See TracBrowser for help on using the repository browser.