OSDN Git Service

Merge remote-tracking branch 'upstream/master'
[proj16/16.git] / src / pcxtest2.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/bitmap.h"\r
28 //----#include "src/lib/planar.h"\r
29 \r
30 global_game_variables_t gvar;\r
31 \r
32 /*\r
33 void\r
34 DrawPBuf(page_t *page, int x, int y, planar_buf_t *p, byte sprite)\r
35 {\r
36         byte plane;\r
37         word px, py;\r
38         word offset;\r
39 \r
40         // TODO Make this fast.  It's SLOOOOOOW\r
41         for(plane=0; plane < 4; plane++) {\r
42         modexSelectPlane(PLANE(plane+x));\r
43         for(px = plane; px < p->width; px+=4) {\r
44                 offset=px;\r
45                 for(py=0; py<p->height/2; py++) {\r
46                 SELECT_ALL_PLANES();\r
47                 if(!sprite || p->plane[offset])\r
48                         page->data = p->plane;\r
49                 //offset+=p->width;\r
50                 //offset++;\r
51                 }\r
52         }\r
53         }\r
54 }\r
55 */\r
56 \r
57 void main() {\r
58         bitmap_t bmp;\r
59 //----  planar_buf_t *p;\r
60         int i;\r
61         word start;\r
62         int plane;\r
63         float t1, t2;\r
64 \r
65         // DOSLIB: check our environment\r
66         probe_dos();\r
67 \r
68         // DOSLIB: what CPU are we using?\r
69         // NTS: I can see from the makefile Sparky4 intends this to run on 8088 by the -0 switch in CFLAGS.\r
70         //      So this code by itself shouldn't care too much what CPU it's running on. Except that other\r
71         //      parts of this project (DOSLIB itself) rely on CPU detection to know what is appropriate for\r
72         //      the CPU to carry out tasks. --J.C.\r
73         cpu_probe();\r
74 \r
75         // DOSLIB: check for VGA\r
76         if (!probe_vga()) {\r
77                 printf("VGA probe failed\n");\r
78                 return;\r
79         }\r
80         // hardware must be VGA or higher!\r
81         if (!(vga_state.vga_flags & VGA_IS_VGA)) {\r
82                 printf("This program requires VGA or higher graphics hardware\n");\r
83                 return;\r
84         }\r
85 \r
86 //0000  bmp = bitmapLoadPcx("data/koishi~~.pcx");\r
87         bmp = bitmapLoadPcx("data/chikyuu.pcx");\r
88 //      bmp = bitmapLoadPcx("data/koishi^^.pcx");\r
89 //      bmp = bitmapLoadPcx("16/PCX_LIB/chikyuu.pcx");\r
90 //----  p = planar_buf_from_bitmap(&bmp);\r
91         VGAmodeX(1, 1, &gvar);\r
92         gvar.video.page[0]=modexDefaultPage(&gvar.video.page[0]);\r
93         gvar.video.page[0].sw+=32;\r
94         gvar.video.page[0].sh+=32;\r
95 \r
96         /* fix up the palette and everything */\r
97         modexPalUpdate1(bmp.palette);\r
98 \r
99         /* clear and draw one sprite and one bitmap */\r
100         modexClearRegion(&gvar.video.page[0], 0, 0, gvar.video.page[0].sw, gvar.video.page[0].sh, 1);\r
101 \r
102         /* update display~*/\r
103         gvar.video.page[0].dx+=16;\r
104         gvar.video.page[0].dy+=16;\r
105         modexShowPage(&gvar.video.page[0]);\r
106 \r
107         /* non sprite comparison */\r
108         start = *clockw;\r
109         //for(i=0; i<100 ;i++) {\r
110                 oldDrawBmp(VGA, 20, 20, &bmp, 0);\r
111         //}\r
112 \r
113         start = *clockw;\r
114         //for(i=0; i<100 ;i++) {\r
115 //0000          modexDrawBmp(&gvar.video.page[0], 20, 20, &bmp);\r
116                 modexDrawBmp(&gvar.video.page[0], 160, 120, &bmp);\r
117         //}\r
118         t1 = (*clockw-start) /18.2;\r
119 \r
120         start = *clockw;\r
121         //for(i=0; i<100; i++) {\r
122 //0000          modexCopyPageRegion(&gvar.video.page[0], &gvar.video.page[0], 20, 20, 128, 20, 64, 64);\r
123                 modexCopyPageRegion(&gvar.video.page[0], &gvar.video.page[0], 0, 0, 0, 0, 320, 240);\r
124         //}\r
125         t2 = (*clockw-start)/18.2;\r
126 \r
127 \r
128         start = *clockw;\r
129         //for(i=0; i<100 ;i++) {\r
130                 oldDrawBmp(VGA, 20, 20, &bmp, 1);\r
131         //}\r
132 \r
133 \r
134         start = *clockw;\r
135         //for(i=0; i<100 ;i++) {\r
136 //0000          modexDrawSprite(&gvar.video.page[0], 20, 20, &bmp);\r
137                 modexDrawSprite(&gvar.video.page[0], 160, 120, &bmp);\r
138         //}\r
139         //_fmemset(MK_FP(0xA000, 0), (int)p->plane, gvar.video.page[0].sw*(gvar.video.page[0].sh*2));\r
140         //modexDrawBmp(&gvar.video.page[0], 0, 0, &bmp);\r
141         while(!kbhit())\r
142         {\r
143                 //DrawPBuf(&gvar.video.page[0], 0, 0, p, 0);\r
144         }\r
145         VGAmodeX(0, 1, &gvar);\r
146         /*printf("\nmain=%Fp\n\n", &i);\r
147         printf("bmp.data=%Fp\n", bmp.data);\r
148         printf("*bmp.data=%Fp\n", *(bmp.data));\r
149         printf("&bmp.data=%Fp\n", &(bmp.data));\r
150 \r
151         printf("\n%d\n", sizeof(p->plane));\r
152         printf("%d\n", sizeof(bmp));*/\r
153 \r
154         /*for(i=0; i<(320*240); i++)\r
155         {\r
156                 fprintf(stdout, "%d", bmp.data[i]);\r
157                 if(i%bmp.width==0) fprintf(stdout, "\n");\r
158         }*/\r
159         printf("CPU to VGA: %f\n", t1);\r
160         printf("VGA to VGA: %f\n", t2);\r
161         printf("gvar.video.page[0].width: %u\n", gvar.video.page[0].width);\r
162         printf("gvar.video.page[0].height: %u\n", gvar.video.page[0].height);\r
163         return;\r
164 }\r