- // 0 is an invalid value for ids under vrs specifications,
- // so it is safe to flush ids to this value
- vrs_cont->anchor_sprite_id = 0;
- vrs_cont->current_sprite_id = 0;
+
+ // Calculate vrl offsets
+
+ // Count sprites
+ vrl_id_iter = (uint16_t huge *)(buffer + vrs_cont->vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST]);
+ while(vrl_id_iter[num_of_vrl]){
+ num_of_vrl++;
+ }
+ // Allocate memory for vrl line offsets table
+ vrl_line_offsets = malloc(sizeof(vrl1_vgax_offset_t *)*num_of_vrl);
+
+ vrl_headers_offsets = (uint32_t huge *)(buffer + vrs_cont->vrs_hdr->offset_table[VRS_HEADER_OFFSET_VRS_LIST]);
+ // Calculate line offsets for each vrl
+ for(i = 0; i < num_of_vrl; i++){
+ curr_vrl = (struct vrl1_vgax_header huge *)(buffer + vrl_headers_offsets[i]);
+
+ // Calc. vrl size as (next_offset - curr_offset)
+ if (i != num_of_vrl - 1){
+ vrl_size = vrl_headers_offsets[i+1] - vrl_headers_offsets[i] - sizeof(struct vrl1_vgax_header);
+ }
+ // If it's the last vrl, size is (next_vrs_struct_offset - curr_offset)
+ else{
+ vrl_size = vrs_cont->vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST] - vrl_headers_offsets[i] - sizeof(struct vrl1_vgax_header);
+ }
+ vrl_line_offsets[i] = vrl1_vgax_genlineoffsets(curr_vrl, (byte *)curr_vrl + sizeof(struct vrl1_vgax_header), vrl_size);
+ }
+ vrs_cont->vrl_line_offsets = vrl_line_offsets;