1 /*
2 
3 Copyright (C) 2015-2018 Night Dive Studios, LLC.
4 
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 
18 */
19 //
20 // $Source: r:/prj/lib/src/2d/RCS/fl8dbl.asm $
21 // $Revision: 1.3 $
22 // $Author: kevin $
23 // $Date: 1994/09/08 00:00:18 $
24 //
25 // Bitmap doubling primitives.
26 //
27 
28 #include <stdbool.h>
29 
30 #include "blndat.h"
31 #include "grs.h"
32 #include "lg.h"
33 
34 // ------------------------------------------------------------------------
35 // PowerPC routines
36 // ------------------------------------------------------------------------
37 // ========================================================================
flat8_flat8_h_double_ubitmap(grs_bitmap * bm)38 void flat8_flat8_h_double_ubitmap(grs_bitmap *bm) {
39     DEBUG("%s: call mark", __FUNCTION__);
40     /* 	int		h,v,endh,endv;
41             uchar *src=bm->bits, *dst=grd_bm.bits;
42             long	srcAdd,dstAdd;
43             uchar	temp;
44 
45             srcAdd = bm->row-bm->w;
46             dstAdd = grd_bm.row - (bm->w<<1);
47             endh = bm->w;
48             endv = bm->h;
49 
50             for (v=0; v<endv; v++)
51              {
52                     for (h=0; h<endh; h++)
53                      {
54                             temp = *(src++);
55                             *(dst++) = temp;
56                             *(dst++) = temp;
57                      }
58 
59                     src+=srcAdd;
60                     dst+=dstAdd;
61              }*/
62 }
63 
64 // ========================================================================
flat8_flat8_smooth_h_double_ubitmap(grs_bitmap * srcb,grs_bitmap * dstb)65 void flat8_flat8_smooth_h_double_ubitmap(grs_bitmap *srcb, grs_bitmap *dstb) {
66     int h, v, endh, endv;
67     uchar *src = srcb->bits, *dst = dstb->bits;
68     long srcAdd, dstAdd;
69     ushort curpix, tempshort;
70     uchar *local_grd_half_blend;
71 
72     local_grd_half_blend = grd_half_blend;
73     if (!local_grd_half_blend)
74         return;
75 
76     srcAdd = (srcb->row - srcb->w) - 1;
77     dstAdd = dstb->row - (srcb->w << 1);
78     endh = srcb->w - 1;
79     endv = srcb->h;
80 
81     for (v = 0; v < endv; v++) {
82         curpix = *(short *)src;
83         src += 2;
84         for (h = 0; h < endh; h++) {
85             tempshort = curpix & 0xff00;
86             tempshort |= local_grd_half_blend[curpix];
87             *(ushort *)dst = tempshort;
88             dst += 2;
89             curpix = (curpix << 8) | *(src++);
90         }
91 
92         // double last pixel
93         curpix >>= 8;
94         *(dst++) = curpix;
95         *(dst++) = curpix;
96 
97         src += srcAdd;
98         dst += dstAdd;
99     }
100 }
101 
102 // ========================================================================
103 // src = eax, dest = edx
flat8_flat8_smooth_hv_double_ubitmap(grs_bitmap * src,grs_bitmap * dst)104 void flat8_flat8_smooth_hv_double_ubitmap(grs_bitmap *src, grs_bitmap *dst) {
105     int tempH, tempW, temp, savetemp;
106     uchar *srcPtr, *dstPtr;
107     uchar *shvd_read_row1, *shvd_write, *shvd_read_row2, *shvd_read_blend;
108     ushort tempc;
109 
110     dstPtr = dst->bits;
111     srcPtr = src->bits;
112 
113     // HAX HAX HAX no smooth doubling for now!
114     for (int y = 0; y < src->h; y++) {
115         for (int x = 0; x < src->w; x++) {
116             *(dstPtr) = *srcPtr;
117             *(dstPtr + 1) = *srcPtr;
118             *(dstPtr + src->w * 2) = *srcPtr;
119             *((dstPtr + src->w * 2) + 1) = *srcPtr;
120             dstPtr += 2;
121             srcPtr++;
122         }
123         dstPtr += src->w * 2;
124     }
125 
126     return;
127 
128 /* // WH - unused code
129     dst->row <<= 1;
130     flat8_flat8_smooth_h_double_ubitmap(src, dst);
131 
132     dst->row = tempW = dst->row >> 1;
133     dstPtr = dst->bits;
134 
135     tempH = src->h - 1;
136     temp = src->w << 1;
137     dstPtr += temp;
138     temp = -temp;
139 
140     shvd_read_row1 = dstPtr;
141     dstPtr += tempW;
142     shvd_write = dstPtr - 1;
143     dstPtr += tempW;
144     shvd_read_row2 = dstPtr;
145     shvd_read_blend = grd_half_blend;
146     savetemp = temp;
147 
148     do {
149         do {
150             tempc = shvd_read_row1[temp];
151             tempc |= ((ushort)shvd_read_row2[temp]) << 8;
152             temp++;
153 
154             shvd_write[temp] = shvd_read_blend[tempc];
155         } while (temp != 0);
156 
157         if (--tempH == 0)
158             break;
159 
160         shvd_read_row1 = dstPtr;
161         dstPtr += tempW;
162         shvd_write = dstPtr - 1;
163         dstPtr += tempW;
164         shvd_read_row2 = dstPtr;
165         temp = savetemp;
166     } while (true);
167 
168     // do last row
169     srcPtr = dstPtr + savetemp;
170     dstPtr += tempW + savetemp;
171     savetemp = -savetemp;
172 
173     for (; savetemp > 0; savetemp--)
174         *(dstPtr++) = *(srcPtr++);
175 */
176 }
177