OSDN Git Service

no idea how to get joy buttons 2 and 3 to function.
[proj16/16.git] / src / vrstest.c
1 /* Project 16 Source Code~\r
2  * Copyright (C) 2012-2021 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 "src/lib/16_head.h"\r
24 #include "src/lib/16_tail.h"\r
25 #include "src/lib/16_vl.h"\r
26 #include "src/lib/16_spri.h"\r
27 #include "src/lib/16_pm.h"\r
28 #include "src/lib/16_ca.h"\r
29 #include "src/lib/16_mm.h"\r
30 \r
31 #ifdef __DEBUG_InputMgr__\r
32 extern boolean dbg_nointest;\r
33 #endif\r
34 boolean panswitch;\r
35 \r
36 static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */\r
37 \r
38 void main()\r
39 {\r
40         static global_game_variables_t gvar;\r
41         //__segment sega;\r
42         memptr bigbuffer;\r
43         int i;\r
44         word start,w;\r
45         float t1, t2;\r
46         //boolean baka;\r
47         entity_t enti;\r
48         //vrl1_vgax_offset_t * off, *off1;\r
49 /*      struct vrs_container vrs; vrl1_vgax_offset_t **vrl_line_offsets;\r
50         uint32_t far *vrl_headers_offsets;\r
51         uint16_t far *vrl_id_iter;\r
52         uint32_t vrl_size;\r
53         int num_of_vrl;\r
54         struct vrl1_vgax_header far *curr_vrl;\r
55         int size=0;\r
56 */\r
57 \r
58 #ifdef __DEBUG_InputMgr__\r
59         dbg_nointest=0;\r
60 #endif\r
61         Startup16(&gvar);\r
62 \r
63 /*      CA_LoadFile("data/spri/chikyuu.vrs", &bigbuffer, &gvar);\r
64 \r
65         // Insert sanity cheks later\r
66         vrs.buffer = bigbuffer;\r
67         vrs.data_size = size - sizeof(struct vrl1_vgax_header);\r
68         num_of_vrl = 0;\r
69         vrl_id_iter = (uint16_t far *)(vrs.buffer + vrs.vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST]);\r
70         while(vrl_id_iter[num_of_vrl]){\r
71                 num_of_vrl++;\r
72         }\r
73 \r
74         // Allocate memory for vrl line offsets table\r
75         vrl_line_offsets = malloc(sizeof(vrl1_vgax_offset_t *)*num_of_vrl);\r
76 \r
77         vrl_headers_offsets = (uint32_t far *)(vrs.buffer + vrs.vrs_hdr->offset_table[VRS_HEADER_OFFSET_VRS_LIST]);\r
78         // Calculate line offsets for each vrl\r
79         for(i = 0; i < num_of_vrl; i++){\r
80                 curr_vrl = (struct vrl1_vgax_header far *)(vrs.buffer + vrl_headers_offsets[i]);\r
81 \r
82                 // Calc. vrl size as (next_offset - curr_offset)\r
83                 if (i != num_of_vrl - 1){\r
84                         vrl_size = vrl_headers_offsets[i+1] - vrl_headers_offsets[i] - sizeof(struct vrl1_vgax_header);\r
85                 }\r
86                 // If it's the last vrl, size is (next_vrs_struct_offset - curr_offset)\r
87                 else{\r
88                         vrl_size = vrs.vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST] - vrl_headers_offsets[i] - sizeof(struct vrl1_vgax_header);\r
89                 }\r
90                 vrl_line_offsets[i] = vrl1_vgax_genlineoffsets(curr_vrl, (byte *)curr_vrl + sizeof(struct vrl1_vgax_header), vrl_size);\r
91         }\r
92         vrs.vrl_line_offsets = vrl_line_offsets;\r
93 \r
94 \r
95 //      read_vrs(&gvar, "data/spri/chikyuu.vrs", &vrs);\r
96 \r
97 \r
98         enti.spri.spritesheet = &vrs;\r
99         enti.spri.sprite_vrl_cont = malloc(sizeof(struct vrl_container));*/\r
100         VRS_LoadVRS("data/spri/chikyuu.vrs", &enti, &gvar);\r
101         i = set_anim_by_id(&(enti.spri), 31);\r
102         if (i == -1)\r
103         {\r
104                 //Quit(&gvar, "ERROR!! glitch IN FILE!\n");\r
105         }\r
106         enti.spri.x = TILEWH-4;\r
107         enti.spri.y = TILEWH;\r
108 \r
109 //      Uncomment to see broken sprites\r
110 /*      sega = mm.bufferseg;\r
111         if(CA_LoadFile("data/spri/CHUBACW1.vrl", &bigbuffer, &mm, &mmi)) baka=1; else baka=0;*/\r
112 \r
113         VGAmodeX(1, 1, &gvar);\r
114         modexHiganbanaPageSetup(&gvar);\r
115         VL_ShowPage(&gvar.video.page[0], 1, 0);\r
116 \r
117         /* non sprite comparison */\r
118         start = *clockw;\r
119         //modexCopyPageRegion(&gvar.video.page[0], &gvar.video.page[0], 0, 0, 0, 0, 320, 240);\r
120         t1 = (*clockw-start) /18.2;\r
121 \r
122         start = *clockw;\r
123 \r
124         t2 = (*clockw-start)/18.2;\r
125 \r
126         /*modexLoadPalFile("data/spri/chikyuu.pal", &pal);\r
127         modexPalUpdate(pal);*/\r
128         //modexClearRegion(&gvar.video.page[0], 0, 0, gvar.video.page[0].width, gvar.video.page[0].height, 2);\r
129         VL_LoadPalFile("data/spri/chikyuu.pal", &gvar.video.palette, &gvar);\r
130         for (i = 0; i < 10; i++){\r
131                 enti.spri.delay = 1;\r
132 \r
133                 if(i==5) set_anim_by_id(&enti.spri, 21);\r
134 \r
135                 animate_spri(&enti, &gvar.video);// enti.spri.x += 16;\r
136                 delay(500);\r
137         }\r
138 \r
139         while(!gvar.in.inst->Keyboard[sc_Escape])\r
140         {\r
141                 switch(w)\r
142                 {\r
143                         case 768:\r
144 //                              modexPalUpdate0(pal);\r
145                                 w=0;\r
146                         default:\r
147                                 w++;\r
148 //                              gvar.video.palette[w]=rand();\r
149                         break;\r
150                 }\r
151                 TAIL_FUNCTIONKEYDRAWJUNKNOMV\r
152                 if(gvar.in.inst->Keyboard[sc_F7]){ VL_ShowPage(&gvar.video.page[0], 1, 1);                                                      IN_UserInput(1, &gvar); }\r
153                 if(gvar.in.inst->Keyboard[sc_F6]){ VL_ShowPage(&gvar.video.page[0], 1, 0);                                                      IN_UserInput(1, &gvar); }\r
154                 if(gvar.in.inst->Keyboard[25]){ modexpdump(0, &gvar);  IN_UserInput(1, &gvar); } //p\r
155         }\r
156         VGAmodeX(0, 1, &gvar);\r
157         MM_ShowMemory(&gvar);\r
158         MM_DumpData(&gvar);\r
159         MM_Report_(&gvar);\r
160         Shutdown16(&gvar);\r
161         MM_FreePtr(&bigbuffer, &gvar);\r
162         //MM_FreePtr(&((void __based(sega)*)enti.spri.spritesheet->buffer), &mm);\r
163         //printf("CPU to VGA: %f\n", t1);\r
164         //printf("VGA to VGA: %f\n", t2);\r
165         //HC_heapdump(&gvar);\r
166         printf("Project 16 vrstest.exe. This is just a test file!\n");\r
167         printf("version %s\n", VERSION);\r
168         printf("t1: %f\n", t1);\r
169         printf("t2: %f\n", t2);\r
170 //0000  printf("gvar.video.page[0].width: %u\n", gvar.video.page[0].width);\r
171 //0000  printf("gvar.video.page[0].height: %u\n", gvar.video.page[0].height);\r
172 //      printf("Num %d", num_of_vrl);\r
173 //      if(baka) printf("\nyay!\n");\r
174 //      else printf("\npoo!\n");\r
175 }\r