2 Copyright (C) 1998 BJ Eirich (aka vecna)
\r
3 This program is free software; you can redistribute it and/or
\r
4 modify it under the terms of the GNU General Public License
\r
5 as published by the Free Software Foundation; either version 2
\r
6 of the License, or (at your option) any later version.
\r
7 This program is distributed in the hope that it will be useful,
\r
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
\r
10 See the GNU General Public Lic
\r
11 See the GNU General Public License for more details.
\r
12 You should have received a copy of the GNU General Public License
\r
13 along with this program; if not, write to the Free Software
\r
14 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
\r
22 #include "keyboard.h"
\r
25 #include "vdriver.h"
\r
27 // ============================ Data ============================
\r
29 unsigned char mvsp[2048]; // mini-VSP dominant color
\r
30 int xoff=0, yoff=0; // x-offset, y-offset
\r
32 // ============================ Code ============================
\r
34 FindDominantColor(int i)
\r
35 { unsigned char *src;
\r
38 // This is a cheap-ass method. I have a more proper method in mind, but
\r
39 // I'm going to do this for now b/c I'm lazy. Actually, the real reason is
\r
44 for (j=0; j<256; j++)
\r
50 mvsp[i]=(unsigned char) tally;
\r
54 void FindDominantColor(int i)
\r
55 { unsigned char *src, tally[256], tab;
\r
59 memset(&tally, 0, 256);
\r
61 for (j=0; j<256; j++)
\r
67 for (j=0; j<256; j++)
\r
69 if (tally[j] > tab) tab=j;
\r
71 mvsp[i]=(unsigned char) tab;
\r
74 void GenerateMiniVSP()
\r
77 for (i=0; i<numtiles; i++)
\r
78 FindDominantColor(i);
\r
87 ptr=(char *) valloc(layer[0].sizex*layer[0].sizey,"minimap",0);
\r
88 //memset(ptr,0,layer[0].sizex*layer[0].sizey);
\r
90 // Now we "draw" the tiles into the buffer.
\r
94 if (!layertoggle[i]) continue;
\r
96 for (_y=0; _y<layer[i].sizey; _y++)
\r
97 for (_x=0; _x<layer[i].sizex; _x++)
\r
99 c=(unsigned char) mvsp[layers[i][(_y*layer[i].sizex)+_x]];
\r
100 if (layers[i][(_y*layer[i].sizex)+_x]) ptr[ct]=c;
\r
105 while (!key[SCAN_ESC] && !mb)
\r
108 CCopySprite(16-xoff, 16-yoff, layer[0].sizex, layer[0].sizey, ptr);
\r
110 HLine(mx, my, 20, white);
\r
111 VLine(mx, my, ty, white);
\r
112 VLine(mx+19, my, ty, white);
\r
113 HLine(mx, my+ty, 20, white);
\r
117 if (key[SCAN_LEFT] && xoff)
\r
119 if (xoff > 0) xoff-=16;
\r
122 if (key[SCAN_UP] && yoff)
\r
124 if (yoff > 0) yoff-=16;
\r
127 if (key[SCAN_DOWN])
\r
129 if (yoff < layer[0].sizey)
\r
133 if (key[SCAN_RIGHT])
\r
135 if (xoff < layer[0].sizex)
\r
141 xwin=(xoff+mx-16)*16;
\r
142 ywin=(yoff+my-16)*16;
\r
143 if (xwin>=(layer[0].sizex*16)-320) xwin=(layer[0].sizex*16)-320;
\r
144 if (ywin>=(layer[0].sizey*16)-tsy-15) ywin=(layer[0].sizey*16)-tsy-15;
\r