]> 4ch.mooo.com Git - 16.git/blob - 16/v2/source/ENGINE/MESSAGE.C
wwww
[16.git] / 16 / v2 / source / ENGINE / MESSAGE.C
1 /*\r
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
15 */\r
16 \r
17 #include "verge.h"\r
18 \r
19 // ================================= Data ====================================\r
20 \r
21 struct message\r
22 {\r
23   char text[44];                     // message text\r
24   int exptime;                       // message expire time\r
25 };\r
26 \r
27 struct message messages[6];          // 5-message buffer\r
28 byte num_msgs=0;                     // number of active messages\r
29 \r
30 // -- cpu usage --\r
31 \r
32 int cputimer=0, frames=0;\r
33 char runprf[3];\r
34 // -- final numbers --\r
35 int fps=0;\r
36 char profile[3];\r
37 \r
38 // ================================= Code ====================================\r
39 \r
40 void CheckMessageExpirations()\r
41 { int i;\r
42 \r
43   for (i=0; i<num_msgs; i++)\r
44     if (systemtime>messages[i].exptime)\r
45     {\r
46        memcpy(messages[i].text, messages[i+1].text, (48*(num_msgs-i+1)));\r
47        num_msgs--;\r
48     }\r
49 }\r
50 \r
51 void RenderGUI()\r
52 { int i;\r
53 \r
54   CheckMessageExpirations();\r
55   for (i=0; i<num_msgs; i++)\r
56   {\r
57     GotoXY(1,1+(i*10));\r
58     printstring(0,messages[i].text);\r
59   }\r
60 \r
61   if (!cpu_watch) return;\r
62   frames++;\r
63 \r
64   i=sx-76;\r
65   GotoXY(i,sy-39);\r
66   sprintf(strbuf,"etc:%d",profile[0]);\r
67   printstring(0,strbuf);\r
68   GotoXY(i,sy-29);\r
69   sprintf(strbuf,"Render:%d",profile[1]);\r
70   printstring(0,strbuf);\r
71   GotoXY(i,sy-19);\r
72   sprintf(strbuf,"PFlip:%d",profile[2]);\r
73   printstring(0,strbuf);\r
74   GotoXY(i,sy-9);\r
75   sprintf(strbuf,"FPS:%d",fps);\r
76   printstring(0,strbuf);\r
77 }\r
78 \r
79 void CPUTick()\r
80 {\r
81   cputimer++;\r
82   runprf[cpubyte]++;\r
83   if (cputimer==100)\r
84   {\r
85      fps=frames;\r
86      frames=0;\r
87      cputimer=0;\r
88 \r
89      profile[0]=runprf[0]; runprf[0]=0;\r
90      profile[1]=runprf[1]; runprf[1]=0;\r
91      profile[2]=runprf[2]; runprf[2]=0;\r
92   }\r
93 }\r
94 \r
95 void Message(char *text, int duration)\r
96 {\r
97   Log("Message: %s", text);\r
98 \r
99   if (num_msgs<5)\r
100   {\r
101     memcpy(messages[num_msgs].text, text, strlen(text));\r
102     messages[num_msgs].exptime=systemtime+duration;\r
103     num_msgs++;\r
104     return;\r
105   }\r
106 \r
107   memcpy(&messages[0].text, &messages[1].text, 192);\r
108   memcpy(messages[4].text, text, strlen(text));\r
109   messages[num_msgs].exptime=systemtime+duration;\r
110 }\r