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

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