]> 4ch.mooo.com Git - 16.git/blob - src/planrpcx.c
planrpcx.exe now can time it's drawing~
[16.git] / src / planrpcx.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 global_game_variables_t gvar;\r
31 \r
32 void main(int argc, char *argv[])\r
33 {\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         int x,y;\r
41         word px,py;\r
42         sword baka;\r
43         char *bakapeee;\r
44 \r
45         bakapeee = malloc(64);\r
46 \r
47         if(argv[1]) bakapeee = argv[1];\r
48         else bakapeee = "data/koishi~.pcx";\r
49 \r
50 //      if(argv[2]) baka = atoi(argv[2]);\r
51 //      else\r
52 baka = 1;\r
53 //0000  bmp = bitmapLoadPcx("data/koishi~~.pcx");\r
54         bmp = bitmapLoadPcx(bakapeee);\r
55         //bmp = bitmapLoadPcx("data/koishi~.pcx");\r
56         p = planar_buf_from_bitmap(&bmp);\r
57         VGAmodeX(baka, &gvar);\r
58         gvar.video.page[0]=modexDefaultPage(&gvar.video.page[0]);\r
59 \r
60         /* fix up the palette and everything */\r
61         modexPalUpdate1(bmp.palette);\r
62 \r
63         /* clear and draw one sprite and one bitmap */\r
64         modexClearRegion(&gvar.video.page[0], 0, 0, gvar.video.page[0].sw, gvar.video.page[0].sh, 0);\r
65 \r
66         /* update display~*/\r
67         gvar.video.page[0].dx+=32;\r
68         gvar.video.page[0].dy+=32;\r
69         modexShowPage(&gvar.video.page[0]);\r
70 \r
71         /* non sprite comparison */\r
72         start = *clockw;\r
73 //              oldDrawBmp(VGA, 20, 20, &bmp, 0);\r
74         for(i=0; i<100 ;i++) {\r
75                 modexDrawBmp(&gvar.video.page[0], 32, 32, &bmp);\r
76         }\r
77         t1 = (*clockw-start) /18.2;\r
78 //      start = *clockw;\r
79 //              modexCopyPageRegion(&gvar.video.page[0], &gvar.video.page[0], 0, 0, 0, 0, 320, 240);\r
80 //      t2 = (*clockw-start)/18.2;\r
81         start = *clockw;\r
82         for(i=0; i<100 ;i++) {\r
83                 DrawPBuf(&gvar.video.page[0], gvar.video.page[0].sw-(p->width), gvar.video.page[0].sh-(p->height), p, 0);\r
84         }\r
85         t2 = (*clockw-start) /18.2;\r
86         while(!kbhit())\r
87         {\r
88         }\r
89         VGAmodeX(0, &gvar);\r
90         /*printf("\nmain=%Fp\n\n", &i);\r
91         printf("bmp.data=%Fp\n", bmp.data);\r
92         printf("*bmp.data=%Fp\n", *(bmp.data));\r
93         printf("&bmp.data=%Fp\n", &(bmp.data));*/\r
94 \r
95         /* print out the contents of each plane */\r
96         for(plane=0; plane < 4; plane++) {\r
97                 i=0;\r
98                 printf("Plane %d\n", plane);\r
99                 for(py=0; py < p->height; py++) {\r
100                         for(px=0; px < p->pwidth; px++) {\r
101                                 printf("%02X ", (int) p->plane[plane][i++]);\r
102                         }\r
103                         printf("\n");\r
104                 }\r
105         }\r
106         fprintf(stderr,"Project 16 planrpcx.exe. This is just a test file!\n");\r
107         fprintf(stderr,"version %s\n", VERSION);\r
108         fprintf(stderr,"%d\n", sizeof(p->plane));\r
109         fprintf(stderr,"pw=%d\n", p->width);\r
110         fprintf(stderr,"ph=%d\n", p->height);\r
111         fprintf(stderr,"ppw=%d\n", p->pwidth);\r
112         fprintf(stderr,"%d\n", sizeof(bmp));\r
113         planar_buf_free(p);\r
114         fprintf(stderr, "modexDrawBmp:  %f\n", t1);\r
115         fprintf(stderr, "DrawPBuf:      %f\n", t2);\r
116         fprintf(stderr, "gvar.video.page[0].width: %u\n", gvar.video.page[0].width);\r
117         fprintf(stderr, "gvar.video.page[0].height: %u\n", gvar.video.page[0].height);\r
118         return;\r
119 }\r