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