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

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

ps3: make everything compile on the PS3. Of course, nothing links yet
because so much support is missing.

File size: 2.1 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, by
8 *  Jonathan Clark, or by Sam Hocevar.
9 */
10
11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include "common.h"
16
17#include "transp.h"
18
19void transp_put(image *im, image *screen, uint8_t *table, int x, int y)
20{
21  int cx1, cy1, cx2, cy2;
22  screen->GetClip(cx1, cy1, cx2, cy2);
23  int xs=0,ys=0,xl=im->Size().x,yl=im->Size().y;
24  if (x<cx1)
25  {
26    int chop=cx1-x;
27    xs+=chop;
28    xl-=chop;
29    x+=chop;
30  }
31  if (y<cy1)
32  {
33    int chop=cy1-y;
34    ys+=chop;
35    yl-=chop;
36    y+=chop;
37  }
38  if (x + xl >= cx2)
39    xl = cx2 - 1 - x;
40  if (y + yl >= cy2)
41    yl = cy2 - 1 - y;
42
43  if (xl<0 || yl<0) return ;
44  screen->AddDirty(x, y, x + xl, y + yl);
45
46  int ye=ys+yl;
47  int xe=xs+xl;
48
49  uint8_t *isl=im->scan_line(ys)+xs;
50  uint8_t *ssl=screen->scan_line(y)+x;
51  int iw=im->Size().x,sw=screen->Size().x;
52
53  for (int iy=ys; iy<ye; iy++,y++,isl+=iw,ssl+=sw)
54  {
55    uint8_t *s=ssl,*i=isl;
56    for (int ix=xs; ix<xe; ix++,s++,i++)
57    {
58      if (*i)
59        *s=*i;
60      else *s=table[*s];
61    }
62  }
63}
64
65
66/*
67void transp_put(image *im, image *screen, uint8_t *table, int x, int y)
68{
69  int cx1, cy1, cx2, cy2;
70  screen->GetClip(cx1, cy1, cx2, cy2);
71  int xs=0,ys=0,xl=im->width(),yl=im->height();
72  if (x<cx1)
73  {
74    int chop=cx1-x;
75    xs+=chop;
76    xl-=chop;
77    x+=chop;
78  }
79  if (y<cy1)
80  {
81    int chop=cy1-y;
82    ys+=chop;
83    yl-=chop;
84    y+=chop;
85  }
86  if (x + xl >= cx2)
87    xl = cx2 - 1 - x;
88  if (y + yl >= cy2)
89    yl = cy2 - 1 - y;
90
91  if (xl<0 || yl<0) return ;
92  screen->AddDirty(x, y, x + xl - 1, y + yl);
93
94  int ye=ys+yl;
95  int xe=xs+xl;
96
97  uint8_t *isl=im->scan_line(ys)+xs;
98  uint8_t *ssl=screen->scan_line(y)+x;
99  int iw=im->width(),sw=screen->width();
100
101  for (int iy=ys; iy<ye; iy++,y++,isl+=iw,ssl+=sw)
102  {
103    uint8_t *s=ssl,*i=isl;
104    for (int ix=xs; ix<xe; ix++,s++,i++)
105      *s=table[((*i)<<8)|(*s)];
106  }
107}
108
109
110*/
Note: See TracBrowser for help on using the repository browser.