]> 4ch.mooo.com Git - 16.git/blob - src/exmmtest.c
not going to work on it until wednesday
[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 //#ifdef __WATCOMC__\r
28 #include "src/lib/16_pm.h"\r
29 //#endif\r
30 #include "src/lib/16_ca.h"\r
31 #include "src/lib/16_mm.h"\r
32 #include "src/lib/16_hc.h"\r
33 //#include "src/lib/16_vl.h"\r
34 #pragma hdrstop\r
35 \r
36 #pragma warn -pro\r
37 #pragma warn -use\r
38 \r
39 //file load or read definition\r
40 #define FILEREAD\r
41 //#define EXMMVERBOSE\r
42 \r
43 void VGAmodeX(sword vq, boolean cmem, global_game_variables_t *gv)\r
44 {\r
45         printf("VGAmodeX dummy:\n       %Fp     %Fp     %Fp\n", &vq, &cmem, gv);\r
46 }\r
47 #define PRINTBB { printf("&main()=      %Fp\n", argv[0]);printf("gvar.ca.tinf[0]=       %Fp\n", gvar.ca.tinf[0]);printf("&gvar.ca.tinf[0]=      %Fp\n", &gvar.ca.tinf[0]);printf("gvar.ca.tinf[0]=      %04x\n", gvar.ca.tinf[0]);printf("&gvar.ca.tinf[0]=     %04x\n", &gvar.ca.tinf[0]); }\r
48 \r
49 #ifdef __WATCOMC__\r
50 void segatesuto()\r
51 {\r
52         __segment screen;\r
53         char __based( void ) * scrptr;\r
54 \r
55         screen = 0xB800;\r
56         scrptr = 0;\r
57         printf( "Top left character is '%c'.\n", *(screen:>scrptr) );\r
58 //      printf("Next string is: [");\r
59 //      while(*scrptr<16)\r
60 //      {\r
61 //              printf("%c", *(screen:>scrptr));\r
62 //              //printf("\b");\r
63 //              scrptr++;\r
64 //\r
65 //      }\r
66 //      printf("]\n");\r
67 //      printf("press any key to continue!\n");\r
68 //      getch();\r
69 }\r
70 #endif\r
71 //static global_game_variables_t gvar;\r
72 \r
73 void\r
74 main(int argc, char *argv[])\r
75 {\r
76         byte w=1;\r
77         static global_game_variables_t gvar;\r
78 //#ifdef __WATCOMC__\r
79 //      __segment sega;\r
80 //#endif\r
81         //static byte bakapee[64];\r
82         char *bakapee1, *bakapee2;\r
83         word baka;\r
84 \r
85 #ifdef __BORLANDC__\r
86         argc=argc;\r
87 #endif\r
88         //file name //\r
89         bakapee1 = malloc(64);\r
90         bakapee2 = malloc(64);\r
91         //file name //\r
92 \r
93 //#ifdef __WATCOMC__\r
94 #ifdef __DEBUG_PM__\r
95         dbg_debugpm=1;  //debug pm\r
96 #endif\r
97 //#endif\r
98 \r
99         //PRINTBB\r
100         if(argv[1]){ bakapee1 = argv[1];\r
101         if(argv[2]) bakapee2 = argv[2]; }\r
102         else{\r
103         //{ printf("filename!: "); scanf("%[^\n]", &bakapee); }\r
104                 bakapee1 = "data/koishi~.pcx";\r
105                 bakapee2 = "data/test.map";\r
106         }\r
107         //printf("main()=%Fp    start MM\n", *argv[0]);\r
108         MM_Startup(&gvar);\r
109         //printf("ok\n");\r
110 //#ifdef __WATCOMC__\r
111 #ifdef __DEBUG_PM__\r
112         if(dbg_debugpm>0)\r
113         {\r
114 #endif\r
115                 PM_Startup(&gvar); PM_CheckMainMem(&gvar); 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, gvar.ca.tinf[0]));\r
130 //      if(CA_FarRead(bakapeehandle,(void far *)&gvar.ca.tinf[0],sizeof(gvar.ca.tinf[0]),&gvar.mm))\r
131         if(w>0)\r
132         {\r
133                 printf("                read\n");\r
134                 if(CA_ReadFile(bakapee2, &gvar.ca.tinf[0], &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, &gvar.ca.tinf[0], &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, gvar.ca.tinf[0]));\r
146 //#endif\r
147 \r
148         printf("contents of the buffer\n[\n%s\n]\n", gvar.ca.tinf[0]);\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(&gvar.ca.tinf[0], &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 ", gvar.ca.tinf[0]);\r
185         //printf("bigbr=        %04x", gvar.ca.tinf[0]);\r
186         //printf("\n");\r
187         printf("&bigb=%Fp ", &gvar.ca.tinf[0]);\r
188         //printf("&bigb=%04x", &gvar.ca.tinf[0]);\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("\n");\r
202         //printf("core left:                    %lu\n", (dword)_coreleft());\r
203         //printf("far core left:                        %lu\n", (dword)_farcoreleft());\r
204         //printf("based core left:                      %lu\n", (dword)_basedcoreleft());\r
205         //printf("huge core left:                       %lu\n", (dword)_hugecoreleft());\r
206 }\r