From: sparky4 Date: Tue, 22 Nov 2022 20:24:16 +0000 (-0600) Subject: added a simpler mmtest.c X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=f775e732b835acb83e1184674be25a861670dd9e;p=16.git added a simpler mmtest.c --- diff --git a/makefile b/makefile index b7c3b5c5..6159b234 100755 --- a/makefile +++ b/makefile @@ -199,6 +199,7 @@ TESTEXEC = & vidtest.exe & paltest.exe & exmmtest.exe & + mmtest.exe & vgmtest.exe & sountest.exe & imfplay.exe & @@ -311,6 +312,7 @@ pcxtest2.exe: pcxtest2.$(OBJ) gfx.lib $(DOSLIB) $(16LIB) maptest.exe: maptest.$(OBJ) 16_map.$(OBJ) 16_head.$(OBJ) gfx.lib $(DOSLIB) $(16LIB) fmemtest.exe: fmemtest.$(OBJ) exmmtest.exe: exmmtest.$(OBJ) $(16LIB) gfx.lib $(DOSLIB) +mmtest.exe: mmtest.$(OBJ) $(16LIB) gfx.lib $(DOSLIB) #16_pm.$(OBJ) 16_head.$(OBJ) 16_ca.$(OBJ) 16_mm.$(OBJ) 16_hc.$(OBJ) kitten.$(OBJ) 16_vl_1.$(OBJ) 16_tail.$(OBJ) 16_in.$(OBJ) 16_dbg.$(OBJ) vgmtest.exe: vgmtest.$(OBJ) vgmsnd.lib $(16LIB) $(DOSLIB) gfx.lib @@ -355,6 +357,7 @@ vrldbg.$(OBJ): $(SRC)/vrldbg.c #testemm0.$(OBJ): $(SRC)/testemm0.c #tsthimem.$(OBJ): $(SRC)/tsthimem.c exmmtest.$(OBJ): $(SRC)/exmmtest.c +mmtest.$(OBJ): $(SRC)/mmtest.c vgmtest.$(OBJ): $(SRC)/vgmtest.c db.$(OBJ): $(UTIL)/db.c ps.$(OBJ): $(SRC)/ps.c diff --git a/src/mmtest.c b/src/mmtest.c new file mode 100755 index 00000000..49f9d169 --- /dev/null +++ b/src/mmtest.c @@ -0,0 +1,223 @@ +/* Project 16 Source Code~ + * Copyright (C) 2012-2022 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. + * + */ +/* + simple mm test +*/ +#include "src/exmmtest.h" + +//////////////////////////////////////////////////////////////////////////// + +#ifdef BBUFNAME +#undef BBUFNAME +#endif +#define BBUFNAME bufferseg + +#ifdef SCROLLLOAD +#define FILENAME_1 "data/spri/chikyuu.vrs" +#define FILENAME_2 "data/test.map" +#else +#define FILENAME_1 "data/spri/chikyuu.sht" +#define FILENAME_2 "data/test.map" +#endif + +//===========================================================================// + +//=======================================// + +// main + +//=======================================// +void +main(int argc, char *argv[]) +{ + static global_game_variables_t gvar; + static memptr BBUFNAME; + + char bakapee1[64] = FILENAME_1; + char bakapee2[64] = FILENAME_2; + + #ifdef __BORLANDC__ + argc=argc; + #endif + +#ifdef __16_PM__ +#ifdef __DEBUG_PM__ + dbg_debugpm=1; //debug pm +#endif +#endif +#ifdef __DEBUG_CA__ + dbg_debugca=1; +#endif +#ifdef __DEBUG_MM__ + dbg_debugmm=1; +#endif + + if(argv[1]){ strcpy(bakapee1, argv[1]);//bakapee1[] = *argv[1]; + if(argv[2]) strcpy(bakapee2, argv[2]); }//bakapee2[] = argv[2]; } + + printf("bakapee1[%s]\n", bakapee1); + printf("bakapee2[%s]\n", bakapee2); + #ifdef EXMMVERBOSE__ + printf("coreleft(): %u\n", coreleft()); + printf("farcoreleft(): %ld\n", farcoreleft()); + #endif + printf("stackavail()=%u\n", stackavail()); + KEYP + + StartupCAMMPM(&gvar); + #ifdef PRINTBBDUMP + //0000 +PRINTBB; KEYP + #endif + + IN_Default(0,&gvar.player[0],ctrl_Keyboard1, &gvar); + IN_SetControlType(&gvar.player[0],ctrl_Keyboard1); + + { + byte w; word baka; + w=0; + #ifdef FILEREADLOAD + #ifdef FILEREAD + for(;w<2;w++) + { + // printf("size of big buffer~=%u\n", _bmsize(segu, BBUF)); + if(w>0) + { + printf("======================================read=====================================\n"); + if(CA_ReadFile(bakapee2, BBUFPTR, &gvar)) baka=1; else baka=0; + printf("====================================read end===================================\n"); + } + #endif //FILEREAD + if(w==0) + { + printf("======================================load=====================================\n"); + if(CA_LoadFile(bakapee1, BBUFPTR, &gvar)) baka=1; else baka=0; + printf("====================================load end===================================\n"); + } + #ifdef BUFFDUMP + { + size_t file_s; + FILE *fh; + + if(!w) fh = fopen(bakapee1, "r"); + else fh = fopen(bakapee2, "r"); + file_s = filesize(fh); + fclose(fh); + printf("contents of the buffer\n[\n%.*s\n]\n", file_s, BBUFSTRING); +#if 0 +//0000 +// mmblocktype far *scan; +// scan = gvar.mm.mmhead; +// while (scan->useptr != &BBUFNAME && scan) +// { +// scan = scan->next; +// } +// printf("\n %Fp %Fp\n", scan->useptr, &BBUFNAME); + printf("\nstrlen of buffer = %zu\n", strlen(BBUFSTRING)); + printf("length of buffer = %zu\n", file_s); +// printf("length of buffer = %lu\n", scan->length); +#endif + } + #endif + #ifdef PRINTBBDUMP + PRINTBB; + #endif + + //printf("dark purple = purgable\n"); + //printf("medium blue = non purgable\n"); + //printf("red = locked\n"); + // KEYP + // DebugMemory_(&gvar, 1); + if(baka) printf("\nyay!\n"); + else printf("\npoo!\n"); + #ifdef BUFFDUMPPAUSE + KEYP + #endif + #ifdef FILEREAD + } + #endif + #endif //filereadload + } + +//0000++++ + MM_ShowMemory(&gvar); + + DebugMemory_(&gvar, 1); + MM_DumpData(&gvar); + KEYP + MM_Report_(&gvar); + //printf("bakapee1=%s\n", bakapee1); + //printf("bakapee2=%s\n", bakapee2); + MM_FreePtr(BBUFPTR, &gvar); + ShutdownCAMMPM(&gvar); + IN_Shutdown(&gvar); + 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 ", BBUF); + //printf("bigbr= %04x", BBUF); + //printf("\n"); + printf("&bigb=%Fp ", BBUFPTR); + //printf("&bigb=%04x", BBUFPTR); + printf("\n"); + #endif + printf("========================================\n"); + + #ifdef EXMMVERBOSE__ + printf("coreleft(): %u\n", coreleft()); + printf("farcoreleft(): %ld\n", farcoreleft()); + #endif + + HC_heapdump(&gvar); + printf("Project 16 "); +#ifdef __WATCOMC__ + printf("mmtest"); +#endif +#ifdef __BORLANDC__ + printf("bcmm"); +#endif + printf(".exe. This is just a test file!\n"); + printf("version %s\n", VERSION); + +//end of program + + +#if defined(__DEBUG__) && ( defined(__DEBUG_PM__) || defined(__DEBUG_MM__) ) +#ifdef __DEBUG_MM__ + printf("debugmm: %u\t", dbg_debugmm); +#endif +#ifdef __DEBUG_PM__ + printf("debugpm: %u", dbg_debugpm); +#endif + printf("\n"); +#endif +// printf("curr_mode=%u\n", gvar.video.curr_mode); +// VL_PrintmodexmemInfo(&gvar.video); + //printf("old_mode=%u VL_Started=%u", gvar.video.old_mode, gvar.video.VL_Started); + //printf("based core left: %lu\n", (dword)_basedcoreleft()); + //printf("huge core left: %lu\n", (dword)_hugecoreleft()); +}