wwww
Revision | b462db3cf431325bd25c81a61351a2d67a454f51 (tree) |
---|---|
Zeit | 2016-08-24 17:09:20 |
Autor | sparky4 <sparky4@cock...> |
Commiter | sparky4 |
wwwwwwwwwwwwwwwwwwwwwwwwwwww vrstest.c works wwwwww yakui-lover wwwww look! wwww
@@ -8,7 +8,7 @@ char* get_curr_anim_name(struct sprite *spri) | ||
8 | 8 | ((byte huge *)vrs + |
9 | 9 | vrs->offset_table[VRS_HEADER_OFFSET_ANIMATION_NAME_LIST]); |
10 | 10 | |
11 | - return (char *)(vrs + anim_names_offsets[spri->curr_anim_spri]); | |
11 | + return (char *)(vrs + anim_names_offsets[spri->curr_anim]); | |
12 | 12 | } |
13 | 13 | |
14 | 14 | void init_anim(struct sprite *spri, int anim_index) |
@@ -22,6 +22,7 @@ void init_anim(struct sprite *spri, int anim_index) | ||
22 | 22 | anim_lists_offsets[anim_index]); |
23 | 23 | |
24 | 24 | // Upon new animation, start from the first sprite in it |
25 | + spri->curr_anim = anim_index; | |
25 | 26 | spri->curr_anim_spri = 0; |
26 | 27 | spri->curr_spri_id = anim_list[0].sprite_id; |
27 | 28 | spri->delay = anim_list[0].delay; |
@@ -44,7 +45,7 @@ int set_anim_by_id(struct sprite *spri, int anim_id) | ||
44 | 45 | while(iter_id = anim_ids[new_anim_index]) |
45 | 46 | { |
46 | 47 | // Return on successful match |
47 | - if (iter_id = anim_id) | |
48 | + if (iter_id == anim_id) | |
48 | 49 | { |
49 | 50 | init_anim(spri, new_anim_index); |
50 | 51 | return 0; |
@@ -64,7 +65,6 @@ void print_anim_ids(struct sprite *spri) | ||
64 | 65 | ((byte huge *)vrs + |
65 | 66 | vrs->offset_table[VRS_HEADER_OFFSET_ANIMATION_ID_LIST]); |
66 | 67 | |
67 | - printf("\nPos %lld off %lld\n", (uint32_t)vrs, vrs->offset_table[VRS_HEADER_OFFSET_ANIMATION_ID_LIST]); | |
68 | 68 | if(!anim_ids[new_anim_index]) |
69 | 69 | exit(3); |
70 | 70 | // Loop through animation id untill match or end of list |
@@ -79,15 +79,14 @@ void print_anim_ids(struct sprite *spri) | ||
79 | 79 | |
80 | 80 | void animate_spri(struct sprite *spri) |
81 | 81 | { |
82 | - struct vrl_container *vrl_cont; | |
83 | 82 | // Events go here |
84 | 83 | |
85 | 84 | // Draw sprite |
86 | - vrl_cont = get_vrl_by_id(spri->spritesheet, spri->curr_spri_id); | |
85 | + get_vrl_by_id(spri->spritesheet, spri->curr_spri_id, spri->sprite_vrl_cont); | |
87 | 86 | draw_vrl1_vgax_modex( spri->x, spri->y, |
88 | - vrl_cont->vrl_header, vrl_cont->line_offsets, | |
89 | - vrl_cont->buffer + sizeof(struct vrl1_vgax_header), | |
90 | - vrl_cont->size - sizeof(struct vrl1_vgax_header)); | |
87 | + spri->sprite_vrl_cont->vrl_header, spri->sprite_vrl_cont->line_offsets, | |
88 | + spri->sprite_vrl_cont->buffer + sizeof(struct vrl1_vgax_header), | |
89 | + spri->sprite_vrl_cont->data_size); | |
91 | 90 | |
92 | 91 | // Depending on delay, update indices |
93 | 92 | switch(spri->delay){ |
@@ -29,6 +29,8 @@ struct sprite | ||
29 | 29 | { |
30 | 30 | // VRS container from which we will extract animation and image data |
31 | 31 | struct vrs_container *spritesheet; |
32 | + // Container for a vrl sprite | |
33 | + struct vrl_container *sprite_vrl_cont; | |
32 | 34 | // Current sprite id |
33 | 35 | int curr_spri_id; |
34 | 36 | // Index of a current sprite in an animation sequence |
@@ -36,7 +36,7 @@ int read_vrs(global_game_variables_t *gvar, char *filename, struct vrs_container | ||
36 | 36 | byte huge *buffer; |
37 | 37 | vrl1_vgax_offset_t **vrl_line_offsets; |
38 | 38 | uint32_t huge *vrl_headers_offsets; |
39 | - uint32_t huge *vrl_id_iter; | |
39 | + uint16_t huge *vrl_id_iter; | |
40 | 40 | uint32_t vrl_size; |
41 | 41 | int num_of_vrl, i; |
42 | 42 | struct vrl1_vgax_header huge *curr_vrl; |
@@ -56,18 +56,18 @@ int read_vrs(global_game_variables_t *gvar, char *filename, struct vrs_container | ||
56 | 56 | fprintf(stderr, "Unablee to load file"); |
57 | 57 | exit(3); |
58 | 58 | } |
59 | - vrs_cont->size = size; | |
59 | + vrs_cont->data_size = size - sizeof(struct vrs_header); | |
60 | 60 | vrs_cont->buffer = buffer; |
61 | 61 | |
62 | 62 | // Calculate vrl offsets |
63 | 63 | |
64 | 64 | // Count sprites |
65 | - vrl_id_iter = (uint32_t huge *)(buffer + vrs_cont->vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST]); | |
65 | + vrl_id_iter = (uint16_t huge *)(buffer + vrs_cont->vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST]); | |
66 | 66 | while(vrl_id_iter[num_of_vrl]){ |
67 | 67 | num_of_vrl++; |
68 | 68 | } |
69 | 69 | // Allocate memory for vrl line offsets table |
70 | - vrl_line_offsets = malloc(sizeof(vrl1_vgax_offset_t)*num_of_vrl); | |
70 | + vrl_line_offsets = malloc(sizeof(vrl1_vgax_offset_t *)*num_of_vrl); | |
71 | 71 | |
72 | 72 | vrl_headers_offsets = (uint32_t huge *)(buffer + vrs_cont->vrs_hdr->offset_table[VRS_HEADER_OFFSET_VRS_LIST]); |
73 | 73 | // Calculate line offsets for each vrl |
@@ -76,68 +76,64 @@ int read_vrs(global_game_variables_t *gvar, char *filename, struct vrs_container | ||
76 | 76 | |
77 | 77 | // Calc. vrl size as (next_offset - curr_offset) |
78 | 78 | if (i != num_of_vrl - 1){ |
79 | - vrl_size = vrl_headers_offsets[i+1] - vrl_headers_offsets[i]; | |
79 | + vrl_size = vrl_headers_offsets[i+1] - vrl_headers_offsets[i] - sizeof(struct vrl1_vgax_header); | |
80 | 80 | } |
81 | 81 | // If it's the last vrl, size is (next_vrs_struct_offset - curr_offset) |
82 | 82 | else{ |
83 | - vrl_size = vrs_cont->vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST] - vrl_headers_offsets[i]; | |
83 | + vrl_size = vrs_cont->vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST] - vrl_headers_offsets[i] - sizeof(struct vrl1_vgax_header); | |
84 | 84 | } |
85 | - vrl_line_offsets[i] = vrl1_vgax_genlineoffsets(curr_vrl, (byte *)curr_vrl + sizeof(*curr_vrl), vrl_size - sizeof(*curr_vrl)); | |
85 | + vrl_line_offsets[i] = vrl1_vgax_genlineoffsets(curr_vrl, (byte *)curr_vrl + sizeof(struct vrl1_vgax_header), vrl_size); | |
86 | 86 | } |
87 | 87 | vrs_cont->vrl_line_offsets = vrl_line_offsets; |
88 | 88 | return 0; |
89 | 89 | } |
90 | 90 | |
91 | 91 | // Seek and return a specified .vrl blob from .vrs blob in far memory |
92 | -struct vrl_container * get_vrl_by_id(struct vrs_container /*huge*/ *vrs_cont, uint16_t id){ | |
92 | +int get_vrl_by_id(struct vrs_container /*huge*/ *vrs_cont, uint16_t id, struct vrl_container *vrl_cont){ | |
93 | 93 | uint16_t huge *ids; |
94 | 94 | uint32_t huge *vrl_offs_list; |
95 | - struct vrl_container huge *vrl_cont; | |
96 | 95 | int counter = 0; |
97 | 96 | |
98 | - // If id is invalid, return null | |
97 | + // If id is invalid, return -1 | |
99 | 98 | if(id == 0){ |
100 | 99 | // Probably add an error message? |
101 | - return 0; | |
100 | + return -1; | |
102 | 101 | } |
103 | 102 | |
104 | 103 | // Get id list from .vrs blob (base + offset) |
105 | - ids = (uint16_t huge*)vrs_cont->buffer + | |
106 | - (dword)vrs_cont->vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST]; | |
104 | + ids = (uint16_t huge*)(vrs_cont->buffer + | |
105 | + vrs_cont->vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST]); | |
107 | 106 | |
108 | 107 | // Loop through the id list until we found the right one or hit the end of the list |
109 | 108 | // Counter is keeping track of the offset(in ids/vrl blobs) |
110 | 109 | while(ids[counter] != id && ids[counter]){ |
111 | 110 | counter++; |
112 | 111 | } |
113 | - // Return null if we couldn't find the requested id | |
112 | + // Return -2 if we couldn't find the requested id | |
114 | 113 | if(!ids[counter]){ |
115 | 114 | // Error message? |
116 | - return 0; | |
115 | + return -2; | |
117 | 116 | } |
118 | 117 | |
119 | 118 | // Get vrl offsets list from .vrs blob (base + offset) |
120 | 119 | vrl_offs_list = (uint32_t huge *)(vrs_cont->buffer + |
121 | 120 | vrs_cont->vrs_hdr->offset_table[VRS_HEADER_OFFSET_VRS_LIST]); |
122 | 121 | |
123 | - // Allocate memory for vrl_cont | |
124 | - vrl_cont = (struct vrl_container *)malloc(sizeof(struct vrl_container)); | |
125 | - | |
126 | 122 | // Get vrl_header from .vrs (base + offset from vrl_list) |
127 | 123 | // Counter is number of vrls to skip (ids and vrls are aligned according to the .vrs specification) |
128 | 124 | vrl_cont->vrl_header = (struct vrl1_vgax_header huge *)(vrs_cont->buffer + vrl_offs_list[counter]); |
129 | 125 | |
130 | 126 | // Get .vrl size by integer arithmetics (next vrl offset - current vrl offset) |
131 | 127 | if(ids[counter+1]){ |
132 | - vrl_cont->size = vrl_offs_list[counter+1] - vrl_offs_list[counter]; | |
128 | + vrl_cont->data_size = vrl_offs_list[counter+1] - vrl_offs_list[counter] - sizeof(struct vrl1_vgax_header); | |
133 | 129 | } |
134 | 130 | // If we are retriving the last vrl, size is ids_list offset - current vrl offset, as next vrl offs is 0 |
135 | 131 | else{ |
136 | - vrl_cont->size = vrs_cont->vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST] - vrl_offs_list[counter]; | |
132 | + vrl_cont->data_size = vrs_cont->vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST] - vrl_offs_list[counter] - sizeof(struct vrl1_vgax_header); | |
137 | 133 | } |
138 | 134 | |
139 | 135 | // Retrive line offsets form .vrs |
140 | 136 | vrl_cont->line_offsets = vrs_cont->vrl_line_offsets[counter]; |
141 | 137 | |
142 | - return vrl_cont; | |
138 | + return 0; | |
143 | 139 | } |
@@ -31,7 +31,8 @@ | ||
31 | 31 | |
32 | 32 | struct vrs_container{ |
33 | 33 | // Size of a .vrs lob in memory |
34 | - dword size; | |
34 | + // minus header | |
35 | + dword data_size; | |
35 | 36 | union{ |
36 | 37 | byte huge *buffer; |
37 | 38 | struct vrs_header huge *vrs_hdr; |
@@ -42,7 +43,8 @@ struct vrs_container{ | ||
42 | 43 | |
43 | 44 | struct vrl_container{ |
44 | 45 | // Size of a .vrl blob in memory |
45 | - dword size; | |
46 | + // minus header | |
47 | + dword data_size; | |
46 | 48 | union{ |
47 | 49 | byte huge *buffer; |
48 | 50 | struct vrl1_vgax_header huge *vrl_header; |
@@ -66,10 +68,11 @@ int read_vrs(global_game_variables_t *gvar, char *filename, struct vrs_container | ||
66 | 68 | * + struct vrs_container *vrs_cont - pointer to the vrs_container |
67 | 69 | * with a loaded .vrs file |
68 | 70 | * + uint16_t id - id of the vrl to retrive |
71 | +* + struct vrl_container * vrl_cont - pointer to vrl_container to load to | |
69 | 72 | * Out: |
70 | -* struct vrl_container* - a pointer to a vrl_container with a pointer | |
73 | +* int - operation status | |
71 | 74 | * to the requested .vrl blob |
72 | 75 | */ |
73 | -struct vrl_container * get_vrl_by_id(struct vrs_container *vrs_cont, uint16_t id); | |
76 | +int get_vrl_by_id(struct vrs_container *vrs_cont, uint16_t id, struct vrl_container * vrl_cont); | |
74 | 77 | |
75 | 78 | #endif |
@@ -1,143 +1,229 @@ | ||
1 | -/* Project 16 Source Code~ | |
2 | - * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover | |
3 | - * | |
4 | - * This file is part of Project 16. | |
5 | - * | |
6 | - * Project 16 is free software; you can redistribute it and/or modify | |
7 | - * it under the terms of the GNU General Public License as published by | |
8 | - * the Free Software Foundation; either version 3 of the License, or | |
9 | - * (at your option) any later version. | |
10 | - * | |
11 | - * Project 16 is distributed in the hope that it will be useful, | |
12 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | - * GNU General Public License for more details. | |
15 | - * | |
16 | - * You should have received a copy of the GNU General Public License | |
17 | - * along with this program. If not, see <http://www.gnu.org/licenses/>, or | |
18 | - * write to the Free Software Foundation, Inc., 51 Franklin Street, | |
19 | - * Fifth Floor, Boston, MA 02110-1301 USA. | |
20 | - * | |
21 | - */ | |
22 | - | |
23 | -#include <stdio.h> | |
24 | -#include <dos.h> | |
25 | -#include <string.h> | |
26 | -#include "src/lib/modex16.h" | |
27 | -#include "src/lib/16_sprite.h" | |
28 | -#include "src/lib/16_ca.h" | |
29 | -#include "src/lib/16_mm.h" | |
30 | - | |
31 | -global_game_variables_t gvar; | |
32 | - | |
33 | -void main() { | |
34 | - mminfo_t mm; mminfotype mmi; | |
35 | - __segment sega; | |
36 | - void __based(sega)* bigbuffer; | |
37 | - int i; | |
38 | - word start; | |
39 | - int plane; | |
40 | - float t1, t2; | |
41 | - boolean baka; | |
42 | - byte *pal; | |
43 | - | |
44 | - // DOSLIB: check our environment | |
45 | - probe_dos(); | |
46 | - | |
47 | - // DOSLIB: what CPU are we using? | |
48 | - // NTS: I can see from the makefile Sparky4 intends this to run on 8088 by the -0 switch in CFLAGS. | |
49 | - // So this code by itself shouldn't care too much what CPU it's running on. Except that other | |
50 | - // parts of this project (DOSLIB itself) rely on CPU detection to know what is appropriate for | |
51 | - // the CPU to carry out tasks. --J.C. | |
52 | - cpu_probe(); | |
53 | - | |
54 | - // DOSLIB: check for VGA | |
55 | - if (!probe_vga()) { | |
56 | - printf("VGA probe failed\n"); | |
57 | - return; | |
58 | - } | |
59 | - // hardware must be VGA or higher! | |
60 | - if (!(vga_state.vga_flags & VGA_IS_VGA)) { | |
61 | - printf("This program requires VGA or higher graphics hardware\n"); | |
62 | - return; | |
63 | - } | |
64 | - | |
65 | - //bmp = bitmapLoadPcx("data/chikyuu.pcx"); | |
66 | - VGAmodeX(1, 1, &gvar); | |
67 | - gvar.video.page[0]=modexDefaultPage(&gvar.video.page[0]); | |
68 | - | |
69 | - mm.mmstarted=0; | |
70 | - MM_Startup(&mm, &mmi); | |
71 | - CA_Startup(&gvar); | |
72 | - if(CA_LoadFile("data/spri/chikyuu.vrs", &bigbuffer, &mm, &mmi)) baka=1; else baka=0; | |
73 | - | |
74 | - /* fix up the palette and everything */ | |
75 | - //modexPalUpdate1(bmp.palette); | |
76 | - //modexLoadPalFile("data/spri/chikyuu.pal", &pal); | |
77 | - //modexPalUpdate1(pal); | |
78 | - | |
79 | - /* clear and draw one sprite and one bitmap */ | |
80 | - modexClearRegion(&gvar.video.page[0], 0, 0, gvar.video.page[0].sw, gvar.video.page[0].sh, 1); | |
81 | - | |
82 | - /* non sprite comparison */ | |
83 | - start = *clockw; | |
84 | - //for(i=0; i<100 ;i++) { | |
85 | - // oldDrawBmp(VGA, 20, 20, &bmp, 0); | |
86 | - //} | |
87 | - | |
88 | - start = *clockw; | |
89 | - //for(i=0; i<100 ;i++) { | |
90 | -//0000 modexDrawBmp(&gvar.video.page[0], 20, 20, &bmp); | |
91 | - // modexDrawBmp(&gvar.video.page[0], 160, 120, &bmp); | |
92 | - //} | |
93 | - t1 = (*clockw-start) /18.2; | |
94 | - | |
95 | - start = *clockw; | |
96 | - //for(i=0; i<100; i++) { | |
97 | -//0000 modexCopyPageRegion(&gvar.video.page[0], &gvar.video.page[0], 20, 20, 128, 20, 64, 64); | |
98 | - modexCopyPageRegion(&gvar.video.page[0], &gvar.video.page[0], 0, 0, 0, 0, 320, 240); | |
99 | - //} | |
100 | - t2 = (*clockw-start)/18.2; | |
101 | - | |
102 | - | |
103 | - start = *clockw; | |
104 | - //for(i=0; i<100 ;i++) { | |
105 | - // oldDrawBmp(VGA, 20, 20, &bmp, 1); | |
106 | - //} | |
107 | - | |
108 | - | |
109 | - start = *clockw; | |
110 | - //for(i=0; i<100 ;i++) { | |
111 | -//0000 modexDrawSprite(&gvar.video.page[0], 20, 20, &bmp); | |
112 | - // modexDrawSprite(&gvar.video.page[0], 160, 120, &bmp); | |
113 | - //} | |
114 | - //_fmemset(MK_FP(0xA000, 0), (int)p->plane, gvar.video.page[0].sw*(gvar.video.page[0].sh*2)); | |
115 | - //modexDrawBmp(&gvar.video.page[0], 0, 0, &bmp); | |
116 | - while(!kbhit()) | |
117 | - { | |
118 | - //DrawPBuf(&gvar.video.page[0], 0, 0, p, 0); | |
119 | - } | |
120 | - VGAmodeX(0, 1, &gvar); | |
121 | - MM_FreePtr(&bigbuffer, &mm); | |
122 | - MM_Shutdown(&mm); | |
123 | - CA_Shutdown(&gvar); | |
124 | - /*printf("\nmain=%Fp\n\n", &i); | |
125 | - printf("bmp.data=%Fp\n", bmp.data); | |
126 | - printf("*bmp.data=%Fp\n", *(bmp.data)); | |
127 | - printf("&bmp.data=%Fp\n", &(bmp.data)); | |
128 | - | |
129 | - printf("\n%d\n", sizeof(p->plane)); | |
130 | - printf("%d\n", sizeof(bmp));*/ | |
131 | - | |
132 | - /*for(i=0; i<(320*240); i++) | |
133 | - { | |
134 | - fprintf(stdout, "%d", bmp.data[i]); | |
135 | - if(i%bmp.width==0) fprintf(stdout, "\n"); | |
136 | - }*/ | |
137 | - printf("CPU to VGA: %f\n", t1); | |
138 | - printf("VGA to VGA: %f\n", t2); | |
139 | - printf("gvar.video.page[0].width: %u\n", gvar.video.page[0].width); | |
140 | - printf("gvar.video.page[0].height: %u\n", gvar.video.page[0].height); | |
141 | - if(baka) printf("\nyay!\n"); | |
142 | - else printf("\npoo!\n"); | |
143 | -} | |
1 | +/* Project 16 Source Code~ | |
2 | + * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover | |
3 | + * | |
4 | + * This file is part of Project 16. | |
5 | + * | |
6 | + * Project 16 is free software; you can redistribute it and/or modify | |
7 | + * it under the terms of the GNU General Public License as published by | |
8 | + * the Free Software Foundation; either version 3 of the License, or | |
9 | + * (at your option) any later version. | |
10 | + * | |
11 | + * Project 16 is distributed in the hope that it will be useful, | |
12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | + * GNU General Public License for more details. | |
15 | + * | |
16 | + * You should have received a copy of the GNU General Public License | |
17 | + * along with this program. If not, see <http://www.gnu.org/licenses/>, or | |
18 | + * write to the Free Software Foundation, Inc., 51 Franklin Street, | |
19 | + * Fifth Floor, Boston, MA 02110-1301 USA. | |
20 | + * | |
21 | + */ | |
22 | + | |
23 | +#include <stdio.h> | |
24 | +#include <dos.h> | |
25 | +#include <string.h> | |
26 | +#include "src/lib/modex16.h" | |
27 | +#include "src/lib/16_sprite.h" | |
28 | +#include "src/lib/16_ca.h" | |
29 | +#include "src/lib/16_mm.h" | |
30 | + | |
31 | +global_game_variables_t gvar; | |
32 | + | |
33 | +void main() { | |
34 | + mminfo_t mm; mminfotype mmi; | |
35 | + __segment sega; | |
36 | + void __based(sega)* bigbuffer; | |
37 | + int i; | |
38 | + word start; | |
39 | + int plane; | |
40 | + float t1, t2; | |
41 | + boolean baka; | |
42 | + byte *pal; | |
43 | + int fd, size, size1; | |
44 | + struct sprite spri; | |
45 | + vrl1_vgax_offset_t * off, *off1; | |
46 | + struct vrs_container vrs; | |
47 | + vrl1_vgax_offset_t **vrl_line_offsets; | |
48 | + uint32_t huge *vrl_headers_offsets; | |
49 | + uint16_t huge *vrl_id_iter; | |
50 | + uint32_t vrl_size; | |
51 | + int num_of_vrl; | |
52 | + struct vrl1_vgax_header huge *curr_vrl; | |
53 | + struct vrl_container *vrl; | |
54 | + int success; | |
55 | + | |
56 | + | |
57 | + | |
58 | + // DOSLIB: check our environment | |
59 | + probe_dos(); | |
60 | + | |
61 | + // DOSLIB: what CPU are we using? | |
62 | + // NTS: I can see from the makefile Sparky4 intends this to run on 8088 by the -0 switch in CFLAGS. | |
63 | + // So this code by itself shouldn't care too much what CPU it's running on. Except that other | |
64 | + // parts of this project (DOSLIB itself) rely on CPU detection to know what is appropriate for | |
65 | + // the CPU to carry out tasks. --J.C. | |
66 | + cpu_probe(); | |
67 | + | |
68 | + // DOSLIB: check for VGA | |
69 | + if (!probe_vga()) { | |
70 | + printf("VGA probe failed\n"); | |
71 | + return; | |
72 | + } | |
73 | + // hardware must be VGA or higher! | |
74 | + if (!(vga_state.vga_flags & VGA_IS_VGA)) { | |
75 | + printf("This program requires VGA or higher graphics hardware\n"); | |
76 | + return; | |
77 | + } | |
78 | + | |
79 | + //bmp = bitmapLoadPcx("data/chikyuu.pcx"); | |
80 | + gvar.video.page[0]=modexDefaultPage(&gvar.video.page[0]); | |
81 | + | |
82 | + mm.mmstarted=0; | |
83 | + MM_Startup(&mm, &mmi); | |
84 | + CA_Startup(&gvar); | |
85 | + if(CA_LoadFile("data/spri/chikyuu.vrs", &bigbuffer, &mm, &mmi)) baka=1; else baka=0; | |
86 | + fd = open("data/spri/chikyuu.vrs", O_RDONLY|O_BINARY); | |
87 | + size = lseek(fd, 0, SEEK_END); | |
88 | + lseek(fd, 0, SEEK_SET); | |
89 | + close(fd); | |
90 | + // Insert sanity cheks later | |
91 | + vrs.buffer = bigbuffer; | |
92 | + vrs.data_size = size - sizeof(struct vrl1_vgax_header); | |
93 | + num_of_vrl = 0; | |
94 | + vrl_id_iter = (uint16_t huge *)(vrs.buffer + vrs.vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST]); | |
95 | + while(vrl_id_iter[num_of_vrl]){ | |
96 | + num_of_vrl++; | |
97 | + } | |
98 | + | |
99 | + // Allocate memory for vrl line offsets table | |
100 | + vrl_line_offsets = malloc(sizeof(vrl1_vgax_offset_t *)*num_of_vrl); | |
101 | + | |
102 | + vrl_headers_offsets = (uint32_t huge *)(vrs.buffer + vrs.vrs_hdr->offset_table[VRS_HEADER_OFFSET_VRS_LIST]); | |
103 | + // Calculate line offsets for each vrl | |
104 | + for(i = 0; i < num_of_vrl; i++){ | |
105 | + curr_vrl = (struct vrl1_vgax_header huge *)(vrs.buffer + vrl_headers_offsets[i]); | |
106 | + | |
107 | + // Calc. vrl size as (next_offset - curr_offset) | |
108 | + if (i != num_of_vrl - 1){ | |
109 | + vrl_size = vrl_headers_offsets[i+1] - vrl_headers_offsets[i] - sizeof(struct vrl1_vgax_header); | |
110 | + } | |
111 | + // If it's the last vrl, size is (next_vrs_struct_offset - curr_offset) | |
112 | + else{ | |
113 | + vrl_size = vrs.vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST] - vrl_headers_offsets[i] - sizeof(struct vrl1_vgax_header); | |
114 | + } | |
115 | + vrl_line_offsets[i] = vrl1_vgax_genlineoffsets(curr_vrl, (byte *)curr_vrl + sizeof(struct vrl1_vgax_header), vrl_size); | |
116 | + } | |
117 | + vrs.vrl_line_offsets = vrl_line_offsets; | |
118 | + | |
119 | + //read_vrs(&gvar, "data/spri/chikyuu.vrs", &vrs); | |
120 | + spri.spritesheet = &vrs; | |
121 | + spri.sprite_vrl_cont = malloc(sizeof(struct vrl_container)); | |
122 | + | |
123 | + vrl = malloc(sizeof(struct vrl_container)); | |
124 | + i = get_vrl_by_id(&vrs, 10, vrl); | |
125 | + if(i == -2) | |
126 | + { | |
127 | + puts("Die"); | |
128 | + return; | |
129 | + } | |
130 | + off = vrl1_vgax_genlineoffsets(curr_vrl/*vrl->buffer*/, vrl->buffer + sizeof(struct vrl1_vgax_header), vrl->data_size); | |
131 | + fd = open("data/spri/chikyuu.vrl", O_RDONLY|O_BINARY); | |
132 | + size = lseek(fd, 0, SEEK_END); | |
133 | + lseek(fd, 0, SEEK_SET); | |
134 | + close(fd); | |
135 | + | |
136 | + if(CA_LoadFile("data/spri/chikyuu.vrl", &bigbuffer, &mm, &mmi)) baka=1; else baka=0; | |
137 | + off1 = vrl1_vgax_genlineoffsets(bigbuffer, (byte *)bigbuffer + sizeof(struct vrl1_vgax_header), size - sizeof(struct vrl1_vgax_header)); | |
138 | + | |
139 | + | |
140 | + //read_vrs(&gvar, "data/spri/chikyuu.vrs", spri.spritesheet); | |
141 | + i = set_anim_by_id(&spri, 10); | |
142 | + if (i == -1) | |
143 | + { | |
144 | + return; | |
145 | + } | |
146 | + spri.x = spri.y = 70; | |
147 | + | |
148 | + | |
149 | + /* fix up the palette and everything */ | |
150 | + //modexPalUpdate1(bmp.palette); | |
151 | + //modexLoadPalFile("data/spri/chikyuu.pal", &pal); | |
152 | + //modexPalUpdate1(pal); | |
153 | + | |
154 | + /* clear and draw one sprite and one bitmap */ | |
155 | + VGAmodeX(1, 1, &gvar); | |
156 | + modexClearRegion(&gvar.video.page[0], 0, 0, gvar.video.page[0].sw, gvar.video.page[0].sh, 1); | |
157 | + | |
158 | + /* non sprite comparison */ | |
159 | + start = *clockw; | |
160 | + //for(i=0; i<100 ;i++) { | |
161 | + // oldDrawBmp(VGA, 20, 20, &bmp, 0); | |
162 | + //} | |
163 | + | |
164 | + start = *clockw; | |
165 | + //for(i=0; i<100 ;i++) { | |
166 | +//0000 modexDrawBmp(&gvar.video.page[0], 20, 20, &bmp); | |
167 | + // modexDrawBmp(&gvar.video.page[0], 160, 120, &bmp); | |
168 | + //} | |
169 | + t1 = (*clockw-start) /18.2; | |
170 | + | |
171 | + start = *clockw; | |
172 | + //for(i=0; i<100; i++) { | |
173 | +//0000 modexCopyPageRegion(&gvar.video.page[0], &gvar.video.page[0], 20, 20, 128, 20, 64, 64); | |
174 | + modexCopyPageRegion(&gvar.video.page[0], &gvar.video.page[0], 0, 0, 0, 0, 320, 240); | |
175 | + animate_spri(&spri); | |
176 | + draw_vrl1_vgax_modex(5,5,curr_vrl/*vrl->buffer*/,vrl->line_offsets,vrl->buffer + sizeof(struct vrl1_vgax_header),vrl->data_size); | |
177 | + draw_vrl1_vgax_modex(40,40,curr_vrl/*vrs.buffer*/ + vrl_headers_offsets[0],vrs.vrl_line_offsets[0],vrs.buffer + vrl_headers_offsets[0] + sizeof(struct vrl1_vgax_header),vrl_headers_offsets[1] - vrl_headers_offsets[0] - sizeof(struct vrl1_vgax_header)); | |
178 | + draw_vrl1_vgax_modex(100, 5, bigbuffer, off1, (byte *)bigbuffer + sizeof(struct vrl1_vgax_header), size - sizeof(struct vrl1_vgax_header)); | |
179 | + | |
180 | + //} | |
181 | + t2 = (*clockw-start)/18.2; | |
182 | + | |
183 | + //for (i = 0; i < 5; i++){ | |
184 | + //animate_spri(&spri); | |
185 | + | |
186 | + start = *clockw; | |
187 | + //for(i=0; i<100 ;i++) { | |
188 | + // oldDrawBmp(VGA, 20, 20, &bmp, 1); | |
189 | + //} | |
190 | + | |
191 | + | |
192 | + start = *clockw; | |
193 | + //for(i=0; i<100 ;i++) { | |
194 | +//0000 modexDrawSprite(&gvar.video.page[0], 20, 20, &bmp); | |
195 | + // modexDrawSprite(&gvar.video.page[0], 160, 120, &bmp); | |
196 | + //} | |
197 | + //_fmemset(MK_FP(0xA000, 0), (int)p->plane, gvar.video.page[0].sw*(gvar.video.page[0].sh*2)); | |
198 | + //modexDrawBmp(&gvar.video.page[0], 0, 0, &bmp); | |
199 | + while(!kbhit()) | |
200 | + { | |
201 | + //DrawPBuf(&gvar.video.page[0], 0, 0, p, 0); | |
202 | + } | |
203 | + VGAmodeX(0, 1, &gvar); | |
204 | + free(spri.sprite_vrl_cont); | |
205 | + MM_FreePtr(&bigbuffer, &mm); | |
206 | + //MM_FreePtr(&((void __based(sega)*)spri.spritesheet->buffer), &mm); | |
207 | + MM_Shutdown(&mm); | |
208 | + CA_Shutdown(&gvar); | |
209 | + /*printf("\nmain=%Fp\n\n", &i); | |
210 | + printf("bmp.data=%Fp\n", bmp.data); | |
211 | + printf("*bmp.data=%Fp\n", *(bmp.data)); | |
212 | + printf("&bmp.data=%Fp\n", &(bmp.data)); | |
213 | + | |
214 | + printf("\n%d\n", sizeof(p->plane)); | |
215 | + printf("%d\n", sizeof(bmp));*/ | |
216 | + | |
217 | + /*for(i=0; i<(320*240); i++) | |
218 | + { | |
219 | + fprintf(stdout, "%d", bmp.data[i]); | |
220 | + if(i%bmp.width==0) fprintf(stdout, "\n"); | |
221 | + }*/ | |
222 | + printf("CPU to VGA: %f\n", t1); | |
223 | + printf("VGA to VGA: %f\n", t2); | |
224 | + printf("gvar.video.page[0].width: %u\n", gvar.video.page[0].width); | |
225 | + printf("gvar.video.page[0].height: %u\n", gvar.video.page[0].height); | |
226 | + printf("Num %d", num_of_vrl); | |
227 | + if(baka) printf("\nyay!\n"); | |
228 | + else printf("\npoo!\n"); | |
229 | +} |
@@ -2,3 +2,8 @@ | ||
2 | 2 | wmake -h clean |
3 | 3 | wmake -h |
4 | 4 | wmake -h comp |
5 | +if [ -f *.err ] | |
6 | +then | |
7 | + echo dumping *.err | |
8 | + cat *.err | |
9 | +fi |