X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Fexmmtest.c;h=b57a6f055b23357c71ca68b072ca702a11d6fb9c;hb=5a54933b41f0bcd3653a5da5fc37cc72a08448a3;hp=8cd440f558bc2a19146c380cd7f806983c662aac;hpb=9ffe77d9a59bd77df9ab71eb98e82c97a1fa6076;p=16.git diff --git a/src/exmmtest.c b/src/exmmtest.c old mode 100644 new mode 100755 index 8cd440f5..b57a6f05 --- a/src/exmmtest.c +++ b/src/exmmtest.c @@ -1,77 +1,190 @@ -/* Project 16 Source Code~ - * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669 - * - * This file is part of Project 16. - * - * Project 16 is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Project 16 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see , or - * write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301 USA. - * - */ -/* - input test -*/ -#include "src/lib/16_ca.h" -#include "src/lib/16_mm.h" -#include "src/lib/modex16.h" - -void -main(int argc, char *argv[]) -{ - mminfo_t mm; mminfotype mmi; - memptr bigbuffer; - __segment segu; - char *bakapee; - word baka; - page_t screen; - - bakapee = malloc(64); -// memset(bakapee, 0, 64); - mm.mmstarted=0; - - if(argv[1]) bakapee = argv[1]; - else bakapee = "data/koishi~~.pcx"; - - textInit(); - - /* setup camera and screen~ */ - screen = modexDefaultPage(); - screen.width += (16*2); - screen.height += (16*2); - - printf("start!\n"); - MM_Startup(&mm, &mmi); - printf("done!\n"); - printf("&main()=%Fp\n", *argv[0]); - if(CA_LoadFile(bakapee, &bigbuffer, &mm, &mmi)) baka=1; - else - baka=0; - //MM_GetPtr(&bigbuffer, mmi.nearheap, &mm, &mmi); - //hmm functions in cache system use the buffered stuff - printf("size of big buffer~=%u\n", _bmsize(segu, bigbuffer)); - getch(); - modexEnter(); - MM_ShowMemory(&screen, &mm); - getch(); - MM_Report(&screen, &mm, &mmi); - modexLeave(); - printf("stop!\n"); - MM_FreePtr(&bigbuffer, &mm); - MM_Shutdown(&mm); - printf("done!\n"); - free(bakapee); - //printf("_bios_memsize=%u\n", _bios_memsize()); - if(baka) printf("\nyay!\n"); - else printf("\npoo!\n"); -} +/* Project 16 Source Code~ + * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover + * + * This file is part of Project 16. + * + * Project 16 is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Project 16 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see , or + * write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301 USA. + * + */ +/* + exmm test +*/ +#include "src/lib/16_head.h" +#include "src/lib/16_pm.h" +#include "src/lib/16_ca.h" +#include "src/lib/16_mm.h" +#include "src/lib/16_hc.h" +#include "src/lib/16_lib.h" +//#include "src/lib/modex16.h" +#pragma hdrstop + +#pragma warn -pro +#pragma warn -use + +//file load or read definition +#define FILEREAD +//#define EXMMVERBOSE + +#define PRINTBB { printf("&main()= %Fp\n", argv[0]);printf("bigbuffer= %Fp\n", bigbuffer);printf("&bigbuffer= %Fp\n", &bigbuffer);printf("bigbuffer= %04x\n", bigbuffer);printf("&bigbuffer= %04x\n", &bigbuffer); } + +#ifdef __WATCOMC__ +void segatesuto() +{ + __segment screen; + char __based( void ) * scrptr; + + screen = 0xB800; + scrptr = 0; + printf( "Top left character is '%c'.\n", *(screen:>scrptr) ); +// printf("Next string is: ["); +// while(*scrptr<16) +// { +// printf("%c", *(screen:>scrptr)); +// //printf("\b"); +// scrptr++; +// +// } +// printf("]\n"); +// printf("press any key to continue!\n"); +// getch(); +} +#endif + +void +main(int argc, char *argv[]) +{ + byte w=1; + static global_game_variables_t gvar; +#ifdef __WATCOMC__ + __segment sega; +#endif + memptr bigbuffer; + + //static byte bakapee[64]; + char *bakapee1, *bakapee2; + word baka; + +#ifdef __BORLANDC__ + argc=argc; +#endif + //file name // + bakapee1 = malloc(64); + bakapee2 = malloc(64); + //file name // + + gvar.mm.mmstarted=0; + debugpm=1; //debug pm + + //PRINTBB + if(argv[1]){ bakapee1 = argv[1]; + if(argv[2]) bakapee2 = argv[2]; } + else{ + //{ printf("filename!: "); scanf("%[^\n]", &bakapee); } + bakapee1 = "data/koishi~.pcx"; + bakapee2 = "data/test.map"; + } + printf("main()=%Fp start MM\n", *argv[0]); + MM_Startup(&gvar); + printf("ok\n"); + if(debugpm>0) + { + PM_Startup(&gvar); + printf("pmstarted ok\n"); + //PM_CheckMainMem(&gvar); + PM_UnlockMainMem(&gvar); + } + CA_Startup(&gvar); +// printf(" done!\n"); + PRINTBB; +// printf("press any key to continue!\n"); +// getch(); +#ifdef FILEREAD +for(w=0;w<2;w++) +{ +// bakapeehandle = open(bakapee,O_RDONLY | O_BINARY, S_IREAD); +// printf("size of big buffer~=%u\n", _bmsize(segu, bigbuffer)); +// if(CA_FarRead(bakapeehandle,(void far *)&bigbuffer,sizeof(bigbuffer),&gvar.mm)) + if(w>0) + { + printf(" read\n"); + if(CA_ReadFile(bakapee2, &bigbuffer, &gvar)) baka=1; else baka=0; + } +#endif + if(w==0) + { + printf(" load\n"); + if(CA_LoadFile(bakapee1, &bigbuffer, &gvar)) baka=1; else baka=0; + } +// close(bakapeehandle); + //hmm functions in cache system use the buffered stuff +#ifdef __WATCOMC__ + printf("\nsize of big buffer~=%u\n", _bmsize(sega, bigbuffer)); +#endif + + printf("contents of the buffer\n[\n%s\n]\n", bigbuffer); + //printf("dark purple = purgable\n"); + //printf("medium blue = non purgable\n"); + //printf("red = locked\n"); + printf("press any key to continue!\n"); + getch(); + MM_ShowMemory(&gvar); + MM_DumpData(&gvar); + MM_Report_(&gvar); + if(baka) printf("\nyay!\n"); + else printf("\npoo!\n"); + printf("press any key to continue!\n"); + getch(); +#ifdef FILEREAD +} +#endif + printf("bakapee1=%s\n", bakapee1); + printf("bakapee2=%s\n", bakapee2); + MM_FreePtr(&bigbuffer, &gvar); + if(debugpm>0) + PM_Shutdown(&gvar); + CA_Shutdown(&gvar); + MM_Shutdown(&gvar); + free(bakapee1); free(bakapee2); + printf("========================================\n"); + printf("near= %Fp ", gvar.mm.nearheap); + printf("far= %Fp", gvar.mm.farheap); + printf("\n"); + printf("&near= %Fp ", &(gvar.mm.nearheap)); + printf("&far= %Fp", &(gvar.mm.farheap)); + printf("\n"); +#ifdef EXMMVERBOSE + printf("bigb= %Fp ", bigbuffer); + //printf("bigbr= %04x", bigbuffer); + //printf("\n"); + printf("&bigb=%Fp ", &bigbuffer); + //printf("&bigb=%04x", &bigbuffer); + printf("\n"); +#endif + printf("========================================\n"); +#ifdef __WATCOMC__ +//this is far printf("Total free: %lu\n", (dword)(GetFreeSize())); + printf("Total near free: %lu\n", (dword)(GetNearFreeSize())); + printf("Total far free: %lu\n", (dword)(GetFarFreeSize())); + heapdump(&gvar); + segatesuto(); +#endif + printf("Project 16 emmtest.exe. This is just a test file!\n"); + printf("version %s\n", VERSION); + //printf("core left: %lu\n", (dword)_coreleft()); + //printf("far core left: %lu\n", (dword)_farcoreleft()); + //printf("based core left: %lu\n", (dword)_basedcoreleft()); + //printf("huge core left: %lu\n", (dword)_hugecoreleft()); +}