source: abuse/branches/lol/src/transp.cpp

Last change on this file was 732, checked in by Sam Hocevar, 8 years ago

build: SDL2 compilation fixes.

File size: 2.0 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
[732]11#if HAVE_CONFIG_H
[555]12#   include "config.h"
13#endif
[56]14
[512]15#include "common.h"
16
[481]17#include "transp.h"
[2]18
[709]19void transp_put(AImage *im, AImage *screen, uint8_t *table, int x, int y)
[2]20{
[682]21    ivec2 caa, cbb;
[665]22    screen->GetClip(caa, cbb);
[2]23
[682]24    ivec2 aa(0), bb = im->Size();
25    ivec2 pos(x, y);
[2]26
[719]27    aa += lol::max(caa - pos, ivec2::zero);
28    bb -= lol::max(caa - pos, ivec2::zero);
[687]29    pos = lol::max(caa, pos);
[2]30
[687]31    bb = lol::min(bb, cbb - ivec2(1) - pos);
[665]32
[719]33    if (!(bb >= ivec2::zero))
[665]34        return;
[670]35    screen->AddDirty(pos, pos + bb);
[665]36
37  int ye=aa.y+bb.y;
38  int xe=aa.x+bb.x;
39
40  uint8_t *isl=im->scan_line(aa.y)+aa.x;
[17]41  uint8_t *ssl=screen->scan_line(y)+x;
[512]42  int iw=im->Size().x,sw=screen->Size().x;
[2]43
[665]44  for (int iy=aa.y; iy<ye; iy++,y++,isl+=iw,ssl+=sw)
[2]45  {
[17]46    uint8_t *s=ssl,*i=isl;
[665]47    for (int ix=aa.x; ix<xe; ix++,s++,i++)
[2]48    {
49      if (*i)
50        *s=*i;
51      else *s=table[*s];
52    }
[124]53  }
[2]54}
55
56
57/*
[709]58void transp_put(AImage *im, AImage *screen, uint8_t *table, int x, int y)
[2]59{
[518]60  int cx1, cy1, cx2, cy2;
61  screen->GetClip(cx1, cy1, cx2, cy2);
[2]62  int xs=0,ys=0,xl=im->width(),yl=im->height();
[124]63  if (x<cx1)
64  {
[2]65    int chop=cx1-x;
66    xs+=chop;
67    xl-=chop;
68    x+=chop;
69  }
[124]70  if (y<cy1)
71  {
[2]72    int chop=cy1-y;
73    ys+=chop;
74    yl-=chop;
75    y+=chop;
76  }
[518]77  if (x + xl >= cx2)
78    xl = cx2 - 1 - x;
79  if (y + yl >= cy2)
80    yl = cy2 - 1 - y;
[2]81
82  if (xl<0 || yl<0) return ;
[518]83  screen->AddDirty(x, y, x + xl - 1, y + yl);
[2]84
85  int ye=ys+yl;
86  int xe=xs+xl;
87
[17]88  uint8_t *isl=im->scan_line(ys)+xs;
89  uint8_t *ssl=screen->scan_line(y)+x;
[2]90  int iw=im->width(),sw=screen->width();
91
[494]92  for (int iy=ys; iy<ye; iy++,y++,isl+=iw,ssl+=sw)
[2]93  {
[17]94    uint8_t *s=ssl,*i=isl;
[494]95    for (int ix=xs; ix<xe; ix++,s++,i++)
[2]96      *s=table[((*i)<<8)|(*s)];
[124]97  }
[2]98}
99
100
101*/
Note: See TracBrowser for help on using the repository browser.