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 "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_dbg.h"
\r
38 //file load or read definition
\r
39 #define FILEREADLOAD
\r
41 //#define EXMMVERBOSE
\r
42 //#define BUFFDUMPPAUSE
\r
43 //#define EXMMVERBOSE__
\r
44 // #define PRINTBBDUMP
\r
52 //#define SCROLLLOAD
\r
56 #define KEYP IN_Shutdown(&gvar); printf("\n\npress any key to continue!\n"); getch(); IN_Startup(&gvar);
\r
58 #define BBUFNAME gvar.mm.bufferseg//bigbuffer
\r
59 //#define INITBBUF static memptr BBUFNAME;
\r
60 #define BBUFPTR MEMPTRCONV BBUFNAME
\r
63 #define BBUF (memptr *)BBUFPTR
\r
64 #define BBUFSTRING (memptr *)BBUFNAME
\r
67 #define BBUF BBUFNAME
\r
68 #define BBUFSTRING BBUF
\r
71 ////////////////////////////////////////////////////////////////////////////
\r
73 void VL_Startup (global_game_variables_t *gvar){ gvar=gvar; }
\r
74 void VL_Shutdown (global_game_variables_t *gvar){ gvar=gvar; }
\r
75 void VGAmodeX(sword vq, boolean cmem, global_game_variables_t *gv)
\r
77 printf("VGAmodeX dummy:\n %Fp %Fp %Fp\n", &vq, &cmem, gv);
\r
81 VL_modexPalOverscan(byte *p, word col)
\r
84 //modexWaitBorder();
\r
85 // vga_wait_for_vsync();
\r
86 outp(PAL_WRITE_REG, 0); /* start at the beginning of palette */
\r
87 for(i=col; i<(3+col); i++)
\r
89 outp(PAL_DATA_REG, p[i]);
\r
94 void TL_VidInit(global_game_variables_t *gvar)
\r
96 gvar->video.old_mode = 3;
\r
100 void VL_ShowPage(page_t *page, boolean vsync, boolean sr){}
\r
101 void modexClearRegion(page_t *page, int x, int y, int w, int h, byte color){}
\r
102 void modexprint(page_t *page, sword x, sword y, word t, boolean tlsw, word color, word bgcolor, boolean vidsw, const byte *str){ printf("%s\n", str); }
\r
103 void modexpdump(nibble pagenum, global_game_variables_t *gvar){}
\r
107 //printf("* %Fp\t", *BBUF);
\r
108 //printf("* %04x\t", *BBUF);
\r
110 printf("-------------------------------------------------------------------------------\n");\
\r
111 printf("&main()= %Fp\n", argv[0]);\
\r
112 printf("buffer:\n");\
\r
113 printf(" %Fp\t", BBUF);\
\r
114 printf("&%Fp\n", BBUFPTR);\
\r
115 printf(" %04x\t", BBUF);\
\r
116 printf("& %04x\n", BBUFPTR);\
\r
117 printf("-------------------------------------------------------------------------------\n");\
\r
119 //printf("&main()= %Fp\n", *argv[0]);
\r
120 //printf("bigbuffer= %Fp\n", bigbuffer);
\r
121 //printf("&bigbuffer= %Fp\n", &bigbuffer);
\r
122 //printf("bigbuffer= %04x\n", bigbuffer);
\r
123 //printf("&bigbuffer= %04x\n", &bigbuffer);
\r
128 char __based( void ) * scrptr;
\r
132 printf( "Top left character is '%c'.\n", *(screen:>scrptr) );
\r
133 // printf("Next string is: [");
\r
134 // while(*scrptr<16)
\r
136 // printf("%c", *(screen:>scrptr));
\r
147 #define FILENAME_1 "data/spri/chikyuu.vrs"
\r
148 #define FILENAME_2 "data/test.map"
\r
150 #define FILENAME_1 "data/koishi~.pcx"
\r
151 #define FILENAME_2 "data/test.map"
\r
154 //===========================================================================//
\r
156 //=======================================//
\r
160 //=======================================//
\r
162 main(int argc, char *argv[])
\r
164 static global_game_variables_t gvar;
\r
169 char bakapee1[64] = FILENAME_1;
\r
170 char bakapee2[64] = FILENAME_2;
\r
172 #ifdef __BORLANDC__
\r
177 //0000PRINTBB; KEYP
\r
180 #ifdef __DEBUG_PM__
\r
181 dbg_debugpm=1; //debug pm
\r
184 #ifdef __DEBUG_CA__
\r
187 #ifdef __DEBUG_MM__
\r
191 if(argv[1]){ strcpy(bakapee1, argv[1]);//bakapee1[] = *argv[1];
\r
192 if(argv[2]) strcpy(bakapee2, argv[2]); }//bakapee2[] = argv[2]; }
\r
194 printf("bakapee1[%s]\n", bakapee1);
\r
195 printf("bakapee2[%s]\n", bakapee2);
\r
196 #ifdef EXMMVERBOSE__
\r
197 printf("coreleft(): %u\n", coreleft());
\r
198 printf("farcoreleft(): %ld\n", farcoreleft());
\r
204 // save the palette
\r
205 modexPalSave(&gvar.video.dpal); //modexFadeOff(4, &gvar.video.dpal); //modexPalBlack();
\r
207 StartupCAMMPM(&gvar);
\r
208 #endif //elsed NOVID
\r
214 IN_Default(0,&gvar.player[0],ctrl_Keyboard1, &gvar);
\r
215 IN_SetControlType(&gvar.player[0],ctrl_Keyboard1);
\r
220 #ifdef FILEREADLOAD
\r
224 // printf("size of big buffer~=%u\n", _bmsize(segu, BBUF));
\r
227 printf("======================================read=====================================\n");
\r
228 if(CA_ReadFile(bakapee2, BBUFPTR, &gvar)) baka=1; else baka=0;
\r
229 printf("====================================read end===================================\n");
\r
234 printf("======================================load=====================================\n");
\r
235 if(CA_LoadFile(bakapee1, BBUFPTR, &gvar)) baka=1; else baka=0;
\r
236 printf("====================================load end===================================\n");
\r
239 printf("contents of the buffer\n[\n%s\n]\n", BBUFSTRING);
\r
245 //printf("dark purple = purgable\n");
\r
246 //printf("medium blue = non purgable\n");
\r
247 //printf("red = locked\n");
\r
249 // DebugMemory_(&gvar, 1);
\r
250 if(baka) printf("\nyay!\n");
\r
251 else printf("\npoo!\n");
\r
252 #ifdef BUFFDUMPPAUSE
\r
258 #endif //filereadload
\r
262 // #else //scrollload
\r
263 // CA_loadmap(bakapee2, &gvar.map, &gvar); //BREAKS!
\r
264 // newloadmap(bakapee2, &gvar.map);
\r
265 VRS_LoadVRS(bakapee1, &gvar.player[0].enti, &gvar);
\r
266 // HC_heapdump(&gvar);
\r
268 #endif //scrollload
\r
271 VL_Startup(&gvar);// VGAmodeX(8, 0, &gvar);
\r
272 modexHiganbanaPageSetup(&gvar);
\r
273 // VL_modexPalScramble(&gvar.video.palette);
\r
274 VL_LoadPalFileCore(&gvar.video.palette, &gvar);
\r
275 // ShapeTest_(&gvar);
\r
277 MM_ShowMemory(&gvar);
\r
282 for (done = false;!done;)
\r
284 while (!(scan = gvar.in.inst->LastScan))
\r
292 // MM_ShowMemory(&gvar);
\r
294 //#ifdef __WATCOMC__
\r
296 VL_modexPalScramble(&gvar.video.palette); modexpdump(&gvar.video.page);
\r
299 modexpdump(&gvar.video.page[0]);
\r
302 VL_PatternDraw(&gvar.video, 0, 1, 1);
\r
314 if(gvar.video.VL_Started)
\r
315 VL_Shutdown (&gvar);//VGAmodeX(0, 0, gvar);
\r
316 modexFadeOn(4, gvar.video.dpal);
\r
318 DebugMemory_(&gvar, 1);
\r
319 MM_DumpData(&gvar);
\r
322 //printf("bakapee1=%s\n", bakapee1);
\r
323 //printf("bakapee2=%s\n", bakapee2);
\r
324 MM_FreePtr(BBUFPTR, &gvar);
\r
328 ShutdownCAMMPM(&gvar);
\r
330 IN_Shutdown(&gvar);
\r
331 printf("========================================\n");
\r
332 printf("near= %Fp ", gvar.mm.nearheap);
\r
333 printf("far= %Fp", gvar.mm.farheap);
\r
335 printf("&near= %Fp ", &(gvar.mm.nearheap));
\r
336 printf("&far= %Fp", &(gvar.mm.farheap));
\r
339 printf("bigb= %Fp ", BBUF);
\r
340 //printf("bigbr= %04x", BBUF);
\r
342 printf("&bigb=%Fp ", BBUFPTR);
\r
343 //printf("&bigb=%04x", BBUFPTR);
\r
346 printf("========================================\n");
\r
348 #ifdef EXMMVERBOSE__
\r
349 printf("coreleft(): %u\n", coreleft());
\r
350 printf("farcoreleft(): %ld\n", farcoreleft());
\r
353 //this is far printf("Total free: %lu\n", (dword)(HC_GetFreeSize()));
\r
354 //super buggy printf("HC_coreleft(): %u\n", HC_coreleft());
\r
355 // printf("HC_farcoreleft(): %lu\n", (dword)HC_farcoreleft());
\r
356 //printf("HC_GetNearFreeSize(): %u\n", HC_GetNearFreeSize());
\r
357 //printf("HC_GetFarFreeSize(): %lu\n", (dword)HC_GetFarFreeSize());
\r
360 #ifdef __BORLANDC__
\r
361 // printf("HC_coreleft: %lu\n", (dword)HC_coreleft());
\r
362 // printf("HC_farcoreleft: %lu\n", (dword)HC_farcoreleft());
\r
363 // printf("HC_Newfarcoreleft(): %lu\n", (dword)HC_Newfarcoreleft());
\r
365 HC_heapdump(&gvar);
\r
366 printf("Project 16 ");
\r
368 printf("exmmtest");
\r
370 #ifdef __BORLANDC__
\r
373 printf(".exe. This is just a test file!\n");
\r
374 printf("version %s\n", VERSION);
\r
379 #if defined(__DEBUG__) && ( defined(__DEBUG_PM__) || defined(__DEBUG_MM__) )
\r
380 #ifdef __DEBUG_MM__
\r
381 printf("debugmm: %u\t", dbg_debugmm);
\r
383 #ifdef __DEBUG_PM__
\r
384 printf("debugpm: %u", dbg_debugpm);
\r
388 // printf("curr_mode=%u\n", gvar.video.curr_mode);
\r
389 // VL_PrintmodexmemInfo(&gvar.video);
\r
390 //printf("old_mode=%u VL_Started=%u", gvar.video.old_mode, gvar.video.VL_Started);
\r
391 //printf("based core left: %lu\n", (dword)_basedcoreleft());
\r
392 //printf("huge core left: %lu\n", (dword)_hugecoreleft());
\r