]> 4ch.mooo.com Git - 16.git/blob - src/exmmtest.c
typedef void __based( void ) * memptr;
[16.git] / src / exmmtest.c
1 /* Project 16 Source Code~\r
2  * Copyright (C) 2012-2016 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_ca.h"\r
27 #include "src/lib/16_mm.h"\r
28 #include "src/lib/16_hc.h"\r
29 //#include "src/lib/modex16.h"\r
30 #pragma hdrstop\r
31 \r
32 #pragma warn -pro\r
33 #pragma warn -use\r
34 \r
35 //file load or read definition\r
36 #define FILERL\r
37 //#define FILEREAD\r
38 \r
39 #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
40 \r
41 void\r
42 main(int argc, char *argv[])\r
43 {\r
44         global_game_variables_t gvar;\r
45 #ifdef __WATCOMC__\r
46         __segment sega;\r
47 #endif\r
48         memptr bigbuffer;\r
49 \r
50 #ifdef FILERL\r
51         //static byte bakapee[64];\r
52         char *bakapee;\r
53         word baka;\r
54 #endif\r
55 \r
56 #ifdef __BORLANDC__\r
57         argc=argc;\r
58 #endif\r
59 #ifdef FILERL\r
60         bakapee = malloc(64);\r
61 #endif\r
62         gvar.mm.mmstarted=0;\r
63 \r
64         //PRINTBB\r
65 #ifdef FILERL\r
66         if(argv[1]) bakapee = argv[1];\r
67         else\r
68         //{ printf("filename!: "); scanf("%[^\n]", &bakapee); }\r
69         bakapee = "data/koishi~.pcx";\r
70 #endif\r
71 \r
72 //      printf("main()=%Fp      start MM\n", *argv[0]);\r
73         MM_Startup(&gvar.mm, &gvar.mmi);\r
74         //PM_Startup();\r
75         //PM_UnlockMainMem();\r
76         CA_Startup(&gvar);\r
77 //      printf("                done!\n");\r
78         //PRINTBB\r
79 //      getch();\r
80 #ifdef FILERL\r
81 //      bakapeehandle = open(bakapee,O_RDONLY | O_BINARY, S_IREAD);\r
82 //      printf("size of big buffer~=%u\n", _bmsize(segu, bigbuffer));\r
83 //      if(CA_FarRead(bakapeehandle,(void far *)&bigbuffer,sizeof(bigbuffer),&gvar.mm))\r
84 #ifdef FILEREAD\r
85         printf("                read\n");\r
86         if(CA_ReadFile(bakapee, &bigbuffer, &gvar.mm))\r
87 #else\r
88         printf("                load\n");\r
89         if(CA_LoadFile(bakapee, &bigbuffer, &gvar.mm, &gvar.mmi))\r
90 #endif\r
91                 baka=1;\r
92         else\r
93                 baka=0;\r
94 //      close(bakapeehandle);\r
95         //hmm functions in cache system use the buffered stuff\r
96 #ifdef __WATCOMC__\r
97         printf("\nsize of big buffer~=%u\n", _bmsize(sega, bigbuffer));\r
98 #endif\r
99 #endif\r
100         printf("press any key to continue!\n");\r
101         getch();\r
102         printf("\n\ncontents of the buffer\n[\n%s\n]\n", bigbuffer);\r
103         //printf("dark purple = purgable\n");\r
104         //printf("medium blue = non purgable\n");\r
105         //printf("red = locked\n");\r
106         printf("press any key to continue!\n");\r
107         getch();\r
108         MM_ShowMemory(&gvar, &gvar.mm);\r
109         //getch();\r
110         MM_DumpData(&gvar.mm);\r
111         MM_Report(&gvar);\r
112 //      printf("                stop!\n");\r
113         getch();\r
114 #ifdef FILERL\r
115         MM_FreePtr(&bigbuffer, &gvar.mm);\r
116 #endif\r
117         //PM_Shutdown();\r
118         CA_Shutdown(&gvar);\r
119         MM_Shutdown(&gvar.mm);\r
120 //      printf("                done!\n");\r
121 #ifdef FILERL\r
122         free(bakapee);\r
123         if(baka) printf("\nyay!\n");\r
124         else printf("\npoo!\n");\r
125 #endif\r
126         printf("========================================\n");\r
127         printf("near=   %Fp ", gvar.mm.nearheap);\r
128         printf("far=    %Fp", gvar.mm.farheap);\r
129         printf("\n");\r
130         printf("&near=  %Fp ", &(gvar.mm.nearheap));\r
131         printf("&far=   %Fp", &(gvar.mm.farheap));\r
132         printf("\n");\r
133 #ifdef EXMMVERBOSE\r
134         printf("bigb=   %Fp ", bigbuffer);\r
135         //printf("bigbr=        %04x", bigbuffer);\r
136         //printf("\n");\r
137         printf("&bigb=%Fp ", &bigbuffer);\r
138         //printf("&bigb=%04x", &bigbuffer);\r
139         printf("\n");\r
140 #endif\r
141         printf("========================================\n");\r
142 #ifdef __WATCOMC__\r
143 //this is far   printf("Total free:                     %lu\n", (dword)(GetFreeSize()));\r
144         printf("Total near free:                %lu\n", (dword)(GetNearFreeSize()));\r
145         printf("Total far free:                 %lu\n", (dword)(GetFarFreeSize()));\r
146         heapdump(&gvar);\r
147         #endif\r
148         printf("Project 16 emmtest.exe. This is just a test file!\n");\r
149         printf("version %s\n", VERSION);\r
150         //printf("core left:                    %lu\n", (dword)_coreleft());\r
151         //printf("far core left:                        %lu\n", (dword)_farcoreleft());\r
152         //printf("based core left:                      %lu\n", (dword)_basedcoreleft());\r
153         //printf("huge core left:                       %lu\n", (dword)_hugecoreleft());\r
154 }\r