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_dbg.h"
\r
39 //file load or read definition
\r
40 #define FILEREADLOAD
\r
42 //#define EXMMVERBOSE
\r
43 //#define BUFFDUMPPAUSE
\r
44 //#define EXMMVERBOSE__
\r
45 // #define PRINTBBDUMP
\r
50 #define KEYP IN_Shutdown(&gvar); printf("\n\npress any key to continue!\n"); getch(); IN_Startup(&gvar);
\r
52 #define BBUFNAME gvar.mm.bufferseg//bigbuffer
\r
53 //#define INITBBUF static memptr BBUFNAME;
\r
54 #define BBUFPTR MEMPTR BBUFNAME
\r
57 #define BBUF (memptr *)BBUFPTR
\r
58 #define BBUFSTRING (memptr *)BBUFNAME
\r
61 #define BBUF BBUFNAME
\r
62 #define BBUFSTRING BBUF
\r
65 ////////////////////////////////////////////////////////////////////////////
\r
67 void VGAmodeX(sword vq, boolean cmem, global_game_variables_t *gv)
\r
69 printf("VGAmodeX dummy:\n %Fp %Fp %Fp\n", &vq, &cmem, gv);
\r
73 //printf("* %Fp\t", *BBUF);
\r
74 //printf("* %04x\t", *BBUF);
\r
76 printf("-------------------------------------------------------------------------------\n");\
\r
77 printf("&main()= %Fp\n", argv[0]);\
\r
78 printf("buffer:\n");\
\r
79 printf(" %Fp\t", BBUF);\
\r
80 printf("&%Fp\n", BBUFPTR);\
\r
81 printf(" %04x\t", BBUF);\
\r
82 printf("& %04x\n", BBUFPTR);\
\r
83 printf("-------------------------------------------------------------------------------\n");\
\r
85 //printf("&main()= %Fp\n", *argv[0]);
\r
86 //printf("bigbuffer= %Fp\n", bigbuffer);
\r
87 //printf("&bigbuffer= %Fp\n", &bigbuffer);
\r
88 //printf("bigbuffer= %04x\n", bigbuffer);
\r
89 //printf("&bigbuffer= %04x\n", &bigbuffer);
\r
94 char __based( void ) * scrptr;
\r
98 printf( "Top left character is '%c'.\n", *(screen:>scrptr) );
\r
99 // printf("Next string is: [");
\r
100 // while(*scrptr<16)
\r
102 // printf("%c", *(screen:>scrptr));
\r
113 #ifdef __DEBUG_PM__
\r
114 dbg_debugpm=1; //debug pm
\r
117 #ifdef __DEBUG_CA__
\r
120 #ifdef __DEBUG_MM__
\r
124 //===========================================================================//
\r
126 //=======================================//
\r
130 //=======================================//
\r
132 main(int argc, char *argv[])
\r
139 static global_game_variables_t gvar;
\r
144 //#ifdef __WATCOMC__
\r
147 char bakapee1[64] = "data/koishi~.pcx";
\r
148 char bakapee2[64] = "data/test.map";
\r
151 #ifdef __BORLANDC__
\r
156 //0000PRINTBB; KEYP
\r
159 if(argv[1]){ strcpy(bakapee1, argv[1]);//bakapee1[] = *argv[1];
\r
160 if(argv[2]) strcpy(bakapee2, argv[2]); }//bakapee2[] = argv[2]; }
\r
163 //{ printf("filename!: "); scanf("%[^\n]", &bakapee); }
\r
164 strcpy(bakapee1, "data/koishi~.pcx"); //bakapee1 = "data/koishi~.pcx";
\r
165 strcpy(bakapee2, "data/test.map"); //bakapee2 = "data/test.map";
\r
168 printf("bakapee1[%s]\n", bakapee1);
\r
169 printf("bakapee2[%s]\n", bakapee2);
\r
174 // save the palette
\r
176 modexPalSave(&gvar.video.dpal); modexFadeOff(4, &gvar.video.dpal); //modexPalBlack();
\r
179 //printf("main()=%Fp start MM\n", *argv[0]);
\r
182 #ifdef __DEBUG_PM__
\r
185 #endif //__DEBUG_PM__
\r
186 PM_Startup(&gvar); PM_CheckMainMem(&gvar); PM_UnlockMainMem(&gvar);
\r
187 //0000printf("PM Started\n"); KEYP
\r
188 #ifdef __DEBUG_PM__
\r
190 #endif //__DEBUG_PM__
\r
192 #endif //elsed NOVID
\r
201 #ifdef FILEREADLOAD
\r
205 // printf("size of big buffer~=%u\n", _bmsize(segu, BBUF));
\r
208 printf("======================================read=====================================\n");
\r
209 if(CA_ReadFile(bakapee2, BBUFPTR, &gvar)) baka=1; else baka=0;
\r
210 printf("====================================read end===================================\n");
\r
215 printf("======================================load=====================================\n");
\r
216 if(CA_LoadFile(bakapee1, BBUFPTR, &gvar)) baka=1; else baka=0;
\r
217 printf("====================================load end===================================\n");
\r
219 //#ifdef __WATCOMC__
\r
220 // printf("\nsize of big buffer~=%u\n", _bmsize(sega, BBUF));
\r
223 printf("contents of the buffer\n[\n%s\n]\n", BBUFSTRING);
\r
229 //endif // BUFFDUMP
\r
231 //printf("dark purple = purgable\n");
\r
232 //printf("medium blue = non purgable\n");
\r
233 //printf("red = locked\n");
\r
235 // DebugMemory_(&gvar, 1);
\r
236 if(baka) printf("\nyay!\n");
\r
237 else printf("\npoo!\n");
\r
238 #ifdef BUFFDUMPPAUSE
\r
244 #endif //filereadload
\r
248 VGAmodeX(1, 0, &gvar);
\r
249 // modexPalUpdate0(&gvar.video.palette);
\r
250 // ShapeTest_(&gvar);
\r
252 for (done = false;!done;)
\r
254 while (!(scan = gvar.in.inst->LastScan))
\r
262 // MM_ShowMemory(&gvar);
\r
264 //#ifdef __WATCOMC__
\r
266 modexPalUpdate0(&gvar.video.palette); modexpdump(&gvar.video.page);
\r
269 modexpdump(&gvar.video.page[0]);
\r
272 VL_PatternDraw(&gvar.video, 0, 1, 1);
\r
281 VGAmodeX(0, 0, &gvar);
\r
284 // MM_ShowMemory(&gvar);
\r
285 DebugMemory_(&gvar, 1);
\r
286 MM_DumpData(&gvar);
\r
288 //printf("bakapee1=%s\n", bakapee1);
\r
289 //printf("bakapee2=%s\n", bakapee2);
\r
290 MM_FreePtr(BBUFPTR, &gvar);
\r
295 #ifdef __DEBUG_PM__
\r
297 #endif //__DEBUG_PM__
\r
298 PM_Shutdown(&gvar);
\r
300 CA_Shutdown(&gvar);
\r
301 MM_Shutdown(&gvar);
\r
303 IN_Shutdown(&gvar);
\r
304 printf("========================================\n");
\r
305 printf("near= %Fp ", gvar.mm.nearheap);
\r
306 printf("far= %Fp", gvar.mm.farheap);
\r
308 printf("&near= %Fp ", &(gvar.mm.nearheap));
\r
309 printf("&far= %Fp", &(gvar.mm.farheap));
\r
312 printf("bigb= %Fp ", BBUF);
\r
313 //printf("bigbr= %04x", BBUF);
\r
315 printf("&bigb=%Fp ", BBUFPTR);
\r
316 //printf("&bigb=%04x", BBUFPTR);
\r
319 printf("========================================\n");
\r
321 #ifdef EXMMVERBOSE__
\r
322 printf("coreleft(): %u\n", _memavl());
\r
323 printf("farcoreleft(): %lu\n", (dword)HC_farcoreleft());
\r
326 //this is far printf("Total free: %lu\n", (dword)(HC_GetFreeSize()));
\r
327 //super buggy printf("HC_coreleft(): %u\n", HC_coreleft());
\r
328 // printf("HC_farcoreleft(): %lu\n", (dword)HC_farcoreleft());
\r
329 //printf("HC_GetNearFreeSize(): %u\n", HC_GetNearFreeSize());
\r
330 //printf("HC_GetFarFreeSize(): %lu\n", (dword)HC_GetFarFreeSize());
\r
331 HC_heapdump(&gvar);
\r
334 /*#ifdef __BORLANDC__
\r
335 //printf("core left: %lu\n", (dword)HC_coreleft());
\r
336 //printf("far core left: %lu\n", (dword)HC_farcoreleft());
\r
337 // printf("\nfarcoreleft(): %lu\n", farcoreleft());
\r
339 printf("Project 16 ");
\r
341 printf("exmmtest");
\r
343 #ifdef __BORLANDC__
\r
346 printf(".exe. This is just a test file!\n");
\r
347 printf("version %s\n", VERSION);
\r
352 #if defined(__DEBUG__) && ( defined(__DEBUG_PM__) || defined(__DEBUG_MM__) )
\r
353 #ifdef __DEBUG_MM__
\r
354 printf("debugmm: %u\t", dbg_debugmm);
\r
356 #ifdef __DEBUG_PM__
\r
357 printf("debugpm: %u", dbg_debugpm);
\r
361 //printf("old_mode=%u VL_Started=%u", gvar.video.old_mode, gvar.video.VL_Started);
\r
362 //printf("based core left: %lu\n", (dword)_basedcoreleft());
\r
363 //printf("huge core left: %lu\n", (dword)_hugecoreleft());
\r