1 /* Project 16 Source Code~
\r
2 * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover
\r
4 * This file is part of Project 16.
\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
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
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
25 #include <malloc.h> // for _memavl()
\r
26 #include "src/lib/16_head.h"
\r
27 #include "src/lib/16_tail.h"
\r
28 #include "src/lib/16_pm.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/16_vl.h"
\r
33 #include "src/lib/16_dbg.h"
\r
40 //file load or read definition
\r
41 #define FILEREADLOAD
\r
43 //#define EXMMVERBOSE
\r
44 //#define BUFFDUMPPAUSE
\r
45 //#define EXMMVERBOSE__
\r
46 // #define PRINTBBDUMP
\r
49 #define BBUFNAME gvar.ca.tinf[0]//bigbuffer
\r
50 //#define INITBBUF static memptr BBUFNAME;
\r
51 #define BBUFPTR (memptr *)&BBUFNAME
\r
54 #define BBUF (memptr *)BBUFPTR//
\r
55 #define BBUFSTRING (memptr *)BBUFNAME
\r
58 #define BBUF BBUFNAME
\r
59 #define BBUFSTRING BBUF
\r
62 ////////////////////////////////////////////////////////////////////////////
\r
64 void VGAmodeX(sword vq, boolean cmem, global_game_variables_t *gv)
\r
66 printf("VGAmodeX dummy:\n %Fp %Fp %Fp\n", &vq, &cmem, gv);
\r
69 //printf("* %Fp\t", *BBUF);
\r
70 //printf("* %04x\t", *BBUF);
\r
72 printf("-------------------------------------------------------------------------------\n");\
\r
73 printf("&main()= %Fp\n", argv[0]);\
\r
74 printf("buffer:\n");\
\r
75 printf(" %Fp\t", BBUF);\
\r
76 printf("&%Fp\n", BBUFPTR);\
\r
77 printf(" %04x\t", BBUF);\
\r
78 printf("& %04x\n", BBUFPTR);\
\r
79 printf("-------------------------------------------------------------------------------\n");\
\r
81 //printf("&main()= %Fp\n", *argv[0]);
\r
82 //printf("bigbuffer= %Fp\n", bigbuffer);
\r
83 //printf("&bigbuffer= %Fp\n", &bigbuffer);
\r
84 //printf("bigbuffer= %04x\n", bigbuffer);
\r
85 //printf("&bigbuffer= %04x\n", &bigbuffer);
\r
90 char __based( void ) * scrptr;
\r
94 printf( "Top left character is '%c'.\n", *(screen:>scrptr) );
\r
95 // printf("Next string is: [");
\r
96 // while(*scrptr<16)
\r
98 // printf("%c", *(screen:>scrptr));
\r
104 // printf("press any key to continue!\n");
\r
110 main(int argc, char *argv[])
\r
113 static global_game_variables_t gvar;
\r
117 //#ifdef __WATCOMC__
\r
120 //static byte bakapee[64];
\r
121 char *bakapee1, *bakapee2;
\r
124 #ifdef __BORLANDC__
\r
128 bakapee1 = malloc(24);
\r
129 bakapee2 = malloc(24);
\r
133 #ifdef __DEBUG_PM__
\r
134 dbg_debugpm=1; //debug pm
\r
138 #ifdef __DEBUG_CA__
\r
142 //0000PRINTBB; printf("press any key to continue!\n"); getch();
\r
144 if(argv[1]){ bakapee1 = argv[1];
\r
145 if(argv[2]) bakapee2 = argv[2]; }
\r
147 //{ printf("filename!: "); scanf("%[^\n]", &bakapee); }
\r
148 bakapee1 = "data/koishi~.pcx";
\r
149 bakapee2 = "data/test.map";
\r
151 //printf("main()=%Fp start MM\n", *argv[0]);
\r
152 MM_Startup(&gvar); //printf("ok\n");
\r
154 #ifdef __DEBUG_PM__
\r
158 PM_Startup(&gvar); PM_CheckMainMem(&gvar); PM_UnlockMainMem(&gvar);
\r
159 //0000 printf("PM Started\n"); printf("press any key to continue!\n"); getch();
\r
160 #ifdef __DEBUG_PM__
\r
165 #ifdef __DEBUG_MM__
\r
169 // printf(" done!\n");
\r
172 PRINTBB; printf("\n\npress any key to continue!\n"); getch();
\r
174 #ifdef __DEBUG_MM__
\r
179 #ifdef FILEREADLOAD
\r
183 // printf("size of big buffer~=%u\n", _bmsize(segu, BBUF));
\r
186 printf("======================================read=====================================\n");
\r
187 if(CA_ReadFile(bakapee2, BBUFPTR, &gvar)) baka=1; else baka=0;
\r
188 printf("====================================read end===================================\n");
\r
193 printf("======================================load=====================================\n");
\r
194 if(CA_LoadFile(bakapee1, BBUFPTR, &gvar)) baka=1; else baka=0;
\r
195 printf("====================================load end===================================\n");
\r
197 //#ifdef __WATCOMC__
\r
198 // printf("\nsize of big buffer~=%u\n", _bmsize(sega, BBUF));
\r
201 printf("contents of the buffer\n[\n%s\n]\n", BBUFSTRING);
\r
206 //endif // BUFFDUMP
\r
208 //printf("dark purple = purgable\n");
\r
209 //printf("medium blue = non purgable\n");
\r
210 //printf("red = locked\n");
\r
211 // printf("press any key to continue!\n");
\r
212 // DebugMemory_(&gvar, 1);
\r
213 if(baka) printf("\nyay!\n");
\r
214 else printf("\npoo!\n");
\r
215 #ifdef BUFFDUMPPAUSE
\r
216 printf("press any key to continue!\n"); getch();
\r
221 #ifndef BUFFDUMPPAUSE
\r
222 printf("press any key to continue!\n"); getch();
\r
224 #endif //filereadload
\r
230 IN_Shutdown(&gvar);
\r
234 DebugMemory_(&gvar, 1);
\r
235 MM_DumpData(&gvar);
\r
237 //printf("bakapee1=%s\n", bakapee1);
\r
238 //printf("bakapee2=%s\n", bakapee2);
\r
239 MM_FreePtr(BBUFPTR, &gvar);
\r
241 #ifdef __DEBUG_PM__
\r
244 PM_Shutdown(&gvar);
\r
246 CA_Shutdown(&gvar);
\r
247 MM_Shutdown(&gvar);
\r
248 free(bakapee1); free(bakapee2);
\r
249 printf("========================================\n");
\r
250 printf("near= %Fp ", gvar.mm.nearheap);
\r
251 printf("far= %Fp", gvar.mm.farheap);
\r
253 printf("&near= %Fp ", &(gvar.mm.nearheap));
\r
254 printf("&far= %Fp", &(gvar.mm.farheap));
\r
257 printf("bigb= %Fp ", BBUF);
\r
258 //printf("bigbr= %04x", BBUF);
\r
260 printf("&bigb=%Fp ", BBUFPTR);
\r
261 //printf("&bigb=%04x", BBUFPTR);
\r
264 printf("========================================\n");
\r
266 #ifdef EXMMVERBOSE__
\r
267 printf("coreleft(): %u\n", _memavl());
\r
268 printf("farcoreleft(): %lu\n", (dword)HC_farcoreleft());
\r
271 //this is far printf("Total free: %lu\n", (dword)(HC_GetFreeSize()));
\r
272 //super buggy printf("HC_coreleft(): %u\n", HC_coreleft());
\r
273 // printf("HC_farcoreleft(): %lu\n", (dword)HC_farcoreleft());
\r
274 //printf("HC_GetNearFreeSize(): %u\n", HC_GetNearFreeSize());
\r
275 //printf("HC_GetFarFreeSize(): %lu\n", (dword)HC_GetFarFreeSize());
\r
276 HC_heapdump(&gvar);
\r
279 /*#ifdef __BORLANDC__
\r
280 //printf("core left: %lu\n", (dword)HC_coreleft());
\r
281 //printf("far core left: %lu\n", (dword)HC_farcoreleft());
\r
282 // printf("\nfarcoreleft(): %lu\n", farcoreleft());
\r
284 printf("Project 16 ");
\r
286 printf("exmmtest");
\r
288 #ifdef __BORLANDC__
\r
291 printf(".exe. This is just a test file!\n");
\r
292 printf("version %s\n", VERSION);
\r
293 #if defined(__DEBUG__) && ( defined(__DEBUG_PM__) || defined(__DEBUG_MM__) )
\r
294 #ifdef __DEBUG_MM__
\r
295 printf("debugmm: %u\t", dbg_debugmm);
\r
297 #ifdef __DEBUG_PM__
\r
298 printf("debugpm: %u", dbg_debugpm);
\r
302 //printf("based core left: %lu\n", (dword)_basedcoreleft());
\r
303 //printf("huge core left: %lu\n", (dword)_hugecoreleft());
\r