]> 4ch.mooo.com Git - 16.git/blob - src/vrstest.c
==== MAJOR CHANGES ARE BEING MADE!! WWWW ====
[16.git] / src / vrstest.c
1 /* Project 16 Source Code~\r
2  * Copyright (C) 2012-2016 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_sprit.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 extern boolean dbg_nointest;\r
32 \r
33 static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */\r
34 static byte palette[768];\r
35 \r
36 void main()\r
37 {\r
38         static global_game_variables_t gvar;\r
39         //__segment sega;\r
40         memptr bigbuffer;\r
41         int i;\r
42         word start;\r
43         float t1, t2;\r
44         //boolean baka;\r
45         struct sprite spri;\r
46         //vrl1_vgax_offset_t * off, *off1;\r
47         struct vrs_container vrs;\r
48         vrl1_vgax_offset_t **vrl_line_offsets;\r
49         uint32_t far *vrl_headers_offsets;\r
50         uint16_t far *vrl_id_iter;\r
51         uint32_t vrl_size;\r
52         int num_of_vrl;\r
53         struct vrl1_vgax_header far *curr_vrl;\r
54         int size=0;\r
55         dbg_nointest=0;\r
56 \r
57         Startup16(&gvar);\r
58 \r
59         // What should be done by read_vrs:\r
60         CA_LoadFile("data/spri/chikyuu.vrs", &bigbuffer, &gvar);//) baka=1; else baka=0;\r
61 \r
62         // Insert sanity cheks later\r
63         vrs.buffer = bigbuffer;\r
64         vrs.data_size = size - sizeof(struct vrl1_vgax_header);\r
65         num_of_vrl = 0;\r
66         vrl_id_iter = (uint16_t far *)(vrs.buffer + vrs.vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST]);\r
67         while(vrl_id_iter[num_of_vrl]){\r
68                 num_of_vrl++;\r
69         }\r
70 \r
71         // Allocate memory for vrl line offsets table\r
72         vrl_line_offsets = malloc(sizeof(vrl1_vgax_offset_t *)*num_of_vrl);\r
73 \r
74         vrl_headers_offsets = (uint32_t far *)(vrs.buffer + vrs.vrs_hdr->offset_table[VRS_HEADER_OFFSET_VRS_LIST]);\r
75         // Calculate line offsets for each vrl\r
76         for(i = 0; i < num_of_vrl; i++){\r
77                 curr_vrl = (struct vrl1_vgax_header far *)(vrs.buffer + vrl_headers_offsets[i]);\r
78 \r
79                 // Calc. vrl size as (next_offset - curr_offset)\r
80                 if (i != num_of_vrl - 1){\r
81                         vrl_size = vrl_headers_offsets[i+1] - vrl_headers_offsets[i] - sizeof(struct vrl1_vgax_header);\r
82                 }\r
83                 // If it's the last vrl, size is (next_vrs_struct_offset - curr_offset)\r
84                 else{\r
85                         vrl_size = vrs.vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST] - vrl_headers_offsets[i] - sizeof(struct vrl1_vgax_header);\r
86                 }\r
87                 vrl_line_offsets[i] = vrl1_vgax_genlineoffsets(curr_vrl, (byte *)curr_vrl + sizeof(struct vrl1_vgax_header), vrl_size);\r
88         }\r
89         vrs.vrl_line_offsets = vrl_line_offsets;\r
90 \r
91 \r
92         //read_vrs(&gvar, "data/spri/chikyuu.vrs", &vrs);\r
93         spri.spritesheet = &vrs;\r
94         spri.sprite_vrl_cont = malloc(sizeof(struct vrl_container));\r
95         i = set_anim_by_id(&spri, 11);\r
96         if (i == -1)\r
97         {\r
98                 return;\r
99         }\r
100         spri.x = 5;\r
101         spri.y = 100;\r
102 \r
103 //      Uncomment to see broken sprites\r
104 /*      sega = mm.bufferseg;\r
105         if(CA_LoadFile("data/spri/CHUBACW1.vrl", &bigbuffer, &mm, &mmi)) baka=1; else baka=0;*/\r
106 \r
107         VGAmodeX(1, 1, &gvar);\r
108         modexHiganbanaPageSetup(&gvar.video);\r
109         VL_ShowPage(&gvar.video.page[0], 0, 1);\r
110 \r
111         /* non sprite comparison */\r
112         start = *clockw;\r
113         modexCopyPageRegion(&gvar.video.page[0], &gvar.video.page[0], 0, 0, 0, 0, 320, 240);\r
114         t1 = (*clockw-start) /18.2;\r
115 \r
116         start = *clockw;\r
117 \r
118         t2 = (*clockw-start)/18.2;\r
119 \r
120         /*modexLoadPalFile("data/spri/chikyuu.pal", &pal);\r
121         modexPalUpdate1(pal);*/\r
122         for (i = 0; i < 5; i++){\r
123         spri.delay = 1; animate_spri(&spri, &gvar); spri.x += 20; /*sleep(1);*/ }\r
124         VL_LoadPalFile("data/spri/chikyuu.pal", &palette);\r
125 \r
126         while(!IN_KeyDown(sc_Escape))\r
127         {\r
128                 /*switch(w)\r
129                 {\r
130                         case 1024:\r
131                                 modexPalUpdate0(pal);\r
132                                 w=0;\r
133                         default:\r
134                                 w++;\r
135                         break;\r
136                 }*/\r
137                 if(IN_KeyDown(24)){ modexpdump(&gvar.video.page[0]);  IN_UserInput(1,1); } //p\r
138 FUNCTIONKEYFUNCTIONS;\r
139         }\r
140         VGAmodeX(0, 1, &gvar);\r
141         MM_ShowMemory(&gvar);\r
142         MM_DumpData(&gvar);\r
143         MM_Report_(&gvar);\r
144         Shutdown16(&gvar);\r
145         free(spri.sprite_vrl_cont);\r
146         free(vrl_line_offsets);\r
147         MM_FreePtr(&bigbuffer, &gvar);\r
148         //MM_FreePtr(&((void __based(sega)*)spri.spritesheet->buffer), &mm);\r
149         //printf("CPU to VGA: %f\n", t1);\r
150         //printf("VGA to VGA: %f\n", t2);\r
151         heapdump(&gvar);\r
152         printf("Project 16 vrstest.exe. This is just a test file!\n");\r
153         printf("version %s\n", VERSION);\r
154         printf("t1: %f\n", t1);\r
155         printf("t2: %f\n", t2);\r
156 //0000  printf("gvar.video.page[0].width: %u\n", gvar.video.page[0].width);\r
157 //0000  printf("gvar.video.page[0].height: %u\n", gvar.video.page[0].height);\r
158         printf("Num %d", num_of_vrl);\r
159 //      if(baka) printf("\nyay!\n");\r
160 //      else printf("\npoo!\n");\r
161 }\r