]> 4ch.mooo.com Git - 16.git/blob - src/planrpcx.c
wwwwwwwwwwwwwww
[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\r
33 DrawPBuf(page_t *page, int x, int y, planar_buf_t *p, byte sprite)\r
34 {\r
35         word plane;\r
36         int px, py, i;\r
37 //      word offset = (word) page->data;\r
38 \r
39         px=x;\r
40         py=y;\r
41         // TODO Make this fast.  It's SLOOOOOOW\r
42 //      for(plane=0; plane < 4; plane++) {\r
43 //              i=0;\r
44 //              modexSelectPlane(PLANE(plane+x));\r
45 //              for(px = plane; px < p->width; px+=4) {\r
46 //                      offset=px;\r
47 //                      for(py=0; py<p->height/2; py++) {\r
48 //                              //SELECT_ALL_PLANES();\r
49 //                              if(!sprite || p->plane[offset])\r
50 //                                      page->data = &(p->plane[offset][i++]);\r
51 //                              offset+=p->width;\r
52 //                              offset++;\r
53 //                      }\r
54 //              }\r
55 //      }\r
56 //      z=0;\r
57         for(plane=0; plane < 4; plane++) {\r
58                 //modexputPixel(page, 120, 90+z, z+1);\r
59                 //z++;\r
60                 i=0;\r
61                 modexSelectPlane(PLANE(plane+x));\r
62                 //modexSelectPlane(plane);\r
63                 for(; y < p->height; y++) {\r
64                         //for(px=0; px < p->width; px++) {\r
65                                 //printf("%02X ", (int) p->plane[plane][i++]);\r
66                                 strncpy(page->data + (((page->width/4) * (y+page->dy)) + ((x+page->dx) / 4))\r
67 ,&(p->plane[plane][i+=p->pwidth]), p->pwidth);\r
68                         //}\r
69                 }\r
70                 //getch();\r
71                 x=px;\r
72                 y=py;\r
73         }\r
74 }\r
75 \r
76 void main(int argc, char *argv[])\r
77 {\r
78         bitmap_t bmp;\r
79         planar_buf_t *p;\r
80         int i;\r
81         //word start;\r
82         int plane;\r
83         //float t1, t2;\r
84         int x,y;\r
85         word px,py;\r
86         sword baka;\r
87         //char *pee;\r
88         char *bakapeee;\r
89 \r
90         bakapeee = malloc(64);\r
91 \r
92         if(argv[1]) bakapeee = argv[1];\r
93         else bakapeee = "data/koishi~.pcx";\r
94 \r
95 //      if(argv[2]) baka = atoi(argv[2]);\r
96 //      else\r
97 baka = 1;\r
98 //0000  bmp = bitmapLoadPcx("data/koishi~~.pcx");\r
99         bmp = bitmapLoadPcx(bakapeee);\r
100         //bmp = bitmapLoadPcx("data/koishi~.pcx");\r
101         p = planar_buf_from_bitmap(&bmp);\r
102         VGAmodeX(baka, &gvar);\r
103         gvar.video.page[0]=modexDefaultPage(&gvar.video.page[0]);\r
104 //      gvar.video.page[0].sw+=32;\r
105 //      gvar.video.page[0].sh+=32;\r
106 \r
107         /* fix up the palette and everything */\r
108         modexPalUpdate1(bmp.palette);\r
109 \r
110         /* clear and draw one sprite and one bitmap */\r
111         modexClearRegion(&gvar.video.page[0], 0, 0, gvar.video.page[0].sw, gvar.video.page[0].sh, 1);\r
112 \r
113         /* update display~*/\r
114         gvar.video.page[0].dx+=32;\r
115         gvar.video.page[0].dy+=32;\r
116         modexShowPage(&gvar.video.page[0]);\r
117 \r
118         /* non sprite comparison */\r
119 //      start = *clockw;\r
120 //              oldDrawBmp(VGA, 20, 20, &bmp, 0);\r
121 //      start = *clockw;\r
122 //0000          modexDrawBmp(&gvar.video.page[0], 20, 20, &bmp);\r
123 //              modexDrawBmp(&gvar.video.page[0], 160, 120, &bmp);\r
124 //      t1 = (*clockw-start) /18.2;\r
125 //      start = *clockw;\r
126 //0000          modexCopyPageRegion(&gvar.video.page[0], &gvar.video.page[0], 20, 20, 128, 20, 64, 64);\r
127 //              modexCopyPageRegion(&gvar.video.page[0], &gvar.video.page[0], 0, 0, 0, 0, 320, 240);\r
128 //      t2 = (*clockw-start)/18.2;\r
129 //      start = *clockw;\r
130 //              oldDrawBmp(VGA, 20, 20, &bmp, 1);\r
131 //      start = *clockw;\r
132 //0000          modexDrawSprite(&gvar.video.page[0], 20, 20, &bmp);\r
133 //              modexDrawSprite(&gvar.video.page[0], 160, 120, &bmp);\r
134 //i=0;\r
135 //plane=0;\r
136 //      _fmemset(VGA, (int) p->plane[plane++][i++], p->width*p->height);\r
137         //modexDrawBmp(&gvar.video.page[0], 0, 0, &bmp);\r
138         DrawPBuf(&gvar.video.page[0], 0, 0, p, 0);\r
139         while(!kbhit())\r
140         {\r
141                 //if(argv[2]) pee = strcpy(VGA, &(p->plane[plane][24]));\r
142         }//gvar.video.page[0].data\r
143         VGAmodeX(0, &gvar);\r
144         planar_buf_free(p);\r
145         /*printf("\nmain=%Fp\n\n", &i);\r
146         printf("bmp.data=%Fp\n", bmp.data);\r
147         printf("*bmp.data=%Fp\n", *(bmp.data));\r
148         printf("&bmp.data=%Fp\n", &(bmp.data));*/\r
149 \r
150         /* print out the contents of each plane */\r
151         /*for(plane=0; plane < 4; plane++) {\r
152                 i=0;\r
153                 printf("Plane %d\n", plane);\r
154                 for(py=0; py < p->height; py++) {\r
155                         for(px=0; px < p->pwidth; px++) {\r
156                                 printf("%02X ", (int) p->plane[plane][i++]);\r
157                         }\r
158                         printf("\n");\r
159                 }\r
160         }*/\r
161         fprintf(stderr,"\n%d\n", sizeof(p->plane));\r
162         fprintf(stderr,"pw=%d\n", p->width);\r
163         fprintf(stderr,"ph=%d\n", p->height);\r
164         fprintf(stderr,"ppw=%d\n", p->pwidth);\r
165         fprintf(stderr,"%d\n", sizeof(bmp));\r
166 //      fprintf(stderr,"%s\n", *pee);\r
167 //      fprintf(stderr, "CPU to VGA: %f\n", t1);\r
168 //      fprintf(stderr, "VGA to VGA: %f\n", t2);\r
169         fprintf(stderr, "gvar.video.page[0].width: %u\n", gvar.video.page[0].width);\r
170         fprintf(stderr, "gvar.video.page[0].height: %u\n", gvar.video.page[0].height);\r
171         return;\r
172 }\r