]> 4ch.mooo.com Git - 16.git/blob - src/planrpcx.c
going to work on this soon
[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         byte l[1024];\r
46         word j,chw,xp,col,bgcol;\r
47 \r
48 \r
49         bakapeee = malloc(64);\r
50 \r
51         if(argv[1]) bakapeee = argv[1];\r
52         else bakapeee = "data/koishi~.pcx";\r
53 \r
54 //      if(argv[2]) baka = atoi(argv[2]);\r
55 //      else\r
56 baka = 1;\r
57 \r
58         bmp = bitmapLoadPcx(bakapeee);\r
59         p = planar_buf_from_bitmap(&bmp);\r
60         VGAmodeX(baka, &gvar);\r
61         gvar.video.page[0]=modexDefaultPage(&gvar.video.page[0]);\r
62 \r
63         /* fix up the palette and everything */\r
64         modexPalUpdate1(bmp.palette);\r
65 \r
66         /* clear and draw one sprite and one bitmap */\r
67         modexClearRegion(&gvar.video.page[0], 0, 0, gvar.video.page[0].sw, gvar.video.page[0].sh, 0);\r
68 \r
69         /* update display~*/\r
70         gvar.video.page[0].dx+=32;\r
71         gvar.video.page[0].dy+=32;\r
72         modexShowPage(&gvar.video.page[0]);\r
73 \r
74         /* non sprite comparison */\r
75         start = *clockw;\r
76 //              oldDrawBmp(VGA, 20, 20, &bmp, 0);\r
77         for(i=0; i<100 ;i++) {\r
78                 modexDrawBmp(&gvar.video.page[0], 32, 32, &bmp);\r
79         }\r
80         t1 = (*clockw-start) /18.2;\r
81 //      start = *clockw;\r
82 //              modexCopyPageRegion(&gvar.video.page[0], &gvar.video.page[0], 0, 0, 0, 0, 320, 240);\r
83 //      t2 = (*clockw-start)/18.2;\r
84         start = *clockw;\r
85         for(i=0; i<100 ;i++) {\r
86                 //DrawPBuf(&gvar.video.page[0], 0, 0, p, 0);\r
87         }\r
88         t2 = (*clockw-start) /18.2;\r
89         while(!kbhit())\r
90         {\r
91         }\r
92         VGAmodeX(0, &gvar);\r
93         /*printf("\nmain=%Fp\n\n", &i);\r
94         printf("bmp.data=%Fp\n", bmp.data);\r
95         printf("*bmp.data=%Fp\n", *(bmp.data));\r
96         printf("&bmp.data=%Fp\n", &(bmp.data));*/\r
97 \r
98         /* print out the contents of each plane */\r
99         for(plane=0; plane < 4; plane++) {\r
100                 i=0;\r
101                 printf("Plane %d\n", plane);\r
102                 for(py=0; py < p->height; py++) {\r
103                         for(px=0; px < p->pwidth; px++) {\r
104                                 printf("%02X ", (int) p->plane[plane][i++]);\r
105                         }\r
106                         printf("\n");\r
107                 }\r
108         }\r
109         col=0x0d, bgcol=0;\r
110         for(i=0; i<8; i++)\r
111         {\r
112                 /*modexSelectPlane(PLANE(x));\r
113                 j=1<<8;\r
114                 *bakapee=(l[i] & j ? col:bgcol);\r
115                 _fmemcpy(page->data + (((page->width/4) * (y+page->dy+i)) + ((x+page->dx+chw) / 4)), bakapee, 8);*/\r
116                 j=4<<8;\r
117                 fprintf(stderr, "j<<=%u\n", j);\r
118                 xp=0;\r
119                 while(j)\r
120                 {\r
121                         //modexputPixel(page, x+xp+chw, y+i, l[i] & j ? col:bgcol);\r
122                         //fprintf(stderr, "%u", l[i] & j ? col:bgcol);\r
123                         xp++;\r
124                         j>>=4;\r
125                         fprintf(stderr, "       j>>=%u\n", j);\r
126                 }\r
127                 //fprintf(stderr, "\n");\r
128         }\r
129         chw += xp;\r
130         fprintf(stderr,"Project 16 planrpcx.exe. This is just a test file!\n");\r
131         fprintf(stderr,"version %s\n", VERSION);\r
132         fprintf(stderr,"%d\n", sizeof(p->plane));\r
133         fprintf(stderr,"pw=%d\n", p->width);\r
134         fprintf(stderr,"ph=%d\n", p->height);\r
135         fprintf(stderr,"ppw=%d\n", p->pwidth);\r
136         fprintf(stderr,"%d\n", sizeof(bmp));\r
137         fprintf(stderr,"%dx%d\n", gvar.video.page[0].sw-(p->width), gvar.video.page[0].sh-(p->height));\r
138         planar_buf_free(p);\r
139         free(bakapeee);\r
140         fprintf(stderr, "modexDrawBmp:  %f\n", t1);\r
141         fprintf(stderr, "DrawPBuf:      %f\n", t2);\r
142         fprintf(stderr, "gvar.video.page[0].width: %u\n", gvar.video.page[0].width);\r
143         fprintf(stderr, "gvar.video.page[0].height: %u\n", gvar.video.page[0].height);\r
144         return;\r
145 }\r