--- /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
+#include "src/lib/modex16.h"\r
+#include "src/lib/16_sprit.h"\r
+#include "src/lib/16_ca.h"\r
+#include "src/lib/16_mm.h"\r
+\r
+global_game_variables_t gvar;\r
+\r
+void main() {\r
+ mminfo_t mm; mminfotype mmi;\r
+ __segment sega;\r
+ void __based(sega)* bigbuffer;\r
+ int i;\r
+ word start;\r
+ int plane;\r
+ float t1, t2;\r
+ boolean baka;\r
+ byte *pal;\r
+ int size, size1;\r
+// struct sprite spri;\r
+// vrl1_vgax_offset_t * off, *off1;\r
+// struct vrs_container vrs;\r
+// vrl1_vgax_offset_t **vrl_line_offsets;\r
+// uint32_t huge *vrl_headers_offsets;\r
+// uint16_t huge *vrl_id_iter;\r
+// uint32_t vrl_size;\r
+// int num_of_vrl;\r
+// struct vrl1_vgax_header huge *curr_vrl;\r
+// struct vrl_container *vrl;\r
+ word w=0;\r
+\r
+\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
+ //bmp = bitmapLoadPcx("data/chikyuu.pcx");\r
+ gvar.video.page[0]=modexDefaultPage(&gvar.video.page[0]);\r
+\r
+ mm.mmstarted=0;\r
+ MM_Startup(&mm, &mmi);\r
+ CA_Startup(&gvar);\r
+ // What should be done by read_vrs:\r
+ //if(CA_LoadFile("data/spri/chikyuu.vrs", &bigbuffer, &mm, &mmi)) baka=1; else baka=0;\r
+\r
+// // Insert sanity cheks later\r
+// vrs.buffer = bigbuffer;\r
+// vrs.data_size = size - sizeof(struct vrl1_vgax_header);\r
+// num_of_vrl = 0;\r
+// vrl_id_iter = (uint16_t huge *)(vrs.buffer + vrs.vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST]);\r
+// while(vrl_id_iter[num_of_vrl]){\r
+// num_of_vrl++;\r
+// }\r
+//\r
+// // Allocate memory for vrl line offsets table\r
+// vrl_line_offsets = malloc(sizeof(vrl1_vgax_offset_t *)*num_of_vrl);\r
+//\r
+// vrl_headers_offsets = (uint32_t huge *)(vrs.buffer + vrs.vrs_hdr->offset_table[VRS_HEADER_OFFSET_VRS_LIST]);\r
+// // Calculate line offsets for each vrl\r
+// for(i = 0; i < num_of_vrl; i++){\r
+// curr_vrl = (struct vrl1_vgax_header huge *)(vrs.buffer + vrl_headers_offsets[i]);\r
+//\r
+// // Calc. vrl size as (next_offset - curr_offset)\r
+// if (i != num_of_vrl - 1){\r
+// vrl_size = vrl_headers_offsets[i+1] - vrl_headers_offsets[i] - sizeof(struct vrl1_vgax_header);\r
+// }\r
+// // If it's the last vrl, size is (next_vrs_struct_offset - curr_offset)\r
+// else{\r
+// vrl_size = vrs.vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST] - vrl_headers_offsets[i] - sizeof(struct vrl1_vgax_header);\r
+// }\r
+// vrl_line_offsets[i] = vrl1_vgax_genlineoffsets(curr_vrl, (byte *)curr_vrl + sizeof(struct vrl1_vgax_header), vrl_size);\r
+// }\r
+// vrs.vrl_line_offsets = vrl_line_offsets;\r
+\r
+\r
+ //read_vrs(&gvar, "data/spri/chikyuu.vrs", &vrs);\r
+// spri.spritesheet = &vrs;\r
+// spri.sprite_vrl_cont = malloc(sizeof(struct vrl_container));\r
+// i = set_anim_by_id(&spri, 11);\r
+// if (i == -1)\r
+// {\r
+// return;\r
+// }\r
+// spri.x = 5;\r
+// spri.y = 100;\r
+\r
+// Uncomment to see broken sprites\r
+/* sega = mm.bufferseg;\r
+ if(CA_LoadFile("data/spri/CHUBACW1.vrl", &bigbuffer, &mm, &mmi)) baka=1; else baka=0;*/\r
+\r
+ /* clear and draw one sprite and one bitmap */\r
+ VGAmodeX(1, 1, &gvar);\r
+ modexClearRegion(&gvar.video.page[0], 0, 0, gvar.video.page[0].sw, gvar.video.page[0].sh, 1);\r
+\r
+ /* non sprite comparison */\r
+ start = *clockw;\r
+ modexCopyPageRegion(&gvar.video.page[0], &gvar.video.page[0], 0, 0, 0, 0, 320, 240);\r
+ t1 = (*clockw-start) /18.2;\r
+\r
+ start = *clockw;\r
+\r
+ t2 = (*clockw-start)/18.2;\r
+\r
+ //for (i = 0; i < 5; i++){\r
+ //spri.delay = 1; animate_spri(&spri); spri.x += 20; sleep(2); }\r
+\r
+ while(!kbhit())\r
+ {\r
+ switch(w)\r
+ {\r
+ case 1024:\r
+ modexPalUpdate0(pal);\r
+ w=0;\r
+ default:\r
+ w++;\r
+ break;\r
+ }\r
+ }\r
+ VGAmodeX(0, 1, &gvar);\r
+ //free(spri.sprite_vrl_cont);\r
+ MM_FreePtr(&bigbuffer, &mm);\r
+ //MM_FreePtr(&((void __based(sega)*)spri.spritesheet->buffer), &mm);\r
+ MM_Shutdown(&mm);\r
+ CA_Shutdown(&gvar);\r
+ //printf("CPU to VGA: %f\n", t1);\r
+ //printf("VGA to VGA: %f\n", t2);\r
+ printf("t1: %f\n", t1);\r
+ printf("t2: %f\n", t2);\r
+ printf("gvar.video.page[0].width: %u\n", gvar.video.page[0].width);\r
+ printf("gvar.video.page[0].height: %u\n", gvar.video.page[0].height);\r
+// printf("Num %d", num_of_vrl);\r
+ if(baka) printf("\nyay!\n");\r
+ else printf("\npoo!\n");\r
+}\r