]> 4ch.mooo.com Git - 16.git/blob - src/vrstest.c
branch is in the master swap branch code added to swap the files out ^^; vrstest...
[16.git] / src / vrstest.c
1 /* Project 16 Source Code~\r
2  * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
3  *\r
4  * This file is part of Project 16.\r
5  *\r
6  * Project 16 is free software; you can redistribute it and/or modify\r
7  * it under the terms of the GNU General Public License as published by\r
8  * the Free Software Foundation; either version 3 of the License, or\r
9  * (at your option) any later version.\r
10  *\r
11  * Project 16 is distributed in the hope that it will be useful,\r
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14  * GNU General Public License for more details.\r
15  *\r
16  * You should have received a copy of the GNU General Public License\r
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>, or\r
18  * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
19  * Fifth Floor, Boston, MA 02110-1301 USA.\r
20  *\r
21  */\r
22 \r
23 #include <stdio.h>\r
24 #include <dos.h>\r
25 #include <string.h>\r
26 #include "src/lib/modex16.h"\r
27 #include "src/lib/16_sprite.h"\r
28 #include "src/lib/16_ca.h"\r
29 #include "src/lib/16_mm.h"\r
30 \r
31 global_game_variables_t gvar;\r
32 \r
33 void main() {\r
34         mminfo_t mm; mminfotype mmi;\r
35         __segment sega;\r
36         void __based(sega)* bigbuffer;\r
37         int i;\r
38         word start;\r
39         int plane;\r
40         float t1, t2;\r
41         boolean baka;\r
42         byte *pal;\r
43 \r
44         // DOSLIB: check our environment\r
45         probe_dos();\r
46 \r
47         // DOSLIB: what CPU are we using?\r
48         // NTS: I can see from the makefile Sparky4 intends this to run on 8088 by the -0 switch in CFLAGS.\r
49         //      So this code by itself shouldn't care too much what CPU it's running on. Except that other\r
50         //      parts of this project (DOSLIB itself) rely on CPU detection to know what is appropriate for\r
51         //      the CPU to carry out tasks. --J.C.\r
52         cpu_probe();\r
53 \r
54         // DOSLIB: check for VGA\r
55         if (!probe_vga()) {\r
56                 printf("VGA probe failed\n");\r
57                 return;\r
58         }\r
59         // hardware must be VGA or higher!\r
60         if (!(vga_state.vga_flags & VGA_IS_VGA)) {\r
61                 printf("This program requires VGA or higher graphics hardware\n");\r
62                 return;\r
63         }\r
64 \r
65         //bmp = bitmapLoadPcx("data/chikyuu.pcx");\r
66         VGAmodeX(1, 1, &gvar);\r
67         gvar.video.page[0]=modexDefaultPage(&gvar.video.page[0]);\r
68 \r
69         mm.mmstarted=0;\r
70         MM_Startup(&mm, &mmi);\r
71         CA_Startup(&gvar);\r
72         if(CA_LoadFile("data/spri/chikyuu.vrs", &bigbuffer, &mm, &mmi)) baka=1; else baka=0;\r
73 \r
74         /* fix up the palette and everything */\r
75         //modexPalUpdate1(bmp.palette);\r
76         //modexLoadPalFile("data/spri/chikyuu.pal", &pal);\r
77         //modexPalUpdate1(pal);\r
78 \r
79         /* clear and draw one sprite and one bitmap */\r
80         modexClearRegion(&gvar.video.page[0], 0, 0, gvar.video.page[0].sw, gvar.video.page[0].sh, 1);\r
81 \r
82         /* non sprite comparison */\r
83         start = *clockw;\r
84         //for(i=0; i<100 ;i++) {\r
85         //      oldDrawBmp(VGA, 20, 20, &bmp, 0);\r
86         //}\r
87 \r
88         start = *clockw;\r
89         //for(i=0; i<100 ;i++) {\r
90 //0000          modexDrawBmp(&gvar.video.page[0], 20, 20, &bmp);\r
91         //      modexDrawBmp(&gvar.video.page[0], 160, 120, &bmp);\r
92         //}\r
93         t1 = (*clockw-start) /18.2;\r
94 \r
95         start = *clockw;\r
96         //for(i=0; i<100; i++) {\r
97 //0000          modexCopyPageRegion(&gvar.video.page[0], &gvar.video.page[0], 20, 20, 128, 20, 64, 64);\r
98                 modexCopyPageRegion(&gvar.video.page[0], &gvar.video.page[0], 0, 0, 0, 0, 320, 240);\r
99         //}\r
100         t2 = (*clockw-start)/18.2;\r
101 \r
102 \r
103         start = *clockw;\r
104         //for(i=0; i<100 ;i++) {\r
105         //      oldDrawBmp(VGA, 20, 20, &bmp, 1);\r
106         //}\r
107 \r
108 \r
109         start = *clockw;\r
110         //for(i=0; i<100 ;i++) {\r
111 //0000          modexDrawSprite(&gvar.video.page[0], 20, 20, &bmp);\r
112         //      modexDrawSprite(&gvar.video.page[0], 160, 120, &bmp);\r
113         //}\r
114         //_fmemset(MK_FP(0xA000, 0), (int)p->plane, gvar.video.page[0].sw*(gvar.video.page[0].sh*2));\r
115         //modexDrawBmp(&gvar.video.page[0], 0, 0, &bmp);\r
116         while(!kbhit())\r
117         {\r
118                 //DrawPBuf(&gvar.video.page[0], 0, 0, p, 0);\r
119         }\r
120         VGAmodeX(0, 1, &gvar);\r
121         MM_FreePtr(&bigbuffer, &mm);\r
122         MM_Shutdown(&mm);\r
123         CA_Shutdown(&gvar);\r
124         /*printf("\nmain=%Fp\n\n", &i);\r
125         printf("bmp.data=%Fp\n", bmp.data);\r
126         printf("*bmp.data=%Fp\n", *(bmp.data));\r
127         printf("&bmp.data=%Fp\n", &(bmp.data));\r
128 \r
129         printf("\n%d\n", sizeof(p->plane));\r
130         printf("%d\n", sizeof(bmp));*/\r
131 \r
132         /*for(i=0; i<(320*240); i++)\r
133         {\r
134                 fprintf(stdout, "%d", bmp.data[i]);\r
135                 if(i%bmp.width==0) fprintf(stdout, "\n");\r
136         }*/\r
137         printf("CPU to VGA: %f\n", t1);\r
138         printf("VGA to VGA: %f\n", t2);\r
139         printf("gvar.video.page[0].width: %u\n", gvar.video.page[0].width);\r
140         printf("gvar.video.page[0].height: %u\n", gvar.video.page[0].height);\r
141         if(baka) printf("\nyay!\n");\r
142         else printf("\npoo!\n");\r
143 }\r