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