+++ /dev/null
-/*\r
-Copyright (C) 1998 BJ Eirich (aka vecna)\r
-This program is free software; you can redistribute it and/or\r
-modify it under the terms of the GNU General Public License\r
-as published by the Free Software Foundation; either version 2\r
-of the License, or (at your option) any later version.\r
-This program is distributed in the hope that it will be useful,\r
-but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\r
-See the GNU General Public Lic\r
-See the GNU General Public License for more details.\r
-You should have received a copy of the GNU General Public License\r
-along with this program; if not, write to the Free Software\r
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\r
-*/\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <malloc.h>\r
-\r
-#include "config.h"\r
-#include "keyboard.h"\r
-#include "maped.h"\r
-#include "mouse.h"\r
-#include "vdriver.h"\r
-\r
-// ============================ Data ============================\r
-\r
-unsigned char mvsp[2048]; // mini-VSP dominant color\r
-int xoff=0, yoff=0; // x-offset, y-offset\r
-\r
-// ============================ Code ============================\r
-/*\r
-FindDominantColor(int i)\r
-{ unsigned char *src;\r
- int j,tally=0;\r
-\r
- // This is a cheap-ass method. I have a more proper method in mind, but\r
- // I'm going to do this for now b/c I'm lazy. Actually, the real reason is\r
- // speed.\r
-\r
- src=vsp+(i*256);\r
-\r
- for (j=0; j<256; j++)\r
- {\r
- tally+=*src;\r
- src++;\r
- }\r
- tally=tally/256;\r
- mvsp[i]=(unsigned char) tally;\r
-}\r
-*/\r
-\r
-void FindDominantColor(int i)\r
-{ unsigned char *src, tally[256], tab;\r
- int j;\r
-\r
- src=vsp+(i*256);\r
- memset(&tally, 0, 256);\r
-\r
- for (j=0; j<256; j++)\r
- {\r
- tally[*src]++;\r
- src++;\r
- }\r
- tab=0;\r
- for (j=0; j<256; j++)\r
- {\r
- if (tally[j] > tab) tab=j;\r
- }\r
- mvsp[i]=(unsigned char) tab;\r
-}\r
-\r
-void GenerateMiniVSP()\r
-{ int i;\r
-\r
- for (i=0; i<numtiles; i++)\r
- FindDominantColor(i);\r
-}\r
-\r
-void MiniMAP()\r
-{ char *ptr,c;\r
- int _x,_y,ct;\r
- int i;\r
-\r
- GenerateMiniVSP();\r
- ptr=(char *) valloc(layer[0].sizex*layer[0].sizey,"minimap",0);\r
- //memset(ptr,0,layer[0].sizex*layer[0].sizey);\r
-\r
- // Now we "draw" the tiles into the buffer.\r
-\r
- for (i=0; i<4; i++)\r
- {\r
- if (!layertoggle[i]) continue;\r
- ct=0;\r
- for (_y=0; _y<layer[i].sizey; _y++)\r
- for (_x=0; _x<layer[i].sizex; _x++)\r
- {\r
- c=(unsigned char) mvsp[layers[i][(_y*layer[i].sizex)+_x]];\r
- if (layers[i][(_y*layer[i].sizex)+_x]) ptr[ct]=c;\r
- ct++;\r
- }\r
- }\r
-\r
- while (!key[SCAN_ESC] && !mb)\r
- {\r
- ClearScreen();\r
- CCopySprite(16-xoff, 16-yoff, layer[0].sizex, layer[0].sizey, ptr);\r
- ReadMouse();\r
- HLine(mx, my, 20, white);\r
- VLine(mx, my, ty, white);\r
- VLine(mx+19, my, ty, white);\r
- HLine(mx, my+ty, 20, white);\r
-\r
- ShowPage();\r
-\r
- if (key[SCAN_LEFT] && xoff)\r
- {\r
- if (xoff > 0) xoff-=16;\r
- key[SCAN_LEFT]=0;\r
- }\r
- if (key[SCAN_UP] && yoff)\r
- {\r
- if (yoff > 0) yoff-=16;\r
- key[SCAN_UP]=0;\r
- }\r
- if (key[SCAN_DOWN])\r
- {\r
- if (yoff < layer[0].sizey)\r
- yoff+=16;\r
- key[SCAN_DOWN]=0;\r
- }\r
- if (key[SCAN_RIGHT])\r
- {\r
- if (xoff < layer[0].sizex)\r
- xoff+=16;\r
- key[SCAN_RIGHT]=0;\r
- }\r
- if (mb)\r
- {\r
- xwin=(xoff+mx-16)*16;\r
- ywin=(yoff+my-16)*16;\r
- if (xwin>=(layer[0].sizex*16)-320) xwin=(layer[0].sizex*16)-320;\r
- if (ywin>=(layer[0].sizey*16)-tsy-15) ywin=(layer[0].sizey*16)-tsy-15;\r
- WaitRelease();\r
- break;\r
- }\r
- }\r
- key[SCAN_ESC]=0;\r
- vfree(ptr);\r
-}\r