]> 4ch.mooo.com Git - 16.git/blob - src/exmmtest.c
THE STACK IS FUCKING UP EVERYTHING! WWWW
[16.git] / src / exmmtest.c
1 /* Project 16 Source Code~\r
2  * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669\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/modex16.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 FILERL\r
39 //#define FILEREAD\r
40 \r
41 void\r
42 main(int argc, char *argv[])\r
43 {\r
44         mminfo_t mm; mminfotype mmi;\r
45         __segment sega;\r
46         void __based(sega)* bigbuffer;\r
47 #ifdef FILERL\r
48         char *bakapee;\r
49         word baka;\r
50 #endif\r
51         //static page_t screen;\r
52 \r
53         printf("&main()=        %Fp\n", *argv[0]);\r
54         printf("bigbuffer=      %Fp\n", bigbuffer);\r
55         printf("&bigbuffer=     %Fp\n", &bigbuffer);\r
56         printf("bigbuffer=      %04x\n", bigbuffer);\r
57         printf("&bigbuffer=     %04x\n", &bigbuffer);\r
58 \r
59 #ifdef FILERL\r
60         bakapee = malloc(64);\r
61 #endif\r
62         mm.mmstarted=0;\r
63 \r
64 #ifdef FILERL\r
65         if(argv[1]) bakapee = argv[1];\r
66         else bakapee = "data/koishi~.pcx";\r
67 #endif\r
68 \r
69         textInit();\r
70 \r
71         /* setup camera and screen~ */\r
72         //bug!!!\r
73         //screen = modexDefaultPage();\r
74         /*screen.width += (16*2);\r
75         screen.height += (16*2);*/\r
76 \r
77         printf("main()=%Fp      start MM\n", *argv[0]);\r
78         MM_Startup(&mm, &mmi);\r
79         //PM_Startup();\r
80         //PM_UnlockMainMem();\r
81         CA_Startup();\r
82         printf("                done!\n");\r
83         printf("&main()=        %Fp\n", *argv[0]);\r
84         printf("bigbuffer=      %Fp\n", bigbuffer);\r
85         printf("&bigbuffer=     %Fp\n", &bigbuffer);\r
86         printf("bigbuffer=      %04x\n", bigbuffer);\r
87         printf("&bigbuffer=     %04x\n", &bigbuffer);\r
88         getch();\r
89 #ifdef FILERL\r
90 //      bakapeehandle = open(bakapee,O_RDONLY | O_BINARY, S_IREAD);\r
91 //      printf("size of big buffer~=%u\n", _bmsize(segu, bigbuffer));\r
92 //      if(CA_FarRead(bakapeehandle,(void far *)&bigbuffer,sizeof(bigbuffer),&mm))\r
93 #ifdef FILEREAD\r
94         printf("                read\n");\r
95         if(CA_ReadFile(bakapee, &bigbuffer, &mm))\r
96 #else\r
97         printf("                load\n");\r
98         if(CA_LoadFile(bakapee, &bigbuffer, &mm, &mmi))\r
99 #endif\r
100                 baka=1;\r
101         else\r
102                 baka=0;\r
103 //      close(bakapeehandle);\r
104         //hmm functions in cache system use the buffered stuff\r
105         printf("size of big buffer~=%u\n", _bmsize(sega, bigbuffer));\r
106 #endif\r
107         printf("dark purple = purgable\n");\r
108         printf("medium blue = non purgable\n");\r
109         printf("red = locked\n");\r
110         getch();\r
111         //++++modexEnter();\r
112         //++++modexShowPage(&screen);\r
113         MM_ShowMemory(/*&screen, */&mm);\r
114         //getch();\r
115         MM_DumpData(&mm);\r
116         //++++modexLeave();\r
117         MM_Report(&mm, &mmi);\r
118         printf("                stop!\n");\r
119 #ifdef FILERL\r
120         MM_FreePtr(&bigbuffer, &mm);\r
121 #endif\r
122         //PM_Shutdown();\r
123         CA_Shutdown();\r
124         MM_Shutdown(&mm);\r
125         printf("                done!\n");\r
126 #ifdef FILERL\r
127         free(bakapee);\r
128         if(baka) printf("\nyay!\n");\r
129         else printf("\npoo!\n");\r
130 #endif\r
131         printf("bigbuffer=      %Fp\n", bigbuffer);\r
132         printf("&bigbuffer=     %Fp\n", &bigbuffer);\r
133         printf("bigbuffer=      %04x\n", bigbuffer);\r
134         printf("&bigbuffer=     %04x\n", &bigbuffer);\r
135         printf("\n\n");\r
136         printf("Total free:                     %lu\n", (dword)(GetFreeSize()));\r
137         printf("Total near free:                %lu\n", (dword)(GetNearFreeSize()));\r
138         printf("Total far free:                 %lu\n", (dword)(GetFarFreeSize()));\r
139         getch();\r
140         printf("\n");\r
141         heapdump();\r
142         printf("core left:                      %lu\n", (dword)_coreleft());\r
143         printf("far core left:                  %lu\n", (dword)_farcoreleft());\r
144         //printf("based core left:                      %lu\n", (dword)_basedcoreleft());\r
145         //printf("huge core left:                       %lu\n", (dword)_hugecoreleft());\r
146 }\r