From 0b6d3fc8ae8869afab2a5c7070c3678fb7bde868 Mon Sep 17 00:00:00 2001 From: sparky4 Date: Fri, 26 Aug 2016 19:41:26 -0500 Subject: [PATCH] what?! OMG! --- src/lib/16_sprite.c | 113 -------------------------------------------- src/lib/16_sprite.h | 74 ----------------------------- 2 files changed, 187 deletions(-) delete mode 100755 src/lib/16_sprite.c delete mode 100755 src/lib/16_sprite.h diff --git a/src/lib/16_sprite.c b/src/lib/16_sprite.c deleted file mode 100755 index 11a063cd..00000000 --- a/src/lib/16_sprite.c +++ /dev/null @@ -1,113 +0,0 @@ -#include "src/lib/16_sprite.h" - -char* get_curr_anim_name(struct sprite *spri) -{ - // Retrive animation name list - struct vrs_header huge *vrs = spri->spritesheet->vrs_hdr; - uint32_t huge *anim_names_offsets = (uint32_t huge *) - ((byte huge *)vrs + - vrs->offset_table[VRS_HEADER_OFFSET_ANIMATION_NAME_LIST]); - - return (char *)(vrs + anim_names_offsets[spri->curr_anim]); -} - -void init_anim(struct sprite *spri, int anim_index) -{ - struct vrs_header huge *vrs = spri->spritesheet->vrs_hdr; - uint32_t huge *anim_lists_offsets = (uint32_t huge *) - ((byte huge *)vrs + - vrs->offset_table[VRS_HEADER_OFFSET_ANIMATION_LIST]); - struct vrs_animation_list_entry_t *anim_list = (struct vrs_animation_list_entry_t huge *) - ((byte huge *)vrs + - anim_lists_offsets[anim_index]); - - // Upon new animation, start from the first sprite in it - spri->curr_anim = anim_index; - spri->curr_anim_spri = 0; - spri->curr_spri_id = anim_list[0].sprite_id; - spri->delay = anim_list[0].delay; - - spri->curr_anim_list = anim_list; -} - - -int set_anim_by_id(struct sprite *spri, int anim_id) -{ - int new_anim_index = 0; - int iter_id; - struct vrs_header huge *vrs = spri->spritesheet->vrs_hdr; - // Retruve animation ids list - uint16_t huge *anim_ids = (uint16_t huge *) - ((byte huge *)vrs + - vrs->offset_table[VRS_HEADER_OFFSET_ANIMATION_ID_LIST]); - - // Loop through animation id untill match or end of list - while(iter_id = anim_ids[new_anim_index]) - { - // Return on successful match - if (iter_id == anim_id) - { - init_anim(spri, new_anim_index); - return 0; - } - new_anim_index++; - } - return -1; -} - -void print_anim_ids(struct sprite *spri) -{ - int new_anim_index = 0; - int iter_id; - struct vrs_header huge *vrs = spri->spritesheet->vrs_hdr; - // Retruve animation ids list - uint16_t huge *anim_ids = (uint16_t huge *) - ((byte huge *)vrs + - vrs->offset_table[VRS_HEADER_OFFSET_ANIMATION_ID_LIST]); - - if(!anim_ids[new_anim_index]) - exit(3); - // Loop through animation id untill match or end of list - while(iter_id = anim_ids[new_anim_index]) - { - // Return on successful match - new_anim_index++; - printf("%d, ", iter_id); - } -} - - -void animate_spri(struct sprite *spri) -{ - // Events go here - - // Draw sprite - get_vrl_by_id(spri->spritesheet, spri->curr_spri_id, spri->sprite_vrl_cont); - draw_vrl1_vgax_modex( spri->x, spri->y, - spri->sprite_vrl_cont->vrl_header, spri->sprite_vrl_cont->line_offsets, - spri->sprite_vrl_cont->buffer + sizeof(struct vrl1_vgax_header), - spri->sprite_vrl_cont->data_size); - - // Depending on delay, update indices - switch(spri->delay){ - // Delay = 0 means that sprite should loop. Nothing to change here - case 0: - break; - - // Delay = 1 means that on next time unit sprite should be changed - case 1: - spri->curr_anim_spri++; - - // If we hit the end of an animation sequence, restart it - if(!(spri->curr_spri_id = spri->curr_anim_list[spri->curr_anim_spri].sprite_id)){ - spri->curr_anim_spri = 0; - spri->curr_spri_id = spri->curr_anim_list[spri->curr_anim_spri].sprite_id; - } - spri->delay = spri->curr_anim_list[spri->curr_anim_spri].delay; - - // Delay > 1 means that we should not change sprite yet. Decrease delay - default: - spri->delay--; - break; - } -} diff --git a/src/lib/16_sprite.h b/src/lib/16_sprite.h deleted file mode 100755 index a93838ac..00000000 --- a/src/lib/16_sprite.h +++ /dev/null @@ -1,74 +0,0 @@ -/* Project 16 Source Code~ - * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover - * - * This file is part of Project 16. - * - * Project 16 is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Project 16 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see , or - * write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301 USA. - * - */ -#ifndef __16_SPRI__ -#define __16_SPRI__ - -#include "src/lib/16_vrs.h" -#include "src/lib/typdefst.h" - -struct sprite -{ - // VRS container from which we will extract animation and image data - struct vrs_container *spritesheet; - // Container for a vrl sprite - struct vrl_container *sprite_vrl_cont; - // Current sprite id - int curr_spri_id; - // Index of a current sprite in an animation sequence - int curr_anim_spri; - // Current animation sequence - struct vrs_animation_list_entry_t *curr_anim_list; - // Index of current animation in relevant VRS offsets table - int curr_anim; - // Delay in time units untill we should change sprite - int delay; - // Position of sprite on screen - int x, y; -}; - -/* Retrive current animation name of sprite -* In: -* + struct sprite *spri - sprite to retrive current animation sequence name from -* Out: -* + char* - animation sequence name -*/ -char* get_curr_anim_name(struct sprite *spri); - -/* Change sprite's current animation to the one given by id - * In: - * struct sprite *spri - sprite to manipulate on - * int id - id of a new animation sequence of th sprite - * Out: - * int - 0 on success, -1 on error - */ -int set_anim_by_id(struct sprite *spri, int id); - -/* Animate sprite, triggering any events and changing indices if necessary - * NB: if you want to change animation sequence after a specific sprite is shown, you should call animate_spri first - * In: - * + struct sprite *spri - sprite to animate - */ -void animate_spri(struct sprite *spri); - -void print_anim_ids(struct sprite *spri); - -#endif -- 2.39.5