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