OSDN Git Service

no idea why bcexmm.exe is broke w tweaked zcroll.exe a bit also Quit is refined now...
[proj16/16.git] / src / pcxtest.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/16_vl.h"\r
27 #include "src/lib/bitmap.h"\r
28 //----#include "src/lib/planar.h"\r
29 \r
30 static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */\r
31 \r
32 void main() {\r
33         static global_game_variables_t gvar;\r
34         bitmap_t bmp;\r
35 //----  planar_buf_t *p;\r
36         int i;\r
37         word start;\r
38         int plane;\r
39         float t1, t2;\r
40 \r
41         // DOSLIB: check our environment\r
42         probe_dos();\r
43 \r
44         // DOSLIB: what CPU are we using?\r
45         // NTS: I can see from the makefile Sparky4 intends this to run on 8088 by the -0 switch in CFLAGS.\r
46         //      So this code by itself shouldn't care too much what CPU it's running on. Except that other\r
47         //      parts of this project (DOSLIB itself) rely on CPU detection to know what is appropriate for\r
48         //      the CPU to carry out tasks. --J.C.\r
49         cpu_probe();\r
50 \r
51         // DOSLIB: check for VGA\r
52         if (!probe_vga()) {\r
53                 printf("VGA probe failed\n");\r
54                 return;\r
55         }\r
56         // hardware must be VGA or higher!\r
57         if (!(vga_state.vga_flags & VGA_IS_VGA)) {\r
58                 printf("This program requires VGA or higher graphics hardware\n");\r
59                 return;\r
60         }\r
61 \r
62 //0000  bmp = bitmapLoadPcx("data/koishi~~.pcx");\r
63         bmp = bitmapLoadPcx("data/chikyuu.pcx");\r
64 //      bmp = bitmapLoadPcx("data/koishi^^.pcx");\r
65 //      bmp = bitmapLoadPcx("16/PCX_LIB/chikyuu.pcx");\r
66 //----  p = planar_buf_from_bitmap(&bmp);\r
67         VGAmodeX(1, 1, &gvar);\r
68         gvar.video.page[0]=modexDefaultPage(&gvar.video.page[0]);\r
69 \r
70         /* fix up the palette and everything */\r
71         modexPalUpdate1(bmp.palette);\r
72 \r
73         /* clear and draw one sprite and one bitmap */\r
74         modexClearRegion(&gvar.video.page[0], 0, 0, gvar.video.page[0].sw, gvar.video.page[0].sh, 1);\r
75 \r
76         /* non sprite comparison */\r
77         start = *clockw;\r
78         //for(i=0; i<100 ;i++) {\r
79                 oldDrawBmp(VGA, 20, 20, &bmp, 0);\r
80         //}\r
81 \r
82         start = *clockw;\r
83         //for(i=0; i<100 ;i++) {\r
84 //0000          modexDrawBmp(&gvar.video.page[0], 20, 20, &bmp);\r
85                 modexDrawBmp(&gvar.video.page[0], 160, 120, &bmp);\r
86         //}\r
87         t1 = (*clockw-start) /18.2;\r
88 \r
89         start = *clockw;\r
90         //for(i=0; i<100; i++) {\r
91 //0000          modexCopyPageRegion(&gvar.video.page[0], &gvar.video.page[0], 20, 20, 128, 20, 64, 64);\r
92                 modexCopyPageRegion(&gvar.video.page[0], &gvar.video.page[0], 0, 0, 0, 0, 320, 240);\r
93         //}\r
94         t2 = (*clockw-start)/18.2;\r
95 \r
96 \r
97         start = *clockw;\r
98         //for(i=0; i<100 ;i++) {\r
99                 oldDrawBmp(VGA, 20, 20, &bmp, 1);\r
100         //}\r
101 \r
102 \r
103         start = *clockw;\r
104         //for(i=0; i<100 ;i++) {\r
105 //0000          modexDrawSprite(&gvar.video.page[0], 20, 20, &bmp);\r
106                 modexDrawSprite(&gvar.video.page[0], 160, 120, &bmp);\r
107         //}\r
108         //_fmemset(MK_FP(0xA000, 0), (int)p->plane, gvar.video.page[0].sw*(gvar.video.page[0].sh*2));\r
109         //modexDrawBmp(&gvar.video.page[0], 0, 0, &bmp);\r
110         while(!kbhit())\r
111         {\r
112                 //DrawPBuf(&gvar.video.page[0], 0, 0, p, 0);\r
113         }\r
114         VGAmodeX(0, 1, &gvar);\r
115         /*printf("\nmain=%Fp\n\n", &i);\r
116         printf("bmp.data=%Fp\n", bmp.data);\r
117         printf("*bmp.data=%Fp\n", *(bmp.data));\r
118         printf("&bmp.data=%Fp\n", &(bmp.data));\r
119 \r
120         printf("\n%d\n", sizeof(p->plane));\r
121         printf("%d\n", sizeof(bmp));*/\r
122 \r
123         /*for(i=0; i<(320*240); i++)\r
124         {\r
125                 fprintf(stdout, "%d", bmp.data[i]);\r
126                 if(i%bmp.width==0) fprintf(stdout, "\n");\r
127         }*/\r
128         printf("CPU to VGA: %f\n", t1);\r
129         printf("VGA to VGA: %f\n", t2);\r
130         printf("gvar.video.page[0].width: %u\n", gvar.video.page[0].width);\r
131         printf("gvar.video.page[0].height: %u\n", gvar.video.page[0].height);\r
132         return;\r
133 }\r