]> 4ch.mooo.com Git - 16.git/blob - src/exmmtest.c
pressing exmmtest.exe for multi file test
[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 #ifdef __WATCOMC__\r
42 void segatesuto()\r
43 {\r
44         __segment screen;\r
45         char __based( void ) * scrptr;\r
46 \r
47         screen = 0xB800;\r
48         scrptr = 0;\r
49         printf( "Top left character is '%c'.\n", *(screen:>scrptr) );\r
50 //      printf("Next string is: [");\r
51 //      while(*scrptr<16)\r
52 //      {\r
53 //              printf("%c", *(screen:>scrptr));\r
54 //              //printf("\b");\r
55 //              scrptr++;\r
56 //\r
57 //      }\r
58 //      printf("]\n");\r
59 //      printf("press any key to continue!\n");\r
60 //      getch();\r
61 }\r
62 #endif\r
63 \r
64 void\r
65 main(int argc, char *argv[])\r
66 {\r
67         global_game_variables_t gvar;\r
68 #ifdef __WATCOMC__\r
69         __segment sega;\r
70 #endif\r
71         memptr bigbuffer;\r
72 \r
73 #ifdef FILERL\r
74         //static byte bakapee[64];\r
75         char *bakapee;\r
76         word baka;\r
77 #endif\r
78 \r
79 #ifdef __BORLANDC__\r
80         argc=argc;\r
81 #endif\r
82 #ifdef FILERL\r
83         bakapee = malloc(64);\r
84 #endif\r
85         gvar.mm.mmstarted=0;\r
86 \r
87         //PRINTBB\r
88 #ifdef FILERL\r
89         if(argv[1]) bakapee = argv[1];\r
90         else\r
91         //{ printf("filename!: "); scanf("%[^\n]", &bakapee); }\r
92         bakapee = "data/koishi~.pcx";\r
93 #endif\r
94 \r
95 //      printf("main()=%Fp      start MM\n", *argv[0]);\r
96         MM_Startup(&gvar.mm, &gvar.mmi);\r
97         //PM_Startup();\r
98         //PM_UnlockMainMem();\r
99         CA_Startup(&gvar);\r
100 //      printf("                done!\n");\r
101         PRINTBB;\r
102 //      printf("press any key to continue!\n");\r
103 //      getch();\r
104 #ifdef FILERL\r
105 //      bakapeehandle = open(bakapee,O_RDONLY | O_BINARY, S_IREAD);\r
106 //      printf("size of big buffer~=%u\n", _bmsize(segu, bigbuffer));\r
107 //      if(CA_FarRead(bakapeehandle,(void far *)&bigbuffer,sizeof(bigbuffer),&gvar.mm))\r
108 #ifdef FILEREAD\r
109         printf("                read\n");\r
110         if(CA_ReadFile(bakapee, &bigbuffer, &gvar))\r
111 #else\r
112         printf("                load\n");\r
113         if(CA_LoadFile(bakapee, &bigbuffer, &gvar))\r
114 #endif\r
115                 baka=1;\r
116         else\r
117                 baka=0;\r
118 //      close(bakapeehandle);\r
119         //hmm functions in cache system use the buffered stuff\r
120 #ifdef __WATCOMC__\r
121         printf("\nsize of big buffer~=%u\n", _bmsize(sega, bigbuffer));\r
122 #endif\r
123 #endif\r
124         printf("contents of the buffer\n[\n%s\n]\n", bigbuffer);\r
125         //printf("dark purple = purgable\n");\r
126         //printf("medium blue = non purgable\n");\r
127         //printf("red = locked\n");\r
128         printf("press any key to continue!\n");\r
129         getch();\r
130         MM_ShowMemory(&gvar, &gvar.mm);\r
131         MM_DumpData(&gvar.mm);\r
132         MM_Report(&gvar);\r
133         printf("press any key to continue!\n");\r
134         getch();\r
135 #ifdef FILERL\r
136         MM_FreePtr(&bigbuffer, &gvar.mm);\r
137 #endif\r
138         //PM_Shutdown();\r
139         CA_Shutdown(&gvar);\r
140         MM_Shutdown(&gvar.mm);\r
141 #ifdef FILERL\r
142         free(bakapee);\r
143         if(baka) printf("\nyay!\n");\r
144         else printf("\npoo!\n");\r
145 #endif\r
146         printf("========================================\n");\r
147         printf("near=   %Fp ", gvar.mm.nearheap);\r
148         printf("far=    %Fp", gvar.mm.farheap);\r
149         printf("\n");\r
150         printf("&near=  %Fp ", &(gvar.mm.nearheap));\r
151         printf("&far=   %Fp", &(gvar.mm.farheap));\r
152         printf("\n");\r
153 #ifdef EXMMVERBOSE\r
154         printf("bigb=   %Fp ", bigbuffer);\r
155         //printf("bigbr=        %04x", bigbuffer);\r
156         //printf("\n");\r
157         printf("&bigb=%Fp ", &bigbuffer);\r
158         //printf("&bigb=%04x", &bigbuffer);\r
159         printf("\n");\r
160 #endif\r
161         printf("========================================\n");\r
162 #ifdef __WATCOMC__\r
163 //this is far   printf("Total free:                     %lu\n", (dword)(GetFreeSize()));\r
164         printf("Total near free:                %lu\n", (dword)(GetNearFreeSize()));\r
165         printf("Total far free:                 %lu\n", (dword)(GetFarFreeSize()));\r
166         heapdump(&gvar);\r
167         segatesuto();\r
168 #endif\r
169         printf("Project 16 emmtest.exe. This is just a test file!\n");\r
170         printf("version %s\n", VERSION);\r
171         //printf("core left:                    %lu\n", (dword)_coreleft());\r
172         //printf("far core left:                        %lu\n", (dword)_farcoreleft());\r
173         //printf("based core left:                      %lu\n", (dword)_basedcoreleft());\r
174         //printf("huge core left:                       %lu\n", (dword)_hugecoreleft());\r
175 }\r