OSDN Git Service

many improvements for testing have been added ^^
[proj16/16.git] / src / pcxtest2.c
1 /* Project 16 Source Code~\r
2  * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669\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 /*\r
31 void\r
32 DrawPBuf(page_t *page, int x, int y, planar_buf_t *p, byte sprite)\r
33 {\r
34         byte plane;\r
35         word px, py;\r
36         word offset;\r
37 \r
38         // TODO Make this fast.  It's SLOOOOOOW\r
39         for(plane=0; plane < 4; plane++) {\r
40         modexSelectPlane(PLANE(plane+x));\r
41         for(px = plane; px < p->width; px+=4) {\r
42                 offset=px;\r
43                 for(py=0; py<p->height/2; py++) {\r
44                 SELECT_ALL_PLANES();\r
45                 if(!sprite || p->plane[offset])\r
46                         page->data = p->plane;\r
47                 //offset+=p->width;\r
48                 //offset++;\r
49                 }\r
50         }\r
51         }\r
52 }\r
53 */\r
54 \r
55 void main() {\r
56         bitmap_t bmp;\r
57         planar_buf_t *p;\r
58         int i;\r
59         page_t page;\r
60         word start;\r
61         int plane;\r
62         float t1, t2;\r
63 \r
64         page=modexDefaultPage();\r
65         page.width+=32;\r
66         page.height+=32;\r
67 //0000  bmp = bitmapLoadPcx("data/koishi~~.pcx");\r
68 //      bmp = bitmapLoadPcx("data/chikyuu.pcx");\r
69         bmp = bitmapLoadPcx("data/koishi^^.pcx");\r
70 //      bmp = bitmapLoadPcx("16/PCX_LIB/chikyuu.pcx");\r
71         p = planar_buf_from_bitmap(&bmp);\r
72         modexEnter();\r
73 \r
74         /* fix up the palette and everything */\r
75         modexPalUpdate1(bmp.palette);\r
76 \r
77         /* clear and draw one sprite and one bitmap */\r
78         modexClearRegion(&page, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 1);\r
79 \r
80         /* update display~*/\r
81         page.dx+=16;\r
82         page.dy+=16;\r
83         modexShowPage(&page);\r
84 \r
85         /* non sprite comparison */\r
86         start = *clockw;\r
87         //for(i=0; i<100 ;i++) {\r
88                 oldDrawBmp(VGA, 20, 20, &bmp, 0);\r
89         //}\r
90 \r
91         start = *clockw;\r
92         //for(i=0; i<100 ;i++) {\r
93 //0000          modexDrawBmp(&page, 20, 20, &bmp);\r
94                 modexDrawBmp(&page, 160, 120, &bmp);\r
95         //}\r
96         t1 = (*clockw-start) /18.2;\r
97 \r
98         start = *clockw;\r
99         //for(i=0; i<100; i++) {\r
100 //0000          modexCopyPageRegion(&page, &page, 20, 20, 128, 20, 64, 64);\r
101                 modexCopyPageRegion(&page, &page, 0, 0, 0, 0, 320, 240);\r
102         //}\r
103         t2 = (*clockw-start)/18.2;\r
104 \r
105 \r
106         start = *clockw;\r
107         //for(i=0; i<100 ;i++) {\r
108                 oldDrawBmp(VGA, 20, 20, &bmp, 1);\r
109         //}\r
110 \r
111 \r
112         start = *clockw;\r
113         //for(i=0; i<100 ;i++) {\r
114 //0000          modexDrawSprite(&page, 20, 20, &bmp);\r
115                 modexDrawSprite(&page, 160, 120, &bmp);\r
116         //}\r
117         //_fmemset(MK_FP(0xA000, 0), (int)p->plane, SCREEN_WIDTH*(SCREEN_HEIGHT*2));\r
118         //modexDrawBmp(&page, 0, 0, &bmp);\r
119         while(!kbhit())\r
120         {\r
121                 //DrawPBuf(&page, 0, 0, p, 0);\r
122         }\r
123         modexLeave();\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("page.width: %u\n", page.width);\r
140         printf("page.height: %u\n", page.height);\r
141         return;\r
142 }\r