OSDN Git Service

added a file and testing pcxtest on other machines
[proj16/16.git] / src / pcxtest.c
1 /* Project 16 Source Code~\r
2  * Copyright (C) 2012-2022 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\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/16_vl.h"\r
27 //#include "16/modex16/bitmap.h"\r
28 //#include "16/modex16/16render.h"\r
29 #include "src/lib/16_in.h"\r
30 \r
31 #include "src/lib/16_tail.h"\r
32 \r
33 static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */\r
34 \r
35 #define PCXBMPVAR               gvar.player[0].data\r
36 #define PCXBMP                  *PCXBMPVAR\r
37 #define PCXBMPPTR               PCXBMPVAR\r
38 \r
39 void main() {\r
40         static global_game_variables_t gvar;\r
41 //----  planar_buf_t *p;\r
42         word start;\r
43         float t1, t2;\r
44 \r
45         // DOSLIB: check our environment\r
46         probe_dos();\r
47 \r
48         // DOSLIB: what CPU are we using?\r
49         // NTS: I can see from the makefile Sparky4 intends this to run on 8088 by the -0 switch in CFLAGS.\r
50         //      So this code by itself shouldn't care too much what CPU it's running on. Except that other\r
51         //      parts of this project (DOSLIB itself) rely on CPU detection to know what is appropriate for\r
52         //      the CPU to carry out tasks. --J.C.\r
53         cpu_probe();\r
54 \r
55         // DOSLIB: check for VGA\r
56         if (!probe_vga()) {\r
57                 printf("VGA probe failed\n");\r
58                 return;\r
59         }\r
60         // hardware must be VGA or higher!\r
61         if (!(vga_state.vga_flags & VGA_IS_VGA)) {\r
62                 printf("This program requires VGA or higher graphics hardware\n");\r
63                 return;\r
64         }\r
65 \r
66 //0000  PCXBMP = bitmapLoadPcx("data/koishi~~.pcx");\r
67 //0000  PCXBMP = bitmapLoadPcx("data/chikyuu.pcx"/*, &gvar*/);\r
68         PCXBMP = bitmapLoadPcx("data/maryai4a.pcx");\r
69 //      PCXBMP = bitmapLoadPcx("data/koishi^^.pcx");\r
70 //      PCXBMP = bitmapLoadPcx("16/PCX_LIB/chikyuu.pcx");\r
71 //----  p = planar_buf_from_bitmap(PCXBMPPTR);\r
72 \r
73         VGAmodeX(1, 1, &gvar);\r
74         //--00  gvar.video.page[0]=modexDefaultPage(&gvar.video.page[0]);\r
75 \r
76         /* fix up the palette and everything */\r
77         modexPalUpdate(&PCXBMP->palette);\r
78 \r
79         /* clear and draw one sprite and one bitmap */\r
80         modexClearRegion(&gvar.video.page[0], 0, 0, gvar.video.page[0].width, gvar.video.page[0].height, 1);\r
81 \r
82         /* non sprite comparison */\r
83         /*start = *clockw;\r
84         //for(i=0; i<100 ;i++) {\r
85                 oldDrawBmp(VGA, 0, 0, PCXBMPPTR, 0);\r
86         //}\r
87 \r
88         start = *clockw;\r
89         //for(i=0; i<100 ;i++) {\r
90 //0000          modexDrawBmp(&gvar.video.page[0], 20, 20, PCXBMPPTR);\r
91                 modexDrawBmp(&gvar.video.page[0], 160, 120, PCXBMPPTR);\r
92         //}\r
93         t1 = (*clockw-start) /18.2;\r
94 \r
95         start = *clockw;\r
96         //for(i=0; i<100; i++) {\r
97 //0000          modexCopyPageRegion(&gvar.video.page[0], &gvar.video.page[0], 20, 20, 128, 20, 64, 64);\r
98                 modexCopyPageRegion(&gvar.video.page[0], &gvar.video.page[0], 0, 0, 0, 0, 320, 240);\r
99         //}\r
100         t2 = (*clockw-start)/18.2;*/\r
101 \r
102 \r
103         start = *clockw;\r
104         //for(i=0; i<100 ;i++) {\r
105                 oldDrawBmp(VGA, 0, 0, PCXBMPPTR, 1);\r
106         //}\r
107         t1 = (*clockw-start) /18.2;\r
108 \r
109 \r
110         start = *clockw;\r
111         //for(i=0; i<100 ;i++) {\r
112 //0000          modexDrawSprite(&gvar.video.page[0], 20, 20, PCXBMPPTR);\r
113                 modexDrawSprite(&(gvar.video.page[0]), 160, 120, PCXBMPPTR);\r
114                 modexDrawBmp(&gvar.video.page[0], 0, 128, PCXBMPPTR);\r
115         //}\r
116         t2 = (*clockw-start)/18.2;\r
117         //_fmemset(MK_FP(0xA000, 0), (int)p->plane, gvar.video.page[0].sw*(gvar.video.page[0].sh*2));\r
118         //modexDrawBmp(&gvar.video.page[0], 0, 0, PCXBMPPTR);\r
119         while(!kbhit())\r
120         {\r
121                 //DrawPBuf(&gvar.video.page[0], 0, 0, p, 0);\r
122         }\r
123         VGAmodeX(0, 1, &gvar);\r
124         /*printf("\nmain=%Fp\n\n", &i);\r
125         printf("PCXBMP.data=%Fp\n", PCXBMP.data);\r
126         printf("*PCXBMP.data=%Fp\n", *(PCXBMP.data));\r
127         printf("PCXBMPPTR.data=%Fp\n", &(PCXBMP.data));\r
128 \r
129         printf("\n%d\n", sizeof(p->plane));\r
130         printf("%d\n", sizeof(PCXBMP));*/\r
131 \r
132         /*for(i=0; i<(320*240); i++)\r
133         {\r
134                 fprintf(stdout, "%d", PCXBMP.data[i]);\r
135                 if(i%PCXBMP.width==0) fprintf(stdout, "\n");\r
136         }*/\r
137         printf("CPU to VGA: %f\n", t1);\r
138         printf("VGA to VGA: %f\n", t2);\r
139         printf("gvar.video.page[0].width: %u\n", gvar.video.page[0].width);\r
140         printf("gvar.video.page[0].height: %u\n", gvar.video.page[0].height);\r
141         return;\r
142 }\r