OSDN Git Service

major changes to entire project for tweaking it amd making it cleaner!! OK PNGWEN...
[proj16/16.git] / src / pcxtest.c
1 /* Project 16 Source Code~
2  * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669
3  *
4  * This file is part of Project 16.
5  *
6  * Project 16 is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Project 16 is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>, or
18  * write to the Free Software Foundation, Inc., 51 Franklin Street,
19  * Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  */
22  
23 #include <stdio.h>
24 #include <dos.h>
25 #include <string.h>\r
26 #include "src/lib/modex16.h"\r
27 #include "src/lib/bitmap.h"
28 #include "src/lib/planar.c"\r
29 \r
30 word far* clockw= (word far*) 0x046C; /* 18.2hz clock */\r
31 \r
32 /*
33 void\r
34 DrawPBuf(page_t *page, int x, int y, planar_buf_t *p, byte sprite)
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++) {
46                 SELECT_ALL_PLANES();\r
47                 if(!sprite || p->plane[offset])\r
48                         page->data = p->plane;\r
49                 //offset+=p->width;
50                 //offset++;\r
51                 }\r
52         }\r
53         }\r
54 }\r
55 */
56 \r
57 void main() {\r
58         bitmap_t bmp;
59         planar_buf_t *p;\r
60         int i;
61         page_t page;\r
62         word start;
63         int plane;\r
64         float t1, t2;\r
65 \r
66         page=modexDefaultPage();\r
67 \r
68 //0000  bmp = bitmapLoadPcx("data/koishi~~.pcx");
69 //      bmp = bitmapLoadPcx("data/chikyuu.pcx");
70         bmp = bitmapLoadPcx("data/koishi^^.pcx");
71 //      bmp = bitmapLoadPcx("16/PCX_LIB/chikyuu.pcx");
72         p = planar_buf_from_bitmap(&bmp);\r
73         modexEnter();\r
74 \r
75         /* fix up the palette and everything */\r
76         modexPalUpdate1(bmp.palette);\r
77 \r
78         /* clear and draw one sprite and one bitmap */\r
79         modexClearRegion(&page, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 1);\r
80 \r
81         /* non sprite comparison */
82         start = *clockw;\r
83         for(i=0; i<100 ;i++) {\r
84                 oldDrawBmp(VGA, 20, 20, &bmp, 0);\r
85         }\r
86 \r
87         start = *clockw;\r
88         for(i=0; i<100 ;i++) {\r
89 //0000          modexDrawBmp(&page, 20, 20, &bmp);
90                 modexDrawBmp(&page, 0, 0, &bmp);\r
91         }\r
92         t1 = (*clockw-start) /18.2;\r
93 \r
94         start = *clockw;\r
95         for(i=0; i<100; i++) {\r
96 //0000          modexCopyPageRegion(&page, &page, 20, 20, 128, 20, 64, 64);
97                 modexCopyPageRegion(&page, &page, 0, 0, 0, 0, 320, 240);\r
98         }\r
99         t2 = (*clockw-start)/18.2;\r
100 \r
101 \r
102         start = *clockw;\r
103         for(i=0; i<100 ;i++) {\r
104                 oldDrawBmp(VGA, 20, 20, &bmp, 1);\r
105         }\r
106 \r
107 \r
108         start = *clockw;\r
109         for(i=0; i<100 ;i++) {\r
110 //0000          modexDrawSprite(&page, 20, 20, &bmp);
111                 modexDrawSprite(&page, 0, 0, &bmp);\r
112         }
113         //_fmemset(MK_FP(0xA000, 0), (int)p->plane, SCREEN_WIDTH*(SCREEN_HEIGHT*2));
114         modexDrawBmp(&page, 0, 0, &bmp);
115         while(!kbhit())
116         {
117                 //DrawPBuf(&page, 0, 0, p, 0);
118         }
119         modexLeave();\r
120
121         printf("\n%d\n", sizeof(p->plane));
122         printf("%d\n", sizeof(bmp));
123
124         for(i=0; i<(320*240); i++)
125         {
126                 fprintf(stdout, "%d", bmp.data[i]);
127                 if(i%320==0) fprintf(stdout, "\n");
128         }\r
129         printf("CPU to VGA: %f\n", t1);\r
130         printf("VGA to VGA: %f\n", t2);\r
131         return;\r
132 }\r