]> 4ch.mooo.com Git - 16.git/commitdiff
ca_t added and vgacamm for sparky4
authorsparky4 <sparky4@cock.li>
Fri, 2 Sep 2016 18:40:29 +0000 (13:40 -0500)
committersparky4 <sparky4@cock.li>
Fri, 2 Sep 2016 18:40:29 +0000 (13:40 -0500)
makefile
src/vgacamm.c [new file with mode: 0755]
src/vrstest.c

index 9cac033ac20c649d5426cbd6ea11b3fa3c9493c4..d9a1228dd1a2c9c9e0eb75d6c69462b29b0b4dde 100755 (executable)
--- a/makefile
+++ b/makefile
@@ -168,7 +168,8 @@ TESTEXEC = &
     inputest.exe &
     palettel.exe &
     exmmtest.exe &
-    vrstest.exe
+    vrstest.exe &
+    vgacamm.exe
 EXEC = &
     16.exe &
     bakapi.exe &
@@ -203,6 +204,7 @@ inputest.exe:     inputest.$(OBJ) $(16LIB) $(DOSLIBLIBS)
 #sountest.exe:    sountest.$(OBJ) $(16LIB)
 pcxtest.exe:      pcxtest.$(OBJ) gfx.lib $(DOSLIBLIBS)
 vrstest.exe:      vrstest.$(OBJ) $(16LIB) gfx.lib $(DOSLIBLIBS)
+vgacamm.exe:      vgacamm.$(OBJ) $(16LIB) gfx.lib $(DOSLIBLIBS)
 palettec.exe:     palettec.$(OBJ) gfx.lib $(DOSLIBLIBS)
 palettel.exe:     palettel.$(OBJ) gfx.lib $(DOSLIBLIBS)
 pcxtest2.exe:     pcxtest2.$(OBJ) gfx.lib $(DOSLIBLIBS)
@@ -222,6 +224,7 @@ test.$(OBJ):      $(SRC)/test.c $(SRCLIB)/modex16.h
 test0.$(OBJ):     $(SRC)/test0.c
 pcxtest.$(OBJ):   $(SRC)/pcxtest.c $(SRCLIB)/modex16.h
 vrstest.$(OBJ):   $(SRC)/vrstest.c $(SRCLIB)/modex16.h
+vgacamm.$(OBJ):   $(SRC)/vgacamm.c $(SRCLIB)/modex16.h
 #planrpcx.$(OBJ): $(SRC)/planrpcx.c $(SRCLIB)/modex16.h
 pcxtest2.$(OBJ):  $(SRC)/pcxtest2.c $(SRCLIB)/modex16.h
 palettec.$(OBJ):  $(SRC)/palettec.c
diff --git a/src/vgacamm.c b/src/vgacamm.c
new file mode 100755 (executable)
index 0000000..de14c24
--- /dev/null
@@ -0,0 +1,173 @@
+/* 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
index fe532b84eb6e6a9f5842c3a5f8d198a28497563f..6ffdab39be398600bcaa0f7770236fe40775c7c2 100755 (executable)
@@ -40,7 +40,7 @@ void main() {
        float t1, t2;
        boolean baka;
        byte *pal;
-       int fd, size, size1;
+       int size, size1;
        struct sprite spri;
        vrl1_vgax_offset_t * off, *off1;
        struct vrs_container vrs;
@@ -51,7 +51,6 @@ void main() {
        int num_of_vrl;
        struct vrl1_vgax_header huge *curr_vrl;
        struct vrl_container *vrl;
-       int success;
        word w=0;
 
 
@@ -86,10 +85,7 @@ void main() {
        // What should be done by read_vrs:
        //sega = (mm.bufferseg);
        if(CA_LoadFile("data/spri/chikyuu.vrs", &bigbuffer, &mm, &mmi)) baka=1; else baka=0;
-       fd = open("data/spri/chikyuu.vrs", O_RDONLY|O_BINARY);
-       size = lseek(fd, 0, SEEK_END);
-       lseek(fd, 0, SEEK_SET);
-       close(fd);
+
        // Insert sanity cheks later
        vrs.buffer = bigbuffer;
        vrs.data_size = size - sizeof(struct vrl1_vgax_header);