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