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