--- /dev/null
+/* Project 16 Source Code~\r
+ * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
+ *\r
+ * This file is part of Project 16.\r
+ *\r
+ * Project 16 is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 3 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Project 16 is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program. If not, see <http://www.gnu.org/licenses/>, or\r
+ * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
+ * Fifth Floor, Boston, MA 02110-1301 USA.\r
+ *\r
+ */\r
+/*\r
+ * 16 library\r
+ */\r
+\r
+#include "src/lib/16_tail.h"\r
+\r
+/*\r
+==========================\r
+=\r
+= Startup16\r
+=\r
+= Load a few things right away\r
+=\r
+==========================\r
+*/\r
+\r
+void Startup16(global_game_variables_t *gvar)\r
+{\r
+ // DOSLIB: check our environment\r
+ probe_dos();\r
+\r
+ // DOSLIB: what CPU are we using?\r
+ // NTS: I can see from the makefile Sparky4 intends this to run on 8088 by the -0 switch in CFLAGS.\r
+ // So this code by itself shouldn't care too much what CPU it's running on. Except that other\r
+ // parts of this project (DOSLIB itself) rely on CPU detection to know what is appropriate for\r
+ // the CPU to carry out tasks. --J.C.\r
+ cpu_probe();\r
+\r
+ // DOSLIB: check for VGA\r
+ if (!probe_vga()) {\r
+ printf("VGA probe failed\n");\r
+ return;\r
+ }\r
+ // hardware must be VGA or higher!\r
+ if (!(vga_state.vga_flags & VGA_IS_VGA)) {\r
+ printf("This program requires VGA or higher graphics hardware\n");\r
+ return;\r
+ }\r
+\r
+ gvar->mm.mmstarted=0;\r
+ gvar->pm.PMStarted=0;\r
+ MM_Startup(gvar);\r
+ IN_Startup(gvar);\r
+ PM_Startup(gvar);\r
+ PM_UnlockMainMem(gvar);\r
+ CA_Startup(gvar);\r
+\r
+}\r
+\r
+//===========================================================================\r
+\r
+/*\r
+==========================\r
+=\r
+= Shutdown16\r
+=\r
+= Shuts down all ID_?? managers\r
+=\r
+==========================\r
+*/\r
+\r
+void Shutdown16(global_game_variables_t *gvar)\r
+{\r
+ PM_Shutdown(gvar);\r
+ IN_Shutdown(gvar);\r
+ CA_Shutdown(gvar);\r
+ MM_Shutdown(gvar);\r
+}\r
+\r
+\r
+//===========================================================================\r
+\r
+/*\r
+==================\r
+=\r
+= DebugMemory\r
+=\r
+==================\r
+*/\r
+\r
+void DebugMemory_(global_game_variables_t *gvar, boolean q)\r
+{\r
+ /*VW_FixRefreshBuffer ();\r
+ US_CenterWindow (16,7);\r
+\r
+ US_CPrint ("Memory Usage");\r
+ US_CPrint ("------------");\r
+ US_Print ("Total :");\r
+ US_PrintUnsigned (mminfo.mainmem/1024);\r
+ US_Print ("k\nFree :");\r
+ US_PrintUnsigned (MM_UnusedMemory()/1024);\r
+ US_Print ("k\nWith purge:");\r
+ US_PrintUnsigned (MM_TotalFree()/1024);\r
+ US_Print ("k\n");\r
+ VW_UpdateScreen();*/\r
+ if(q){\r
+ printf("========================================\n");\r
+ printf(" DebugMemory_\n");\r
+ printf("========================================\n");}\r
+ if(q) { printf("Memory Usage\n");\r
+ printf("------------\n"); }else printf(" %c%c", 0xD3, 0xC4);\r
+ printf("Total: "); if(q) printf(" "); printf("%uk", gvar->mmi.mainmem/1024);\r
+ if(q) printf("\n"); else printf(" ");\r
+ printf("Free: "); if(q) printf(" "); printf("%uk", MM_UnusedMemory(gvar)/1024);\r
+ if(q) printf("\n"); else printf(" ");\r
+ printf("With purge:"); if(q) printf(" "); printf("%uk\n", MM_TotalFree(gvar)/1024);\r
+ if(q) printf("------------\n");\r
+#ifdef __WATCOMC__\r
+ IN_Ack ();\r
+#endif\r
+ if(q) MM_ShowMemory (gvar);\r
+}\r
+#ifdef __WATCOMC__\r
+/*\r
+==========================\r
+=\r
+= Quit\r
+=\r
+==========================\r
+*/\r
+\r
+void Quit (char *error)\r
+{\r
+ unsigned finscreen;\r
+ memptr screen;\r
+ union REGS in, out;\r
+\r
+ //ClearMemory ();\r
+ if (!*error)\r
+ {\r
+ //WriteConfig ();\r
+ }\r
+ else\r
+ {\r
+ //CA_CacheGrChunk (ERRORSCREEN);\r
+ //screen = grsegs[ERRORSCREEN];\r
+ }\r
+\r
+ //ShutdownId ();\r
+ IN_Shutdown();\r
+ //modexLeave();\r
+ in.h.ah = 0x00;\r
+ in.h.al = 0x3;\r
+ int86(0x10, &in, &out);\r
+\r
+ if (error && *error)\r
+ {\r
+ //movedata ((unsigned)screen,7,0xb800,0,7*160);\r
+ //gotoxy (10,4);\r
+ fprintf(stderr, "%s\n", error);\r
+ //gotoxy (1,8);\r
+ exit(1);\r
+ }\r
+ else\r
+ if (!error || !(*error))\r
+ {\r
+ //clrscr();\r
+ //#ifndef JAPAN\r
+ movedata ((unsigned)screen,7,0xb800,0,4000);\r
+ //gotoxy(1,24);\r
+ //#endif\r
+//asm mov bh,0\r
+//asm mov dh,23 // row\r
+//asm mov dl,0 // collumn\r
+//asm mov ah,2\r
+//asm int 0x10\r
+ }\r
+\r
+ exit(0);\r
+}\r
+#endif\r
+\r
+//===========================================================================\r
--- /dev/null
+/* Project 16 Source Code~\r
+ * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
+ *\r
+ * This file is part of Project 16.\r
+ *\r
+ * Project 16 is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 3 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Project 16 is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program. If not, see <http://www.gnu.org/licenses/>, or\r
+ * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
+ * Fifth Floor, Boston, MA 02110-1301 USA.\r
+ *\r
+ */\r
+\r
+#ifndef __16_TAIL__\r
+#define __16_TAIL__\r
+\r
+#include "src/lib/16_head.h"\r
+#include "src/lib/16_pm.h"\r
+#include "src/lib/16_mm.h"\r
+#include "src/lib/16_in.h"\r
+\r
+void DebugMemory_(global_game_variables_t *gvar, boolean q);\r
+#ifdef __WATCOMC__\r
+void Quit (char *error);\r
+#endif\r
+\r
+#endif\r