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