]> 4ch.mooo.com Git - 16.git/blob - src/planrpcx.c
==YAY! I GOT IT WORKING THE PLANAR BUFFER RENDERING==
[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 //0000          modexDrawBmp(&gvar.video.page[0], 20, 20, &bmp);\r
75 //              modexDrawBmp(&gvar.video.page[0], 160, 120, &bmp);\r
76 //      t1 = (*clockw-start) /18.2;\r
77 //      start = *clockw;\r
78 //0000          modexCopyPageRegion(&gvar.video.page[0], &gvar.video.page[0], 20, 20, 128, 20, 64, 64);\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 //              oldDrawBmp(VGA, 20, 20, &bmp, 1);\r
83 //0000          modexDrawSprite(&gvar.video.page[0], 20, 20, &bmp);\r
84 //              modexDrawSprite(&gvar.video.page[0], 160, 120, &bmp);\r
85         DrawPBuf(&gvar.video.page[0], 0, 0, p, 0);\r
86         t1 = (*clockw-start) /18.2;\r
87         while(!kbhit())\r
88         {\r
89         }\r
90         VGAmodeX(0, &gvar);\r
91         /*printf("\nmain=%Fp\n\n", &i);\r
92         printf("bmp.data=%Fp\n", bmp.data);\r
93         printf("*bmp.data=%Fp\n", *(bmp.data));\r
94         printf("&bmp.data=%Fp\n", &(bmp.data));*/\r
95 \r
96         /* print out the contents of each plane */\r
97         for(plane=0; plane < 4; plane++) {\r
98                 i=0;\r
99                 printf("Plane %d\n", plane);\r
100                 for(py=0; py < p->height; py++) {\r
101                         for(px=0; px < p->pwidth; px++) {\r
102                                 printf("%02X ", (int) p->plane[plane][i++]);\r
103                         }\r
104                         printf("\n");\r
105                 }\r
106         }\r
107         fprintf(stderr,"Project 16 planrpcx.exe. This is just a test file!\n");\r
108         fprintf(stderr,"version %s\n", VERSION);\r
109         fprintf(stderr,"%d\n", sizeof(p->plane));\r
110         fprintf(stderr,"pw=%d\n", p->width);\r
111         fprintf(stderr,"ph=%d\n", p->height);\r
112         fprintf(stderr,"ppw=%d\n", p->pwidth);\r
113         fprintf(stderr,"%d\n", sizeof(bmp));\r
114         planar_buf_free(p);\r
115         fprintf(stderr, "CPU to VGA: %f\n", t1);\r
116 //      fprintf(stderr, "VGA to VGA: %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