]> 4ch.mooo.com Git - 16.git/blob - src/exmmtest.c
==== bloody! ====
[16.git] / src / exmmtest.c
1 /* Project 16 Source Code~\r
2  * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
3  *\r
4  * This file is part of Project 16.\r
5  *\r
6  * Project 16 is free software; you can redistribute it and/or modify\r
7  * it under the terms of the GNU General Public License as published by\r
8  * the Free Software Foundation; either version 3 of the License, or\r
9  * (at your option) any later version.\r
10  *\r
11  * Project 16 is distributed in the hope that it will be useful,\r
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14  * GNU General Public License for more details.\r
15  *\r
16  * You should have received a copy of the GNU General Public License\r
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>, or\r
18  * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
19  * Fifth Floor, Boston, MA 02110-1301 USA.\r
20  *\r
21  */\r
22 /*\r
23         exmm test\r
24 */\r
25 #include "src/lib/16_head.h"\r
26 #include "src/lib/16_tail.h"\r
27 #include "src/lib/16_pm.h"\r
28 #include "src/lib/16_ca.h"\r
29 #include "src/lib/16_mm.h"\r
30 #include "src/lib/16_hc.h"\r
31 //#include "src/lib/16_vl.h"\r
32 #pragma hdrstop\r
33 \r
34 #pragma warn -pro\r
35 #pragma warn -use\r
36 \r
37 //file load or read definition\r
38 #define FILEREAD\r
39 //#define EXMMVERBOSE\r
40 \r
41 void VGAmodeX(sword vq, boolean cmem, global_game_variables_t *gv){}\r
42 #define PRINTBB { printf("&main()=      %Fp\n", argv[0]);printf("bigbuffer=     %Fp\n", bigbuffer);printf("&bigbuffer=  %Fp\n", &bigbuffer);printf("bigbuffer=  %04x\n", bigbuffer);printf("&bigbuffer= %04x\n", &bigbuffer); }\r
43 \r
44 #ifdef __WATCOMC__\r
45 void segatesuto()\r
46 {\r
47         __segment screen;\r
48         char __based( void ) * scrptr;\r
49 \r
50         screen = 0xB800;\r
51         scrptr = 0;\r
52         printf( "Top left character is '%c'.\n", *(screen:>scrptr) );\r
53 //      printf("Next string is: [");\r
54 //      while(*scrptr<16)\r
55 //      {\r
56 //              printf("%c", *(screen:>scrptr));\r
57 //              //printf("\b");\r
58 //              scrptr++;\r
59 //\r
60 //      }\r
61 //      printf("]\n");\r
62 //      printf("press any key to continue!\n");\r
63 //      getch();\r
64 }\r
65 #endif\r
66 //static global_game_variables_t gvar;\r
67 \r
68 void\r
69 main(int argc, char *argv[])\r
70 {\r
71         byte w=1;\r
72         static global_game_variables_t gvar;\r
73 //#ifdef __WATCOMC__\r
74 //      __segment sega;\r
75 //#endif\r
76         memptr bigbuffer;\r
77 \r
78         //static byte bakapee[64];\r
79         char *bakapee1, *bakapee2;\r
80         word baka;\r
81 \r
82 #ifdef __BORLANDC__\r
83         argc=argc;\r
84 #endif\r
85         //file name //\r
86         bakapee1 = malloc(64);\r
87         bakapee2 = malloc(64);\r
88         //file name //\r
89 \r
90         gvar.mm.mmstarted=0;\r
91 \r
92 #ifdef __DEBUG_PM__\r
93         dbg_debugpm=1;  //debug pm\r
94 #endif\r
95 \r
96         //PRINTBB\r
97         if(argv[1]){ bakapee1 = argv[1];\r
98         if(argv[2]) bakapee2 = argv[2]; }\r
99         else{\r
100         //{ printf("filename!: "); scanf("%[^\n]", &bakapee); }\r
101                 bakapee1 = "data/koishi~.pcx";\r
102                 bakapee2 = "data/test.map";\r
103         }\r
104         //printf("main()=%Fp    start MM\n", *argv[0]);\r
105         MM_Startup(&gvar);\r
106         //printf("ok\n");\r
107 //#ifdef __WATCOMC__\r
108 #ifdef __DEBUG_PM__\r
109         if(dbg_debugpm>0)\r
110         {\r
111 #endif\r
112                 PM_Startup(&gvar);\r
113                 //printf("pmstarted ok\n");\r
114                 //PM_CheckMainMem(&gvar);\r
115                 PM_UnlockMainMem(&gvar);\r
116 #ifdef __DEBUG_PM__\r
117         }\r
118 #endif\r
119 //#endif\r
120         CA_Startup(&gvar);\r
121 //      printf("                done!\n");\r
122         //0000PRINTBB;\r
123 //      printf("press any key to continue!\n");\r
124 //      getch();\r
125 #ifdef FILEREAD\r
126 for(w=0;w<2;w++)\r
127 {\r
128 //      bakapeehandle = open(bakapee,O_RDONLY | O_BINARY, S_IREAD);\r
129 //      printf("size of big buffer~=%u\n", _bmsize(segu, bigbuffer));\r
130 //      if(CA_FarRead(bakapeehandle,(void far *)&bigbuffer,sizeof(bigbuffer),&gvar.mm))\r
131         if(w>0)\r
132         {\r
133                 printf("                read\n");\r
134                 if(CA_ReadFile(bakapee2, &bigbuffer, &gvar)) baka=1; else baka=0;\r
135         }\r
136 #endif\r
137         if(w==0)\r
138         {\r
139         printf("                load\n");\r
140         if(CA_LoadFile(bakapee1, &bigbuffer, &gvar)) baka=1; else baka=0;\r
141         }\r
142 //      close(bakapeehandle);\r
143         //hmm functions in cache system use the buffered stuff\r
144 //#ifdef __WATCOMC__\r
145 //      printf("\nsize of big buffer~=%u\n", _bmsize(sega, bigbuffer));\r
146 //#endif\r
147 \r
148         printf("contents of the buffer\n[\n%s\n]\n", bigbuffer);\r
149         //printf("dark purple = purgable\n");\r
150         //printf("medium blue = non purgable\n");\r
151         //printf("red = locked\n");\r
152 //      printf("press any key to continue!\n");\r
153 //      DebugMemory_(&gvar, 1);\r
154         if(baka) printf("\nyay!\n");\r
155         else printf("\npoo!\n");\r
156         printf("press any key to continue!\n");\r
157         getch();\r
158 #ifdef FILEREAD\r
159 }\r
160 #endif\r
161         DebugMemory_(&gvar, 1);\r
162         MM_DumpData(&gvar);\r
163         MM_Report_(&gvar);\r
164         //printf("bakapee1=%s\n", bakapee1);\r
165         //printf("bakapee2=%s\n", bakapee2);\r
166         MM_FreePtr(&bigbuffer, &gvar);\r
167 //#ifdef __WATCOMC__\r
168 #ifdef __DEBUG_PM__\r
169         if(dbg_debugpm>0)\r
170 #endif\r
171                 PM_Shutdown(&gvar);\r
172 //#endif\r
173         CA_Shutdown(&gvar);\r
174         MM_Shutdown(&gvar);\r
175         free(bakapee1); free(bakapee2);\r
176         printf("========================================\n");\r
177         printf("near=   %Fp ", gvar.mm.nearheap);\r
178         printf("far=    %Fp", gvar.mm.farheap);\r
179         printf("\n");\r
180         printf("&near=  %Fp ", &(gvar.mm.nearheap));\r
181         printf("&far=   %Fp", &(gvar.mm.farheap));\r
182         printf("\n");\r
183 #ifdef EXMMVERBOSE\r
184         printf("bigb=   %Fp ", bigbuffer);\r
185         //printf("bigbr=        %04x", bigbuffer);\r
186         //printf("\n");\r
187         printf("&bigb=%Fp ", &bigbuffer);\r
188         //printf("&bigb=%04x", &bigbuffer);\r
189         printf("\n");\r
190         printf("========================================\n");\r
191 #endif\r
192 #ifdef __WATCOMC__\r
193 //this is far   printf("Total free:                     %lu\n", (dword)(GetFreeSize()));\r
194         printf("Total near free:                %lub\n", (dword)(GetNearFreeSize()));\r
195         printf("Total far free:                 %lub\n", (dword)(GetFarFreeSize()));\r
196         heapdump(&gvar);\r
197         segatesuto();\r
198 #endif\r
199         printf("Project 16 exmmtest.exe. This is just a test file!\n");\r
200         printf("version %s\n", VERSION);\r
201         //printf("core left:                    %lu\n", (dword)_coreleft());\r
202         //printf("far core left:                        %lu\n", (dword)_farcoreleft());\r
203         //printf("based core left:                      %lu\n", (dword)_basedcoreleft());\r
204         //printf("huge core left:                       %lu\n", (dword)_hugecoreleft());\r
205 }\r