X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Fexmmtest.c;h=b97f7693699af7f466317de4769b32ffc52bd4c3;hb=3d7af30456302e0bf6accc07431e8210b3af052e;hp=ac19617b3c54157cd354dab178e514dab6cd4631;hpb=99fae0e9cff0b5609ca955a238ff22804c7fb2dc;p=16.git
diff --git a/src/exmmtest.c b/src/exmmtest.c
old mode 100644
new mode 100755
index ac19617b..b97f7693
--- a/src/exmmtest.c
+++ b/src/exmmtest.c
@@ -1,107 +1,355 @@
-/* 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"
-
-#define FILERL
-//#define FILEINIT
-
-void
-main(int argc, char *argv[])
-{
- static mminfo_t mm; mminfotype mmi;
- static memptr bigbuffer;
- static __segment segu;
- static char *bakapee;
- static word baka;
- page_t screen;
-
- printf("&main()=%Fp\n", *argv[0]);
-
- 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~ */
- //bug!!!
- /*screen = modexDefaultPage();
- screen.width += (16*2);
- screen.height += (16*2);*/
-
- printf("&main()=%Fp start MM\n", *argv[0]);
- MM_Startup(&mm, &mmi);
- printf(" done!\n");
- /*if(FP_SEG(*argv[0])==0)
- {
- MM_Report(&screen, &mm, &mmi);
- MM_Shutdown(&mm);
- printf("&main()=%Fp\n", *argv[0]);
- printf("&main() == %u\n", FP_SEG(*argv[0]));
- exit(-5);
- }*/
- printf("&main()=%Fp\n", *argv[0]);
-#ifdef FILERL
-#ifdef FILEINIT
- printf(" read\n");
- if(CA_ReadFile(bakapee, &bigbuffer, &mm/*, &mmi*/))
-#else
- printf(" load\n");
- if(CA_LoadFile(bakapee, &bigbuffer, &mm, &mmi))
-#endif
- baka=1;
- else
- baka=0;
-#endif
- //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));
- printf("dark purple = purgable\n");
- printf("medium blue = non purgable\n");
- printf("red = locked\n");
- getch();
- modexEnter();
- modexShowPage(&screen);
- MM_ShowMemory(&screen, &mm);
- getch();
- MM_DumpData(&mm);
- modexLeave();
- MM_Report(&screen, &mm, &mmi);
- printf(" stop!\n");
- MM_FreePtr(&bigbuffer, &mm);
- MM_Shutdown(&mm);
- printf(" done!\n");
-#ifdef FILERL
- free(bakapee);
- //printf("_bios_memsize=%u\n", _bios_memsize());
- if(baka) printf("\nyay!\n");
- else printf("\npoo!\n");
-#endif
-}
+/* Project 16 Source Code~
+ * Copyright (C) 2012-2017 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 // for _memavl()
+#include "src/lib/16_head.h"
+#include "src/lib/16_tail.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_vl.h"
+#include "src/lib/16_dbg.h"
+
+#pragma hdrstop
+
+#pragma warn -pro
+#pragma warn -use
+
+//file load or read definition
+#define FILEREADLOAD
+#define FILEREAD
+//#define EXMMVERBOSE
+//#define BUFFDUMPPAUSE
+//#define EXMMVERBOSE__
+// #define PRINTBBDUMP
+#define BUFFDUMP
+#define NOVID
+
+
+#define KEYP IN_Shutdown(&gvar); printf("\n\npress any key to continue!\n"); getch(); IN_Startup(&gvar);
+
+#define BBUFNAME bigbuffer//gvar.ca.tinf[0]
+#define INITBBUF static memptr BBUFNAME;
+#define BBUFPTR MEMPTR BBUFNAME
+
+#ifdef __BORLANDC__
+#define BBUF (memptr *)BBUFPTR//
+#define BBUFSTRING (memptr *)BBUFNAME
+#endif
+#ifdef __WATCOMC__
+#define BBUF BBUFNAME
+#define BBUFSTRING BBUF
+#endif
+
+////////////////////////////////////////////////////////////////////////////
+#ifdef __BORLANDC__
+void VGAmodeX(sword vq, boolean cmem, global_game_variables_t *gv)
+{
+ printf("VGAmodeX dummy:\n %Fp %Fp %Fp\n", &vq, &cmem, gv);
+}
+#endif
+
+//printf("* %Fp\t", *BBUF);
+//printf("* %04x\t", *BBUF);
+#define PRINTBB {\
+ printf("-------------------------------------------------------------------------------\n");\
+ printf("&main()= %Fp\n", argv[0]);\
+ printf("buffer:\n");\
+ printf(" %Fp\t", BBUF);\
+ printf("&%Fp\n", BBUFPTR);\
+ printf(" %04x\t", BBUF);\
+ printf("& %04x\n", BBUFPTR);\
+ printf("-------------------------------------------------------------------------------\n");\
+}
+ //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");
+// KEYP
+}
+#endif
+
+
+
+void
+main(int argc, char *argv[])
+{
+ byte w;
+#ifndef NOVID
+ boolean done;
+ ScanCode scan;
+#endif
+ static global_game_variables_t gvar;
+#ifdef INITBBUF
+ INITBBUF
+#endif
+//#ifdef __WATCOMC__
+// __segment sega;
+//#endif
+ char bakapee1[64],bakapee2[64];
+ word baka;
+
+#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 PRINTBBDUMP
+//0000PRINTBB; KEYP
+#endif
+ if(argv[1]){ strcpy(bakapee1, argv[1]);//bakapee1[] = *argv[1];
+ if(argv[2]) strcpy(bakapee2, argv[2]); }//bakapee2[] = argv[2]; }
+ else{
+ //{ printf("filename!: "); scanf("%[^\n]", &bakapee); }
+ strcpy(bakapee1, "data/koishi~.pcx"); //bakapee1 = "data/koishi~.pcx";
+ strcpy(bakapee2, "data/test.map"); //bakapee2 = "data/test.map";
+ }
+#ifndef NOVID
+ Startup16(&gvar);
+
+ // save the palette
+#ifdef __WATCOMC__
+ modexPalSave(&gvar.video.dpal); modexFadeOff(4, &gvar.video.dpal); //modexPalBlack();
+#endif
+#else //NOVID
+ //printf("main()=%Fp start MM\n", *argv[0]);
+ MM_Startup(&gvar); //printf("ok\n");
+#ifdef __16_PM__
+#ifdef __DEBUG_PM__
+ if(dbg_debugpm>0)
+ {
+#endif
+ PM_Startup(&gvar); PM_CheckMainMem(&gvar); PM_UnlockMainMem(&gvar);
+//0000 printf("PM Started\n"); KEYP
+#ifdef __DEBUG_PM__
+ }
+#endif
+#endif
+
+#endif //NOVID
+#ifdef __DEBUG_MM__
+ dbg_debugmm=0;
+#endif
+ CA_Startup(&gvar);
+// printf(" done!\n");
+#ifdef PRINTBBDUMP
+//0000
+PRINTBB; KEYP
+#endif
+#ifdef __DEBUG_MM__
+ dbg_debugmm=1;
+#endif
+
+ 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
+ if(w==0)
+ {
+ printf("======================================load=====================================\n");
+ if(CA_LoadFile(bakapee1, BBUFPTR, &gvar)) baka=1; else baka=0;
+ printf("====================================load end===================================\n");
+ }
+//#ifdef __WATCOMC__
+// printf("\nsize of big buffer~=%u\n", _bmsize(sega, BBUF));
+//#endif
+#ifdef BUFFDUMP
+ printf("contents of the buffer\n[\n%s\n]\n", BBUFSTRING);
+#endif// #else
+#ifdef PRINTBBDUMP
+ PRINTBB;
+#endif
+
+//endif // BUFFDUMP
+
+ //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
+#ifndef BUFFDUMPPAUSE
+ KEYP
+#endif
+#endif //filereadload
+
+#ifdef __WATCOMC__
+#ifndef NOVID
+ VGAmodeX(1, 0, &gvar);
+// modexPalUpdate0(&gvar.video.palette);
+// ShapeTest_(&gvar);
+
+ for (done = false;!done;)
+ {
+ while (!(scan = gvar.in.inst->LastScan))
+ {}
+ // SD_Poll();
+
+ IN_ClearKey(scan);
+ switch (scan)
+ {
+ case sc_Space:
+ MM_ShowMemory(&gvar);
+ break;
+//#ifdef __WATCOMC__
+ case sc_O:
+ modexPalUpdate0(&gvar.video.palette); modexpdump(&gvar.video.page);
+ break;
+ case sc_P:
+ modexpdump(&gvar.video.page[0]);
+ break;
+ case sc_V:
+ VL_PatternDraw(&gvar.video, 0, 1, 1);
+ break;
+//#endif
+ default:
+ case sc_Escape:
+ done = true;
+ break;
+ }
+ }
+ VGAmodeX(0, 0, &gvar);
+#endif
+#endif
+ MM_ShowMemory(&gvar);
+ DebugMemory_(&gvar, 1);
+ MM_DumpData(&gvar);
+ MM_Report_(&gvar);
+ //printf("bakapee1=%s\n", bakapee1);
+ //printf("bakapee2=%s\n", bakapee2);
+ MM_FreePtr(BBUFPTR, &gvar);
+#ifndef NOVID
+ Shutdown16(&gvar);
+#else
+#ifdef __16_PM__
+#ifdef __DEBUG_PM__
+ if(dbg_debugpm>0)
+#endif
+ PM_Shutdown(&gvar);
+#endif
+ CA_Shutdown(&gvar);
+ MM_Shutdown(&gvar);
+#endif //NOVID
+ 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", _memavl());
+ printf("farcoreleft(): %lu\n", (dword)HC_farcoreleft());
+#endif
+#ifdef __WATCOMC__
+//this is far printf("Total free: %lu\n", (dword)(HC_GetFreeSize()));
+//super buggy printf("HC_coreleft(): %u\n", HC_coreleft());
+// printf("HC_farcoreleft(): %lu\n", (dword)HC_farcoreleft());
+ //printf("HC_GetNearFreeSize(): %u\n", HC_GetNearFreeSize());
+ //printf("HC_GetFarFreeSize(): %lu\n", (dword)HC_GetFarFreeSize());
+ HC_heapdump(&gvar);
+// segatesuto();
+#endif
+/*#ifdef __BORLANDC__
+ //printf("core left: %lu\n", (dword)HC_coreleft());
+ //printf("far core left: %lu\n", (dword)HC_farcoreleft());
+// printf("\nfarcoreleft(): %lu\n", farcoreleft());
+#endif*/
+ printf("Project 16 ");
+#ifdef __WATCOMC__
+ printf("exmmtest");
+#endif
+#ifdef __BORLANDC__
+ printf("bcexmm");
+#endif
+ printf(".exe. This is just a test file!\n");
+ printf("version %s\n", VERSION);
+#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("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());
+}