"""ANM0 files handling. This module provides classes for handling the ANM0 file format. The ANM0 format is a format used in Touhou 6: EoSD to describe sprites and animations. Almost everything rendered in the game is described by an ANM0 file. """ from struct import pack, unpack from pytouhou.utils.helpers import read_string, get_logger from pytouhou.formats import WrongFormatError from pytouhou.formats.animation import Animation from pytouhou.formats.thtx import Texture logger = get_logger(__name__) #TODO: refactor/clean up class Script(list): def __init__(self): list.__init__(self) self.interrupts = {} class ANM0(Animation): _instructions = { 0: { 0: ('', 'delete'), 1: ('I', 'set_sprite'),
## it under the terms of the GNU General Public License as published ## by the Free Software Foundation; version 3 only. ## ## This program 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. ## from random import randrange, random from pytouhou.utils.helpers import get_logger from pytouhou.vm.common import MetaRegistry, instruction logger = get_logger(__name__) class ANMRunner(metaclass=MetaRegistry): __slots__ = ('_anm', '_sprite', 'running', 'sprite_index_offset', 'script', 'instruction_pointer', 'frame', 'waiting', 'handlers', 'variables', 'version', 'timeout') #TODO: check! formulae = {0: None, 1: lambda x: x ** 2, 2: lambda x: x ** 3, 3: lambda x: x ** 4, 4: lambda x: 2 * x - x ** 2, 5: lambda x: 2 * x - x ** 3, 6: lambda x: 2 * x - x ** 4,