repo_name
stringlengths
5
122
path
stringlengths
3
232
text
stringlengths
6
1.05M
lbovolini/ordena-comprime-enad
ordenacao/string_aux.c
<reponame>lbovolini/ordena-comprime-enad #include <stdio.h> #include <stdlib.h> #include "string_aux.h" // Retorna substring char *get_substring (char *string, int inicio, int fim) { if (inicio == fim) { printf ("Erro get_substring() Ini: %d Fim: %d\n", inicio, fim); exit (EXIT_FAILURE); } int i = 0; char *substring = NULL; fim--; if (!string) { printf ("Erro get_substring()\n"); exit (EXIT_FAILURE); } if (!(substring = (char*) malloc ((fim - inicio) * sizeof (char)))) { printf ("Erro get_substring()\n"); exit (EXIT_FAILURE); } while (i < (fim - inicio)) { substring[i] = string[inicio + i]; i++; } substring[i] = '\0'; return substring; } // SE COLUNA VAZIA, TIPO? float get_number (char *string, int inicio, int fim) { float num; char *substring = NULL; if (!string) { printf ("Erro get_num()\n"); exit (EXIT_FAILURE); } if (string[inicio] == '"') { inicio++; fim--; } substring = get_substring (string, inicio, fim); num = atof (substring); return num; }
lbovolini/ordena-comprime-enad
ordenacao/string_aux.h
// Retorna substring char *get_substring (char *, int, int); // Retorna numero float get_number (char *, int, int);
lbovolini/ordena-comprime-enad
compressao/compress.c
<reponame>lbovolini/ordena-comprime-enad /* !TODO * - Inserir arvore no arquivo comprimido * - Descomprimir * - Dividir em arquivos * - Comentar */ #include <stdio.h> #include <stdlib.h> #define BIT_MAIS_BAIXO 1 typedef struct code { int *code; char caracter; int tam; } bin_code; typedef struct lista { char caracter; int cont; struct lista *prox, *esq, *dir; } st_lista; typedef struct descritor_lista { int n; st_lista *prim; } descritor_lista; int CODE_MAX_SIZE = 0; bin_code *codigos_bin; int codigos_index = 0; // Cria descritor lista e retorna descritor_lista *cria_descritor_lista(void) { descritor_lista *descritor = NULL; if(!(descritor = (descritor_lista*)malloc(sizeof(descritor_lista)))) { printf("Falta de memoria!\n"); exit(1); } descritor->n = 0; descritor->prim = NULL; return descritor; } // Cria lista e retorna st_lista *cria_lista(char caracter) { st_lista *nova = NULL; if(!(nova = (st_lista*)malloc(sizeof(st_lista)))) { printf("Falta de memoria!\n"); exit(EXIT_FAILURE); } nova->caracter = caracter; nova->cont = 1; nova->prox = NULL; nova->esq = NULL; nova->dir = NULL; return nova; } /* Busca caracter na lista, se encontrado retorna sua posicao, se nao retorna NULL */ st_lista *busca_caracter(descritor_lista *descritor, char caracter) { st_lista *percorrer = NULL; percorrer = descritor->prim; if(!percorrer) return NULL; while(percorrer) { if(percorrer->caracter == caracter) return percorrer; percorrer = percorrer->prox; } // nao encontrado return NULL; } // Insere na lista void *insere_lista(descritor_lista *descritor, char caracter) { st_lista *existe = NULL; if(!descritor) return NULL; // Busca caracter na lista existe = busca_caracter(descritor, caracter); if(!existe) { st_lista *lista = NULL, *percorrer = NULL; lista = cria_lista(caracter); // Lista vazia if(descritor->prim == NULL) { descritor->prim = lista; } else { // Insere no fim percorrer = descritor->prim; while(percorrer->prox) percorrer = percorrer->prox; percorrer->prox = lista; } descritor->n++; } else { existe->cont++; } return NULL; } // Remove da lista st_lista *remove_lista(descritor_lista *descritor) { if(!descritor || !descritor->prim) return NULL; st_lista *percorrer = NULL; percorrer = descritor->prim; // remove do inicio descritor->prim = percorrer->prox; percorrer->prox = NULL; return percorrer; } /* Ordena a lista por InsertionSort https://en.wikipedia.org/wiki/Insertion_sort */ st_lista *ordena_lista(descritor_lista *descritor) { st_lista *pList = descritor->prim; // zero or one element in list if(pList == NULL || pList->prox == NULL) return pList; // head is the first element of resulting sorted list st_lista * head = NULL; while(pList != NULL) { st_lista * atual = pList; pList = pList->prox; if(head == NULL || atual->cont < head->cont) { // insert into the head of the sorted list // or as the first element into an empty sorted list atual->prox = head; head = atual; } else { // insert current element into proper position in non-empty sorted list st_lista *p = head; while(p != NULL) { if(p->prox == NULL || // last element of the sorted list atual->cont < p->prox->cont) // middle of the list { // insert into middle of the sorted list or as the last element atual->prox = p->prox; p->prox = atual; break; // done } p = p->prox; } } } descritor->prim = head; return head; } // Imprime lista void imprime_lista(descritor_lista *descritor) { if(!descritor || !descritor->prim) return; st_lista *percorrer = NULL; percorrer = descritor->prim; while(percorrer) { printf("%c ", percorrer->caracter); printf("%d\n", percorrer->cont); percorrer = percorrer->prox; } } // Insere ordenado na lista void *insere_ordenado_lista(descritor_lista *descritor, st_lista *lista) { st_lista *percorrer = NULL; if(!descritor) return NULL; // Lista vazia if(!descritor->prim || descritor->prim->cont >= lista->cont) { lista->prox = descritor->prim; descritor->prim = lista; return NULL; } percorrer = descritor->prim; while(percorrer->prox != NULL && percorrer->prox->cont < lista->cont) { percorrer = percorrer->prox; } lista->prox = percorrer->prox; percorrer->prox = lista; return NULL; } // Gera arvore de Huffman void *gera_arvore(descritor_lista *descritor) { st_lista *esq = NULL, *dir = NULL, *novo = NULL; if(!descritor || !descritor->prim) return NULL; while(descritor->prim->prox != NULL) { esq = remove_lista(descritor); dir = remove_lista(descritor); if(!esq || !dir) { printf("Erro gera_arvore\n"); exit(EXIT_FAILURE); } novo = cria_lista('\0'); novo->cont = esq->cont + dir->cont; novo->esq = esq; novo->dir = dir; insere_ordenado_lista(descritor, novo); } return NULL; } // Imprime arvore em ordem void imprime_arvore(st_lista *raiz) { st_lista *pRaiz = raiz; if(pRaiz != NULL) { imprime_arvore(pRaiz->esq); printf("%c - %d\n", pRaiz->caracter, pRaiz->cont); imprime_arvore(pRaiz->dir); } } // void imprime_vetor(int arr[], int n) { int i = 0; for (i = 0; i < n; i++) printf("%d", arr[i]); printf("\n"); } // Verifica se o no eh folha int folha(st_lista *raiz) { return !(raiz->esq) && !(raiz->dir) ; } void arrCpy(int src[], int dest[], int size) { int i = 0; for(i = 0; i < size; i++) { dest[i] = src[i]; } } // Aloca vetor de inteiros int *aloca_vetor(int n) { return (int*) malloc(n * sizeof(int)); } // Aloca vetor de codigos binarios bin_code *aloca_bin(int n) { return (bin_code*) malloc(n * sizeof(bin_code)); } // Prints huffman codes from the root of Huffman Tree. It uses arr[] to // store codes void imprime_codigos(st_lista *raiz, int arr[], int top) { // Assign 0 to left edge and recur if(raiz->esq) { arr[top] = 0; imprime_codigos(raiz->esq, arr, top + 1); } // Assign 1 to right edge and recur if(raiz->dir) { arr[top] = 1; imprime_codigos(raiz->dir, arr, top + 1); } // If this is a leaf node, then it contains one of the input // characters, print the character and its code from arr[] if (folha(raiz)) { printf("%d: ", raiz->caracter); imprime_vetor(arr, top); codigos_bin[codigos_index].caracter = raiz->caracter; codigos_bin[codigos_index].code = aloca_vetor(top); codigos_bin[codigos_index].tam = top; arrCpy(arr, codigos_bin[codigos_index].code, top); codigos_index++; } } // Retorna indice do codigo correspondente ao caracter int get_code_index(char caracter) { int i = 0; for (i = 0; i < CODE_MAX_SIZE; i++) { if(codigos_bin[i].caracter == caracter) return i; } return - 1; } // Main int main() { int i, j; long lSize; char *buffer; size_t result; FILE *arquivo = NULL, *arquivo_saida = NULL; descritor_lista *descritor = NULL; arquivo = fopen("microdados_enade_2014_CCSI.csv", "r"); if(!arquivo) { fputs("File error", stderr); exit(EXIT_FAILURE); } // obtem tamanho do arquivo fseek(arquivo , 0 , SEEK_END); lSize = ftell(arquivo); rewind(arquivo); // aloca memoria para todo o arquivo buffer = (char*) malloc(sizeof(char) * lSize); if(buffer == NULL) { fputs("Memory error", stderr); exit(EXIT_FAILURE); } // copia o arquivo para o buffer result = fread(buffer, 1, lSize, arquivo); if(result != lSize) { fputs("Reading error", stderr); exit (EXIT_FAILURE); } // fecha arquivo fclose (arquivo); descritor = cria_descritor_lista(); for(int i = 0; i <= lSize; i++) { insere_lista(descritor, *(buffer + i)); } ordena_lista(descritor); imprime_lista(descritor); CODE_MAX_SIZE = descritor->n; codigos_bin = aloca_bin(CODE_MAX_SIZE); gera_arvore(descritor); int arr[CODE_MAX_SIZE]; imprime_codigos(descritor->prim, arr, 0); /* for(i = 0; i < CODE_MAX_SIZE; ++i) { printf("!%d: ", codigos_bin[i].caracter); for(j = 0; j < codigos_bin[i].tam; j++) { printf("%d", codigos_bin[i].code[j]); } printf("\n"); } */ arquivo_saida = fopen("saida.bin", "w+b"); unsigned int saida = 0, mascara, aux; unsigned int numBits; int cont, total = 0; for(i = 0; i <= lSize; i++) { int index = get_code_index(buffer[i]); for(j = 0; j < codigos_bin[index].tam; j++) { char entrada = codigos_bin[index].code[j]; numBits = 1; //printf("entrada: %x saida: %x\n", entrada, saida); for(; numBits >= 1 && total < 32; total++) { saida = saida << 1; for(cont = 1, mascara = BIT_MAIS_BAIXO; cont < numBits; cont++) mascara = mascara << 1; aux = entrada & mascara; for(cont = 1; cont < numBits; cont++) aux = aux >> 1; saida = saida | aux; //printf("entrada: %x saida: %x\n", entrada, saida); numBits--; } if(total == 32) { //done fwrite(&saida, sizeof(unsigned int), 1, arquivo_saida); if(ferror(arquivo_saida)) { perror(__func__); exit(EXIT_FAILURE); } saida = 0; total = 0; } } } if(total != 0) { int desl = 32 - total; total = total << desl; //done fwrite(&saida, sizeof(unsigned int), 1, arquivo_saida); if(ferror(arquivo_saida)) { perror(__func__); exit(EXIT_FAILURE); } } // hexdump -C saida.bin // http://stackoverflow.com/questions/759707/efficient-way-of-storing-huffman-tree fclose(arquivo_saida); free (buffer); return EXIT_SUCCESS; }
lbovolini/ordena-comprime-enad
ordenacao/sort.h
<filename>ordenacao/sort.h #ifndef SORT #define SORT #include <string.h> // Insetionsort para strings void insertionsort (char **, int *, int **, int, int); // Quicksort para strings void quicksort_string (char **, int *, int **, int, int, int, int); // Quicksort para numeros void quicksort_number (char **, int *, int **, int, int, int, int); #endif
lbovolini/ordena-comprime-enad
ordenacao/main.c
/* !TODO * - Ordenar por 2 colunas * - Comentar */ #include <stdio.h> #include <stdlib.h> #include "sort.h" #include "string_aux.h" #include "aux.h" #define NUMBER 0 #define STRING 1 #define N 26162 // get_tipo_coluna(); int const indice_tipo_coluna[156] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // argc1 => arquivo // argv2 => coluna1 // argv3 => coluna2 // argv4 => algoritmo int main (int argc, char **argv) { FILE *arquivo_entrada = NULL; int coluna1 = 0; int num_linhas = N; int num_separadores = 156; int indice_linhas[num_linhas]; int **indice_separadores; char **arquivo_memoria; //long start_time, end_time; if (argc != 3) { printf ("Uso: %s <arquivo> <coluna1>\n", argv[0]); exit (EXIT_FAILURE); } arquivo_entrada = fopen (argv[1], "r"); if (!arquivo_entrada) { printf ("Erro ao abrir o arquivo"); exit (EXIT_FAILURE); } coluna1 = atoi (argv[2]); if ((coluna1 < 1) || (coluna1 > 155)) { printf ("Coluna1 invalida\n"); exit (EXIT_FAILURE); } inicializa_indice_linhas (indice_linhas, num_linhas); indice_separadores = aloca_indice_separadores (num_separadores, num_linhas); arquivo_memoria = carrega_arquivo_memoria (arquivo_entrada, num_linhas); fclose (arquivo_entrada); inicializa_indice_separadores (arquivo_memoria, indice_separadores, num_linhas); //start_time = wtime(); if (indice_tipo_coluna[coluna1 - 1] == NUMBER) { quicksort_number (arquivo_memoria, indice_linhas, indice_separadores, coluna1, num_linhas, 1, num_linhas - 1); } else { quicksort_string (arquivo_memoria, indice_linhas, indice_separadores, coluna1, num_linhas, 1, num_linhas - 1); } //end_time = wtime(); //printf("Tempo de calculo = %ld us = %ld s\n", (long) (end_time - start_time), ((long) (end_time - start_time)) / 1000000) ; imprime_arquivo (arquivo_memoria, indice_linhas, num_linhas); return EXIT_SUCCESS; }
zachary0249/Vectrix
vectrix.h
<gh_stars>1-10 #ifndef vx_H #define vx_H #include <iostream> #include <vector> #include <cmath> #include <fstream> #include <string> #include <stdio.h> #include <stdlib.h> #include <sstream> #include <cstdlib> #include <map> template <typename T> class vx { // defining class members private: std::vector<T> vectrix; unsigned rows; unsigned cols; public: vx(unsigned _rows, unsigned _cols, const T &_initial); // takes # rows, # cols, and the inital value for each cell vx(const vx<T> &elem); // copy constructor vx(const std::vector<T> &elem); vx(const std::vector<std::vector<T>> &elem); // takes 2D vector and returns as matrix virtual ~vx(); // deconstructor // operator overloading for math operations // matrix math vx<T> &operator=(const vx<T> &elem); vx<T> operator+(const vx<T> &elem); vx<T> &operator+=(const vx<T> &elem); vx<T> operator*(const vx<T> &elem); vx<T> &operator*=(const vx<T> &elem); vx<T> operator-(const vx<T> &elem); vx<T> &operator-=(const vx<T> &elem); vx<T> matmul(const vx<T> &elem1, const vx<T> &elem2); vx<T> transpose(); float sum(); float mean(); float median() const; float SD(); std::vector<T> flatten(); // flattens the matrix into a vector T max(); T min(); vx<T> &absolute(); // absolute value of a matrix std::vector<vx<T>> balance(const vx<T> &elem1, const vx<T> &elem2, const T value); // balances out two matrices such that their result is of the same order std::vector<T> diag_vec(); // returns the diagonal of a matrix // vector operations float dot_product(const vx<T> &elem); // dot product of two vectors float cross_product(const vx<T> &elem); // cross product of two vectors // scalar to matrix math vx<T> operator+(const T elem); vx<T> &operator+=(const T elem); vx<T> operator-(const T elem); vx<T> &operator-=(const T elem); vx<T> operator*(const T elem); vx<T> &operator*=(const T elem); vx<T> operator/(const T elem); vx<T> &operator/=(const T elem); vx<T> operator^(const T elem); // utility functions std::vector<unsigned> dims(bool print = true) const; // for matrix unsigned nitems() const; // for matrix unsigned nrows() const; // for matrix unsigned ncols() const; // for matrix vx<T> reshape(const unsigned rows, const unsigned cols); bool is_ragged(); // ragged meaning rows of different lengths void print() const; // prints the matrix T &operator()(const unsigned &row, const unsigned &col = 0); // accessing specific index of matrix const T &operator()(const unsigned &row, const unsigned &col = 0) const; // accessing specific index of (const) matrix unsigned digit_count() const; // max digits of elements in matrix }; /* DEFINING NON CLASS FUNCTIONS AND VARIABLES: */ static const double pi = 3.14159265358979323846; static const double e = 2.71828182845904523536; // gets the index given the cols and rows unsigned GetIndex(const unsigned &num_cols, const unsigned &_row, const unsigned &_col); // random number generation std::vector<double> getRandom_decimal(const unsigned n); // vector math template <typename T> std::vector<T> &add(std::vector<T> &elem1, std::vector<T> &elem2); // add two vectors template <typename T> std::vector<T> &add(std::vector<T> &elem1, const T &elem2); // add each member of a vector with a scalar template <typename T> std::vector<T> &subtract(std::vector<T> &elem1, const T &elem2); // subtract each member of a vector with a scalar template <typename T> std::vector<T> &subtract(std::vector<T> &elem1, std::vector<T> &elem2); // subtract two vectors template <typename T> std::vector<T> &scale(std::vector<T> &elem1, const T &elem2); // multiplies each member by the scale factor; to shrink the vector apply the inverse of the scalar template <typename T> float sum(const std::vector<T> &elem); template <typename T> float sum(const std::vector<std::vector<T>> &elem); template <typename T> float mean(const std::vector<T> &elem); template <typename T> float mean(const std::vector<std::vector<T>> &elem); template <typename T> float SD(std::vector<T> &elem); template <typename T> float SD(std::vector<std::vector<T>> &elem); template <typename T> vx<T> expand(const std::vector<T> &elem); // expands a 1D vector into a vx row Matrix template <typename T> T max(const std::vector<T> &elem); template <typename T> T max(const std::vector<std::vector<T>> &elem); template <typename T> T min(const std::vector<T> &elem); template <typename T> T min(const std::vector<std::vector<T>> &elem); template <typename T> float angle_between(const std::vector<T> &elem1, const std::vector<T> &elem2); // angle between two vectors; in degrees template <typename T> float distance(const std::vector<T> &elem); // Calculates the distance between two points (endpoints of the line); AKA vector magnitude template <typename T> float vec_angle(const std::vector<T> &elem); // gets the angle (direction) of a vector; in degrees template <typename T> float slope(const std::vector<T> &elem); template <typename T> float rad_to_deg(T value); template <typename T> float deg_to_rad(T value); template <typename T> std::vector<unsigned> dims(const std::vector<std::vector<T>> &elem, bool print = true); // for 2D vector template <typename T> bool is_ragged(const std::vector<std::vector<T>> &elem); // ragged meaning rows of different lengths template <typename T> void print(const T &elem); // prints scalar template <typename T> void print(const std::vector<T> &elem); // prints vector template <typename T> void print(const std::vector<std::vector<T>> &elem); // prints 2D vector template <typename T> T &absolute(T &value); template <typename T> std::vector<T> &absolute(std::vector<T> &elem); template <typename T> std::vector<std::vector<T>> &absolute(std::vector<std::vector<T>> &elem); template <typename T> unsigned nitems(const std::vector<std::vector<T>> &elem); template <typename T> unsigned nrows(const std::vector<std::vector<T>> &elem); template <typename T> unsigned ncols(const std::vector<std::vector<T>> &elem); template <typename T> std::vector<T> range1D(const T stop, const T start, const T increment); // range vector template <typename T> vx<T> range2D(const T stop, const T start, const T increment, const unsigned numrows); // range matrix template <typename T> unsigned digit_count(const T &num); template <typename T> unsigned digit_count(const std::vector<T> &elem); // returns the max digit count in vector template <typename T> std::vector<T> &sort(std::vector<T> &elem); template <typename T> float median(std::vector<T> &elem); #include "vectrix.cpp" #endif
TommyTu/Firework
src/gl/textures/TextureParameters.h
#ifndef TEXTUREPARAMETERS_H #define TEXTUREPARAMETERS_H #include "GL/glew.h" namespace CS123 { namespace GL { class Texture2D; class TextureParameters { public: enum class FILTER_METHOD { NEAREST = GL_NEAREST, LINEAR = GL_LINEAR }; enum class WRAP_METHOD { CLAMP_TO_EDGE = GL_CLAMP_TO_EDGE, REPEAT = GL_REPEAT }; void applyTo(const Texture2D &texture); friend class TextureParametersBuilder; private: TextureParameters(FILTER_METHOD filterMethod, WRAP_METHOD wrapMethod); FILTER_METHOD m_filterMethod; WRAP_METHOD m_wrapMethod; }; }} #endif // TEXTUREPARAMETERS_H
TommyTu/Firework
src/gl/textures/RenderBuffer.h
<filename>src/gl/textures/RenderBuffer.h #ifndef RENDERBUFFER_H #define RENDERBUFFER_H namespace CS123 { namespace GL { class RenderBuffer { public: RenderBuffer(); virtual ~RenderBuffer(); RenderBuffer(const RenderBuffer &that) = delete; RenderBuffer& operator=(const RenderBuffer &that) = delete; RenderBuffer(RenderBuffer &&that); RenderBuffer& operator=(RenderBuffer &&that); void bind() const; unsigned int id() const; void unbind() const; protected: unsigned int m_handle; }; }} #endif // RENDERBUFFER_H
TommyTu/Firework
src/openglshape.h
#ifndef OPENGLSHAPE_H #define OPENGLSHAPE_H #include "GL/glew.h" #include <memory> #include <vector> #include "gl/datatype/VBO.h" #include "gl/datatype/VBOAttribMarker.h" namespace CS123 { namespace GL { class VAO; }} using namespace CS123::GL; class OpenGLShape { public: OpenGLShape(); ~OpenGLShape(); /** Initialize the VBO with the given vertex data. */ void setVertexData(GLfloat *data, int size, VBO::GEOMETRY_LAYOUT drawMode, int numVertices); /** Enables the specified attribute and calls glVertexAttribPointer with the given arguments. */ void setAttribute(GLuint index, GLuint numElementsPerVertex, int offset, VBOAttribMarker::DATA_TYPE type, bool normalize); /** Build the VAO given the specified vertex data and atrributes */ void buildVAO(); /** Draw the initialized geometry. */ void draw(); private: GLfloat *m_data; /// vector of floats containing the vertex data. GLsizeiptr m_size; /// size of the data array, in bytes. VBO::GEOMETRY_LAYOUT m_drawMode; /// drawing mode int m_numVertices; /// number of vertices to be rendered std::vector<VBOAttribMarker> m_markers; /// list of VBOAttribMarkers that describe how the data is laid out. std::unique_ptr<CS123::GL::VAO> m_VAO; /// a wrapper for the vertex array object (VAO) }; #endif // OPENGLSHAPE_H
TommyTu/Firework
glew-1.10.0/auto/src/glew_str_head.c
<filename>glew-1.10.0/auto/src/glew_str_head.c<gh_stars>1000+ #ifdef GLEW_MX GLboolean GLEWAPIENTRY glewContextIsSupported (const GLEWContext* ctx, const char* name) #else GLboolean GLEWAPIENTRY glewIsSupported (const char* name) #endif { GLubyte* pos = (GLubyte*)name; GLuint len = _glewStrLen(pos); GLboolean ret = GL_TRUE; while (ret && len > 0) { if (_glewStrSame1(&pos, &len, (const GLubyte*)"GL_", 3)) {
TommyTu/Firework
src/mainwindow.h
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QList> #include "glwidget.h" namespace Ui { class MainWindow; } class DataBinding; class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); public slots: // Used internally to keep data bindings and settings in sync. void settingsChanged(); protected: // Overridden from QWidget void closeEvent(QCloseEvent *event); private: Ui::MainWindow *m_ui; QList<DataBinding *> m_bindings; GLWidget *m_glWidget; void dataBind(); }; #endif // MAINWINDOW_H
TommyTu/Firework
src/gl/textures/DepthBuffer.h
#ifndef DEPTHBUFFER_H #define DEPTHBUFFER_H #include "RenderBuffer.h" namespace CS123 { namespace GL { class DepthBuffer : public RenderBuffer { public: DepthBuffer(int width, int height); private: int m_width; int m_height; }; }} #endif // DEPTHBUFFER_H
TommyTu/Firework
src/glwidget.h
#ifndef GLWIDGET_H #define GLWIDGET_H #include "GL/glew.h" #include <QGLWidget> #include <QTimer> #include <QtMultimedia/QAudioOutput> #include "glm/glm.hpp" // glm::vec*, mat*, and basic glm functions #include "glm/gtx/transform.hpp" // glm::translate, scale, rotate #include "glm/gtc/type_ptr.hpp" // glm::value_ptr #include <memory> // std::unique_ptr #include "gl/datatype/FBO.h" class OpenGLShape; using namespace CS123::GL; class GLWidget : public QGLWidget { Q_OBJECT public: GLWidget(QGLFormat format, QWidget *parent = 0); ~GLWidget(); protected: void initializeGL(); void paintGL(); void resizeGL(int w, int h); void mousePressEvent(QMouseEvent *e); void mouseMoveEvent(QMouseEvent *e); void wheelEvent(QWheelEvent *e); private: void drawWater(); void drawParticles(); void setParticleViewport(); void rebuildMatrices(); int m_width; int m_height; GLuint m_waterProgram; GLuint m_terrainProgram; GLuint m_terrain_texture_id; std::unique_ptr<OpenGLShape> m_quad; std::unique_ptr<OpenGLShape> m_sphere; std::unique_ptr<FBO> m_blurFBO1; std::unique_ptr<FBO> m_blurFBO2; GLuint m_particlesVAO; std::shared_ptr<FBO> m_particlesFBO1; std::shared_ptr<FBO> m_particlesFBO2; bool m_firstPass; bool m_evenPass; int m_numParticles; QAudioOutput* m_audio; glm::mat4 m_view, m_projection; /** For mouse interaction. */ float m_angleX, m_angleY, m_zoom; QPoint m_prevMousePos; public slots: void finishedPlaying(QAudio::State newState); }; #endif // GLWIDGET_H
TommyTu/Firework
src/gl/GLDebug.h
<filename>src/gl/GLDebug.h<gh_stars>0 #ifndef GLDEBUG_H #define GLDEBUG_H #include "GL/glew.h" namespace CS123 { namespace GL { void checkError(); void printGLErrorCodeInEnglish(GLenum err); void checkFramebufferStatus(); void printFramebufferErrorCodeInEnglish(GLenum err); void checkShaderCompilationStatus(GLuint shaderID); void checkShaderLinkStatus(GLuint shaderProgramID); }} #endif // GLDEBUG_H
TommyTu/Firework
src/gl/textures/Texture.h
<reponame>TommyTu/Firework<filename>src/gl/textures/Texture.h #ifndef TEXTURE_H #define TEXTURE_H namespace CS123 { namespace GL { class Texture { public: Texture(); virtual ~Texture(); Texture(const Texture &that) = delete; Texture& operator=(const Texture &that) = delete; Texture(Texture &&that); Texture& operator=(Texture &&that); virtual void bind() const = 0; unsigned int id() const; virtual void unbind() const = 0; protected: unsigned int m_handle; }; }} #endif // TEXTURE_H
TommyTu/Firework
src/settings.h
#ifndef SETTINGS_H #define SETTINGS_H #include <QObject> // Enumeration values for the modes from which the user can choose in the GUI. enum Mode { MODE_WATER, MODE_PARTICLES, NUM_MODES }; /** @struct Settings @brief Stores application settings for the CS123 GUI. You can access all app settings through the "settings" global variable. The settings will be automatically updated when things are changed in the GUI (the reverse is not true however: changing the value of a setting does not update the GUI). */ struct Settings { // Loads settings from disk, or fills in default values if no saved settings exist. void loadSettingsOrDefaults(); // Saves the current settings to disk. void saveSettings(); bool useCameraMotion; bool useDispMapping; int color_r; int color_g; int color_b; int numFire; int numPar; int mode; // The currently selected mode. }; // The global Settings object, will be initialized by MainWindow extern Settings settings; #endif // SETTINGS_H
TommyTu/Firework
src/databinding.h
/*! @file Databinding.h @author <NAME> (<EMAIL>) @author <NAME> (<EMAIL>) @date Fall 2010 */ #ifndef DATABINDING_H #define DATABINDING_H #include <QObject> #include <QVariant> #include <QSlider> #include <QLineEdit> #include <QCheckBox> #include <QButtonGroup> #include <QRadioButton> #include <QDockWidget> #include <QTabWidget> #include <QDial> /*! @class DataBinding @brief Binds a slider and a textbox to an int. This class binds a slider and a textbox to an int, so when either the slider or the textbox is changed, the other is also changed and the int is updated with the new value. This does not update either the slider or the textbox when the int is set to a new value. **/ class DataBinding : public QObject { Q_OBJECT public: DataBinding(QObject *parent = 0) : QObject(parent) {} virtual ~DataBinding() {} signals: void dataChanged(); }; /** * @class BoolBinding * * This class binds a checkbox to a bool, so when the checkbox is changed the bool is updated * with the new value. This does not update the checkbox when the bool is set to a new value. */ class BoolBinding : public DataBinding { Q_OBJECT public: virtual ~BoolBinding() {} static BoolBinding* bindCheckbox(QCheckBox *checkbox, bool &value); private slots: void boolChanged(bool newValue); private: BoolBinding(bool &value) : DataBinding(), m_value(value) {} bool &m_value; }; class IntBinding : public DataBinding { Q_OBJECT public: virtual ~IntBinding() {} static IntBinding* bindSliderAndTextbox( QSlider *slider, QLineEdit *textbox, int &value, int minValue, int maxValue); static IntBinding* bindTextbox(QLineEdit *textbox, int &value); private slots: void intChanged(int newValue); void stringChanged(QString newValue); signals: void updateInt(int newValue); void updateString(QString newValue); private: IntBinding(int &value) : DataBinding(), m_value(value) {} static void connectToSliders(IntBinding* binding, QSlider *slider, QLineEdit *textbox); static void setWidgetValues(QSlider *slider, QLineEdit *textbox, int value, int minValue, int maxValue); int &m_value; }; /*! @class ChoiceBinding @brief Binds a group of radio buttons to an int (enum) value. This class binds a group of radio buttons to an int, so when a radio button is clicked the int is updated with the index of the currently checked button in the group. This does not update the radio buttons when the int is set to a new value. **/ class ChoiceBinding : public DataBinding { Q_OBJECT public: virtual ~ChoiceBinding() {} static ChoiceBinding* bindRadioButtons(int numRadioButtons, int &value, ...); static ChoiceBinding* bindTabs(QTabWidget *tabs, int &value); private slots: void intChanged(int newValue); private: ChoiceBinding(int &value) : DataBinding(), m_value(value) {} int &m_value; }; #endif // DATABINDING_H
TommyTu/Firework
src/gl/datatype/VBOAttribMarker.h
#ifndef VBOATTRIBMARKER_H #define VBOATTRIBMARKER_H #include <string> #include "GL/glew.h" namespace CS123 { namespace GL { struct VBOAttribMarker { enum DATA_TYPE{ FLOAT = GL_FLOAT, INT = GL_INT, UNSIGNED_BYTE = GL_UNSIGNED_BYTE }; enum DATA_NORMALIZE{ GLTRUE = GL_TRUE, GLFALSE = GL_FALSE }; /** * @brief VBOAttribMarker * @param name OpenGL handle to the attribute location. These are specified in ShaderAttribLocations.h * @param numElementsPerVertex Number of elements per vertex. Must be 1, 2, 3 or 4 (e.g. position = 3 for x,y,z) * @param offset Offset in BYTES from the start of the array to the beginning of the first element * @param type Primitive type (FLOAT, INT, UNSIGNED_BYTE) * @param normalize */ VBOAttribMarker(GLuint name, GLuint numElementsPerVertex, int offset, DATA_TYPE type = FLOAT, bool normalize = false); GLuint name; DATA_TYPE dataType; DATA_NORMALIZE dataNormalize; GLuint numElements; size_t offset; }; }} #endif // VBOATTRIBMARKER_H
TommyTu/Firework
cs123_lib/resourceloader.h
<filename>cs123_lib/resourceloader.h #ifndef SHADER_H #define SHADER_H #include "GL/glew.h" class ResourceLoader { public: ResourceLoader(); static GLuint createShaderProgram(const char * vertex_file_path,const char * fragment_file_path); static void initializeGlew(); private: static GLuint createShader(GLenum shaderType, const char *filepath); }; #endif // SHADER_H
TommyTu/Firework
cs123_lib/sphere.h
#ifndef SPHERE_H #define SPHERE_H // 600 hard-coded sphere vertices weeee... #define NUM_SPHERE_VERTICES 600 #define SPHERE_VERTEX_POSITIONS {\ 0.154508, 0.475528, 0, \ -2.18557e-08, 0.5, -0, \ -1.76816e-08, 0.5, -1.28465e-08, \ 0.125, 0.475528, 0.0908178, \ 0.154508, 0.475528, 0, \ -1.76816e-08, 0.5, -1.28465e-08, \ 0.125, 0.475528, 0.0908178, \ -1.76816e-08, 0.5, -1.28465e-08, \ -6.75378e-09, 0.5, -2.0786e-08, \ 0.0477457, 0.475528, 0.146946, \ 0.125, 0.475528, 0.0908178, \ -6.75378e-09, 0.5, -2.0786e-08, \ 0.0477457, 0.475528, 0.146946, \ -6.75378e-09, 0.5, -2.0786e-08, \ 6.75378e-09, 0.5, -2.0786e-08, \ -0.0477458, 0.475528, 0.146946, \ 0.0477457, 0.475528, 0.146946, \ 6.75378e-09, 0.5, -2.0786e-08, \ -0.0477458, 0.475528, 0.146946, \ 6.75378e-09, 0.5, -2.0786e-08, \ 1.76816e-08, 0.5, -1.28465e-08, \ -0.125, 0.475528, 0.0908178, \ -0.0477458, 0.475528, 0.146946, \ 1.76816e-08, 0.5, -1.28465e-08, \ -0.125, 0.475528, 0.0908178, \ 1.76816e-08, 0.5, -1.28465e-08, \ 2.18557e-08, 0.5, 1.91069e-15, \ -0.154508, 0.475528, -1.35076e-08, \ -0.125, 0.475528, 0.0908178, \ 2.18557e-08, 0.5, 1.91069e-15, \ -0.154508, 0.475528, -1.35076e-08, \ 2.18557e-08, 0.5, 1.91069e-15, \ 1.76816e-08, 0.5, 1.28465e-08, \ -0.125, 0.475528, -0.0908178, \ -0.154508, 0.475528, -1.35076e-08, \ 1.76816e-08, 0.5, 1.28465e-08, \ -0.125, 0.475528, -0.0908178, \ 1.76816e-08, 0.5, 1.28465e-08, \ 6.75378e-09, 0.5, 2.0786e-08, \ -0.0477458, 0.475528, -0.146946, \ -0.125, 0.475528, -0.0908178, \ 6.75378e-09, 0.5, 2.0786e-08, \ -0.0477458, 0.475528, -0.146946, \ 6.75378e-09, 0.5, 2.0786e-08, \ -6.75378e-09, 0.5, 2.0786e-08, \ 0.0477458, 0.475528, -0.146946, \ -0.0477458, 0.475528, -0.146946, \ -6.75378e-09, 0.5, 2.0786e-08, \ 0.0477458, 0.475528, -0.146946, \ -6.75378e-09, 0.5, 2.0786e-08, \ -1.76816e-08, 0.5, 1.28465e-08, \ 0.125, 0.475528, -0.0908178, \ 0.0477458, 0.475528, -0.146946, \ -1.76816e-08, 0.5, 1.28465e-08, \ 0.125, 0.475528, -0.0908178, \ -1.76816e-08, 0.5, 1.28465e-08, \ -2.18557e-08, 0.5, -3.82137e-15, \ 0.154508, 0.475528, 2.70151e-08, \ 0.125, 0.475528, -0.0908178, \ -2.18557e-08, 0.5, -3.82137e-15, \ 0.293893, 0.404508, 0, \ 0.154508, 0.475528, 0, \ 0.125, 0.475528, 0.0908178, \ 0.237764, 0.404508, 0.172746, \ 0.293893, 0.404508, 0, \ 0.125, 0.475528, 0.0908178, \ 0.237764, 0.404508, 0.172746, \ 0.125, 0.475528, 0.0908178, \ 0.0477457, 0.475528, 0.146946, \ 0.0908178, 0.404508, 0.279509, \ 0.237764, 0.404508, 0.172746, \ 0.0477457, 0.475528, 0.146946, \ 0.0908178, 0.404508, 0.279509, \ 0.0477457, 0.475528, 0.146946, \ -0.0477458, 0.475528, 0.146946, \ -0.0908178, 0.404508, 0.279509, \ 0.0908178, 0.404508, 0.279509, \ -0.0477458, 0.475528, 0.146946, \ -0.0908178, 0.404508, 0.279509, \ -0.0477458, 0.475528, 0.146946, \ -0.125, 0.475528, 0.0908178, \ -0.237764, 0.404508, 0.172746, \ -0.0908178, 0.404508, 0.279509, \ -0.125, 0.475528, 0.0908178, \ -0.237764, 0.404508, 0.172746, \ -0.125, 0.475528, 0.0908178, \ -0.154508, 0.475528, -1.35076e-08, \ -0.293893, 0.404508, -2.56929e-08, \ -0.237764, 0.404508, 0.172746, \ -0.154508, 0.475528, -1.35076e-08, \ -0.293893, 0.404508, -2.56929e-08, \ -0.154508, 0.475528, -1.35076e-08, \ -0.125, 0.475528, -0.0908178, \ -0.237764, 0.404508, -0.172746, \ -0.293893, 0.404508, -2.56929e-08, \ -0.125, 0.475528, -0.0908178, \ -0.237764, 0.404508, -0.172746, \ -0.125, 0.475528, -0.0908178, \ -0.0477458, 0.475528, -0.146946, \ -0.0908179, 0.404508, -0.279509, \ -0.237764, 0.404508, -0.172746, \ -0.0477458, 0.475528, -0.146946, \ -0.0908179, 0.404508, -0.279509, \ -0.0477458, 0.475528, -0.146946, \ 0.0477458, 0.475528, -0.146946, \ 0.0908179, 0.404508, -0.279509, \ -0.0908179, 0.404508, -0.279509, \ 0.0477458, 0.475528, -0.146946, \ 0.0908179, 0.404508, -0.279509, \ 0.0477458, 0.475528, -0.146946, \ 0.125, 0.475528, -0.0908178, \ 0.237764, 0.404508, -0.172746, \ 0.0908179, 0.404508, -0.279509, \ 0.125, 0.475528, -0.0908178, \ 0.237764, 0.404508, -0.172746, \ 0.125, 0.475528, -0.0908178, \ 0.154508, 0.475528, 2.70151e-08, \ 0.293893, 0.404508, 5.13858e-08, \ 0.237764, 0.404508, -0.172746, \ 0.154508, 0.475528, 2.70151e-08, \ 0.404509, 0.293893, 0, \ 0.293893, 0.404508, 0, \ 0.237764, 0.404508, 0.172746, \ 0.327254, 0.293893, 0.237764, \ 0.404509, 0.293893, 0, \ 0.237764, 0.404508, 0.172746, \ 0.327254, 0.293893, 0.237764, \ 0.237764, 0.404508, 0.172746, \ 0.0908178, 0.404508, 0.279509, \ 0.125, 0.293893, 0.38471, \ 0.327254, 0.293893, 0.237764, \ 0.0908178, 0.404508, 0.279509, \ 0.125, 0.293893, 0.38471, \ 0.0908178, 0.404508, 0.279509, \ -0.0908178, 0.404508, 0.279509, \ -0.125, 0.293893, 0.38471, \ 0.125, 0.293893, 0.38471, \ -0.0908178, 0.404508, 0.279509, \ -0.125, 0.293893, 0.38471, \ -0.0908178, 0.404508, 0.279509, \ -0.237764, 0.404508, 0.172746, \ -0.327254, 0.293893, 0.237764, \ -0.125, 0.293893, 0.38471, \ -0.237764, 0.404508, 0.172746, \ -0.327254, 0.293893, 0.237764, \ -0.237764, 0.404508, 0.172746, \ -0.293893, 0.404508, -2.56929e-08, \ -0.404509, 0.293893, -3.53633e-08, \ -0.327254, 0.293893, 0.237764, \ -0.293893, 0.404508, -2.56929e-08, \ -0.404509, 0.293893, -3.53633e-08, \ -0.293893, 0.404508, -2.56929e-08, \ -0.237764, 0.404508, -0.172746, \ -0.327254, 0.293893, -0.237764, \ -0.404509, 0.293893, -3.53633e-08, \ -0.237764, 0.404508, -0.172746, \ -0.327254, 0.293893, -0.237764, \ -0.237764, 0.404508, -0.172746, \ -0.0908179, 0.404508, -0.279509, \ -0.125, 0.293893, -0.38471, \ -0.327254, 0.293893, -0.237764, \ -0.0908179, 0.404508, -0.279509, \ -0.125, 0.293893, -0.38471, \ -0.0908179, 0.404508, -0.279509, \ 0.0908179, 0.404508, -0.279509, \ 0.125, 0.293893, -0.38471, \ -0.125, 0.293893, -0.38471, \ 0.0908179, 0.404508, -0.279509, \ 0.125, 0.293893, -0.38471, \ 0.0908179, 0.404508, -0.279509, \ 0.237764, 0.404508, -0.172746, \ 0.327254, 0.293893, -0.237764, \ 0.125, 0.293893, -0.38471, \ 0.237764, 0.404508, -0.172746, \ 0.327254, 0.293893, -0.237764, \ 0.237764, 0.404508, -0.172746, \ 0.293893, 0.404508, 5.13858e-08, \ 0.404509, 0.293893, 7.07265e-08, \ 0.327254, 0.293893, -0.237764, \ 0.293893, 0.404508, 5.13858e-08, \ 0.475528, 0.154508, 0, \ 0.404509, 0.293893, 0, \ 0.327254, 0.293893, 0.237764, \ 0.38471, 0.154508, 0.279509, \ 0.475528, 0.154508, 0, \ 0.327254, 0.293893, 0.237764, \ 0.38471, 0.154508, 0.279509, \ 0.327254, 0.293893, 0.237764, \ 0.125, 0.293893, 0.38471, \ 0.146946, 0.154508, 0.452254, \ 0.38471, 0.154508, 0.279509, \ 0.125, 0.293893, 0.38471, \ 0.146946, 0.154508, 0.452254, \ 0.125, 0.293893, 0.38471, \ -0.125, 0.293893, 0.38471, \ -0.146946, 0.154508, 0.452254, \ 0.146946, 0.154508, 0.452254, \ -0.125, 0.293893, 0.38471, \ -0.146946, 0.154508, 0.452254, \ -0.125, 0.293893, 0.38471, \ -0.327254, 0.293893, 0.237764, \ -0.38471, 0.154508, 0.279508, \ -0.146946, 0.154508, 0.452254, \ -0.327254, 0.293893, 0.237764, \ -0.38471, 0.154508, 0.279508, \ -0.327254, 0.293893, 0.237764, \ -0.404509, 0.293893, -3.53633e-08, \ -0.475528, 0.154508, -4.1572e-08, \ -0.38471, 0.154508, 0.279508, \ -0.404509, 0.293893, -3.53633e-08, \ -0.475528, 0.154508, -4.1572e-08, \ -0.404509, 0.293893, -3.53633e-08, \ -0.327254, 0.293893, -0.237764, \ -0.38471, 0.154508, -0.279509, \ -0.475528, 0.154508, -4.1572e-08, \ -0.327254, 0.293893, -0.237764, \ -0.38471, 0.154508, -0.279509, \ -0.327254, 0.293893, -0.237764, \ -0.125, 0.293893, -0.38471, \ -0.146946, 0.154508, -0.452254, \ -0.38471, 0.154508, -0.279509, \ -0.125, 0.293893, -0.38471, \ -0.146946, 0.154508, -0.452254, \ -0.125, 0.293893, -0.38471, \ 0.125, 0.293893, -0.38471, \ 0.146946, 0.154508, -0.452254, \ -0.146946, 0.154508, -0.452254, \ 0.125, 0.293893, -0.38471, \ 0.146946, 0.154508, -0.452254, \ 0.125, 0.293893, -0.38471, \ 0.327254, 0.293893, -0.237764, \ 0.38471, 0.154508, -0.279509, \ 0.146946, 0.154508, -0.452254, \ 0.327254, 0.293893, -0.237764, \ 0.38471, 0.154508, -0.279509, \ 0.327254, 0.293893, -0.237764, \ 0.404509, 0.293893, 7.07265e-08, \ 0.475528, 0.154508, 8.3144e-08, \ 0.38471, 0.154508, -0.279509, \ 0.404509, 0.293893, 7.07265e-08, \ 0.5, -0, 0, \ 0.475528, 0.154508, 0, \ 0.38471, 0.154508, 0.279509, \ 0.404509, -0, 0.293893, \ 0.5, -0, 0, \ 0.38471, 0.154508, 0.279509, \ 0.404509, -0, 0.293893, \ 0.38471, 0.154508, 0.279509, \ 0.146946, 0.154508, 0.452254, \ 0.154508, -0, 0.475528, \ 0.404509, -0, 0.293893, \ 0.146946, 0.154508, 0.452254, \ 0.154508, -0, 0.475528, \ 0.146946, 0.154508, 0.452254, \ -0.146946, 0.154508, 0.452254, \ -0.154509, -0, 0.475528, \ 0.154508, -0, 0.475528, \ -0.146946, 0.154508, 0.452254, \ -0.154509, -0, 0.475528, \ -0.146946, 0.154508, 0.452254, \ -0.38471, 0.154508, 0.279508, \ -0.404509, -0, 0.293893, \ -0.154509, -0, 0.475528, \ -0.38471, 0.154508, 0.279508, \ -0.404509, -0, 0.293893, \ -0.38471, 0.154508, 0.279508, \ -0.475528, 0.154508, -4.1572e-08, \ -0.5, -0, -4.37114e-08, \ -0.404509, -0, 0.293893, \ -0.475528, 0.154508, -4.1572e-08, \ -0.5, -0, -4.37114e-08, \ -0.475528, 0.154508, -4.1572e-08, \ -0.38471, 0.154508, -0.279509, \ -0.404508, -0, -0.293893, \ -0.5, -0, -4.37114e-08, \ -0.38471, 0.154508, -0.279509, \ -0.404508, -0, -0.293893, \ -0.38471, 0.154508, -0.279509, \ -0.146946, 0.154508, -0.452254, \ -0.154509, -0, -0.475528, \ -0.404508, -0, -0.293893, \ -0.146946, 0.154508, -0.452254, \ -0.154509, -0, -0.475528, \ -0.146946, 0.154508, -0.452254, \ 0.146946, 0.154508, -0.452254, \ 0.154509, -0, -0.475528, \ -0.154509, -0, -0.475528, \ 0.146946, 0.154508, -0.452254, \ 0.154509, -0, -0.475528, \ 0.146946, 0.154508, -0.452254, \ 0.38471, 0.154508, -0.279509, \ 0.404508, -0, -0.293893, \ 0.154509, -0, -0.475528, \ 0.38471, 0.154508, -0.279509, \ 0.404508, -0, -0.293893, \ 0.38471, 0.154508, -0.279509, \ 0.475528, 0.154508, 8.3144e-08, \ 0.5, -0, 8.74228e-08, \ 0.404508, -0, -0.293893, \ 0.475528, 0.154508, 8.3144e-08, \ 0.475528, -0.154509, 0, \ 0.5, -0, 0, \ 0.404509, -0, 0.293893, \ 0.38471, -0.154509, 0.279508, \ 0.475528, -0.154509, 0, \ 0.404509, -0, 0.293893, \ 0.38471, -0.154509, 0.279508, \ 0.404509, -0, 0.293893, \ 0.154508, -0, 0.475528, \ 0.146946, -0.154509, 0.452254, \ 0.38471, -0.154509, 0.279508, \ 0.154508, -0, 0.475528, \ 0.146946, -0.154509, 0.452254, \ 0.154508, -0, 0.475528, \ -0.154509, -0, 0.475528, \ -0.146946, -0.154509, 0.452254, \ 0.146946, -0.154509, 0.452254, \ -0.154509, -0, 0.475528, \ -0.146946, -0.154509, 0.452254, \ -0.154509, -0, 0.475528, \ -0.404509, -0, 0.293893, \ -0.38471, -0.154509, 0.279508, \ -0.146946, -0.154509, 0.452254, \ -0.404509, -0, 0.293893, \ -0.38471, -0.154509, 0.279508, \ -0.404509, -0, 0.293893, \ -0.5, -0, -4.37114e-08, \ -0.475528, -0.154509, -4.1572e-08, \ -0.38471, -0.154509, 0.279508, \ -0.5, -0, -4.37114e-08, \ -0.475528, -0.154509, -4.1572e-08, \ -0.5, -0, -4.37114e-08, \ -0.404508, -0, -0.293893, \ -0.38471, -0.154509, -0.279509, \ -0.475528, -0.154509, -4.1572e-08, \ -0.404508, -0, -0.293893, \ -0.38471, -0.154509, -0.279509, \ -0.404508, -0, -0.293893, \ -0.154509, -0, -0.475528, \ -0.146946, -0.154509, -0.452254, \ -0.38471, -0.154509, -0.279509, \ -0.154509, -0, -0.475528, \ -0.146946, -0.154509, -0.452254, \ -0.154509, -0, -0.475528, \ 0.154509, -0, -0.475528, \ 0.146946, -0.154509, -0.452254, \ -0.146946, -0.154509, -0.452254, \ 0.154509, -0, -0.475528, \ 0.146946, -0.154509, -0.452254, \ 0.154509, -0, -0.475528, \ 0.404508, -0, -0.293893, \ 0.38471, -0.154509, -0.279509, \ 0.146946, -0.154509, -0.452254, \ 0.404508, -0, -0.293893, \ 0.38471, -0.154509, -0.279509, \ 0.404508, -0, -0.293893, \ 0.5, -0, 8.74228e-08, \ 0.475528, -0.154509, 8.3144e-08, \ 0.38471, -0.154509, -0.279509, \ 0.5, -0, 8.74228e-08, \ 0.404509, -0.293893, 0, \ 0.475528, -0.154509, 0, \ 0.38471, -0.154509, 0.279508, \ 0.327254, -0.293893, 0.237764, \ 0.404509, -0.293893, 0, \ 0.38471, -0.154509, 0.279508, \ 0.327254, -0.293893, 0.237764, \ 0.38471, -0.154509, 0.279508, \ 0.146946, -0.154509, 0.452254, \ 0.125, -0.293893, 0.38471, \ 0.327254, -0.293893, 0.237764, \ 0.146946, -0.154509, 0.452254, \ 0.125, -0.293893, 0.38471, \ 0.146946, -0.154509, 0.452254, \ -0.146946, -0.154509, 0.452254, \ -0.125, -0.293893, 0.38471, \ 0.125, -0.293893, 0.38471, \ -0.146946, -0.154509, 0.452254, \ -0.125, -0.293893, 0.38471, \ -0.146946, -0.154509, 0.452254, \ -0.38471, -0.154509, 0.279508, \ -0.327254, -0.293893, 0.237764, \ -0.125, -0.293893, 0.38471, \ -0.38471, -0.154509, 0.279508, \ -0.327254, -0.293893, 0.237764, \ -0.38471, -0.154509, 0.279508, \ -0.475528, -0.154509, -4.1572e-08, \ -0.404509, -0.293893, -3.53633e-08, \ -0.327254, -0.293893, 0.237764, \ -0.475528, -0.154509, -4.1572e-08, \ -0.404509, -0.293893, -3.53633e-08, \ -0.475528, -0.154509, -4.1572e-08, \ -0.38471, -0.154509, -0.279509, \ -0.327254, -0.293893, -0.237764, \ -0.404509, -0.293893, -3.53633e-08, \ -0.38471, -0.154509, -0.279509, \ -0.327254, -0.293893, -0.237764, \ -0.38471, -0.154509, -0.279509, \ -0.146946, -0.154509, -0.452254, \ -0.125, -0.293893, -0.38471, \ -0.327254, -0.293893, -0.237764, \ -0.146946, -0.154509, -0.452254, \ -0.125, -0.293893, -0.38471, \ -0.146946, -0.154509, -0.452254, \ 0.146946, -0.154509, -0.452254, \ 0.125, -0.293893, -0.38471, \ -0.125, -0.293893, -0.38471, \ 0.146946, -0.154509, -0.452254, \ 0.125, -0.293893, -0.38471, \ 0.146946, -0.154509, -0.452254, \ 0.38471, -0.154509, -0.279509, \ 0.327254, -0.293893, -0.237764, \ 0.125, -0.293893, -0.38471, \ 0.38471, -0.154509, -0.279509, \ 0.327254, -0.293893, -0.237764, \ 0.38471, -0.154509, -0.279509, \ 0.475528, -0.154509, 8.3144e-08, \ 0.404509, -0.293893, 7.07265e-08, \ 0.327254, -0.293893, -0.237764, \ 0.475528, -0.154509, 8.3144e-08, \ 0.293893, -0.404509, 0, \ 0.404509, -0.293893, 0, \ 0.327254, -0.293893, 0.237764, \ 0.237764, -0.404509, 0.172746, \ 0.293893, -0.404509, 0, \ 0.327254, -0.293893, 0.237764, \ 0.237764, -0.404509, 0.172746, \ 0.327254, -0.293893, 0.237764, \ 0.125, -0.293893, 0.38471, \ 0.0908178, -0.404509, 0.279509, \ 0.237764, -0.404509, 0.172746, \ 0.125, -0.293893, 0.38471, \ 0.0908178, -0.404509, 0.279509, \ 0.125, -0.293893, 0.38471, \ -0.125, -0.293893, 0.38471, \ -0.0908178, -0.404509, 0.279508, \ 0.0908178, -0.404509, 0.279509, \ -0.125, -0.293893, 0.38471, \ -0.0908178, -0.404509, 0.279508, \ -0.125, -0.293893, 0.38471, \ -0.327254, -0.293893, 0.237764, \ -0.237764, -0.404509, 0.172746, \ -0.0908178, -0.404509, 0.279508, \ -0.327254, -0.293893, 0.237764, \ -0.237764, -0.404509, 0.172746, \ -0.327254, -0.293893, 0.237764, \ -0.404509, -0.293893, -3.53633e-08, \ -0.293893, -0.404509, -2.56929e-08, \ -0.237764, -0.404509, 0.172746, \ -0.404509, -0.293893, -3.53633e-08, \ -0.293893, -0.404509, -2.56929e-08, \ -0.404509, -0.293893, -3.53633e-08, \ -0.327254, -0.293893, -0.237764, \ -0.237764, -0.404509, -0.172746, \ -0.293893, -0.404509, -2.56929e-08, \ -0.327254, -0.293893, -0.237764, \ -0.237764, -0.404509, -0.172746, \ -0.327254, -0.293893, -0.237764, \ -0.125, -0.293893, -0.38471, \ -0.0908178, -0.404509, -0.279508, \ -0.237764, -0.404509, -0.172746, \ -0.125, -0.293893, -0.38471, \ -0.0908178, -0.404509, -0.279508, \ -0.125, -0.293893, -0.38471, \ 0.125, -0.293893, -0.38471, \ 0.0908179, -0.404509, -0.279508, \ -0.0908178, -0.404509, -0.279508, \ 0.125, -0.293893, -0.38471, \ 0.0908179, -0.404509, -0.279508, \ 0.125, -0.293893, -0.38471, \ 0.327254, -0.293893, -0.237764, \ 0.237764, -0.404509, -0.172746, \ 0.0908179, -0.404509, -0.279508, \ 0.327254, -0.293893, -0.237764, \ 0.237764, -0.404509, -0.172746, \ 0.327254, -0.293893, -0.237764, \ 0.404509, -0.293893, 7.07265e-08, \ 0.293893, -0.404509, 5.13858e-08, \ 0.237764, -0.404509, -0.172746, \ 0.404509, -0.293893, 7.07265e-08, \ 0.154509, -0.475528, 0, \ 0.293893, -0.404509, 0, \ 0.237764, -0.404509, 0.172746, \ 0.125, -0.475528, 0.0908178, \ 0.154509, -0.475528, 0, \ 0.237764, -0.404509, 0.172746, \ 0.125, -0.475528, 0.0908178, \ 0.237764, -0.404509, 0.172746, \ 0.0908178, -0.404509, 0.279509, \ 0.0477458, -0.475528, 0.146946, \ 0.125, -0.475528, 0.0908178, \ 0.0908178, -0.404509, 0.279509, \ 0.0477458, -0.475528, 0.146946, \ 0.0908178, -0.404509, 0.279509, \ -0.0908178, -0.404509, 0.279508, \ -0.0477458, -0.475528, 0.146946, \ 0.0477458, -0.475528, 0.146946, \ -0.0908178, -0.404509, 0.279508, \ -0.0477458, -0.475528, 0.146946, \ -0.0908178, -0.404509, 0.279508, \ -0.237764, -0.404509, 0.172746, \ -0.125, -0.475528, 0.0908178, \ -0.0477458, -0.475528, 0.146946, \ -0.237764, -0.404509, 0.172746, \ -0.125, -0.475528, 0.0908178, \ -0.237764, -0.404509, 0.172746, \ -0.293893, -0.404509, -2.56929e-08, \ -0.154509, -0.475528, -1.35076e-08, \ -0.125, -0.475528, 0.0908178, \ -0.293893, -0.404509, -2.56929e-08, \ -0.154509, -0.475528, -1.35076e-08, \ -0.293893, -0.404509, -2.56929e-08, \ -0.237764, -0.404509, -0.172746, \ -0.125, -0.475528, -0.0908179, \ -0.154509, -0.475528, -1.35076e-08, \ -0.237764, -0.404509, -0.172746, \ -0.125, -0.475528, -0.0908179, \ -0.237764, -0.404509, -0.172746, \ -0.0908178, -0.404509, -0.279508, \ -0.0477458, -0.475528, -0.146946, \ -0.125, -0.475528, -0.0908179, \ -0.0908178, -0.404509, -0.279508, \ -0.0477458, -0.475528, -0.146946, \ -0.0908178, -0.404509, -0.279508, \ 0.0908179, -0.404509, -0.279508, \ 0.0477458, -0.475528, -0.146946, \ -0.0477458, -0.475528, -0.146946, \ 0.0908179, -0.404509, -0.279508, \ 0.0477458, -0.475528, -0.146946, \ 0.0908179, -0.404509, -0.279508, \ 0.237764, -0.404509, -0.172746, \ 0.125, -0.475528, -0.0908178, \ 0.0477458, -0.475528, -0.146946, \ 0.237764, -0.404509, -0.172746, \ 0.125, -0.475528, -0.0908178, \ 0.237764, -0.404509, -0.172746, \ 0.293893, -0.404509, 5.13858e-08, \ 0.154509, -0.475528, 2.70151e-08, \ 0.125, -0.475528, -0.0908178, \ 0.293893, -0.404509, 5.13858e-08, \ -2.18557e-08, -0.5, -0, \ 0.154509, -0.475528, 0, \ 0.125, -0.475528, 0.0908178, \ -1.76816e-08, -0.5, -1.28465e-08, \ -2.18557e-08, -0.5, -0, \ 0.125, -0.475528, 0.0908178, \ -1.76816e-08, -0.5, -1.28465e-08, \ 0.125, -0.475528, 0.0908178, \ 0.0477458, -0.475528, 0.146946, \ -6.75378e-09, -0.5, -2.0786e-08, \ -1.76816e-08, -0.5, -1.28465e-08, \ 0.0477458, -0.475528, 0.146946, \ -6.75378e-09, -0.5, -2.0786e-08, \ 0.0477458, -0.475528, 0.146946, \ -0.0477458, -0.475528, 0.146946, \ 6.75378e-09, -0.5, -2.0786e-08, \ -6.75378e-09, -0.5, -2.0786e-08, \ -0.0477458, -0.475528, 0.146946, \ 6.75378e-09, -0.5, -2.0786e-08, \ -0.0477458, -0.475528, 0.146946, \ -0.125, -0.475528, 0.0908178, \ 1.76816e-08, -0.5, -1.28465e-08, \ 6.75378e-09, -0.5, -2.0786e-08, \ -0.125, -0.475528, 0.0908178, \ 1.76816e-08, -0.5, -1.28465e-08, \ -0.125, -0.475528, 0.0908178, \ -0.154509, -0.475528, -1.35076e-08, \ 2.18557e-08, -0.5, 1.91069e-15, \ 1.76816e-08, -0.5, -1.28465e-08, \ -0.154509, -0.475528, -1.35076e-08, \ 2.18557e-08, -0.5, 1.91069e-15, \ -0.154509, -0.475528, -1.35076e-08, \ -0.125, -0.475528, -0.0908179, \ 1.76816e-08, -0.5, 1.28465e-08, \ 2.18557e-08, -0.5, 1.91069e-15, \ -0.125, -0.475528, -0.0908179, \ 1.76816e-08, -0.5, 1.28465e-08, \ -0.125, -0.475528, -0.0908179, \ -0.0477458, -0.475528, -0.146946, \ 6.75378e-09, -0.5, 2.0786e-08, \ 1.76816e-08, -0.5, 1.28465e-08, \ -0.0477458, -0.475528, -0.146946, \ 6.75378e-09, -0.5, 2.0786e-08, \ -0.0477458, -0.475528, -0.146946, \ 0.0477458, -0.475528, -0.146946, \ -6.75378e-09, -0.5, 2.0786e-08, \ 6.75378e-09, -0.5, 2.0786e-08, \ 0.0477458, -0.475528, -0.146946, \ -6.75378e-09, -0.5, 2.0786e-08, \ 0.0477458, -0.475528, -0.146946, \ 0.125, -0.475528, -0.0908178, \ -1.76816e-08, -0.5, 1.28465e-08, \ -6.75378e-09, -0.5, 2.0786e-08, \ 0.125, -0.475528, -0.0908178, \ -1.76816e-08, -0.5, 1.28465e-08, \ 0.125, -0.475528, -0.0908178, \ 0.154509, -0.475528, 2.70151e-08, \ -2.18557e-08, -0.5, -3.82137e-15, \ -1.76816e-08, -0.5, 1.28465e-08, \ 0.154509, -0.475528, 2.70151e-08} #endif // SPHERE_H
TommyTu/Firework
src/gl/textures/TextureParametersBuilder.h
#ifndef TEXTUREPARAMETERSBUILDER_H #define TEXTUREPARAMETERSBUILDER_H #include "TextureParameters.h" namespace CS123 { namespace GL { class TextureParametersBuilder { public: TextureParametersBuilder(); void setFilter(TextureParameters::FILTER_METHOD filterMethod); void setWrap(TextureParameters::WRAP_METHOD wrapMethod); TextureParameters build(); private: TextureParameters::FILTER_METHOD m_filterMethod; TextureParameters::WRAP_METHOD m_wrapMethod; }; }} #endif // TEXTUREPARAMETERSBUILDER_H
TommyTu/Firework
cs123_lib/errorchecker.h
<reponame>TommyTu/Firework<gh_stars>0 #ifndef ERRORCHECKER_H #define ERRORCHECKER_H #include <string> class ErrorChecker { public: /** * Prints the current OpenGL error codes. "prefix" should be a string that indicates * a location in your code, such as "line 100" or "after glClear". */ static void printGLErrors(std::string prefix); }; #endif // ERRORCHECKER_H
TommyTu/Firework
src/gl/datatype/FBO.h
#ifndef FBO_H #define FBO_H #include <memory> #include <vector> #include "gl/textures/TextureParameters.h" namespace CS123 { namespace GL { class RenderBuffer; class Texture2D; class FBO { public: enum class DEPTH_STENCIL_ATTACHMENT { DEPTH_ONLY, DEPTH_STENCIL, NONE }; FBO(int numberOfColorAttachments, DEPTH_STENCIL_ATTACHMENT attachmentType, int m_width, int m_height, TextureParameters::WRAP_METHOD wrapMethod = TextureParameters::WRAP_METHOD::REPEAT, TextureParameters::FILTER_METHOD filterMethod = TextureParameters::FILTER_METHOD::LINEAR, GLenum type = GL_UNSIGNED_BYTE); ~FBO(); void bind(); void unbind(); const Texture2D& getColorAttachment(int i) const; const RenderBuffer& getDepthStencilAttachment() const; size_t getNumColorAttachments() const; private: void generateColorAttachments(int count, TextureParameters::WRAP_METHOD wrapMethod, TextureParameters::FILTER_METHOD filterMethod, GLenum type); void generateColorAttachment(int i, TextureParameters::WRAP_METHOD wrapMethod, TextureParameters::FILTER_METHOD filterMethod, GLenum type); void generateDepthStencilAttachment(); std::vector<Texture2D> m_colorAttachments; std::unique_ptr<RenderBuffer> m_depthAttachment; DEPTH_STENCIL_ATTACHMENT m_depthStencilAttachmentType; unsigned int m_handle; int m_width; int m_height; }; }} #endif // FBO_H
TommyTu/Firework
src/gl/textures/Texture2D.h
<reponame>TommyTu/Firework<filename>src/gl/textures/Texture2D.h #ifndef TEXTURE2D_H #define TEXTURE2D_H #include "Texture.h" #include "GL/glew.h" namespace CS123 { namespace GL { class Texture2D : public Texture { public: Texture2D(unsigned char *data, int width, int height, GLenum type = GL_UNSIGNED_BYTE); virtual void bind() const override; virtual void unbind() const override; }; }} #endif // TEXTURE2D_H
vymaztom/ATTINY13A_433_TX_TX
433/transmitter/VirtualWire_TX.h
// VirtualWire.h // // Virtual Wire implementation for Arduino // See the README file in this directory fdor documentation // // Author: <NAME> (<EMAIL>) // Copyright (C) 2008 <NAME> // $Id: VirtualWire.h,v 1.3 2009/03/30 00:07:24 mikem Exp $ #ifndef VirtualWire_h #define VirtualWire_h //#include <stdlib.h> //#include <wiring.h> //#include <Wire.h> #define lo8(x) ((x)&0xff) #define hi8(x) ((x)>>8) // Maximum number of bytes in a message, counting the byte count and FCS #define VW_MAX_MESSAGE_LEN 30 // The maximum payload length #define VW_MAX_PAYLOAD VW_MAX_MESSAGE_LEN-3 // The size of the receiver ramp. Ramp wraps modulu this number #define VW_RX_RAMP_LEN 160 // Number of samples per bit #define VW_RX_SAMPLES_PER_BIT 8 // Ramp adjustment parameters // Standard is if a transition occurs before VW_RAMP_TRANSITION (80) in the ramp, // the ramp is retarded by adding VW_RAMP_INC_RETARD (11) // else by adding VW_RAMP_INC_ADVANCE (29) // If there is no transition it is adjusted by VW_RAMP_INC (20) #define VW_RAMP_INC (VW_RX_RAMP_LEN/VW_RX_SAMPLES_PER_BIT) #define VW_RAMP_TRANSITION VW_RX_RAMP_LEN/2 #define VW_RAMP_ADJUST 9 #define VW_RAMP_INC_RETARD (VW_RAMP_INC-VW_RAMP_ADJUST) #define VW_RAMP_INC_ADVANCE (VW_RAMP_INC+VW_RAMP_ADJUST) // Outgoing message bits grouped as 6-bit words // 36 alternating 1/0 bits, followed by 12 bits of start symbol // Followed immediately by the 4-6 bit encoded byte count, // message buffer and 2 byte FCS // Each byte from the byte count on is translated into 2x6-bit words // Caution, each symbol is transmitted LSBit first, // but each byte is transmitted high nybble first #define VW_HEADER_LEN 8 // Cant really do this as a real C++ class, since we need to have // an ISR extern "C" { // Set the digital IO pin to be for transmit data // Defaults to 12 extern void vw_set_tx_pin(uint8_t pin); // By default the PTT pin goes high when the transmitter is enabled. // This flag forces it low when the transmitter is enabled. extern void vw_set_ptt_inverted(uint8_t inverted); // Initialise the VirtualWire software, to operate at speed bits per second // Call this one in your setup() after any vw_set_* calls // Must call vw_rx_start() before you will get any messages extern void vw_setup(uint16_t speed); // Block until the transmitter is idle extern void vw_wait_tx(); // Send a message with the given length. Returns almost immediately, // and message will be sent at the right timing by interrupts // Returns true if the message was accepted for transmissions // Returns false if the message is too long (>VW_MAX_MESSAGE_LEN - 3) extern uint8_t vw_send(uint8_t* buf, uint8_t len); } #endif
YADetector/YADetectorFF
YADetectorFF.framework/Headers/Unexported.h
<reponame>YADetector/YADetectorFF #import <Foundation/Foundation.h> //! Project version number for YADetectorFF. FOUNDATION_EXPORT double YADetectorFFVersionNumber; //! Project version string for YADetectorFF. FOUNDATION_EXPORT const unsigned char YADetectorFFVersionString[];
ShakingMap/sealtalk-ios
ios-sealtalk/RCloudMessage/Sections/Debug/ChatroomStatus/RCDDebugAlertView.h
<filename>ios-sealtalk/RCloudMessage/Sections/Debug/ChatroomStatus/RCDDebugAlertView.h // // RCDDebugAlertView.h // SealTalk // // Created by 孙浩 on 2019/10/18. // Copyright © 2019 RongCloud. All rights reserved. // #import <UIKit/UIKit.h> NS_ASSUME_NONNULL_BEGIN typedef enum : NSUInteger { RCDDebugAlertViewTypeSet, RCDDebugAlertViewTypeGet, RCDDebugAlertViewTypeDelete, } RCDDebugAlertViewType; @interface RCDDebugAlertView : UIView typedef void (^FinishBlock)(RCDDebugAlertView *alertView); @property (nonatomic, strong) NSString *key; @property (nonatomic, strong) NSString *value; @property (nonatomic, assign) BOOL isDelete; @property (nonatomic, assign) BOOL isNotice; @property (nonatomic, strong) NSString *extra; @property (nonatomic, copy) FinishBlock finishBlock; - (instancetype)initWithAlertViewType:(RCDDebugAlertViewType)type; @end NS_ASSUME_NONNULL_END
AndrewGrim/RemoveComments
source/main.c
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <string.h> int main(int argc, char *argv[]) { char inputFile[150]; char outputFile[150]; for (int i = 1; i < argc; i++) { if (strcmp(argv[i], "-input") == 0) { strcpy(inputFile, argv[i + 1]); } else if (strcmp(argv[i],"-output") == 0) { strcpy(outputFile, argv[i + 1]); } } FILE *fileObject = fopen(inputFile, "r"); FILE *modifiedFile = fopen(outputFile, "w+"); int size = 1; while (fgetc(fileObject) != EOF) { size++; } fseek(fileObject, 0, 0); char fileContent[size]; int index = 0; char input; char lastInput; bool isSingleLineComment = false; bool isMultiLineComment = false; char nextChar; while ((input = fgetc(fileObject)) != EOF) { nextChar = getc(fileObject); if ((input == '/' && nextChar == '/') && (lastInput != '"')) { isSingleLineComment = true; isMultiLineComment = false; } else if ((input == '/' && nextChar == '*') && (lastInput != '"')) { isMultiLineComment = true; isSingleLineComment = false; } ungetc(nextChar, fileObject); if (!isSingleLineComment && !isMultiLineComment) { fileContent[index] = input; fputc(fileContent[index], modifiedFile); } if (input == '\n') { if (isSingleLineComment) { fputc('\n', modifiedFile); isSingleLineComment = false; } } if (input == '*' && nextChar == '/') { getc(fileObject); isMultiLineComment = false; } lastInput = input; index++; } fclose(modifiedFile); fclose(fileObject); free(fileContent); return 0; }
porres/pd-cyclone
cyclone_objects/binaries/audio/wave.c
<gh_stars>100-1000 /* Copyright (c) 2002-2003 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ #include <string.h> #define _USE_MATH_DEFINES #include <math.h> #include "m_pd.h" #include <common/api.h> #include "signal/cybuf.h" #include "common/shared.h" #define CYWAVEMAXOUT 64 //max number of outs #define CYWAVEINTERP 1 //default interp mode // CHECKME (the refman): the extra channels are not played //adding wave_getarraysmp, adding attributes, dearsiced/cybufed - <NAME> 2016 typedef struct _wave { t_object x_obj; t_cybuf *x_cybuf; int x_bufsize; int x_interp_mode; int x_numouts; //number of outputs float x_ksr; //sample rate in ms t_float x_f; //dummy t_float x_bias; t_float x_tension; t_inlet *x_startlet; t_inlet *x_endlet; t_float *x_in; //main inlet signal vector t_float *x_st; //start inlet vector t_float *x_e; //end inlet vector t_float **x_ovecs; // output vectors } t_wave; static t_class *wave_class; static void wave_float(t_wave *x, t_float f) { pd_error(x, "wave~: no method for 'float'"); } /* interpolation functions w/ jump table -- code was cleaner than a massive switch - case block in the wave_perform() routine; might be very slightly less efficient this way but I think the clarity was worth it. The Max/MSP wave~ class seems to copy all of its interpolation functions directly from http://paulbourke.net/miscellaneous/interpolation/ without attribution. Note that "cubic" is not the same interpolator as in tabread4~. For convenience, I've added that interpolator as wave_lagrange(). -- <NAME> */ static void wave_interp_bias(t_wave *x, t_floatarg f) { x->x_bias = f; return; } static void wave_interp_tension(t_wave *x, t_floatarg f) { x->x_tension = f; return; } static void wave_interp(t_wave *x, t_floatarg f) { x->x_interp_mode = f < 0 ? 0 : f; x->x_interp_mode = x->x_interp_mode > 7 ? 7 : x->x_interp_mode; cybuf_setminsize(x->x_cybuf,(x->x_interp_mode >= 4 ? 4 : 1)); cybuf_playcheck(x->x_cybuf); } static void wave_set(t_wave *x, t_symbol *s) { cybuf_setarray(x->x_cybuf, s); } /*stupid hacks; sorry. This saves a lot of typing.*/ #define BOUNDS_CHECK() \ if (spos < 0) spos = 0; \ else if (spos > maxindex) spos = maxindex; \ if (epos > maxindex || epos <= 0) epos = maxindex; \ else if (epos < spos) epos = spos; \ int siz = (int)(epos - spos + 1.5); \ int ndx; \ int ch = nch; \ if (phase < 0) phase = 0; \ else if (phase > 1.0) phase = 0; \ int sposi = (int)spos; \ int eposi = sposi + siz #define INDEX_2PT(TYPE) \ int ndx1; \ TYPE a, b; \ TYPE xpos = phase*siz + spos; \ ndx = (int)xpos; \ TYPE frac = xpos - ndx; \ if (ndx == eposi) ndx = sposi; \ ndx1 = ndx + 1; \ if (ndx1 == eposi) ndx1 = sposi #define INDEX_4PT() \ int ndxm1, ndx1, ndx2; \ double a, b, c, d; \ double xpos = phase*siz + spos; \ ndx = (int)xpos; \ double frac = xpos - ndx; \ if (ndx == eposi) ndx = sposi; \ ndxm1 = ndx - 1; \ if (ndxm1 < sposi) ndxm1 = eposi - 1; \ ndx1 = ndx + 1; \ if (ndx1 == eposi) ndx1 = sposi; \ ndx2 = ndx1 + 1; \ if (ndx2 == eposi) ndx2 = sposi; static void wave_nointerp(t_wave *x, t_int *outp, t_float *xin, t_float *sin, t_float *ein, int nblock, int nch, int maxindex, float ksr, t_word **vectable) { int iblock; for (iblock = 0; iblock < nblock; iblock++) { t_float phase = *xin++; t_float spos = *sin++ * ksr; t_float epos = *ein++ * ksr; BOUNDS_CHECK(); ndx = (int)(phase*siz + spos); ndx = (ndx >= eposi ? sposi : ndx); while (ch--) { t_word *vp = vectable[ch]; t_float *out = (t_float *)(outp[ch]); out[iblock] = (vp ? vp[ndx].w_float : 0); } } return; } static void wave_linear(t_wave *x, t_int *outp, t_float *xin, t_float *sin, t_float *ein, int nblock, int nch, int maxindex, float ksr, t_word **vectable) { int iblock; for (iblock = 0; iblock < nblock; iblock++) { double phase = (double)(*xin++); double spos = (double)(*sin++) * ksr; double epos = (double)(*ein++) * ksr; BOUNDS_CHECK(); INDEX_2PT(double); while (ch--) { t_word *vp = vectable[ch]; t_float *out = (t_float *)(outp[ch]); if (vp) { a = (double)vp[ndx].w_float; b = (double)vp[ndx1].w_float; out[iblock] = (t_float)(a * (1.0 - frac) + b * frac); } else out[iblock] = 0; } } return; } static void wave_linlq(t_wave *x, t_int *outp, t_float *xin, t_float *sin, t_float *ein, int nblock, int nch, int maxindex, float ksr, t_word **vectable) { int iblock; for (iblock = 0; iblock < nblock; iblock++) { t_float phase = *xin++; t_float spos = *sin++ * ksr; t_float epos = *ein++ * ksr; BOUNDS_CHECK(); INDEX_2PT(float); while (ch--) { t_word *vp = vectable[ch]; t_float *out = (t_float *)(outp[ch]); if (vp) { a = vp[ndx].w_float; b = vp[ndx1].w_float; out[iblock] = a + frac * (b - a); } else out[iblock] = 0; } } return; } static void wave_cosine(t_wave *x, t_int *outp, t_float *xin, t_float *sin, t_float *ein, int nblock, int nch, int maxindex, float ksr, t_word **vectable) { int iblock; for (iblock = 0; iblock < nblock; iblock++) { t_float phase = *xin++; t_float spos = *sin++ * ksr; t_float epos = *ein++ * ksr; BOUNDS_CHECK(); INDEX_2PT(double); while (ch--) { t_word *vp = vectable[ch]; t_float *out = (t_float *)(outp[ch]); if (vp) { a = (double)vp[ndx].w_float; b = (double)vp[ndx1].w_float; frac = (1 - cos(frac * M_PI)) / 2.0; out[iblock] = (t_float)(a * (1 - frac) + b * (frac)); } else out[iblock] = 0; } } return; } static void wave_cubic(t_wave *x, t_int *outp, t_float *xin, t_float *sin, t_float *ein, int nblock, int nch, int maxindex, float ksr, t_word **vectable) { int iblock; for (iblock = 0; iblock < nblock; iblock++) { t_float phase = *xin++; t_float spos = *sin++ * ksr; t_float epos = *ein++ * ksr; BOUNDS_CHECK(); INDEX_4PT(); while (ch--) { t_word *vp = vectable[ch]; t_float *out = (t_float *)(outp[ch]); if (vp) { a = (double)vp[ndxm1].w_float; b = (double)vp[ndx].w_float; c = (double)vp[ndx1].w_float; d = (double)vp[ndx2].w_float; double p0, p1, p2; p0 = d - a + b - c; p1 = a - b - p0; p2 = c - a; out[iblock] = (t_float)(b+frac*(p2+frac*(p1+frac*p0))); } else out[iblock] = 0; } } return; } static void wave_spline(t_wave *x, t_int *outp, t_float *xin, t_float *sin, t_float *ein, int nblock, int nch, int maxindex, float ksr, t_word **vectable) { int iblock; for (iblock = 0; iblock < nblock; iblock++) { t_float phase = *xin++; t_float spos = *sin++ * ksr; t_float epos = *ein++ * ksr; BOUNDS_CHECK(); INDEX_4PT(); while (ch--) { t_word *vp = vectable[ch]; t_float *out = (t_float *)(outp[ch]); if (vp) { a = (double)vp[ndxm1].w_float; b = (double)vp[ndx].w_float; c = (double)vp[ndx1].w_float; d = (double)vp[ndx2].w_float; double p0, p1, p2; p0 = 0.5*(d - a) + 1.5*(b - c); p2 = 0.5*(c - a); p1 = a - b + p2 - p0; out[iblock] = (t_float)(b+frac*(p2+frac*(p1+frac*p0))); } else out[iblock] = 0; } } return; } static void wave_hermite(t_wave *x, t_int *outp, t_float *xin, t_float *sin, t_float *ein, int nblock, int nch, int maxindex, float ksr, t_word **vectable) { int iblock; for (iblock = 0; iblock < nblock; iblock++) { t_float phase = *xin++; t_float spos = *sin++ * ksr; t_float epos = *ein++ * ksr; BOUNDS_CHECK(); INDEX_4PT(); double tension = (double)x->x_tension; double bias = (double)x->x_bias; while (ch--) { t_word *vp = vectable[ch]; t_float *out = (t_float *)(outp[ch]); if (vp) { a = (double)vp[ndxm1].w_float; b = (double)vp[ndx].w_float; c = (double)vp[ndx1].w_float; d = (double)vp[ndx2].w_float; double p0, p1, p2, p3, m0, m1; double frac2 = frac*frac; double frac3 = frac*frac2; double cminusb = c - b; double bias1 = 1. - bias; bias++; tension = 0.5 * (1. - tension); m0 = tension * ((b-a)*bias + cminusb*bias1); m1 = tension * (cminusb*bias + (d-c)*bias1); p2 = frac3 - frac2; p0 = 2*p2 - frac2 + 1.; p1 = p2 - frac2 + frac; p3 = frac2 - 2*p2; out[iblock] = (t_float)(p0*b + p1*m0 + p2*m1 + p3*c); } else out[iblock] = 0; } } return; } static void wave_lagrange(t_wave *x, t_int *outp, t_float *xin, t_float *sin, t_float *ein, int nblock, int nch, int maxindex, float ksr, t_word **vectable) { int iblock; for (iblock = 0; iblock < nblock; iblock++) { t_float phase = *xin++; t_float spos = *sin++ * ksr; t_float epos = *ein++ * ksr; BOUNDS_CHECK(); INDEX_4PT(); while (ch--) { t_word *vp = vectable[ch]; t_float *out = (t_float *)(outp[ch]); if (vp) { a = (double)vp[ndxm1].w_float; b = (double)vp[ndx].w_float; c = (double)vp[ndx1].w_float; d = (double)vp[ndx2].w_float; double cminusb = c-b; out[iblock] = (t_float)(b + frac * ( cminusb - (1. - frac)/6. * ( (d - a - 3.0*cminusb) * frac + d + 2.0*a - 3.0*b ) )); } else out[iblock] = 0; } } return; } static t_int *wave_perform(t_int *w) { /* The jump table; "wif" = "wave interpolation functions." */ static void (* const wif[])(t_wave *x, t_int *outp, t_float *xin, t_float *sin, t_float *ein, int nblock, int nch, int maxindex, float ksr, t_word **vectable) = { wave_nointerp, wave_linear, wave_linlq, wave_cosine, wave_cubic, wave_spline, wave_hermite, wave_lagrange }; t_wave *x = (t_wave *)(w[1]); int nblock = (int)(w[2]); t_cybuf * c = x->x_cybuf; // t_int *outp = w + 6; t_int *outp = (t_int *)x->x_ovecs; int nch = c->c_numchans; if (c->c_playable) { //t_wave *x = (t_wave *)sic; int npts = c->c_npts; float ksr = x->x_ksr; t_word **vectable = c->c_vectors; //t_float *xin = (t_float *)(w[3]); //t_float *sin = (t_float *)(w[4]); //t_float *ein = (t_float *)(w[5]); t_float *xin = x->x_in; t_float *sin = x->x_st; t_float *ein = x->x_e; int maxindex = npts - 1; int interp_mode = x->x_interp_mode; /*Choose interpolation function from jump table. The interpolation functions also perform the block loop in order not to make a bunch of per-sample decisions.*/ wif[interp_mode](x, outp, xin, sin, ein, nblock, nch, maxindex, ksr, vectable); } else { int ch = nch; while (ch--) { t_float *out = (t_float *)outp[ch]; int n = nblock; while (n--) *out++ = 0; } } return (w + 3); } static void wave_dsp(t_wave *x, t_signal **sp) { cybuf_checkdsp(x->x_cybuf); x->x_ksr = sp[0]->s_sr * 0.001; int i, nblock = sp[0]->s_n; t_signal **sigp = sp; x->x_in = (*sigp++)->s_vec; //the first sig in is the input x->x_st = (*sigp++)->s_vec; //next is the start input x->x_e = (*sigp++)->s_vec; //next is the end input for (i = 0; i < x->x_numouts; i++){ //now for the outputs *(x->x_ovecs+i) = (*sigp++)->s_vec; }; dsp_add(wave_perform, 2, x, nblock); } static void wave_free(t_wave *x) { inlet_free(x->x_startlet); inlet_free(x->x_endlet); cybuf_free(x->x_cybuf); freebytes(x->x_ovecs, x->x_numouts * sizeof(*x->x_ovecs)); } static void *wave_new(t_symbol *s, int argc, t_atom * argv){ //mostly copying this for what i did with record~ - DXK t_symbol * name = NULL; int nameset = 0; //flag if name is set int floatarg = 0; //argument counter for floatargs (don't include symbol arg) //setting defaults t_float stpt = 0; t_float endpt = SHARED_FLT_MAX; //default to max float size (hacky i know) int numouts = 1; //i'm assuming the default is 1 - DXK t_float bias = 0; t_float tension = 0; t_float interp = CYWAVEINTERP; while(argc){ if(argv->a_type == A_SYMBOL){ // symbol if(floatarg == 0 && !nameset){ //we haven't hit any floatargs, go ahead and set name name = atom_getsymbolarg(0, argc, argv); nameset = 1; //set nameset flag argc--; argv++; } else if(nameset){ t_symbol * curarg = atom_getsymbolarg(0, argc, argv); //parse args only if array name is set, sound alright? -DXK if(argc >=2){ //needs to be at least two args left, the attribute symbol and the arg for it t_float curfl = atom_getfloatarg(1, argc, argv); if(strcmp(curarg->s_name, "@interp") == 0){ interp = curfl; } else if(strcmp(curarg->s_name, "@interp_bias") == 0){ bias = curfl; } else if(strcmp(curarg->s_name, "@interp_tension") == 0){ tension = curfl; } else{ goto errstate; }; argc -=2; argv+=2; } else{ goto errstate; }; }; } else{ // float if(nameset){ //else we're dealing with a float switch(floatarg){ case 0: stpt = atom_getfloatarg(0, argc, argv); break; case 1: endpt = atom_getfloatarg(0, argc, argv); break; case 2: numouts = (int)atom_getfloatarg(0, argc, argv); break; default: break; }; floatarg++; //increment the floatarg we're looking at argc--; argv++; } else{ nameset = 1; //set nameset flag and ignore array name argc--; argv++; }; }; }; //some boundschecking if(numouts > CYWAVEMAXOUT){ numouts = CYWAVEMAXOUT; } else if(numouts < 1){ numouts = 1; }; t_wave *x = (t_wave *)pd_new(wave_class); x->x_cybuf = cybuf_init((t_class *)x, name, numouts, 0); x->x_numouts = numouts; //allocating output vectors x->x_ovecs = getbytes(x->x_numouts * sizeof(*x->x_ovecs)); //more boundschecking //it looks everything is stored as samples then later converted to ms if(stpt < 0){ stpt = 0; } else{ stpt = (t_float)floor(stpt); //basically typecasting to int without actual typecasting }; if(endpt < 0){ endpt = 0; } else{//if passed, floor it endpt = (t_float)floor(endpt); }; x->x_ksr = (double)sys_getsr() * 0.001; wave_interp(x, interp); x->x_bias = bias; x->x_tension = tension; x->x_startlet = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); x->x_endlet = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); pd_float((t_pd *)x->x_startlet, stpt); pd_float( (t_pd *)x->x_endlet, endpt); int i; for(i=0; i < numouts; i++){ outlet_new(&x->x_obj, gensym("signal")); }; return (x); errstate: post("wave~: improper args"); return NULL; } CYCLONE_OBJ_API void wave_tilde_setup(void) { wave_class = class_new(gensym("wave~"), (t_newmethod)wave_new, (t_method)wave_free, sizeof(t_wave), 0, A_GIMME, 0); class_addmethod(wave_class, (t_method)wave_set, gensym("set"), A_SYMBOL, 0); class_addmethod(wave_class, (t_method)wave_interp, gensym("interp"), A_FLOAT, 0); class_addmethod(wave_class, (t_method)wave_interp_bias, gensym("interp_bias"), A_FLOAT, 0); class_addmethod(wave_class, (t_method)wave_interp_tension, gensym("interp_tension"), A_FLOAT, 0); class_addmethod(wave_class, (t_method)wave_dsp, gensym("dsp"), A_CANT, 0); class_domainsignalin(wave_class, -1); class_addfloat(wave_class, (t_method)wave_float); }
porres/pd-cyclone
shared/common/grow.c
/* Copyright (c) 2002-2003 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ /* LATER generic handling of reentrant output request and self-invoked set */ #include <string.h> #include "m_pd.h" #include "grow.h" /* Prior to this call a caller is supposed to check for *nrequested > *sizep. Returns a reallocated buffer's pointer (success) or a given 'bufini' default value (failure). Upon return *nrequested contains the actual number of elements: requested (success) or a given default value of 'inisize' (failure). */ void *grow_nodata(int *nrequested, int *sizep, void *bufp, int inisize, void *bufini, size_t typesize){ int newsize = *sizep * 2; while(newsize < *nrequested) newsize *= 2; if(bufp == bufini) bufp = getbytes(newsize * typesize); else bufp = resizebytes(bufp, *sizep * typesize, newsize * typesize); if(bufp){ *sizep = newsize; return (bufp); } else{ *nrequested = *sizep = inisize; return (bufini); } } /* Like grow_nodata(), but preserving first *nexisting elements. */ void *grow_withdata(int *nrequested, int *nexisting, int *sizep, void *bufp, int inisize, void *bufini, size_t typesize){ int newsize = *sizep * 2; while(newsize < *nrequested) newsize *= 2; if(bufp == bufini){ if(!(bufp = getbytes(newsize * typesize))){ *nrequested = *sizep = inisize; return (bufini); } *sizep = newsize; memcpy(bufp, bufini, *nexisting * typesize); } else{ // int oldsize = *sizep; if(!(bufp = resizebytes(bufp, *sizep * typesize, newsize * typesize))){ *nrequested = *sizep = inisize; *nexisting = 0; return (bufini); } *sizep = newsize; } return(bufp); } /* Like grow_nodata(), but preserving a 'tail' of *nexisting elements, starting from *startp. */ /* LATER rethink handling of a start pointer (clumsy now) */ void *grow_withtail(int *nrequested, int *nexisting, char **startp, int *sizep, void *bufp, int inisize, void *bufini, size_t typesize){ int newsize = *sizep * 2; while(newsize < *nrequested) newsize *= 2; if(bufp == bufini){ char *oldstart = *startp; if(!(bufp = getbytes(newsize * typesize))){ *nrequested = *sizep = inisize; return (bufini); } *startp = (char *)bufp + (newsize - *nexisting) * typesize; *sizep = newsize; memcpy(*startp, oldstart, *nexisting * typesize); } else{ int oldsize = *sizep; if(!(bufp = resizebytes(bufp, *sizep * typesize, newsize * typesize))){ *startp = (char *)bufini + inisize * typesize; *nrequested = *sizep = inisize; *nexisting = 0; return (bufini); } *startp = (char *)bufp + (newsize - *nexisting) * typesize; *sizep = newsize; memmove(*startp, (char *)bufp + (oldsize - *nexisting) * typesize, *nexisting * typesize); } return(bufp); }
porres/pd-cyclone
cyclone_objects/binaries/control/seq.c
<gh_stars>100-1000 /* Copyright (c) 2002-2005 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ /* CHECKED no sharing of data among seq objects having the same creation arg */ #include <stdlib.h> #include <stdio.h> #include <string.h> #include "m_pd.h" //#include "g_canvas.h" #include <common/api.h> #include "common/grow.h" #include "common/file.h" #include "control/mifi.h" /* #ifdef KRZYSZCZ #define SEQ_DEBUG #endif */ #define SEQ_INISEQSIZE 256 /* LATER rethink */ #define SEQ_INITEMPOMAPSIZE 128 /* LATER rethink */ #define SEQ_EOM 255 /* end of message marker, LATER rethink */ #define SEQ_TICKSPERSEC 48 #define SEQ_MINTICKDELAY 1. /* LATER rethink */ #define SEQ_TICKEPSILON ((double).0001) #define SEQ_STARTEPSILON .0001 /* if inside: play unmodified */ #define SEQ_TEMPOEPSILON .0001 /* if inside: pause */ #define SEQ_ISRUNNING(x) ((x)->x_prevtime > (double).0001) #define SEQ_ISPAUSED(x) ((x)->x_prevtime <= (double).0001) enum{SEQ_IDLEMODE, SEQ_RECMODE, SEQ_PLAYMODE, SEQ_SLAVEMODE}; typedef struct _seqevent{ double e_delta; unsigned char e_bytes[4]; }t_seqevent; typedef struct _seqtempo{ double t_scoretime; /* score ticks from start */ double t_sr; /* score ticks per second */ }t_seqtempo; typedef struct _seq{ t_object x_ob; t_canvas *x_canvas; t_symbol *x_defname; t_file *x_filehandle; int x_mode; int x_playhead; t_float x_delay; t_float x_event_delay; double x_nextscoretime; float x_timescale; float x_newtimescale; double x_prevtime; double x_slaveprevtime; double x_clockdelay; unsigned char x_status; int x_evelength; int x_expectedlength; int x_eventreadhead; int x_seqsize; /* as allocated */ int x_nevents; /* as used */ t_seqevent *x_sequence; t_seqevent x_seqini[SEQ_INISEQSIZE]; int x_temporeadhead; int x_tempomapsize; /* as allocated */ int x_ntempi; /* as used */ t_seqtempo *x_tempomap; t_seqtempo x_tempomapini[SEQ_INITEMPOMAPSIZE]; t_clock *x_clock; t_clock *x_slaveclock; t_outlet *x_bangout; }t_seq; static t_class *seq_class; static void seq_eventstring(t_seq *x, char *buf, t_seqevent *ep, int editable, t_float *sum){ x = NULL; unsigned char *bp = ep->e_bytes; int i; *sum += ep->e_delta; if(editable) sprintf(buf, "%g", *sum); else if(*bp < 128 || *bp == 247) sprintf(buf, "(%g)->", *sum); else sprintf(buf, "(%g)", *sum); buf += strlen(buf); sprintf(buf, " %g", (float)*bp); for(i = 0, bp++; i < 3 && *bp != SEQ_EOM; i++, bp++){ buf += strlen(buf); sprintf(buf, " %g", (float)*bp); } } static void seq_update(t_seq *x){ sys_vgui(" if {[winfo exists .%lx]} {\n", (unsigned long)x->x_filehandle); sys_vgui(" .%lx.text delete 1.0 end\n", (unsigned long)x->x_filehandle); sys_gui(" }\n"); t_seqevent *ep = x->x_sequence; int nevents = x->x_nevents; char buf[MAXPDSTRING+2]; t_float sum = 0; while(nevents--){ // LATER rethink sysex continuation seq_eventstring(x, buf, ep, 1, &sum); strcat(buf, ";\n"); editor_append(x->x_filehandle, buf); ep++; } editor_setdirty(x->x_filehandle, 0); } static void seq_doclear(t_seq *x, int dofree){ if(dofree){ if(x->x_sequence != x->x_seqini){ freebytes(x->x_sequence, x->x_seqsize * sizeof(*x->x_sequence)); x->x_sequence = x->x_seqini; x->x_seqsize = SEQ_INISEQSIZE; } if(x->x_tempomap != x->x_tempomapini){ freebytes(x->x_tempomap, x->x_tempomapsize * sizeof(*x->x_tempomap)); x->x_tempomap = x->x_tempomapini; x->x_tempomapsize = SEQ_INITEMPOMAPSIZE; } } x->x_nevents = x->x_ntempi = 0; } static void seq_clear(t_seq *x){ seq_doclear(x, 0); seq_update(x); } static int seq_dogrowing(t_seq *x, int nevents, int ntempi){ if(nevents > x->x_seqsize){ int nrequested = nevents; /* #ifdef SEQ_DEBUG loudbug_post("growing for %d events...", nevents); #endif */ x->x_sequence = grow_nodata(&nrequested, &x->x_seqsize, x->x_sequence, SEQ_INISEQSIZE, x->x_seqini, sizeof(*x->x_sequence)); if(nrequested < nevents){ x->x_nevents = 0; x->x_ntempi = 0; return(0); } } if(ntempi > x->x_tempomapsize){ int nrequested = ntempi; /* #ifdef SEQ_DEBUG loudbug_post("growing for %d tempi...", ntempi); #endif */ x->x_tempomap = grow_nodata(&nrequested, &x->x_tempomapsize, x->x_tempomap, SEQ_INITEMPOMAPSIZE, x->x_tempomapini, sizeof(*x->x_tempomap)); if(nrequested < ntempi){ x->x_ntempi = 0; return(0); } } x->x_nevents = nevents; x->x_ntempi = ntempi; return(1); } static void seq_complete(t_seq *x){ if(x->x_evelength < x->x_expectedlength){ /* CHECKED no warning if no data after status byte requiring data */ if(x->x_evelength > 1) post("seq: truncated midi message"); /* CHECKED */ /* CHECKED nothing stored */ } else{ t_seqevent *ep = &x->x_sequence[x->x_nevents]; ep->e_delta = clock_gettimesince(x->x_prevtime); x->x_prevtime = clock_getlogicaltime(); if(x->x_evelength < 4) ep->e_bytes[x->x_evelength] = SEQ_EOM; x->x_nevents++; if(x->x_nevents >= x->x_seqsize){ int nexisting = x->x_seqsize; /* store-ahead scheme, LATER consider using x_currevent */ int nrequested = x->x_nevents + 1; /* #ifdef SEQ_DEBUG loudbug_post("growing..."); #endif */ x->x_sequence = grow_withdata(&nrequested, &nexisting, &x->x_seqsize, x->x_sequence, SEQ_INISEQSIZE, x->x_seqini, sizeof(*x->x_sequence)); if(nrequested <= x->x_nevents) x->x_nevents = 0; } } x->x_evelength = 0; } static void seq_checkstatus(t_seq *x, unsigned char c){ if(x->x_status && x->x_evelength > 1) /* LATER rethink */ seq_complete(x); if(c < 192) x->x_expectedlength = 3; else if(c < 224) x->x_expectedlength = 2; else if(c < 240) x->x_expectedlength = 3; else if(c < 248){ /* FIXME */ x->x_expectedlength = -1; } else{ x->x_sequence[x->x_nevents].e_bytes[0] = c; x->x_evelength = x->x_expectedlength = 1; seq_complete(x); return; } x->x_status = x->x_sequence[x->x_nevents].e_bytes[0] = c; x->x_evelength = 1; } static void seq_addbyte(t_seq *x, unsigned char c, int docomplete){ x->x_sequence[x->x_nevents].e_bytes[x->x_evelength++] = c; if(x->x_evelength == x->x_expectedlength){ seq_complete(x); if(x->x_status){ x->x_sequence[x->x_nevents].e_bytes[0] = x->x_status; x->x_evelength = 1; } } else if(x->x_evelength == 4){ if(x->x_status != 240) pd_error(x, "bug [seq]: seq_addbyte"); /* CHECKED sysex is broken into 4-byte packets marked with the actual delta time of last byte received in a packet */ seq_complete(x); } else if(docomplete) seq_complete(x); } static void seq_endofsysex(t_seq *x){ seq_addbyte(x, 247, 1); x->x_status = 0; } static void seq_stoprecording(t_seq *x){ if(x->x_status == 240){ post("seq: incomplete sysex"); /* CHECKED */ seq_endofsysex(x); /* CHECKED 247 added implicitly */ } else if(x->x_status) seq_complete(x); /* CHECKED running status used in recording, but not across recordings */ x->x_status = 0; } static void seq_stopplayback(t_seq *x){ /* FIXME */ /* CHECKED "seq: incomplete sysex" at playback stop, 247 added implicitly */ /* CHECKME resetting controllers, etc. */ /* CHECKED bang not sent if playback stopped early */ clock_unset(x->x_clock); x->x_playhead = 0; x->x_nextscoretime = 0.; } static void seq_stopslavery(t_seq *x){ /* FIXME */ clock_unset(x->x_clock); clock_unset(x->x_slaveclock); x->x_playhead = 0; x->x_nextscoretime = 0.; } static void seq_startrecording(t_seq *x){ x->x_prevtime = clock_getlogicaltime(); x->x_status = 0; x->x_evelength = 0; x->x_expectedlength = -1; /* LATER rethink */ } /* CHECKED running status not used in playback */ static void seq_startplayback(t_seq *x, int modechanged){ clock_unset(x->x_clock); x->x_playhead = 0; x->x_nextscoretime = 0.; /* CHECKED bang not sent if sequence is empty */ if(x->x_nevents){ if(modechanged){ x->x_nextscoretime = x->x_sequence->e_delta; /* playback data never sent within the scheduler event of a start message (even for the first delta <= 0), LATER rethink */ x->x_clockdelay = x->x_sequence->e_delta * x->x_newtimescale; } else { /* CHECKED timescale change */ if(SEQ_ISRUNNING(x)) x->x_clockdelay -= clock_gettimesince(x->x_prevtime); x->x_clockdelay *= x->x_newtimescale / x->x_timescale; } if(x->x_clockdelay < 0.) x->x_clockdelay = 0.; x->x_timescale = x->x_newtimescale; clock_delay(x->x_clock, x->x_clockdelay); x->x_prevtime = clock_getlogicaltime(); } else x->x_mode = SEQ_IDLEMODE; } static void seq_startslavery(t_seq *x){ if(x->x_nevents){ x->x_playhead = 0; x->x_nextscoretime = 0.; x->x_prevtime = 0.; x->x_slaveprevtime = 0.; } else x->x_mode = SEQ_IDLEMODE; } static void seq_setmode(t_seq *x, int newmode){ int changed = (x->x_mode != newmode); if(changed){ switch (x->x_mode){ case SEQ_IDLEMODE: break; case SEQ_RECMODE: seq_stoprecording(x); break; case SEQ_PLAYMODE: seq_stopplayback(x); break; case SEQ_SLAVEMODE: seq_stopslavery(x); break; default: pd_error(x, "bug [seq]: seq_setmode (old)"); return; } x->x_mode = newmode; } switch (newmode){ case SEQ_IDLEMODE: break; case SEQ_RECMODE: seq_startrecording(x); break; case SEQ_PLAYMODE: seq_startplayback(x, changed); break; case SEQ_SLAVEMODE: seq_startslavery(x); break; default: pd_error(x, "bug [seq]: seq_setmode (new)"); } } static void seq_settimescale(t_seq *x, float newtimescale){ if(newtimescale < 1e-20) x->x_newtimescale = 1e-20; else if(newtimescale > 1e20) x->x_newtimescale = 1e20; else x->x_newtimescale = newtimescale; } static void seq_clocktick(t_seq *x){ if(x->x_mode == SEQ_PLAYMODE || x->x_mode == SEQ_SLAVEMODE){ t_seqevent *ep = &x->x_sequence[x->x_playhead++]; unsigned char *bp = ep->e_bytes; nextevent: outlet_float(((t_object *)x)->ob_outlet, *bp++); if(*bp != SEQ_EOM){ outlet_float(((t_object *)x)->ob_outlet, *bp++); if(*bp != SEQ_EOM){ outlet_float(((t_object *)x)->ob_outlet, *bp++); if(*bp != SEQ_EOM) outlet_float(((t_object *)x)->ob_outlet, *bp++); } } if(x->x_mode != SEQ_PLAYMODE && x->x_mode != SEQ_SLAVEMODE) return; /* protecting against outlet -> 'stop' etc. */ if(x->x_playhead < x->x_nevents){ ep++; x->x_nextscoretime += ep->e_delta; if(ep->e_delta < SEQ_TICKEPSILON){ /* continue output in the same scheduler event, LATER rethink */ x->x_playhead++; bp = ep->e_bytes; goto nextevent; } else{ x->x_clockdelay = ep->e_delta * x->x_timescale; if(x->x_clockdelay < 0.) x->x_clockdelay = 0.; clock_delay(x->x_clock, x->x_clockdelay); x->x_prevtime = clock_getlogicaltime(); } } else{ seq_setmode(x, SEQ_IDLEMODE); /* CHECKED bang sent immediately _after_ last byte */ outlet_bang(x->x_bangout); /* LATER think about reentrancy */ } } } /* timeout handler ('tick' is late) */ static void seq_slaveclocktick(t_seq *x){ if(x->x_mode == SEQ_SLAVEMODE) clock_unset(x->x_clock); } // LATER dealing with self-invokation (outlet -> 'tick') static void seq_tick(t_seq *x){ if(x->x_mode == SEQ_SLAVEMODE){ if(x->x_slaveprevtime >= 0){ double elapsed = clock_gettimesince(x->x_slaveprevtime); if(elapsed < SEQ_MINTICKDELAY) return; clock_delay(x->x_slaveclock, elapsed); seq_settimescale(x, (float)(elapsed * (SEQ_TICKSPERSEC / 1000.))); if(SEQ_ISRUNNING(x)){ x->x_clockdelay -= clock_gettimesince(x->x_prevtime); x->x_clockdelay *= x->x_newtimescale / x->x_timescale; } else x->x_clockdelay = x->x_sequence[x->x_playhead].e_delta * x->x_newtimescale; if(x->x_clockdelay < 0.) x->x_clockdelay = 0.; clock_delay(x->x_clock, x->x_clockdelay); x->x_prevtime = clock_getlogicaltime(); x->x_slaveprevtime = x->x_prevtime; x->x_timescale = x->x_newtimescale; } else{ x->x_clockdelay = 0.; // redundant x->x_prevtime = 0.; // redundant x->x_slaveprevtime = clock_getlogicaltime(); x->x_timescale = 1.; // redundant } } } // CHECKED bang does the same as 'start 1024', not 'start <current-timescale>' (also if already in SEQ_PLAYMODE) static void seq_bang(t_seq *x){ seq_settimescale(x, 1.); seq_setmode(x, SEQ_PLAYMODE); // CHECKED 'bang' stops recording } static void seq_float(t_seq *x, t_float f){ if(x->x_mode == SEQ_RECMODE){ unsigned char c = (unsigned char)f; // CHECKED noninteger and out of range silently truncated if(c < 128){ if(x->x_status) seq_addbyte(x, c, 0); } else if(c != 254){ // CHECKED active sensing ignored if(x->x_status == 240){ if(c == 247) seq_endofsysex(x); else{ /* CHECKED rt bytes alike */ post("seq: unterminated sysex"); /* CHECKED */ seq_endofsysex(x); /* CHECKED 247 added implicitly */ seq_checkstatus(x, c); } } else if(c != 247) seq_checkstatus(x, c); } seq_update(x); } } static void seq_symbol(t_seq *x, t_symbol *s){ s = NULL; pd_error(x, "[seq]: no method for symbol"); } static void seq_list(t_seq *x, t_symbol *s, int ac, t_atom *av){ s = NULL; if(ac && av->a_type == A_FLOAT) seq_float(x, av->a_w.w_float); /* CHECKED anything else/more silently ignored */ } static void seq_record(t_seq *x){ // CHECKED 'record' stops playback, resets recording seq_doclear(x, 0); seq_update(x); seq_setmode(x, SEQ_RECMODE); } static void seq_append(t_seq *x){ /* CHECKED 'append' stops playback */ /* CHECKED if in SEQ_RECMODE, 'append' resets the timer */ seq_setmode(x, SEQ_RECMODE); } static void seq_start(t_seq *x, t_floatarg f){ if(f < -SEQ_STARTEPSILON) /* FIXME */ seq_setmode(x, SEQ_SLAVEMODE); // ticks else{ seq_settimescale(x, (f > SEQ_STARTEPSILON ? 1024. / f : 1.)); seq_setmode(x, SEQ_PLAYMODE); // CHECKED 'start' stops recording } } static void seq_stop(t_seq *x){ seq_setmode(x, SEQ_IDLEMODE); } // CHECKED first delta time is set permanently (it is stored in a file) static void seq_delay(t_seq *x, t_floatarg f){ if(x->x_nevents){ // CHECKED signed/unsigned bug (not emulated) t_float total_delay; x->x_delay = (f > SEQ_TICKEPSILON ? f : 0.); total_delay = (x->x_delay + x->x_event_delay); x->x_sequence->e_delta = (total_delay < 0 ? 0 : total_delay); } } static void seq_eventdelay(t_seq *x, t_floatarg f){ if(x->x_nevents){ // CHECKED signed/unsigned bug (not emulated) x->x_event_delay += f; t_float total_delay = (x->x_delay + x->x_event_delay); x->x_sequence->e_delta = (total_delay < 0 ? 0 : total_delay); } } // CHECKED all delta times are set permanently (they are stored in a file) static void seq_hook(t_seq *x, t_floatarg f){ int nevents; if((nevents = x->x_nevents)){ t_seqevent *ev = x->x_sequence; if(f < 0) f = 0; /* CHECKED signed/unsigned bug (not emulated) */ while(nevents--) ev++->e_delta *= f; } } // start of extra (not available in Max) static void seq_pause(t_seq *x){ if(x->x_mode == SEQ_PLAYMODE && SEQ_ISRUNNING(x)){ x->x_clockdelay -= clock_gettimesince(x->x_prevtime); if(x->x_clockdelay < 0.) x->x_clockdelay = 0.; clock_unset(x->x_clock); x->x_prevtime = 0.; } } static void seq_continue(t_seq *x){ if(x->x_mode == SEQ_PLAYMODE && SEQ_ISPAUSED(x)){ if(x->x_clockdelay < 0.) x->x_clockdelay = 0.; clock_delay(x->x_clock, x->x_clockdelay); x->x_prevtime = clock_getlogicaltime(); } } static void seq_click(t_seq *x, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt){ ctrl = alt = xpos = ypos = shift = 0; t_seqevent *ep = x->x_sequence; int nevents = x->x_nevents; char buf[MAXPDSTRING+2]; editor_open(x->x_filehandle, (char*)(x->x_defname && x->x_defname != &s_ ? x->x_defname->s_name : "<anonymous>"), 0); t_float sum = 0; while(nevents--){ // LATER rethink sysex continuation seq_eventstring(x, buf, ep, 1, &sum); strcat(buf, ";\n"); editor_append(x->x_filehandle, buf); ep++; } editor_setdirty(x->x_filehandle, 0); sys_vgui(" if {[winfo exists .%lx]} {\n", (unsigned long)x->x_filehandle); sys_vgui(" wm deiconify .%lx\n", (unsigned long)x->x_filehandle); sys_vgui(" raise .%lx\n", (unsigned long)x->x_filehandle); sys_vgui(" focus .%lx.text\n", (unsigned long)x->x_filehandle); sys_gui(" }\n"); } // not available in Max and removed for not working or not being pertinent (hence, unsupported) /* static void seq_goto(t_seq *x, t_floatarg f1, t_floatarg f2){ // takes sec / ms if(x->x_nevents){ t_seqevent *ev; int ndx, nevents = x->x_nevents; double ms = (double)f1 * 1000. + f2, sum; if(ms <= SEQ_TICKEPSILON) ms = 0.; if(x->x_mode != SEQ_PLAYMODE){ seq_settimescale(x, x->x_timescale); seq_setmode(x, SEQ_PLAYMODE); // clock_delay() has been called in setmode, LATER avoid clock_unset(x->x_clock); x->x_prevtime = 0.; } for(ndx = 0, ev = x->x_sequence, sum = SEQ_TICKEPSILON; ndx < nevents; ndx++, ev++){ if((sum += ev->e_delta) >= ms){ x->x_playhead = ndx; x->x_nextscoretime = sum; x->x_clockdelay = sum - SEQ_TICKEPSILON - ms; if(x->x_clockdelay < 0.) x->x_clockdelay = 0.; if(SEQ_ISRUNNING(x)){ clock_delay(x->x_clock, x->x_clockdelay); x->x_prevtime = clock_getlogicaltime(); } break; } } } } static void seq_scoretime(t_seq *x, t_symbol *s){ // send score time to a receive name s = canvas_realizedollar(x->x_canvas, s); if(s && s->s_thing && x->x_mode == SEQ_PLAYMODE){ // LATER other modes t_atom aout[2]; double ms, clockdelay = x->x_clockdelay; t_float f1, f2; if(SEQ_ISRUNNING(x)) clockdelay -= clock_gettimesince(x->x_prevtime); ms = x->x_nextscoretime - clockdelay / x->x_timescale; // Send ms as a pair of floats (f1, f2) = (coarse in sec, fine in msec). // Any ms may then be exactly reconstructed as (double)f1 * 1000. + f2. // Currently, f2 may be negative. LATER consider truncating f1 so that // only significant digits are on (when using 1 ms resolution, a float // stores only up to 8.7 minutes without distortion, 100 ms resolution // gives 14.5 hours of non-distorted floats, etc.) f1 = ms * .001; f2 = ms - (double)f1 * 1000.; if(f2 < .001 && f2 > -.001) f2 = 0.; SETFLOAT(&aout[0], f1); SETFLOAT(&aout[1], f2); pd_list(s->s_thing, &s_list, 2, aout); } } static void seq_tempo(t_seq *x, t_floatarg f){ if(f > SEQ_TEMPOEPSILON){ seq_settimescale(x, 1. / f); if(x->x_mode == SEQ_PLAYMODE) seq_startplayback(x, 0); } // FIXME else pause, LATER reverse playback if(f < -SEQ_TEMPOEPSILON) } static void seq_cd(t_seq *x, t_symbol *s){ panel_setopendir(x->x_filehandle, s); } static void seq_pwd(t_seq *x, t_symbol *s){ t_symbol *dir; s = canvas_realizedollar(x->x_canvas, s); if(s && s->s_thing && (dir = panel_getopendir(x->x_filehandle))) pd_symbol(s->s_thing, dir); }*/ // end of extra static int seq_eventcomparehook(const void *e1, const void *e2){ return(((t_seqevent *)e1)->e_delta > ((t_seqevent *)e2)->e_delta ? 1 : -1); } static int seq_tempocomparehook(const void *t1, const void *t2){ return(((t_seqtempo *)t1)->t_scoretime > ((t_seqtempo *)t2)->t_scoretime ? 1 : -1); } static int seq_mrhook(t_mifiread *mr, void *hookdata, int evtype){ t_seq *x = (t_seq *)hookdata; double scoretime = mifiread_getscoretime(mr); if((evtype >= 0x80 && evtype < 0xf0) || (evtype == MIFIMETA_EOT)){ if(x->x_eventreadhead < x->x_nevents){ t_seqevent *sev = &x->x_sequence[x->x_eventreadhead++]; int status = mifiread_getstatus(mr); sev->e_delta = scoretime; sev->e_bytes[0] = status | mifiread_getchannel(mr); sev->e_bytes[1] = mifiread_getdata1(mr); if(MIFI_ONEDATABYTE(status) || evtype == 0x2f) sev->e_bytes[2] = SEQ_EOM; else{ sev->e_bytes[2] = mifiread_getdata2(mr); sev->e_bytes[3] = SEQ_EOM; } } else if(x->x_eventreadhead == x->x_nevents){ pd_error(x, "bug [seq]: seq_mrhook 1"); x->x_eventreadhead++; } } else if(evtype == MIFIMETA_TEMPO){ if(x->x_temporeadhead < x->x_ntempi){ t_seqtempo *stm = &x->x_tempomap[x->x_temporeadhead++]; stm->t_scoretime = scoretime; stm->t_sr = mifiread_gettempo(mr); /* #ifdef SEQ_DEBUG loudbug_post("tempo %g at %g", stm->t_sr, scoretime); #endif */ } else if(x->x_temporeadhead == x->x_ntempi){ pd_error(x, "bug [seq]: seq_mrhook 2"); x->x_temporeadhead++; } } return(1); } /* apply tempo and fold */ static void seq_foldtime(t_seq *x, double deftempo){ t_seqevent *sev; t_seqtempo *stm = x->x_tempomap; double coef = 1000. / deftempo; int ex, tx = 0; double prevscoretime = 0.; while(tx < x->x_ntempi && stm->t_scoretime < SEQ_TICKEPSILON) tx++, coef = 1000. / stm++->t_sr; for(ex = 0, sev = x->x_sequence; ex < x->x_nevents; ex++, sev++){ double clockdelta = 0.; while(tx < x->x_ntempi && stm->t_scoretime <= sev->e_delta){ clockdelta += (stm->t_scoretime - prevscoretime) * coef; prevscoretime = stm->t_scoretime; tx++; coef = 1000. / stm++->t_sr; } clockdelta += (sev->e_delta - prevscoretime) * coef; prevscoretime = sev->e_delta; sev->e_delta = clockdelta; } } static int seq_mfread(t_seq *x, char *path){ int result = 0; t_mifiread *mr = mifiread_new((t_pd *)x); if(!mifiread_open(mr, path, "", 0)) goto mfreadfailed; /* #ifdef SEQ_DEBUG post("midifile (format %d): %d tracks, %d ticks", mifiread_getformat(mr), mifiread_gethdtracks(mr), mifiread_getbeatticks(mr)); if(mifiread_getnframes(mr)) post(" (%d smpte frames)", mifiread_getnframes(mr)); else post(" per beat"); #endif */ if(!seq_dogrowing(x, mifiread_getnevents(mr), mifiread_getntempi(mr))) goto mfreadfailed; x->x_eventreadhead = 0; x->x_temporeadhead = 0; if(mifiread_doit(mr, seq_mrhook, x) != MIFIREAD_EOF) goto mfreadfailed; if(x->x_eventreadhead < x->x_nevents){ pd_error(x, "bug [seq]: seq_mfread 1"); post("declared %d events, got %d", x->x_nevents, x->x_eventreadhead); x->x_nevents = x->x_eventreadhead; } if(x->x_nevents) qsort(x->x_sequence, x->x_nevents, sizeof(*x->x_sequence), seq_eventcomparehook); if(x->x_temporeadhead < x->x_ntempi){ pd_error(x, "bug [seq]: seq_mfread 2"); post("declared %d tempi, got %d", x->x_ntempi, x->x_temporeadhead); x->x_ntempi = x->x_temporeadhead; } if(x->x_ntempi) qsort(x->x_tempomap, x->x_ntempi, sizeof(*x->x_tempomap), seq_tempocomparehook); seq_foldtime(x, mifiread_getdeftempo(mr)); /* #ifdef SEQ_DEBUG loudbug_post("seq: got %d events from midi file", x->x_nevents); #endif */ result = 1; mfreadfailed: mifiread_free(mr); return(result); } static int seq_mfwrite(t_seq *x, char *path){ int result = 0; t_seqevent *sev = x->x_sequence; int nevents = x->x_nevents; t_mifiwrite *mw = mifiwrite_new((t_pd *)x); if(!mifiwrite_open(mw, path, "", 1, 1)) goto mfwritefailed; if(!mifiwrite_opentrack(mw, "seq-track", 1)) goto mfwritefailed; while(nevents--){ unsigned char *bp = sev->e_bytes; unsigned status = *bp & 0xf0; if(status > 127 && status < 240){ if(!mifiwrite_channelevent(mw, sev->e_delta, status, *bp & 0x0f, bp[1], bp[2])){ /* SEQ_EOM ignored */ pd_error(x, "[seq] cannot write channel event %d", status); goto mfwritefailed; } } /* FIXME system, sysex (first, and continuation) */ sev++; } if(!mifiwrite_closetrack(mw, 0., 1)) goto mfwritefailed; mifiwrite_close(mw); result = 1; mfwritefailed: if(!result) post("while saving sequence into midi file \"%s\"", path); mifiwrite_free(mw); return(result); } /* CHECKED text file input: absolute timestamps, semi-terminated, verified */ /* FIXME prevent loading .pd files... */ static int seq_fromatoms(t_seq *x, int ac, t_atom *av){ int i, nevents = 0; t_atom *ap; for(i = 0, ap = av; i < ac; i++, ap++) if(ap->a_type == A_SEMI) /* FIXME parsing */ nevents++; if(nevents){ t_seqevent *ep; float prevtime = 0; if(!seq_dogrowing(x, nevents, 0)) return(0); i = -1; nevents = 0; ep = x->x_sequence; while(ac--){ if(av->a_type == A_FLOAT){ if(i < 0){ ep->e_delta = av->a_w.w_float - prevtime; prevtime = av->a_w.w_float; i = 0; } else if(i < 4) ep->e_bytes[i++] = av->a_w.w_float; // CHECKME else } else if(av->a_type == A_SEMI && i > 0){ if(i < 4) ep->e_bytes[i] = SEQ_EOM; nevents++; ep++; i = -1; } // CHECKME else av++; } x->x_nevents = nevents; } return(nevents); } static void seq_tobinbuf(t_seq *x, t_binbuf *bb){ int nevents = x->x_nevents; t_seqevent *ep = x->x_sequence; t_atom at[5]; float timestamp = 0; while(nevents--){ unsigned char *bp = ep->e_bytes; int i; t_atom *ap = at; timestamp += ep->e_delta; SETFLOAT(ap, timestamp); /* CHECKED same for sysex continuation */ ap++; SETFLOAT(ap, *bp); for(i = 0, ap++, bp++; i < 3 && *bp != SEQ_EOM; i++, ap++, bp++) SETFLOAT(ap, *bp); binbuf_add(bb, i + 2, at); binbuf_addsemi(bb); ep++; } } static void seq_textread(t_seq *x, char *path){ t_binbuf *bb; bb = binbuf_new(); if(binbuf_read(bb, path, "", 0)) // CHECKED no complaint, open dialog presented panel_open(x->x_filehandle, 0); /* LATER rethink */ else{ int nlines = /* CHECKED absolute timestamps */ seq_fromatoms(x, binbuf_getnatom(bb), binbuf_getvec(bb)); if(nlines < 0) /* CHECKED "bad MIDI file (truncated)" alert, even if a text file */ pd_error(x, "[seq]: bad text file (truncated)"); else if(nlines == 0){ /* CHECKED no complaint, sequence erased, LATER rethink */ } } binbuf_free(bb); } static void seq_textwrite(t_seq *x, char *path){ t_binbuf *bb; bb = binbuf_new(); seq_tobinbuf(x, bb); /* CHECKED empty sequence stored as an empty file */ if(binbuf_write(bb, path, "", 0)){ /* CHECKME complaint and FIXME */ pd_error(x, "[seq]: error writing text file"); } binbuf_free(bb); } static void seq_doread(t_seq *x, t_symbol *fn){ char buf[MAXPDSTRING]; /* FIXME use open_via_path() */ if(x->x_canvas) canvas_makefilename(x->x_canvas, fn->s_name, buf, MAXPDSTRING); else{ strncpy(buf, fn->s_name, MAXPDSTRING); buf[MAXPDSTRING-1] = 0; } FILE *fp = sys_fopen(buf, "r"); if(!(fp)){ post("[seq] file '%s' not found", buf); fclose(fp); return; } fclose(fp); /* CHECKED all cases: arg or not, message and creation */ // post("seq: reading %s", fn->s_name); if(!seq_mfread(x, buf)) seq_textread(x, buf); x->x_playhead = 0; seq_update(x); } static void seq_dowrite(t_seq *x, t_symbol *fn){ char buf[MAXPDSTRING], *dotp; if(x->x_canvas) canvas_makefilename(x->x_canvas, fn->s_name, buf, MAXPDSTRING); else{ strncpy(buf, fn->s_name, MAXPDSTRING); buf[MAXPDSTRING-1] = 0; } // post("seq: writing %s", fn->s_name); /* save as text for any extension other then ".mid" */ if((dotp = strrchr(fn->s_name, '.')) && strcmp(dotp + 1, "mid")) seq_textwrite(x, buf); else /* save as mf for ".mid" (FIXME ignore case?) or no extension at all, LATER rethink */ seq_mfwrite(x, buf); } static void seq_readhook(t_pd *z, t_symbol *fn, int ac, t_atom *av){ ac = 0; av = NULL; seq_doread((t_seq *)z, fn); } static void seq_writehook(t_pd *z, t_symbol *fn, int ac, t_atom *av){ ac = 0; av = NULL; seq_dowrite((t_seq *)z, fn); } static void seq_read(t_seq *x, t_symbol *s){ if(s && s != &s_) seq_doread(x, s); else /* CHECKED no default file name */ /* start in a dir last read from, if any, otherwise in a canvas dir */ panel_open(x->x_filehandle, 0); } static void seq_write(t_seq *x, t_symbol *s){ if(s && s != &s_) seq_dowrite(x, s); else /* CHECKED creation arg is a default file name */ panel_save(x->x_filehandle, canvas_getdir(x->x_canvas), x->x_defname); /* always start in canvas dir */ } static void seq_print(t_seq *x){ int nevents = x->x_nevents; startpost("midiseq:"); // CHECKED if(nevents){ t_seqevent *ep = x->x_sequence; char buf[MAXPDSTRING+2]; int truncated; if(nevents > 16) nevents = 16, truncated = 1; else truncated = 0; endpost(); t_float sum = 0; while(nevents--){ // CHECKED bytes are space-separated, no semi seq_eventstring(x, buf, ep, 0, &sum); post(buf); ep++; } if(truncated) post("..."); // CHECKED } else post(" no sequence"); // CHECKED } static void seq_editorhook(t_pd *z, t_symbol *s, int ac, t_atom *av){ s = NULL; seq_fromatoms((t_seq *)z, ac, av); } static void seq_free(t_seq *x){ if(x->x_clock) clock_free(x->x_clock); if(x->x_slaveclock) clock_free(x->x_slaveclock); if(x->x_filehandle) file_free(x->x_filehandle); if(x->x_sequence != x->x_seqini) freebytes(x->x_sequence, x->x_seqsize * sizeof(*x->x_sequence)); if(x->x_tempomap != x->x_tempomapini) freebytes(x->x_tempomap, x->x_tempomapsize * sizeof(*x->x_tempomap)); } static void *seq_new(t_symbol *s){ t_seq *x = (t_seq *)pd_new(seq_class); x->x_canvas = canvas_getcurrent(); x->x_filehandle = file_new((t_pd *)x, 0, seq_readhook, seq_writehook, seq_editorhook); x->x_timescale = 1.; x->x_newtimescale = 1.; x->x_prevtime = 0.; x->x_slaveprevtime = 0.; x->x_seqsize = SEQ_INISEQSIZE; x->x_nevents = 0; x->x_delay = x->x_event_delay = 0; x->x_sequence = x->x_seqini; x->x_tempomapsize = SEQ_INITEMPOMAPSIZE; x->x_ntempi = 0; x->x_tempomap = x->x_tempomapini; outlet_new((t_object *)x, &s_anything); x->x_bangout = outlet_new((t_object *)x, &s_bang); if(s && s != &s_){ x->x_defname = s; /* CHECKME if 'read' changes this */ seq_doread(x, s); } else x->x_defname = &s_; x->x_clock = clock_new(x, (t_method)seq_clocktick); x->x_slaveclock = clock_new(x, (t_method)seq_slaveclocktick); return(x); } CYCLONE_OBJ_API void seq_setup(void){ seq_class = class_new(gensym("seq"), (t_newmethod)seq_new, (t_method)seq_free, sizeof(t_seq), 0, A_DEFSYM, 0); class_addbang(seq_class, seq_bang); class_addfloat(seq_class, seq_float); // CHECKED symbol rejected class_addsymbol(seq_class, seq_symbol); // CHECKED 1st atom of a list accepted if a float, ignored if a symbol class_addlist(seq_class, seq_list); class_addmethod(seq_class, (t_method)seq_clear, gensym("clear"), 0); class_addmethod(seq_class, (t_method)seq_record, gensym("record"), 0); class_addmethod(seq_class, (t_method)seq_append, gensym("append"), 0); class_addmethod(seq_class, (t_method)seq_start, gensym("start"), A_DEFFLOAT, 0); class_addmethod(seq_class, (t_method)seq_stop, gensym("stop"), 0); class_addmethod(seq_class, (t_method)seq_tick, gensym("tick"), 0); class_addmethod(seq_class, (t_method)seq_delay, gensym("delay"), A_FLOAT, 0); class_addmethod(seq_class, (t_method)seq_eventdelay, gensym("addeventdelay"), A_FLOAT, 0); class_addmethod(seq_class, (t_method)seq_hook, gensym("hook"), A_FLOAT, 0); class_addmethod(seq_class, (t_method)seq_read, gensym("read"), A_DEFSYM, 0); class_addmethod(seq_class, (t_method)seq_write, gensym("write"), A_DEFSYM, 0); class_addmethod(seq_class, (t_method)seq_print, gensym("print"), 0); // not available in Max class_addmethod(seq_class, (t_method)seq_pause, gensym("pause"), 0); class_addmethod(seq_class, (t_method)seq_continue, gensym("continue"), 0); class_addmethod(seq_class, (t_method)seq_click, gensym("click"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); // not available in Max and removed for being considered problematic (hence, unsupported) /* class_addmethod(seq_class, (t_method)seq_goto, gensym("goto"), A_DEFFLOAT, A_DEFFLOAT, 0); class_addmethod(seq_class, (t_method)seq_scoretime, gensym("scoretime"), A_SYMBOL, 0); class_addmethod(seq_class, (t_method)seq_tempo, gensym("tempo"), A_FLOAT, 0); class_addmethod(seq_class, (t_method)seq_cd, gensym("cd"), A_DEFSYM, 0); class_addmethod(seq_class, (t_method)seq_pwd, gensym("pwd"), A_SYMBOL, 0);*/ file_setup(seq_class, 0); }
porres/pd-cyclone
cyclone_objects/binaries/audio/deltaclip.c
<gh_stars>100-1000 /* Copyright (c) 2002-2003 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ // updated 2016 by <NAME> and 2021 by porres #include "m_pd.h" #include <common/api.h> typedef struct _deltaclip{ t_object x_obj; t_float x_last; t_inlet *x_lolet; t_inlet *x_hilet; }t_deltaclip; static t_class *deltaclip_class; static t_int *deltaclip_perform(t_int *w){ t_deltaclip *x = (t_deltaclip *)(w[1]); int nblock = (int)(w[2]); t_float *in1 = (t_float *)(w[3]); t_float *in2 = (t_float *)(w[4]); t_float *in3 = (t_float *)(w[5]); t_float *out = (t_float *)(w[6]); t_float last = x->x_last; while(nblock--){ float f = *in1++; float delta = f - last; float lo = *in2++; if(lo > 0) lo = 0; float hi = *in3++; if(hi < 0) hi = 0; if(delta < lo) f = last + lo; else if (delta > hi) f = last + hi; *out++ = last = f; } x->x_last = last; return(w+7); } static void deltaclip_dsp(t_deltaclip *x, t_signal **sp){ dsp_add(deltaclip_perform, 6, x, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec); } static void deltaclip_reset(t_deltaclip *x){ x->x_last = 0; } static void *deltaclip_free(t_deltaclip *x){ inlet_free(x->x_lolet); inlet_free(x->x_hilet); return(void *)x; } static void *deltaclip_new(t_symbol *s, int argc, t_atom *argv){ t_deltaclip *x = (t_deltaclip *)pd_new(deltaclip_class); t_float cliplo = 0, cliphi = 0; int argnum = 0; while(argc > 0){ if(argv -> a_type == A_FLOAT){ t_float argval = atom_getfloatarg(0,argc,argv); switch(argnum){ case 0: cliplo = argval; break; case 1: cliphi = argval; break; default: break; }; argc--; argv++; argnum++; } else{ goto errstate; }; }; x->x_lolet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); pd_float((t_pd *)x->x_lolet, cliplo); x->x_hilet = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal); pd_float((t_pd *)x->x_hilet, cliphi); outlet_new((t_object *)x, &s_signal); x->x_last = 0; return(x); errstate: pd_error(x, "deltaclip~: improper args"); return(NULL); } CYCLONE_OBJ_API void deltaclip_tilde_setup(void){ deltaclip_class = class_new(gensym("deltaclip~"), (t_newmethod)deltaclip_new, (t_method)deltaclip_free, sizeof(t_deltaclip), 0, A_GIMME, 0); class_addmethod(deltaclip_class, nullfn, gensym("signal"), 0); class_addmethod(deltaclip_class, (t_method)deltaclip_dsp, gensym("dsp"), A_CANT, 0); class_addmethod(deltaclip_class, (t_method)deltaclip_reset, gensym("reset"), 0); }
porres/pd-cyclone
cyclone_objects/binaries/control/coll.c
<filename>cyclone_objects/binaries/control/coll.c<gh_stars>100-1000 /* Copyright (c) 2002-2005 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ /*2016 - making COLLTHREAD,COLLEMBED, coll_embed, attribute parsing, redundant insert2, edit to not autosort in collcommon_tonumkey, adding coll_renumber2 and collcommon_renumber2 before used to always bang on callback, now only bangs now due to new x->x_filebang (which i'm not sure works with panel_open....) - <NAME> */ #include <stdio.h> #include <string.h> #include "m_pd.h" #include <common/api.h> #include "g_canvas.h" #include "common/file.h" #include <pthread.h> #ifdef HAVE_UNISTD_H #include <unistd.h> #endif /* LATER profile for the bottlenecks of insertion and sorting */ /* LATER make sure that ``reentrancy protection hack'' is really working... */ /* #ifdef KRZYSZCZ //#define COLL_DEBUG #endif */ #define COLLTHREAD 1 //default is threaded #define COLLEMBED 0 //default for save in patch #define COLL_ALLBANG 1 //bang all when read instead of specific object #define COLL_MAXEXTLEN 4 //maximum file extension length enum{COLL_HEADRESET, COLL_HEADNEXT, COLL_HEADPREV, // distinction not used, currently COLL_HEADDELETED }; typedef struct _collelem{ int e_hasnumkey; int e_numkey; t_symbol *e_symkey; struct _collelem *e_prev; struct _collelem *e_next; int e_size; t_atom *e_data; }t_collelem; typedef struct _collcommon{ t_pd c_pd; struct _coll *c_refs; /* used in read-banging and dirty flag handling */ int c_increation; int c_volatile; int c_selfmodified; int c_fileoninit; //if successfully loading a file on init int c_entered; /* a counter, LATER rethink */ int c_embedflag; /* common field (CHECKED in 'TEXT' files) */ t_symbol *c_filename; /* CHECKED common for all, read and write */ t_canvas *c_lastcanvas; t_file *c_filehandle; t_collelem *c_first; t_collelem *c_last; t_collelem *c_head; int c_headstate; }t_collcommon; typedef struct _coll_q{ /* element in a linked list of stored messages waiting to be sent out */ struct _coll_q *q_next; /* next in list */ char *q_s; /* the string */ }t_coll_q; typedef struct _coll{ t_object x_ob; t_canvas *x_canvas; t_symbol *x_name; t_collcommon *x_common; t_file *x_filehandle; t_outlet *x_keyout; t_outlet *x_filebangout; t_outlet *x_dumpbangout; t_symbol *x_bindsym; int x_is_opened; int x_threaded; int x_nosearch; int x_initread; //if we're reading a file for the first time int x_filebang; //if we're expecting to bang out 3rd outlet struct _coll *x_next; // for thread-unsafe file i/o operations added by <NAME> <<EMAIL>> 9-24-2010 // http://disis.music.vt.edu http://l2ork.music.vt.edu t_clock *x_clock; pthread_t unsafe_t; pthread_mutex_t unsafe_mutex; pthread_cond_t unsafe_cond; t_symbol *x_s; t_symbol *x_fileext; t_int unsafe; t_int init; //used to make sure that the secondary thread is ready to go t_int threaded; //used to decide whether this should be a threaded instance t_coll_q *x_q; //a list of error messages to be processed }t_coll; typedef struct _msg{ int m_flag; int m_line; }t_msg; typedef struct _threadedFunctionParams{ t_coll *x; }t_threadedFunctionParams; static t_class *coll_class; static t_class *collcommon_class; // if fileext is set, append it static t_symbol * coll_fullfilename(t_coll *x, t_symbol * filename){ char buf[MAXPDSTRING]; if(x->x_fileext != &s_){ strncpy(buf, filename->s_name, MAXPDSTRING - COLL_MAXEXTLEN - 1); //need space for period strcat(buf, "."); strcat(buf, x->x_fileext->s_name); return (gensym(buf)); } else return (filename); } /// Porres: de-louding in a lazy way void coll_messarg(t_pd *x, t_symbol *s){ pd_error(x, "[coll]: bad arguments for message \"%s\"", s->s_name); } int coll_checkint(t_pd *x, t_float f, int *valuep, t_symbol *mess){ if((*valuep = (int)f) == f) return (1); else{ if(mess == &s_float) pd_error(x, "[coll]: doesn't understand \"noninteger float\""); else if(mess) pd_error(x, "[coll]: \"noninteger float\" argument invalid for message \"%s\"", mess->s_name); return (0); } } /// static void coll_q_free(t_coll *x){ t_coll_q *q2; while(x->x_q){ q2 = x->x_q->q_next; t_freebytes(x->x_q->q_s, strlen(x->x_q->q_s) + 1); t_freebytes(x->x_q, sizeof(*x->x_q)); x->x_q = q2; } x->x_q = NULL; } static void coll_q_post(t_coll_q *q){ t_coll_q *qtmp; for(qtmp = q; qtmp; qtmp = qtmp->q_next) post("%s", qtmp->q_s); } static void coll_q_enqueue(t_coll *x, const char *s){ t_coll_q *q, *q2 = NULL; q = (t_coll_q *)(getbytes(sizeof(*q))); q->q_next = NULL; q->q_s = (char *)getbytes(strlen(s) + 1); strcpy(q->q_s, s); if(!x->x_q) x->x_q = q; else{ q2 = x->x_q; while(q2->q_next) q2 = q2->q_next; q2->q_next = q; } } static void coll_enqueue_threaded_msgs(t_coll *x, t_msg *m){ char s[MAXPDSTRING]; if(m->m_flag & 1) coll_q_enqueue(x, s); if(m->m_flag & 2){ sprintf(s, "coll: can't find file '%s'", x->x_s->s_name); coll_q_enqueue(x, s); } if(m->m_flag & 4){ //sprintf(s, "coll: finished reading %d lines from text file '%s'", m->m_line, x->x_s->s_name); //coll_q_enqueue(x, s); } if(m->m_flag & 8) { sprintf(s, "coll: error in line %d of text file '%s'", m->m_line, x->x_s->s_name); coll_q_enqueue(x, s); } if(m->m_flag & 16){ sprintf(s, "coll: can't find file '%s'", x->x_s->s_name); coll_q_enqueue(x, s); } if(m->m_flag & 32) { sprintf(s, "coll: error writing text file '%s'", x->x_s->s_name); coll_q_enqueue(x, s); } } static void coll_tick(t_coll *x){ if(x->x_q){ coll_q_post(x->x_q); coll_q_free(x); }; if(x->x_filebang && (!COLL_ALLBANG || x->x_initread)){ x->x_initread = 0; outlet_bang(x->x_filebangout); x->x_filebang = 0; }; } static t_collelem *collelem_new(int ac, t_atom *av, int *np, t_symbol *s){ t_collelem *ep = (t_collelem *)getbytes(sizeof(*ep)); if((ep->e_hasnumkey = (np != 0))) ep->e_numkey = *np; ep->e_symkey = s; ep->e_prev = ep->e_next = 0; if((ep->e_size = ac)){ t_atom *ap = getbytes(ac * sizeof(*ap)); ep->e_data = ap; if(av) while(ac--) *ap++ = *av++; else while(ac--){ SETFLOAT(ap, 0); ap++; } } else ep->e_data = 0; return (ep); } static void collelem_free(t_collelem *ep){ if(ep->e_data) freebytes(ep->e_data, ep->e_size * sizeof(*ep->e_data)); freebytes(ep, sizeof(*ep)); } /* CHECKME again... apparently c74 is not able to fix this for good */ /* result: 1 for ep1 < ep2, 0 for ep1 >= ep2, all symbols are < any float */ static int collelem_less(t_collelem *ep1, t_collelem *ep2, int ndx, int swap){ int isless; if(swap){ t_collelem *ep = ep1; ep1 = ep2; ep2 = ep; } if(ndx < 0){ const char *st1 = ep1->e_symkey->s_name; const char *st2 = ep2->e_symkey->s_name; if(ep1->e_symkey) // CHECKED incompatible with 4.07, but consistent isless = (ep2->e_symkey ? strcmp(st1, st2) < 0 : 1); else if(ep2->e_symkey) isless = 0; // CHECKED incompatible with 4.07, but consistent else isless = (ep1->e_numkey < ep2->e_numkey); // CHECKED in 4.07 } else{ t_atom *ap1 = (ndx < ep1->e_size ? ep1->e_data + ndx : ep1->e_data + ep1->e_size - 1); t_atom *ap2 = (ndx < ep2->e_size ? ep2->e_data + ndx : ep2->e_data + ep2->e_size - 1); if(ap1->a_type == A_FLOAT){ if(ap2->a_type == A_FLOAT) isless = (ap1->a_w.w_float < ap2->a_w.w_float); else if(ap2->a_type == A_SYMBOL) isless = 0; else isless = 1; } else if(ap1->a_type == A_SYMBOL){ if(ap2->a_type == A_FLOAT) isless = 1; else if(ap2->a_type == A_SYMBOL) isless = (strcmp(ap1->a_w.w_symbol->s_name, ap2->a_w.w_symbol->s_name) < 0); else isless = 1; } else isless = 0; } return(isless); } static t_collelem *collcommon_numkey(t_collcommon *cc, int numkey){ t_collelem *ep; for(ep = cc->c_first; ep; ep = ep->e_next) if(ep->e_hasnumkey && ep->e_numkey == numkey) return(ep); return(0); } static t_collelem *collcommon_symkey(t_collcommon *cc, t_symbol *symkey){ t_collelem *ep; for(ep = cc->c_first; ep; ep = ep->e_next) if(ep->e_symkey == symkey) return(ep); return(0); } static void collcommon_takeout(t_collcommon *cc, t_collelem *ep){ if(ep->e_prev) ep->e_prev->e_next = ep->e_next; else cc->c_first = ep->e_next; if(ep->e_next) ep->e_next->e_prev = ep->e_prev; else cc->c_last = ep->e_prev; if(cc->c_head == ep){ cc->c_head = ep->e_next; /* asymmetric, LATER rethink */ cc->c_headstate = COLL_HEADDELETED; } } static void collcommon_modified(t_collcommon *cc, int relinked){ if(cc->c_increation) return; if(relinked) cc->c_volatile = 1; if(cc->c_embedflag){ t_coll *x; for(x = cc->c_refs; x; x = x->x_next) if(x->x_canvas && glist_isvisible(x->x_canvas)) canvas_dirty(x->x_canvas, 1); } } /* atomic collcommon modifiers: clearall, remove, replace, putbefore, putafter, swaplinks, swapkeys, changesymkey, renumber, sort */ static void collcommon_clearall(t_collcommon *cc){ if(cc->c_first){ t_collelem *ep1 = cc->c_first, *ep2; do{ ep2 = ep1->e_next; collelem_free(ep1); } while((ep1 = ep2)); cc->c_first = cc->c_last = 0; cc->c_head = 0; cc->c_headstate = COLL_HEADRESET; collcommon_modified(cc, 1); } } static void collcommon_remove(t_collcommon *cc, t_collelem *ep){ collcommon_takeout(cc, ep); collelem_free(ep); collcommon_modified(cc, 1); } static void collcommon_replace(t_collcommon *cc, t_collelem *ep, int ac, t_atom *av, int *np, t_symbol *s){ if((ep->e_hasnumkey = (np != 0))) ep->e_numkey = *np; ep->e_symkey = s; if(ac){ int i = ac; t_atom *ap; if(ep->e_data){ if(ep->e_size != ac) ap = resizebytes(ep->e_data, ep->e_size * sizeof(*ap), ac * sizeof(*ap)); else ap = ep->e_data; } else ap = getbytes(ac * sizeof(*ap)); ep->e_data = ap; if(av) while(i --) *ap++ = *av++; else while(i --){ SETFLOAT(ap, 0); ap++; } } else{ if(ep->e_data) freebytes(ep->e_data, ep->e_size * sizeof(*ep->e_data)); ep->e_data = 0; } ep->e_size = ac; collcommon_modified(cc, 0); } static void collcommon_putbefore(t_collcommon *cc, t_collelem *ep, t_collelem *next){ if(next){ ep->e_next = next; if((ep->e_prev = next->e_prev)) ep->e_prev->e_next = ep; else cc->c_first = ep; next->e_prev = ep; } else if(cc->c_first || cc->c_last) bug("collcommon_putbefore"); else cc->c_first = cc->c_last = ep; collcommon_modified(cc, 1); } static void collcommon_putafter(t_collcommon *cc, t_collelem *ep, t_collelem *prev){ if(prev){ ep->e_prev = prev; if((ep->e_next = prev->e_next)) ep->e_next->e_prev = ep; else cc->c_last = ep; prev->e_next = ep; } else if(cc->c_first || cc->c_last) bug("collcommon_putafter"); else cc->c_first = cc->c_last = ep; collcommon_modified(cc, 1); } /* LATER consider making it faster, if there is a real need. Now called only in the sort routine, once per sort. */ static void collcommon_swaplinks(t_collcommon *cc, t_collelem *ep1, t_collelem *ep2){ if(ep1 != ep2){ t_collelem *prev1 = ep1->e_prev, *prev2 = ep2->e_prev; if(prev1 == ep2){ collcommon_takeout(cc, ep2); collcommon_putafter(cc, ep2, ep1); } else if(prev2 == ep1){ collcommon_takeout(cc, ep1); collcommon_putafter(cc, ep1, ep2); } else if(prev1){ if(prev2){ collcommon_takeout(cc, ep1); collcommon_takeout(cc, ep2); collcommon_putafter(cc, ep1, prev2); collcommon_putafter(cc, ep2, prev1); } else{ t_collelem *next2 = ep2->e_next; collcommon_takeout(cc, ep1); collcommon_takeout(cc, ep2); collcommon_putbefore(cc, ep1, next2); collcommon_putafter(cc, ep2, prev1); } } else if(prev2){ t_collelem *next1 = ep1->e_next; collcommon_takeout(cc, ep1); collcommon_takeout(cc, ep2); collcommon_putafter(cc, ep1, prev2); collcommon_putbefore(cc, ep2, next1); } else bug("collcommon_swaplinks"); } } static void collcommon_swapkeys(t_collcommon *cc, t_collelem *ep1, t_collelem *ep2){ int hasnumkey = ep2->e_hasnumkey, numkey = ep2->e_numkey; t_symbol *symkey = ep2->e_symkey; ep2->e_hasnumkey = ep1->e_hasnumkey; ep2->e_numkey = ep1->e_numkey; ep2->e_symkey = ep1->e_symkey; ep1->e_hasnumkey = hasnumkey; ep1->e_numkey = numkey; ep1->e_symkey = symkey; collcommon_modified(cc, 0); } static void collcommon_changesymkey(t_collcommon *cc, t_collelem *ep, t_symbol *s){ ep->e_symkey = s; collcommon_modified(cc, 0); } static void collcommon_renumber2(t_collcommon *cc, int startkey){ //entries with keys >= startkey get incremented by one t_collelem *ep; for(ep = cc->c_first; ep; ep = ep->e_next){ if(ep->e_hasnumkey){ if(ep->e_numkey >= startkey){ ep->e_numkey = ep->e_numkey + 1; }; }; }; //i have no idea what this does but renumber does it so i'm doing it too - DK collcommon_modified(cc, 0); } static void collcommon_renumber(t_collcommon *cc, int startkey){ t_collelem *ep; for(ep = cc->c_first; ep; ep = ep->e_next) if(ep->e_hasnumkey) ep->e_numkey = startkey++; collcommon_modified(cc, 0); } /* LATER choose a better algo, after coll's storage structures stabilize. Note, that even the simple insertion sort below (n-square) might prove better for bi-directional lists, than theoretically efficient algo (nlogn) requiring random access emulation. Avoiding recursion is not a bad idea, too. */ static void collcommon_sort(t_collcommon *cc, int descending, int ndx){ t_collelem *min = cc->c_first; t_collelem *ep; if(min && (ep = min->e_next)){ cc->c_increation = 1; // search for a sentinel element do if(collelem_less(ep, min, ndx, descending)) min = ep; while((ep = ep->e_next)); // prepend it collcommon_swaplinks(cc, cc->c_first, min); // sort ep = min->e_next->e_next; while(ep){ t_collelem *next = ep->e_next; for(min = ep->e_prev; min && collelem_less(ep, min, ndx, descending); min = min->e_prev); if(!min) /* LATER remove */ bug("collcommon_sort"); else if(ep != min->e_next){ collcommon_takeout(cc, ep); collcommon_putafter(cc, ep, min); } ep = next; } cc->c_increation = 0; collcommon_modified(cc, 1); } } static void collcommon_adddata(t_collcommon *cc, t_collelem *ep, int ac, t_atom *av){ if(ac){ t_atom *ap; int newsize = ep->e_size + ac; if(ep->e_data) ap = resizebytes(ep->e_data, ep->e_size * sizeof(*ap), newsize * sizeof(*ap)); else{ ep->e_size = 0; /* redundant, hopefully */ ap = getbytes(newsize * sizeof(*ap)); } ep->e_data = ap; ap += ep->e_size; if(av) while(ac--) *ap++ = *av++; else while(ac--){ SETFLOAT(ap, 0); ap++; } ep->e_size = newsize; collcommon_modified(cc, 0); } } /* //old autosorting collcommon_tonumkey which INSERTS static t_collelem *collcommon_tonumkey(t_collcommon *cc, int numkey, int ac, t_atom *av, int replace) { t_collelem *old = collcommon_numkey(cc, numkey), *new; if(old && replace) collcommon_replace(cc, new = old, ac, av, &numkey, 0); else { new = collelem_new(ac, av, &numkey, 0); if(old) { collcommon_putbefore(cc, new, old); do if(old->e_hasnumkey) //CHECKED incremented up to the last one; incompatible: // elements with numkey == 0 not incremented (a bug?) old->e_numkey++; while(old = old->e_next); } else { // CHECKED negative numkey always put before the last element, // zero numkey always becomes the new head int closestkey = 0; t_collelem *closest = 0, *ep; for(ep = cc->c_first; ep; ep = ep->e_next) { if(ep->e_hasnumkey) { if(numkey >= closestkey && numkey <= ep->e_numkey) { collcommon_putbefore(cc, new, ep); break; } closestkey = ep->e_numkey; } closest = ep; } if(!ep) { if(numkey <= closestkey) collcommon_putbefore(cc, new, closest); else collcommon_putafter(cc, new, closest); } } } return (new); } */ static t_collelem *collcommon_tonumkey(t_collcommon *cc, int numkey, int ac, t_atom *av, int replace){ //collcommon_numkey checks existence of key t_collelem *old = collcommon_numkey(cc, numkey), *new; if(old && replace) collcommon_replace(cc, new = old, ac, av, &numkey, 0); else{ new = collelem_new(ac, av, &numkey, 0); if(old){ do if(old->e_hasnumkey) //CHECKED incremented up to the last one; incompatible: // elements with numkey == 0 not incremented (a bug?) old->e_numkey++; while((old = old->e_next)); }; // CHECKED negative numkey always put before the last element, // zero numkey always becomes the new head t_collelem *closest = 0, *ep; for(ep = cc->c_first; ep; ep = ep->e_next) closest = ep; collcommon_putafter(cc, new, closest); } return(new); } static t_collelem *collcommon_tosymkey(t_collcommon *cc, t_symbol *symkey, int ac, t_atom *av, int replace){ t_collelem *old = collcommon_symkey(cc, symkey), *new; if(old && replace) collcommon_replace(cc, new = old, ac, av, 0, symkey); else collcommon_putafter(cc, new = collelem_new(ac, av, 0, symkey), cc->c_last); return (new); } static int collcommon_fromatoms(t_collcommon *cc, int ac, t_atom *av){ int hasnumkey = 0, numkey; t_symbol *symkey = 0; int size = 0; t_atom *data = 0; int nlines = 0; cc->c_increation = 1; collcommon_clearall(cc); while(ac--){ if(data){ if(av->a_type == A_SEMI){ t_collelem *ep = collelem_new(size, data, hasnumkey ? &numkey : 0, symkey); collcommon_putafter(cc, ep, cc->c_last); hasnumkey = 0; symkey = 0; data = 0; nlines++; } if(av->a_type == A_COMMA){ /* CHECKED rejecting a comma */ collcommon_clearall(cc); /* LATER rethink */ cc->c_increation = 0; return (-nlines); } else size++; } else if(av->a_type == A_COMMA){ size = 0; data = av + 1; } else if(av->a_type == A_SYMBOL) symkey = av->a_w.w_symbol; else if(av->a_type == A_FLOAT && coll_checkint(0, av->a_w.w_float, &numkey, 0)) hasnumkey = 1; else{ post("coll: bad atom"); collcommon_clearall(cc); /* LATER rethink */ cc->c_increation = 0; return (-nlines); } av++; } if(data){ post("coll: incomplete"); collcommon_clearall(cc); /* LATER rethink */ cc->c_increation = 0; return (-nlines); } cc->c_increation = 0; return (nlines); } static int collcommon_frombinbuf(t_collcommon *cc, t_binbuf *bb){ return (collcommon_fromatoms(cc, binbuf_getnatom(bb), binbuf_getvec(bb))); } static t_msg *collcommon_doread(t_collcommon *cc, t_symbol *fn, t_canvas *cv, int threaded){ t_binbuf *bb; t_msg *m = (t_msg *)(getbytes(sizeof(*m))); m->m_flag = 0; m->m_line = 0; char buf[MAXPDSTRING]; if(!fn && !(fn = cc->c_filename)) /* !fn: 'readagain' */ return(m); /* FIXME use open_via_path() */ if(cv || (cv = cc->c_lastcanvas)) /* !cv: 'read' w/o arg, 'readagain' */ canvas_makefilename(cv, fn->s_name, buf, MAXPDSTRING); else{ strncpy(buf, fn->s_name, MAXPDSTRING); buf[MAXPDSTRING-1] = 0; } if(!cc->c_refs){ /* loading during object creation -- avoid binbuf_read()'s complaints, LATER rethink */ FILE *fp; char fname[MAXPDSTRING]; sys_bashfilename(buf, fname); if(!(fp = fopen(fname, "r"))){ m->m_flag |= 0x01; return(m); }; fclose(fp); } bb = binbuf_new(); if(binbuf_read(bb, buf, "", 0)){ m->m_flag |= 0x02; if(!threaded) post("coll: can't find file '%s'", fn->s_name); } else if(!binbuf_read(bb, buf, "", 0)){ int nlines = collcommon_frombinbuf(cc, bb); if(nlines > 0){ t_coll *x; /* LATER consider making this more robust //now taken care of by coll_read for obj specificity //leaving here so i remember how to do this o/wise - DK */ if(COLL_ALLBANG){ for(x = cc->c_refs; x; x = x->x_next){ outlet_bang(x->x_filebangout); }; }; cc->c_lastcanvas = cv; cc->c_filename = fn; m->m_flag |= 0x04; m->m_line = nlines; /* if(!threaded) post("coll: finished reading %d lines from text file '%s'", nlines, fn->s_name); */ } else if(nlines < 0){ m->m_flag |= 0x08; m->m_line = 1 - nlines; if(!threaded) post("coll: error in line %d of text file '%s'", 1 - nlines, fn->s_name); } else{ m->m_flag |= 0x16; if(!threaded) post("coll: can't find file '%s'", fn->s_name); } if(cc->c_refs) collcommon_modified(cc, 1); } binbuf_free(bb); return(m); } static void collcommon_readhook(t_pd *z, t_symbol *fn, int ac, t_atom *av){ ac = 0; av = NULL; collcommon_doread((t_collcommon *)z, fn, 0, 0); } static void collcommon_tobinbuf(t_collcommon *cc, t_binbuf *bb){ t_collelem *ep; t_atom at[3]; for(ep = cc->c_first; ep; ep = ep->e_next){ t_atom *ap = at; int cnt = 1; if(ep->e_hasnumkey){ SETFLOAT(ap, ep->e_numkey); ap++; cnt++; } if(ep->e_symkey){ SETSYMBOL(ap, ep->e_symkey); ap++; cnt++; } SETCOMMA(ap); binbuf_add(bb, cnt, at); binbuf_add(bb, ep->e_size, ep->e_data); binbuf_addsemi(bb); } } static t_msg *collcommon_dowrite(t_collcommon *cc, t_symbol *fn, t_canvas *cv, int threaded){ t_binbuf *bb; t_msg *m = (t_msg *)(getbytes(sizeof(*m))); m->m_flag = 0; m->m_line = 0; char buf[MAXPDSTRING]; if(!fn && !(fn = cc->c_filename)) /* !fn: 'writeagain' */ return(0); if(cv || (cv = cc->c_lastcanvas)) /* !cv: 'write' w/o arg, 'writeagain' */ canvas_makefilename(cv, fn->s_name, buf, MAXPDSTRING); else{ strncpy(buf, fn->s_name, MAXPDSTRING); buf[MAXPDSTRING-1] = 0; } bb = binbuf_new(); collcommon_tobinbuf(cc, bb); if(binbuf_write(bb, buf, "", 0)) { m->m_flag |= 0x32; if(!threaded) post("coll: error writing text file '%s'", fn->s_name); } else if(!binbuf_write(bb, buf, "", 0)){ cc->c_lastcanvas = cv; cc->c_filename = fn; } binbuf_free(bb); return(m); } static void collcommon_writehook(t_pd *z, t_symbol *fn, int ac, t_atom *av){ ac = 0, av = NULL; collcommon_dowrite((t_collcommon *)z, fn, 0, 0); } static void coll_embedhook(t_pd *z, t_binbuf *bb, t_symbol *bindsym){ t_coll *x = (t_coll *)z; t_collcommon *cc = x->x_common; if(cc->c_embedflag){ t_collelem *ep; t_atom at[6]; binbuf_addv(bb, "ssii;", bindsym, gensym("flags"), 1, 0); SETSYMBOL(at, bindsym); for(ep = cc->c_first; ep; ep = ep->e_next){ t_atom *ap = at + 1; int cnt; if(ep->e_hasnumkey && ep->e_symkey){ SETSYMBOL(ap, gensym("nstore")); ap++; SETSYMBOL(ap, ep->e_symkey); ap++; SETFLOAT(ap, ep->e_numkey); cnt = 4; } else if(ep->e_symkey){ SETSYMBOL(ap, gensym("store")); ap++; SETSYMBOL(ap, ep->e_symkey); cnt = 3; } else{ SETFLOAT(ap, ep->e_numkey); cnt = 2; } binbuf_add(bb, cnt, at); binbuf_add(bb, ep->e_size, ep->e_data); binbuf_addsemi(bb); }; }; obj_saveformat(x,bb); } static void collcommon_editorhook(t_pd *z, t_symbol *s, int ac, t_atom *av){ s = NULL; int nlines = collcommon_fromatoms((t_collcommon *)z, ac, av); if(nlines < 0) post("coll: editing error in line %d", 1 - nlines); } static void collcommon_free(t_collcommon *cc){ t_collelem *ep1, *ep2 = cc->c_first; while((ep1 = ep2)){ ep2 = ep1->e_next; collelem_free(ep1); } } static void *collcommon_new(void){ t_collcommon *cc = (t_collcommon *)pd_new(collcommon_class); cc->c_embedflag = 0; cc->c_first = cc->c_last = 0; cc->c_head = 0; cc->c_headstate = COLL_HEADRESET; cc->c_fileoninit = 0; //loaded file on init, change when successful loading return (cc); } /*static t_collcommon *coll_checkcommon(t_coll *x) { // unused if(x->x_name && x->x_common != (t_collcommon *)pd_findbyclass(x->x_name, collcommon_class)) { bug("coll_checkcommon"); return (0); } return (x->x_common); }*/ static void coll_unbind(t_coll *x){ /* LATER consider calling coll_checkcommon(x) */ t_collcommon *cc = x->x_common; t_coll *prev, *next; if((prev = cc->c_refs) == x){ if(!(cc->c_refs = x->x_next)){ file_free(cc->c_filehandle); collcommon_free(cc); if(x->x_name) pd_unbind(&cc->c_pd, x->x_name); pd_free(&cc->c_pd); } } else if(prev){ while((next = prev->x_next)){ if(next == x){ prev->x_next = next->x_next; break; } prev = next; } } x->x_common = 0; x->x_name = 0; x->x_next = 0; } static void coll_bind(t_coll *x, t_symbol *name){ int no_search = x->x_nosearch; t_collcommon *cc = 0; if(name == &s_) name = 0; else if(name) cc = (t_collcommon *)pd_findbyclass(name, collcommon_class); if(!cc){ cc = (t_collcommon *)collcommon_new(); cc->c_refs = 0; cc->c_increation = 0; //x->x_common = cc; //x->x_s = name; if(name){ pd_bind(&cc->c_pd, name); /* LATER rethink canvas unpredictability */ //x->unsafe = 1; //pthread_mutex_lock(&x->unsafe_mutex); //pthread_cond_signal(&x->unsafe_cond); //pthread_mutex_unlock(&x->unsafe_mutex); if(!no_search){ t_msg * msg = collcommon_doread(cc, name, x->x_canvas, 0); if(msg->m_line > 0){ //bang if file read successful //need to use clock bc x not returned yet - DK cc->c_fileoninit = 1; x->x_filebang = 1; x->x_initread = 1; clock_delay(x->x_clock, 0); }; }; } else{ cc->c_filename = 0; cc->c_lastcanvas = 0; } cc->c_filehandle = file_new((t_pd *)cc, 0, collcommon_readhook, collcommon_writehook, collcommon_editorhook); } else{ //bang if you find collcommon existing already, //but shouldn't be for no search if(!no_search && cc->c_filename != 0 && cc->c_fileoninit){ x->x_filebang = 1; x->x_initread = 1; clock_delay(x->x_clock, 0); }; }; x->x_common = cc; x->x_name = name; x->x_next = cc->c_refs; cc->c_refs = x; } static int coll_rebind(t_coll *x, t_symbol *name){ t_collcommon *cc; if(name && name != &s_ && (cc = (t_collcommon *)pd_findbyclass(name, collcommon_class))){ coll_unbind(x); x->x_common = cc; x->x_name = name; x->x_next = cc->c_refs; cc->c_refs = x; return(1); } else return(0); } static void coll_dooutput(t_coll *x, int ac, t_atom *av){ if(ac > 1){ if(av->a_type == A_FLOAT) outlet_list(((t_object *)x)->ob_outlet, &s_list, ac, av); else if(av->a_type == A_SYMBOL) outlet_anything(((t_object *)x)->ob_outlet, av->a_w.w_symbol, ac-1, av+1); } else if(ac){ if(av->a_type == A_FLOAT) outlet_float(((t_object *)x)->ob_outlet, av->a_w.w_float); else if(av->a_type == A_SYMBOL) outlet_symbol(((t_object *)x)->ob_outlet, av->a_w.w_symbol); } } static void coll_keyoutput(t_coll *x, t_collelem *ep){ t_collcommon *cc = x->x_common; if(!cc->c_entered++) cc->c_selfmodified = 0; cc->c_volatile = 0; if(ep->e_hasnumkey) outlet_float(x->x_keyout, ep->e_numkey); else if(ep->e_symkey) outlet_symbol(x->x_keyout, ep->e_symkey); else outlet_float(x->x_keyout, 0); if(cc->c_volatile) cc->c_selfmodified = 1; cc->c_entered--; } static t_collelem *coll_findkey(t_coll *x, t_atom *key, t_symbol *mess){ t_collcommon *cc = x->x_common; t_collelem *ep = 0; if(key->a_type == A_FLOAT){ int numkey; if(coll_checkint((t_pd *)x, key->a_w.w_float, &numkey, mess)) ep = collcommon_numkey(cc, numkey); else mess = 0; } else if(key->a_type == A_SYMBOL) ep = collcommon_symkey(cc, key->a_w.w_symbol); else if(mess){ coll_messarg((t_pd *)x, mess); mess = 0; } if(!ep && mess) pd_error((t_pd *)x, "no such key"); return(ep); } static t_collelem *coll_tokey(t_coll *x, t_atom *key, int ac, t_atom *av, int replace, t_symbol *mess){ t_collcommon *cc = x->x_common; t_collelem *ep = 0; if(key->a_type == A_FLOAT){ int numkey; if(coll_checkint((t_pd *)x, key->a_w.w_float, &numkey, mess)) ep = collcommon_tonumkey(cc, numkey, ac, av, replace); } else if(key->a_type == A_SYMBOL) ep = collcommon_tosymkey(cc, key->a_w.w_symbol, ac, av, replace); else if(mess) coll_messarg((t_pd *)x, mess); return(ep); } static t_collelem *coll_firsttyped(t_coll *x, int ndx, t_atomtype type){ t_collcommon *cc = x->x_common; t_collelem *ep; for(ep = cc->c_first; ep; ep = ep->e_next) if(ep->e_size > ndx && ep->e_data[ndx].a_type == type) return (ep); return (0); } static void coll_do_update(t_coll *x){ if(x->x_is_opened){ t_collcommon *cc = x->x_common; t_binbuf *bb = binbuf_new(); int natoms, newline; t_atom *ap; char buf[MAXPDSTRING]; collcommon_tobinbuf(cc, bb); natoms = binbuf_getnatom(bb); ap = binbuf_getvec(bb); newline = 1; sys_vgui(" if {[winfo exists .%lx]} {\n", (unsigned long)cc->c_filehandle); sys_vgui(" .%lx.text delete 1.0 end\n", (unsigned long)cc->c_filehandle); sys_gui(" }\n"); while(natoms--){ char *ptr = buf; if(ap->a_type != A_SEMI && ap->a_type != A_COMMA && !newline) *ptr++ = ' '; atom_string(ap, ptr, MAXPDSTRING); if(ap->a_type == A_SEMI){ strcat(buf, "\n"); newline = 1; } else newline = 0; editor_append(cc->c_filehandle, buf); ap++; } editor_setdirty(cc->c_filehandle, 0); binbuf_free(bb); } } static void coll_do_open(t_coll *x){ t_collcommon *cc = x->x_common; if(x->x_is_opened){ unsigned long wname = (unsigned long)cc->c_filehandle; sys_vgui("wm deiconify .%lx\n", wname); sys_vgui("raise .%lx\n", wname); sys_vgui("focus .%lx.text\n", wname); } else{ char buf[MAXPDSTRING]; char *name = (char *)(x->x_name ? x->x_name->s_name : "Untitled"); editor_open(cc->c_filehandle, name, "coll"); t_binbuf *bb = binbuf_new(); collcommon_tobinbuf(cc, bb); int natoms = binbuf_getnatom(bb); t_atom *ap = binbuf_getvec(bb); int newline = 1; while(natoms--){ char *ptr = buf; if(ap->a_type != A_SEMI && ap->a_type != A_COMMA && !newline) *ptr++ = ' '; atom_string(ap, ptr, MAXPDSTRING); if(ap->a_type == A_SEMI){ strcat(buf, "\n"); newline = 1; } else newline = 0; editor_append(cc->c_filehandle, buf); ap++; } editor_setdirty(cc->c_filehandle, 0); binbuf_free(bb); x->x_is_opened = 1; } } static void coll_is_opened(t_coll *x, t_floatarg f, t_floatarg open){ x->x_is_opened = (int)f; open ? coll_do_open(x) : coll_do_update(x); } static void check_open(t_coll *x, int open){ sys_vgui("if {[winfo exists .%lx]} {\n", (unsigned long)x->x_common->c_filehandle); sys_vgui("pdsend \"%s _is_opened 1 %d\"\n", x->x_bindsym->s_name, open); sys_vgui("} else {pdsend \"%s _is_opened 0 %d\"\n", x->x_bindsym->s_name, open); sys_gui(" }\n"); } static void coll_update(t_coll *x){ check_open(x, 0); } // methods ------------------------------------------------------------------------------------- static void coll_wclose(t_coll *x){ // if edited, closing window asks and replace the contents editor_close(x->x_common->c_filehandle, 1); } static void coll_open(t_coll *x){ check_open(x, 1); } static void coll_click(t_coll *x, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt){ xpos = ypos = shift = ctrl = alt = 0; check_open(x, 1); } static void coll_float(t_coll *x, t_float f){ t_collcommon *cc = x->x_common; t_collelem *ep; int numkey; if(coll_checkint((t_pd *)x, f, &numkey, &s_float) && (ep = collcommon_numkey(cc, numkey))){ coll_keyoutput(x, ep); if(!cc->c_selfmodified || (ep = collcommon_numkey(cc, numkey))) coll_dooutput(x, ep->e_size, ep->e_data); } } static void coll_symbol(t_coll *x, t_symbol *s){ t_collcommon *cc = x->x_common; t_collelem *ep; if((ep = collcommon_symkey(cc, s))){ coll_keyoutput(x, ep); if(!cc->c_selfmodified || (ep = collcommon_symkey(cc, s))) coll_dooutput(x, ep->e_size, ep->e_data); } } static void coll_list(t_coll *x, t_symbol *s, int ac, t_atom *av){ s = NULL; if(ac >= 2 && av->a_type == A_FLOAT){ coll_tokey(x, av, ac-1, av+1, 1, &s_list); coll_update(x); } else coll_messarg((t_pd *)x, &s_list); } static void coll_anything(t_coll *x, t_symbol *s, int ac, t_atom *av){ ac = 0, av = NULL; coll_symbol(x, s); } static void coll_store(t_coll *x, t_symbol *s, int ac, t_atom *av){ if(ac >= 2){ coll_tokey(x, av, ac-1, av+1, 1, s); coll_update(x); } else pd_error(x, "bad arguments for message '%s'", s->s_name); } static void coll_nstore(t_coll *x, t_symbol *s, int ac, t_atom *av){ if(ac >= 3){ t_collcommon *cc = x->x_common; t_collelem *ep; int numkey; if(av->a_type == A_FLOAT && av[1].a_type == A_SYMBOL){ if(coll_checkint((t_pd *)x, av->a_w.w_float, &numkey, s)){ if((ep = collcommon_symkey(cc, av[1].a_w.w_symbol))) collcommon_remove(cc, ep); ep = collcommon_tonumkey(cc, numkey, ac-2, av+2, 1); ep->e_symkey = av[1].a_w.w_symbol; } coll_update(x); } else if(av->a_type == A_SYMBOL && av[1].a_type == A_FLOAT){ if(coll_checkint((t_pd *)x, av[1].a_w.w_float, &numkey, s)){ if((ep = collcommon_numkey(cc, numkey))) collcommon_remove(cc, ep); ep = collcommon_tosymkey(cc, av->a_w.w_symbol, ac-2, av+2, 1); ep->e_hasnumkey = 1; ep->e_numkey = numkey; } coll_update(x); } else pd_error(x, "bad arguments for message '%s'", s->s_name); } else pd_error(x, "bad arguments for message '%s'", s->s_name); } static void coll_insert2(t_coll *x, t_symbol *s, int ac, t_atom *av){ t_collcommon *cc = x->x_common; t_collelem *epnew = NULL; t_collelem *ep; int numkey; if(ac >= 2 && av->a_type == A_FLOAT){ // get the int from the first elt if exists and store in numkey coll_checkint((t_pd *) x, av->a_w.w_float, &numkey, 0); // retrieve elem with numkey if it exists ep = collcommon_numkey(cc, numkey); if(ep){ epnew = collelem_new(ac-1, av+1, &numkey, 0); // put new element before the one we just found collcommon_putbefore(cc, epnew, ep); // increment all keys which are >= the numkey - aside from the one we just made for(ep = cc->c_first; ep; ep = ep->e_next){ if(ep->e_hasnumkey){ if((ep->e_numkey >= numkey) && (ep != epnew)){ ep->e_numkey = ep->e_numkey + 1; }; }; }; //it looks like you use this when you don't change data, just keys? -DK collcommon_modified(cc, 0); } else{ coll_tokey(x, av, ac-1, av+1, 0, s); coll_update(x); } } else pd_error(x, "bad arguments for message '%s'", s->s_name); } static void coll_insert(t_coll *x, t_symbol *s, int ac, t_atom *av){ t_collcommon *cc = x->x_common; t_collelem *epnew = NULL; t_collelem *ep; int numkey; if(ac >= 2 && av->a_type == A_FLOAT){ // get the int from the first elt if exists and store in numkey coll_checkint((t_pd *) x, av->a_w.w_float, &numkey, 0); // retrieve elem with numkey if it exists ep = collcommon_numkey(cc, numkey); if(ep){ epnew = collelem_new(ac-1, av+1, &numkey, 0); // put new element before the one we just found collcommon_putbefore(cc, epnew, ep); } else{ // we didn't find it, put the new elem last ep = cc->c_last; epnew = collelem_new(ac-1, av+1, &numkey, 0); collcommon_putafter(cc, epnew, ep); }; // increment all keys which are >= the numkey - aside from the one we just made for(ep = cc->c_first; ep; ep = ep->e_next){ if(ep->e_hasnumkey){ if((ep->e_numkey >= numkey) && (ep != epnew)){ ep->e_numkey = ep->e_numkey + 1; }; }; }; // it looks like you use this when you don't change data, just keys? -DK collcommon_modified(cc, 0); coll_update(x); } else pd_error(x, "bad arguments for message '%s'", s->s_name); } static void coll_remove(t_coll *x, t_symbol *s, int ac, t_atom *av){ if(ac){ t_collelem *ep; if((ep = coll_findkey(x, av, s))) collcommon_remove(x->x_common, ep); coll_update(x); } else pd_error(x, "bad arguments for message '%s'", s->s_name); } static void coll_delete(t_coll *x, t_symbol *s, int ac, t_atom *av){ if(ac){ t_collelem *ep; if((ep = coll_findkey(x, av, s))){ if(av->a_type == A_FLOAT){ int numkey = ep->e_numkey; t_collelem *next; for(next = ep->e_next; next; next = next->e_next) if(next->e_hasnumkey && next->e_numkey > numkey) next->e_numkey--; } collcommon_remove(x->x_common, ep); coll_update(x); } } else pd_error(x, "bad arguments for message '%s'", s->s_name); } static void coll_assoc(t_coll *x, t_symbol *s, t_floatarg f){ int numkey; if(coll_checkint((t_pd *)x, f, &numkey, gensym("assoc"))){ t_collcommon *cc = x->x_common; t_collelem *ep1, *ep2; if((ep1 = collcommon_numkey(cc, numkey)) && ep1->e_symkey != s){ // LATER rethink if((ep2 = collcommon_symkey(cc, s))) collcommon_remove(cc, ep2); collcommon_changesymkey(cc, ep1, s); } coll_update(x); } } static void coll_deassoc(t_coll *x, t_symbol *s, t_floatarg f){ s = NULL; int numkey; if(coll_checkint((t_pd *)x, f, &numkey, gensym("deassoc"))){ t_collcommon *cc = x->x_common; t_collelem *ep; if((ep = collcommon_numkey(cc, numkey))) collcommon_changesymkey(cc, ep, 0); } coll_update(x); } static void coll_subsym(t_coll *x, t_symbol *s1, t_symbol *s2){ t_collelem *ep; if(s1 != s2 && (ep = collcommon_symkey(x->x_common, s2))){ collcommon_changesymkey(x->x_common, ep, s1); coll_update(x); } } static void coll_renumber2(t_coll *x, t_floatarg f){ int startkey; if(coll_checkint((t_pd *)x, f, &startkey, gensym("renumber"))){ collcommon_renumber2(x->x_common, startkey); coll_update(x); } } static void coll_renumber(t_coll *x, t_floatarg f){ int startkey; if(coll_checkint((t_pd *)x, f, &startkey, gensym("renumber"))){ collcommon_renumber(x->x_common, startkey); coll_update(x); } } static void coll_merge(t_coll *x, t_symbol *s, int ac, t_atom *av){ if(ac >= 2){ t_collcommon *cc = x->x_common; t_collelem *ep; if(av->a_type == A_FLOAT){ int numkey; if(coll_checkint((t_pd *)x, av->a_w.w_float, &numkey, s)){ if((ep = collcommon_numkey(cc, numkey))) collcommon_adddata(cc, ep, ac-1, av+1); else /* LATER consider defining collcommon_toclosest() */ collcommon_tonumkey(cc, numkey, ac-1, av+1, 1); } coll_update(x); } else if(av->a_type == A_SYMBOL){ if((ep = collcommon_symkey(cc, av->a_w.w_symbol))) collcommon_adddata(cc, ep, ac-1, av+1); else{ ep = collelem_new(ac-1, av+1, 0, av->a_w.w_symbol); collcommon_putafter(cc, ep, cc->c_last); } coll_update(x); } else pd_error(x, "bad arguments for message '%s'", s->s_name); } else pd_error(x, "bad arguments for message '%s'", s->s_name); } static void coll_sub(t_coll *x, t_symbol *s, int ac, t_atom *av){ if(ac){ t_collelem *ep; if((ep = coll_findkey(x, av, s))){ t_collcommon *cc = x->x_common; t_atom *key = av++; ac--; while(ac >= 2){ if(av->a_type == A_FLOAT){ int ndx; if(coll_checkint((t_pd *)x, av->a_w.w_float, &ndx, 0) && ndx >= 1 && ndx <= ep->e_size) ep->e_data[ndx-1] = av[1]; } ac -= 2; av += 2; } if(s == gensym("sub")){ coll_keyoutput(x, ep); if(!cc->c_selfmodified || (ep = coll_findkey(x, key, 0))) coll_dooutput(x, ep->e_size, ep->e_data); } } coll_update(x); } else pd_error(x, "bad arguments for message '%s'", s->s_name); } static void coll_sort(t_coll *x, t_floatarg f1, t_floatarg f2){ int dir, ndx; if(coll_checkint((t_pd *)x, f1, &dir, gensym("sort")) && coll_checkint((t_pd *)x, f2, &ndx, gensym("sort"))){ collcommon_sort(x->x_common, (dir < 0 ? 0 : 1), (ndx < 0 ? -1 : (ndx ? ndx - 1 : 0))); coll_update(x); } } static void coll_clear(t_coll *x){ t_collcommon *cc = x->x_common; collcommon_clearall(cc); sys_vgui(" if {[winfo exists .%lx]} {\n", (unsigned long)cc->c_filehandle); sys_vgui(" .%lx.text delete 1.0 end\n", (unsigned long)cc->c_filehandle); sys_gui(" }\n"); } /* According to the refman, the data should be swapped, rather than the keys -- easy here, but apparently c74 people have chosen to avoid some effort needed in case of their implementation... */ static void coll_swap(t_coll *x, t_symbol *s, int ac, t_atom *av){ if(ac == 2){ t_collelem *ep1, *ep2; if((ep1 = coll_findkey(x, av, s)) && (ep2 = coll_findkey(x, av + 1, s))){ collcommon_swapkeys(x->x_common, ep1, ep2); coll_update(x); } } else pd_error(x, "bad arguments for message '%s'", s->s_name); } /* CHECKED traversal direction change is consistent with the general rule: 'next' always outputs e_next of a previous output, and 'prev' always outputs e_prev, whether preceded by 'prev', or by 'next'. This is currently implemented by pre-updating of the head (which is inhibited if there was no previous output, i.e. after 'goto', 'end', or collection initialization). CHECKME again. */ static void coll_next(t_coll *x){ t_collcommon *cc = x->x_common; if(cc->c_headstate != COLL_HEADRESET && cc->c_headstate != COLL_HEADDELETED){// asymmetric, LATER rethink if(cc->c_head) cc->c_head = cc->c_head->e_next; if(!cc->c_head && !(cc->c_head = cc->c_first)) /* CHECKED wrapping */ return; } else if(!cc->c_head && !(cc->c_head = cc->c_first)) return; cc->c_headstate = COLL_HEADNEXT; coll_keyoutput(x, cc->c_head); if(cc->c_head) coll_dooutput(x, cc->c_head->e_size, cc->c_head->e_data); else if(!cc->c_selfmodified) bug("coll_next"); /* LATER rethink */ } static void coll_prev(t_coll *x){ t_collcommon *cc = x->x_common; if(cc->c_headstate != COLL_HEADRESET){ if(cc->c_head) cc->c_head = cc->c_head->e_prev; if(!cc->c_head && !(cc->c_head = cc->c_last)) /* CHECKED wrapping */ return; } else if(!cc->c_head && !(cc->c_head = cc->c_first)) return; cc->c_headstate = COLL_HEADPREV; coll_keyoutput(x, cc->c_head); if(cc->c_head) coll_dooutput(x, cc->c_head->e_size, cc->c_head->e_data); else if(!cc->c_selfmodified) bug("coll_prev"); /* LATER rethink */ } static void coll_start(t_coll *x){ t_collcommon *cc = x->x_common; cc->c_head = cc->c_first; cc->c_headstate = COLL_HEADRESET; } static void coll_end(t_coll *x){ t_collcommon *cc = x->x_common; cc->c_head = cc->c_last; cc->c_headstate = COLL_HEADRESET; } static void coll_goto(t_coll *x, t_symbol *s, int ac, t_atom *av){ if(ac){ t_collelem *ep = coll_findkey(x, av, s); if(ep){ t_collcommon *cc = x->x_common; cc->c_head = ep; cc->c_headstate = COLL_HEADRESET; } } else coll_start(x); } static void coll_nth(t_coll *x, t_symbol *s, int ac, t_atom *av){ if(ac >= 2 && av[1].a_type == A_FLOAT){ int ndx; t_collelem *ep; if(coll_checkint((t_pd *)x, av[1].a_w.w_float, &ndx, s) && (ep = coll_findkey(x, av, s)) &&ep->e_size >= ndx){ t_atom *ap = ep->e_data + --ndx; if(ap->a_type == A_FLOAT) outlet_float(((t_object *)x)->ob_outlet, ap->a_w.w_float); else if(ap->a_type == A_SYMBOL) outlet_symbol(((t_object *)x)->ob_outlet, ap->a_w.w_symbol); } } else pd_error(x, "bad arguments for message '%s'", s->s_name); } static void coll_length(t_coll *x){ t_collcommon *cc = x->x_common; t_collelem *ep = cc->c_first; int result = 0; while(ep) result++, ep = ep->e_next; outlet_float(((t_object *)x)->ob_outlet, result); } static void coll_min(t_coll *x, t_floatarg f){ int ndx; if(coll_checkint((t_pd *)x, f, &ndx, gensym("min"))){ t_collelem *found; if(ndx > 0) ndx--; /* LATER consider complaining: */ else if(ndx < 0) return; /* CHECKED silently rejected */ /* else CHECKED silently defaults to 1 */ if((found = coll_firsttyped(x, ndx, A_FLOAT))){ t_float result = found->e_data[ndx].a_w.w_float; t_collelem *ep; for(ep = found->e_next; ep; ep = ep->e_next){ if(ep->e_size > ndx && ep->e_data[ndx].a_type == A_FLOAT && ep->e_data[ndx].a_w.w_float < result){ found = ep; result = ep->e_data[ndx].a_w.w_float; } } coll_keyoutput(x, found); outlet_float(((t_object *)x)->ob_outlet, result); } } } static void coll_max(t_coll *x, t_floatarg f){ int ndx; if(coll_checkint((t_pd *)x, f, &ndx, gensym("max"))){ t_collelem *found; if(ndx > 0) ndx--; /* LATER consider complaining: */ else if(ndx < 0) return; /* CHECKED silently rejected */ /* else CHECKED silently defaults to 1 */ if((found = coll_firsttyped(x, ndx, A_FLOAT))){ t_float result = found->e_data[ndx].a_w.w_float; t_collelem *ep; for(ep = found->e_next; ep; ep = ep->e_next){ if(ep->e_size > ndx && ep->e_data[ndx].a_type == A_FLOAT && ep->e_data[ndx].a_w.w_float > result) { found = ep; result = ep->e_data[ndx].a_w.w_float; } } coll_keyoutput(x, found); outlet_float(((t_object *)x)->ob_outlet, result); } } } static void coll_refer(t_coll *x, t_symbol *s){ coll_rebind(x, s); } static void coll_flags(t_coll *x, t_float f1, t_float f2){ int i1; f2 = 0; if(coll_checkint((t_pd *)x, f1, &i1, gensym("flags"))){ t_collcommon *cc = x->x_common; cc->c_embedflag = (i1 != 0); } } static void coll_embed(t_coll *x, t_float f){ int embed = f == 0 ? 0 : 1; coll_flags(x, (t_float) embed, 0); } static void coll_read(t_coll *x, t_symbol *s){ if(!x->unsafe) { t_collcommon *cc = x->x_common; if(s && s != &s_) { x->x_s = coll_fullfilename(x,s); if(x->x_threaded == 1) { x->unsafe = 1; pthread_mutex_lock(&x->unsafe_mutex); pthread_cond_signal(&x->unsafe_cond); pthread_mutex_unlock(&x->unsafe_mutex); //collcommon_doread(cc, s, x->x_canvas, 0); } else{ t_msg * msg = collcommon_doread(cc, s, x->x_canvas, 0); if((!COLL_ALLBANG) && (msg->m_line > 0)){ x->x_filebang = 1; clock_delay(x->x_clock, 0); }; } } else panel_open(cc->c_filehandle, 0); } } static void coll_write(t_coll *x, t_symbol *s){ if(!x->unsafe){ t_collcommon *cc = x->x_common; if(s && s != &s_){ x->x_s = coll_fullfilename(x,s); if(x->x_threaded == 1){ x->unsafe = 10; pthread_mutex_lock(&x->unsafe_mutex); pthread_cond_signal(&x->unsafe_cond); pthread_mutex_unlock(&x->unsafe_mutex); //collcommon_dowrite(cc, s, x->x_canvas, 0); } else collcommon_dowrite(cc, s, x->x_canvas, 0); } else panel_save(cc->c_filehandle, 0, 0); /* CHECKED no default name */ } } static void coll_readagain(t_coll *x){ t_collcommon *cc = x->x_common; if(cc->c_filename){ if(x->x_threaded == 1){ x->unsafe = 2; pthread_mutex_lock(&x->unsafe_mutex); pthread_cond_signal(&x->unsafe_cond); pthread_mutex_unlock(&x->unsafe_mutex); //collcommon_doread(cc, 0, 0, 0); } else { t_msg * msg = collcommon_doread(cc, 0, 0, 0); if((!COLL_ALLBANG) && msg->m_line > 0){ x->x_filebang = 1; clock_delay(x->x_clock, 0); }; } } else panel_open(cc->c_filehandle, 0); } static void coll_writeagain(t_coll *x){ t_collcommon *cc = x->x_common; if(cc->c_filename) { if(x->x_threaded == 1) { x->unsafe = 11; pthread_mutex_lock(&x->unsafe_mutex); pthread_cond_signal(&x->unsafe_cond); pthread_mutex_unlock(&x->unsafe_mutex); //collcommon_dowrite(cc, 0, 0, 0); } else collcommon_dowrite(cc, 0, 0, 0); } else panel_save(cc->c_filehandle, 0, 0); /* CHECKED no default name */ } static void coll_filetype(t_coll *x, t_symbol *s, int argc, t_atom * argv){ s = NULL; int ext_set = 0; if(argc > 0){ if(argv[0].a_type == A_SYMBOL){ t_symbol * cursym = atom_getsymbolarg(0, argc, argv); if(cursym != &s_){ if(strlen(cursym->s_name) <= COLL_MAXEXTLEN){ x->x_fileext = cursym; ext_set = 1; }; }; }; }; if(ext_set <= 0) x->x_fileext = &s_; } static void coll_dump(t_coll *x){ t_collcommon *cc = x->x_common; t_collelem *ep; for(ep = cc->c_first; ep; ep = ep->e_next){ coll_keyoutput(x, ep); if(cc->c_selfmodified) break; coll_dooutput(x, ep->e_size, ep->e_data); /* FIXME dooutput() may invalidate ep as well as keyoutput()... */ } outlet_bang(x->x_dumpbangout); } /* #ifdef COLL_DEBUG static void collelem_post(t_collelem *ep) { if(ep->e_hasnumkey && ep->e_symkey) loudbug_startpost("%d %s:", ep->e_numkey, ep->e_symkey->s_name); else if(ep->e_hasnumkey) loudbug_startpost("%d:", ep->e_numkey); else if(ep->e_symkey) loudbug_startpost("%s:", ep->e_symkey->s_name); else loudbug_bug("collcommon_post"); loudbug_postatom(ep->e_size, ep->e_data); loudbug_endpost(); } static void collcommon_post(t_collcommon *cc) { t_collelem *ep; for(ep = cc->c_first; ep; ep = ep->e_next) collelem_post(ep); } static void coll_debug(t_coll *x, t_floatarg f) { t_collcommon *cc = coll_checkcommon(x); if(cc) { t_coll *x1 = cc->c_refs; t_collelem *ep, *last; int i = 0; while(x1) i++, x1 = x1->x_next; bug("refcount %d", i); for(ep = cc->c_first, last = 0; ep; ep = ep->e_next) last = ep; if(last != cc->c_last) bug("coll_debug: last element"); collcommon_post(cc); } } #endif */ static void *coll_threaded_fileio(void *ptr){ t_threadedFunctionParams *rPars = (t_threadedFunctionParams*)ptr; t_coll *x = rPars->x; t_msg *m = NULL; while(x->unsafe > -1){ pthread_mutex_lock(&x->unsafe_mutex); if(x->unsafe == 0) if(!x->init) x->init = 1; pthread_cond_wait(&x->unsafe_cond, &x->unsafe_mutex); if(x->unsafe == 1) { //read m = collcommon_doread(x->x_common, x->x_s, x->x_canvas, 1); if(m->m_flag) coll_enqueue_threaded_msgs(x, m); if(m->m_line > 0){ x->x_filebang = 1; }; clock_delay(x->x_clock, 0); } else if(x->unsafe == 2) { //read m = collcommon_doread(x->x_common, 0, 0, 1); if(m->m_flag) coll_enqueue_threaded_msgs(x, m); if(m->m_line > 0){ x->x_filebang = 1; }; clock_delay(x->x_clock, 0); } else if(x->unsafe == 10) { //write m = collcommon_dowrite(x->x_common, x->x_s, x->x_canvas, 1); if(m->m_flag) coll_enqueue_threaded_msgs(x, m); } else if(x->unsafe == 11) { //write m = collcommon_dowrite(x->x_common, 0, 0, 1); if(m->m_flag) coll_enqueue_threaded_msgs(x, m); }; if(m != NULL){ t_freebytes(m, sizeof(*m)); m = NULL; } if(x->unsafe != -1) x->unsafe = 0; pthread_mutex_unlock(&x->unsafe_mutex); } pthread_exit(0); } static void coll_separate(t_coll *x, t_floatarg f){ int indx; t_collcommon *cc = x->x_common; if(coll_checkint((t_pd *)x, f, &indx, gensym("separate"))){ t_collelem *ep; for(ep = cc->c_first; ep; ep = ep->e_next) if(ep->e_hasnumkey && ep->e_numkey >= indx) ep->e_numkey += 1; collcommon_modified(cc, 0); coll_update(x); } } static void coll_dothread(t_coll *x, int create){ if(create){ int ret; t_threadedFunctionParams rPars; x->unsafe = 0; rPars.x = x; pthread_mutex_init(&x->unsafe_mutex, NULL); pthread_cond_init(&x->unsafe_cond, NULL); ret = pthread_create( &x->unsafe_t, NULL, (void *) &coll_threaded_fileio, (void *) &rPars); while(!x->init) sched_yield(); } else{ x->unsafe = -1; pthread_mutex_lock(&x->unsafe_mutex); pthread_cond_signal(&x->unsafe_cond); pthread_mutex_unlock(&x->unsafe_mutex); pthread_join(x->unsafe_t, NULL); pthread_mutex_destroy(&x->unsafe_mutex); if(x->x_q) coll_q_free(x); x->unsafe = 0; }; } static void coll_threaded(t_coll *x, t_float f){ int th = f == 0 ? 0 : 1; if(th != x->x_threaded) coll_dothread(x, th); x->x_threaded = th; } static void coll_free(t_coll *x){ coll_wclose(x); if(x->x_threaded == 1) coll_dothread(x, 0); pd_unbind(&x->x_ob.ob_pd, x->x_bindsym); clock_free(x->x_clock); file_free(x->x_filehandle); coll_unbind(x); } static void *coll_new(t_symbol *s, int argc, t_atom *argv){ s = NULL; t_coll *x = (t_coll *)pd_new(coll_class); t_symbol *file = NULL; x->x_fileext = &s_; x->x_canvas = canvas_getcurrent(); char buf[MAXPDSTRING]; buf[MAXPDSTRING-1] = 0; sprintf(buf, "#%lx", (long)x); pd_bind(&x->x_ob.ob_pd, x->x_bindsym = gensym(buf)); outlet_new((t_object *)x, &s_); x->x_keyout = outlet_new((t_object *)x, &s_); x->x_filebangout = outlet_new((t_object *)x, &s_bang); x->x_dumpbangout = outlet_new((t_object *)x, &s_bang); x->x_filehandle = file_new((t_pd *)x, coll_embedhook, 0, 0, 0); int no_search = 0; int embed = COLLEMBED; int threaded = COLLTHREAD; // check arguments for filename and threaded version // right now, don't care about arg order (mb we should?) - DK while(argc){ if(argv -> a_type == A_SYMBOL){ t_symbol * cursym = atom_getsymbolarg(0, argc, argv); argc--; argv++; if(strcmp(cursym -> s_name, "@embed") == 0){ if(argc){ t_float curf = atom_getfloatarg(0, argc, argv); argc--; argv++; embed = curf > 0 ? 1 : 0; }; } else if(strcmp(cursym -> s_name, "@threaded") == 0){ if(argc){ t_float curf = atom_getfloatarg(0, argc, argv); argc--; argv++; threaded = curf != 0 ? 1 : 0; }; } else file = cursym; } else if(argv -> a_type == A_FLOAT){ t_float nosearch = atom_getfloatarg(0, argc, argv); no_search = nosearch != 0 ? 1 : 0; argc--; argv++; } else goto errstate; }; x->x_is_opened = 0; x->x_threaded = 0; //changed from -1 which broke on windows x->x_nosearch = no_search; x->x_filebang = 0; // if no file name provided, associate with empty symbol if(file == NULL) file = &s_; x->unsafe = 0; x->init = 0; //lines below used to be only for threaded, but it's //needed for bang on the 3rd outlet - DK & Porres x->x_clock = clock_new(x, (t_method)coll_tick); coll_threaded(x, threaded); coll_bind(x, file); coll_flags(x, (int)embed, 0); return(x); errstate: pd_error(x, "coll: improper args"); return NULL; } CYCLONE_OBJ_API void coll_setup(void){ coll_class = class_new(gensym("coll"), (t_newmethod)coll_new, (t_method)coll_free, sizeof(t_coll), 0, A_GIMME, 0); class_addbang(coll_class, coll_next); class_addfloat(coll_class, coll_float); class_addsymbol(coll_class, coll_symbol); class_addlist(coll_class, coll_list); class_addanything(coll_class, coll_anything); class_addmethod(coll_class, (t_method)coll_store, gensym("store"), A_GIMME, 0); class_addmethod(coll_class, (t_method)coll_nstore, gensym("nstore"), A_GIMME, 0); class_addmethod(coll_class, (t_method)coll_insert, gensym("insert"), A_GIMME, 0); class_addmethod(coll_class, (t_method)coll_insert2, gensym("insert2"), A_GIMME, 0); class_addmethod(coll_class, (t_method)coll_remove, gensym("remove"), A_GIMME, 0); class_addmethod(coll_class, (t_method)coll_delete, gensym("delete"), A_GIMME, 0); class_addmethod(coll_class, (t_method)coll_assoc, gensym("assoc"), A_SYMBOL, A_FLOAT, 0); class_addmethod(coll_class, (t_method)coll_deassoc, gensym("deassoc"), A_SYMBOL, A_FLOAT, 0); class_addmethod(coll_class, (t_method)coll_subsym, gensym("subsym"), A_SYMBOL, A_SYMBOL, 0); class_addmethod(coll_class, (t_method)coll_renumber, gensym("renumber"), A_DEFFLOAT, 0); class_addmethod(coll_class, (t_method)coll_renumber2, gensym("renumber2"), A_DEFFLOAT, 0); class_addmethod(coll_class, (t_method)coll_merge, gensym("merge"), A_GIMME, 0); class_addmethod(coll_class, (t_method)coll_sub, gensym("sub"), A_GIMME, 0); class_addmethod(coll_class, (t_method)coll_sub, gensym("nsub"), A_GIMME, 0); class_addmethod(coll_class, (t_method)coll_clear, gensym("clear"), 0); class_addmethod(coll_class, (t_method)coll_sort, gensym("sort"), A_FLOAT, A_DEFFLOAT, 0); class_addmethod(coll_class, (t_method)coll_swap, gensym("swap"), A_GIMME, 0); class_addmethod(coll_class, (t_method)coll_next, gensym("next"), 0); class_addmethod(coll_class, (t_method)coll_prev, gensym("prev"), 0); class_addmethod(coll_class, (t_method)coll_end, gensym("end"), 0); class_addmethod(coll_class, (t_method)coll_goto, gensym("goto"), A_GIMME, 0); class_addmethod(coll_class, (t_method)coll_nth, gensym("nth"), A_GIMME, 0); class_addmethod(coll_class, (t_method)coll_length, gensym("length"), 0); class_addmethod(coll_class, (t_method)coll_min, gensym("min"), A_DEFFLOAT, 0); class_addmethod(coll_class, (t_method)coll_max, gensym("max"), A_DEFFLOAT, 0); class_addmethod(coll_class, (t_method)coll_refer, gensym("refer"), A_SYMBOL, 0); class_addmethod(coll_class, (t_method)coll_flags, gensym("flags"), A_FLOAT, A_FLOAT, 0); class_addmethod(coll_class, (t_method)coll_embed, gensym("embed"), A_FLOAT,0); class_addmethod(coll_class, (t_method)coll_threaded, gensym("threaded"), A_FLOAT,0); class_addmethod(coll_class, (t_method)coll_read, gensym("read"), A_DEFSYM, 0); class_addmethod(coll_class, (t_method)coll_start, gensym("start"), 0); class_addmethod(coll_class, (t_method)coll_write, gensym("write"), A_DEFSYM, 0); class_addmethod(coll_class, (t_method)coll_readagain, gensym("readagain"), 0); class_addmethod(coll_class, (t_method)coll_writeagain, gensym("writeagain"), 0); class_addmethod(coll_class, (t_method)coll_filetype, gensym("filetype"), A_GIMME, 0); class_addmethod(coll_class, (t_method)coll_dump, gensym("dump"), 0); class_addmethod(coll_class, (t_method)coll_open, gensym("open"), 0); class_addmethod(coll_class, (t_method)coll_wclose, gensym("wclose"), 0); class_addmethod(coll_class, (t_method)coll_click, gensym("click"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); class_addmethod(coll_class, (t_method)coll_separate, gensym("separate"), A_FLOAT, 0); class_addmethod(coll_class, (t_method)coll_is_opened, gensym("_is_opened"), A_FLOAT , A_FLOAT, 0); /* #ifdef COLL_DEBUG class_addmethod(coll_class, (t_method)coll_debug, gensym("debug"), A_DEFFLOAT, 0); #endif */ file_setup(coll_class, 1); collcommon_class = class_new(gensym("coll"), 0, 0, sizeof(t_collcommon), CLASS_PD, 0); /* this call is a nop (collcommon does not embed, and the file class itself has been already set up above), but it is better to have it around, just in case... */ file_setup(collcommon_class, 0); }
porres/pd-cyclone
shared/common/file.h
/* Copyright (c) 2004-2005 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ #ifndef __OS_H__ #define __OS_H__ EXTERN_STRUCT _osdir; #define t_osdir struct _osdir #define OSDIR_FILEMODE 1 #define OSDIR_DIRMODE 2 int ospath_length(char *path, char *cwd); char *ospath_absolute(char *path, char *cwd, char *result); FILE *fileread_open(char *filename, t_canvas *cv, int textmode); FILE *filewrite_open(char *filename, t_canvas *cv, int textmode); t_osdir *osdir_open(char *dirname); void osdir_setmode(t_osdir *dp, int flags); void osdir_close(t_osdir *dp); void osdir_rewind(t_osdir *dp); char *osdir_next(t_osdir *dp); int osdir_isfile(t_osdir *dp); int osdir_isdir(t_osdir *dp); #endif #ifndef __FILE_H__ #define __FILE_H__ EXTERN_STRUCT _file; #define t_file struct _file typedef void (*t_filefn)(t_pd *, t_symbol *, int, t_atom *); typedef void (*t_embedfn)(t_pd *, t_binbuf *, t_symbol *); void editor_open(t_file *f, char *title, char *owner); void editor_close(t_file *f, int ask); void editor_append(t_file *f, char *contents); void editor_setdirty(t_file *f, int flag); void panel_open(t_file *f, t_symbol *inidir); void panel_setopendir(t_file *f, t_symbol *dir); t_symbol *panel_getopendir(t_file *f); void panel_save(t_file *f, t_symbol *inidir, t_symbol *inifile); void panel_setsavedir(t_file *f, t_symbol *dir); t_symbol *panel_getsavedir(t_file *f); int file_ismapped(t_file *f); int file_isloading(t_file *f); int file_ispasting(t_file *f); void file_free(t_file *f); t_file *file_new(t_pd *master, t_embedfn embedfn, t_filefn readfn, t_filefn writefn, t_filefn updatefn); void file_setup(t_class *c, int embeddable); #endif
InamdarAbid/DS
BankersAlgorithm.c
<filename>BankersAlgorithm.c #include <stdio.h> int main(){ int count = 0, m, n, process, temp, resource; int allocation_table[5] = {0, 0, 0, 0, 0}; int available[5], current[5][5], maximum_claim[5][5]; int maximum_resources[5], running[5], safe_state = 0; printf("\nEnter The Total Number Of Processes:\t"); scanf("%d", &process); for(m = 0; m < process; m++) { running[m] = 1; count++; } printf("\nEnter The Total Number Of Resources To Allocate:\t"); scanf("%d", &resource); printf("\nEnter The Claim Vector:\t"); for(m = 0; m < resource; m++) { scanf("%d", &maximum_resources[m]); } printf("\nEnter Allocated Resource Table:\n"); for(m = 0; m < process; m++) { for(n = 0; n < resource; n++) { scanf("%d", &current[m][n]); } } printf("\nEnter The Maximum Claim Table:\n"); for(m = 0; m < process; m++) { for(n = 0; n < resource; n++) { scanf("%d", &maximum_claim[m][n]); } } printf("\nThe Claim Vector \n"); for(m = 0; m < resource; m++) { printf("\t%d ", maximum_resources[m]); } printf("\n The Allocated Resource Table\n"); for(m = 0; m < process; m++) { for(n = 0; n < resource; n++) { printf("\t%d", current[m][n]); } printf("\n"); } printf("\nThe Maximum Claim Table \n"); for(m = 0; m < process; m++) { for(n = 0; n < resource; n++) { printf("\t%d", maximum_claim[m][n]); } printf("\n"); } for(m = 0; m < process; m++) { for(n = 0; n < resource; n++) { allocation_table[n] = allocation_table[n] + current[m][n]; } } printf("\nAllocated Resources \n"); for(m = 0; m < resource; m++) { printf("\t%d", allocation_table[m]); } for(m = 0; m < resource; m++) { available[m] = maximum_resources[m] - allocation_table[m]; } printf("\nAvailable Resources:"); for(m = 0; m < resource; m++) { printf("\t%d", available[m]); } printf("\n"); while(count != 0) { safe_state = 0; for(m = 0; m < process; m++) { if(running[m]) { temp = 1; for(n = 0; n < resource; n++) { if(maximum_claim[m][n] - current[m][n] > available[n]) { temp = 0; break; } } if(temp) { printf("\nProcess %d Is In Execution \n", m + 1); running[m] = 0; count--; safe_state = 1; for(n = 0; n < resource; n++) { available[n] = available[n] + current[m][n]; } break; } } } if(!safe_state) { printf("\nThe Processes Are In An Unsafe State \n"); break; } else { printf("\nThe Process Is In A Safe State \n"); printf("\nAvailable Vector\n"); for(m = 0; m < resource; m++) { printf("\t%d", available[m]); } printf("\n"); } } return 0; }
AlexX333BY/ess-stm32-leds-accumulation
Src/main.c
<filename>Src/main.c /** ****************************************************************************** * @file : main.c * @brief : Main program body ****************************************************************************** * @attention * * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics. * All rights reserved.</center></h2> * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include <stdbool.h> /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); static void MX_GPIO_Init(void); bool isRunning = true; /** * @brief The application entry point. * @retval int */ int main(void) { /* MCU Configuration--------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* Initialize all configured peripherals */ MX_GPIO_Init(); /* Infinite loop */ const uint32_t delayLength = 1000; const uint8_t ledsCount = 8; uint8_t filledLeds = 0; uint16_t led; while (true) { if (!isRunning) { HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7, GPIO_PIN_RESET); filledLeds = 0; while (!isRunning) { HAL_Delay(1); } } /* if all leds were filled, reset all leds */ if (filledLeds == ledsCount) { HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7, GPIO_PIN_RESET); filledLeds = 0; HAL_Delay(delayLength); } /* for leds that are not filled, set them for 1 sec */ led = GPIO_PIN_0; for (uint8_t ledNo = 0; isRunning && (ledNo < (ledsCount - filledLeds)); ++ledNo) { HAL_GPIO_WritePin(GPIOB, led, GPIO_PIN_SET); HAL_Delay(delayLength); HAL_GPIO_WritePin(GPIOB, led, GPIO_PIN_RESET); led <<= 1; } /* set last unfilled led */ HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0 << (ledsCount - filledLeds - 1), GPIO_PIN_SET); ++filledLeds; } } /** * @brief System Clock Configuration * @retval None */ void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; /** Initializes the CPU, AHB and APB busses clocks */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { Error_Handler(); } /** Initializes the CPU, AHB and APB busses clocks */ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK) { Error_Handler(); } } /** * @brief GPIO Initialization Function * @param None * @retval None */ static void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct = {0}; /* GPIO Ports Clock Enable */ __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7, GPIO_PIN_RESET); /*Configure GPIO pin : PA0 */ GPIO_InitStruct.Pin = GPIO_PIN_0; GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /*Configure GPIO pins : PB0 PB1 PB2 PB3 PB4 PB5 PB6 PB7 */ GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); HAL_NVIC_EnableIRQ(EXTI0_IRQn); } void EXTI0_IRQHandler(void) { isRunning = !isRunning; } /** * @brief This function is executed in case of error occurrence. * @retval None */ void Error_Handler(void) { /* User can add his own implementation to report the HAL error return state */ } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t *file, uint32_t line) { /* User can add his own implementation to report the file name and line number, tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ } #endif /* USE_FULL_ASSERT */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
regexident/Captain
Captain/Captain.h
// // Captain.h // Captain // // Created by <NAME> on 5/25/18. // Copyright © 2018 <NAME>. All rights reserved. // #import <UIKit/UIKit.h> //! Project version number for Captain. FOUNDATION_EXPORT double CaptainVersionNumber; //! Project version string for Captain. FOUNDATION_EXPORT const unsigned char CaptainVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import <Captain/PublicHeader.h>
tanpengsccd/RazzleDazzle
Sources/RazzleDazzle/RazzleDazzle.h
// // RazzleDazzle.h // RazzleDazzle // // Created by <NAME> on 6/11/15. // Copyright (c) 2015 IFTTT. All rights reserved. // #import <Foundation/Foundation.h> //! Project version number for RazzleDazzle. FOUNDATION_EXPORT double RazzleDazzleVersionNumber; //! Project version string for RazzleDazzle. FOUNDATION_EXPORT const unsigned char RazzleDazzleVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import <RazzleDazzle/PublicHeader.h>
NinakoLovu/Xv6_Stride_scheduler
wtf.c
#include "types.h" #include "user.h" #define MAX_TICKETS 1000 #define arg 3 int roulette(); void waste_time(); int main(){ printf(1, "Testing!\n"); int num; int i; for(i = 0; i < arg; i++){ num = roulette() % MAX_TICKETS; if(fork(num)== 0){ waste_time(); exit(); } } for(i = 0; i < arg; i++){ wait(); } exit(); } void waste_time(){ unsigned long i = 0; while(i < 10000000000){ // RUN FOREVER!!!!!!!! i++; } } int seed = 3; int roulette(){ seed = (seed * 1103515245) + 12345; if(seed < 0) seed = seed * (-1); //cprintf("%d\n", seed); return seed; }
makaleks/libload
tests/overview/tests/overview.c
<gh_stars>1-10 #include <stdio.h> #include <test_shared.h> #include <libload.h> int main () { puts("Example of libload started\n"); LIBLOAD_STATUS status = LIBLOAD_SUCCESS; function_str_str func_ptr = NULL; LibloadHandler handler; // 'test-shared.so' in Unix, 'test-shared' in Windows char library_path [] = "test-shared.so"; // Meson note: user ../src/test-shared for default --layout // and test-shared for --layout=flat status = libloadfile(&handler, library_path); if (LIBLOAD_SUCCESS != status) { puts("Error on file load!"); return -1; } puts("[done]: library loaded"); status = libloadsymbol( &handler, (LibloadSymbol*)&func_ptr, "test_shared" ); if (LIBLOAD_SUCCESS != status) { puts("Error on symbol load!"); libloadfinish(&handler); return -1; } puts("[done]: requested function was found in library"); puts(""); char test_str[] = "Test string"; char *test_ptr = NULL; test_ptr = func_ptr(NULL); printf("[library output 1]: %s\n", test_ptr); test_ptr = func_ptr(test_str); printf("[library output 2]: %s\n", test_ptr); puts(""); puts("[done]: code from library has run"); status = libloadfinish(&handler); if (LIBLOAD_SUCCESS != status) { puts("Error on symbol unload!"); return -1; } puts("[done]: library unloaded"); puts("\nExample of libload finished!"); return 0; }
makaleks/libload
tests/overview/src/test-shared.c
<filename>tests/overview/src/test-shared.c #include "test_shared.h" #include <stddef.h> // NULL #include <ctype.h> // toupper() // Compiler will help in case of mismatch with .h-file char* test_shared (char *str) { if (NULL == str) { // Data-provided return "Hello, plugin!"; } else { // Data-supplied char *cur = str; while ('\0' != *cur) { *cur = toupper(*cur); cur++; } return str; } }
makaleks/libload
src/libload.c
#include "libload.h" #include "buildtime_config.h" #include <stddef.h> #include <string.h> #if PLATFORM_NAME == 'POSX' // http://man7.org/linux/man-pages/man3/dlopen.3.html #include <dlfcn.h> #elif PLATFORM_NAME == 'WIN' // https://docs.microsoft.com/windows/win32/dlls/using-run-time-dynamic-linking // https://docs.microsoft.com/windows/win32/api/windef/ // /Wall causes errors in Windows.handler // Using <libloaderapi.h> instead of Windows.h causes "No Target Architecture" error #include <Windows.h> #endif LIBLOAD_STATUS libloadfile (LibloadHandler *handler, char *editable_filepath) { if ( NULL == handler || NULL == editable_filepath || '\0' == *editable_filepath ) { return LIBLOAD_ERROR; } void *raw_handler = NULL; #if PLATFORM_NAME == 'POSX' raw_handler = dlopen(editable_filepath, RTLD_NOW); #elif PLATFORM_NAME == 'WIN' // LoadLibrary automatically appends .dll size_t filepath_length = strlen(editable_filepath); char *filepath_suffix = editable_filepath + filepath_length - 3; char suffix_backup = '\0'; if ( filepath_suffix > editable_filepath && 0 == strcmp(".so", filepath_suffix) ) { suffix_backup = *filepath_suffix; *filepath_suffix = '\0'; } puts(editable_filepath); raw_handler = LoadLibrary(editable_filepath); if ('\0' != suffix_backup) { *filepath_suffix = suffix_backup; } #endif if (NULL == raw_handler) { //unsigned long err = GetLastError(); //printf("Error: %lu\n", err); return LIBLOAD_ERROR; } memset(handler, 0, sizeof(*handler)); handler->_handler = raw_handler; return LIBLOAD_SUCCESS; } LIBLOAD_STATUS libloadsymbol ( LibloadHandler *handler, LibloadSymbol *symbol, char *symbol_name ) { if ( NULL == handler || NULL == symbol || NULL == symbol_name || '\0' == *symbol_name ) { return LIBLOAD_ERROR; } #if PLATFORM_NAME == 'POSX' LibloadSymbol raw_symbol = NULL; // ISO C doesn't actually *forbids* the conversion void=>void(*)(), // but POSIX actually *allows* it // https://stackoverflow.com/a/31528674 *(void**)&raw_symbol = dlsym(handler->_handler, symbol_name); #elif PLATFORM_NAME == 'WIN' int (__stdcall *raw_symbol)() = NULL; raw_symbol = GetProcAddress(handler->_handler, symbol_name); #endif // TODO: compare & use errors from dlerror(), etc. if (NULL == raw_symbol) { //unsigned long err = GetLastError(); //printf("Error: %lu\n", err); return LIBLOAD_ERROR; } else { *symbol = (LibloadSymbol)raw_symbol; return LIBLOAD_SUCCESS; } } LIBLOAD_STATUS libloadfinish (LibloadHandler *handler) { if (NULL == handler) { return LIBLOAD_ERROR; } int raw_status = 0; #if PLATFORM_NAME == 'POSX' raw_status = dlclose(handler->_handler); #elif PLATFORM_NAME == 'WIN' raw_status = !FreeLibrary(handler->_handler); #endif if (0 != raw_status) return LIBLOAD_ERROR; memset(handler, 0, sizeof(*handler)); return LIBLOAD_SUCCESS; }
makaleks/libload
tests/overview/include/test_shared.h
<reponame>makaleks/libload<gh_stars>1-10 #ifndef TEST_SHARED_H_INCLUDED #define TEST_SHARED_H_INCLUDED 0 #ifdef __cplusplus extern "C" { #endif // See (theory) // https://docs.microsoft.com/en-us/cpp/build/walkthrough-creating-and-using-a-dynamic-link-library-cpp // https://gcc.gnu.org/wiki/Visibility // and (practic) // https://github.com/glfw/glfw/blob/master/include/GLFW/glfw3.h // for examples about how do deal with Windows headache // A single define for Windows #if !defined(_WIN32) && (defined(__WIN32__)\ || defined(WIN32) || defined(__MINGW32__)) #define _WIN32 #endif // Minimal DLL API #ifndef _WIN32 // For GCC you can also use // __attribute__((visibility("hidden"))) // and -fvisibility=hidden compilation flag. It is a good // flag, but this example is 'minimal to work' #define TEST_SHARED_API #else #ifdef TEST_SHARED_BUILD // API to build DLL #define TEST_SHARED_API __declspec(dllexport) #else // API to call DLL #define TEST_SHARED_API __declspec(dllimport) #endif #endif typedef char* (*function_str_str)(char*); TEST_SHARED_API char* test_shared(char*); #ifdef __cplusplus } #endif #endif
makaleks/libload
include/libload.h
<reponame>makaleks/libload #ifndef LIBLOAD_H_INCLUDED #define LIBLOAD_H_INCLUDED 0 #ifdef __cplusplus extern "C" { #endif typedef enum { LIBLOAD_SUCCESS = 0, LIBLOAD_ERROR } LIBLOAD_STATUS; typedef struct { void *_handler; } LibloadHandler; typedef void (*LibloadSymbol)(void); LIBLOAD_STATUS libloadfile (LibloadHandler *handler, char *editable_filepath); LIBLOAD_STATUS libloadsymbol ( LibloadHandler *handler, LibloadSymbol *symbol, char *symbol_name ); LIBLOAD_STATUS libloadfinish (LibloadHandler *handler); #ifdef __cplusplus } #endif #endif
liyanboy74/avr-stepper-motor
prog/key.h
#define KEYPAD_PORT PORTB #define KEYPAD_PIN PINB #define KEYPAD_DDR DDRB char getkey(void);
liyanboy74/avr-stepper-motor
prog/main.c
<filename>prog/main.c /* By Liyanboy74 https://github.com/liyanboy74 */ #include <mega16.h> #include <stdlib.h> #include <delay.h> #include <alcd.h> //KeyPad Lib #include "key.h" //Stepper motor StepAngel #define step_angle 0.8 #define STEPPER_PORT PORTA #define STEPPER_PIN PINA #define STEPPER_DDR DDRA //Step Codes const unsigned char StepCodes[]={0b0001,0b0011, 0b0010, 0b0110 ,0b0100 ,0b1100 ,0b1000 ,0b1001 }; //Buffer unsigned char lcd_b[32]; int angle=0,Step=0; //Run Pulse Generator void run_prog(int angle) { int i,temp; float temp2; if(angle>=0) temp=angle/(float)(step_angle/2.0); else temp=(-angle)/(float)(step_angle/2.0); temp2=temp*(step_angle/2.0); lcd_clear(); lcd_puts("Angle="); ftoa(temp2,1,lcd_b); if(angle>=0)lcd_putchar('+'); else lcd_putchar('-'); lcd_puts(lcd_b); lcd_puts("\xdf"); lcd_gotoxy(0,1); lcd_puts("Raning Prog.."); if(angle>=0) { for(i=0; i<temp; i++) { Step++; if(Step>7)Step=0; STEPPER_PORT = StepCodes[Step]; delay_ms(50); } } else { for(i=0; i<temp; i++) { Step--; if(Step<0)Step=7; STEPPER_PORT = StepCodes[Step]; delay_ms(50); } } lcd_gotoxy(0,1); lcd_puts("Prog Completed."); delay_ms(3000); return; } void main(void) { //KeyPad Buffer char ch; //GPIO Initial STEPPER_PORT=0b00000000; STEPPER_DDR= 0b00001111; //Startup Output State STEPPER_PORT=StepCodes[0]; // Alphanumeric LCD initialization // Connections are specified in the // Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu: // Characters/line: 16 lcd_init(16); while(1) { lcd_clear(); lcd_puts("Motor Angle="); itoa(angle,lcd_b); lcd_gotoxy(0,1); if(angle>=0)lcd_putchar('+'); lcd_puts(lcd_b); lcd_puts("\xdf"); ch=getkey(); if(ch=='+'||ch=='-') { if(ch=='+') { if(angle<=0)angle=(-1)*angle; } else if(ch=='-') { if(angle>=0)angle=(-1)*angle; } } else if(ch=='='){run_prog(angle);} else if(ch=='c') { angle=0; } else { if(angle<100) angle=(angle*10)+(ch-48); } } }
AmmarRabie/asm-gen
asmShape.h
/* **************************************** * * * Author: <NAME> * * Sec: 2 BN: 4 * * GitHibLink: * * desc: this prog is designed for * * bonus task in term holiday * * for D.Khaled * * * **************************************** */ #pragma once #include<vector> #include<iostream> using namespace std; struct Vertix { int x; int y; Vertix(int x, int y); Vertix(); }; struct Rect { Vertix min; Vertix max; Rect(Vertix v1, Vertix v2); void move(int x, int y); void multiply(float x, float y); }; class asmShape abstract { vector<Rect> _verices; // rectangles forming this duck Vertix _center; Vertix _vmin; Vertix _vmax; Vertix getVmin(const vector<Rect>& basicVerices); Vertix getVmax(const vector<Rect>& basicVerices); protected: void refresh(); public: asmShape(vector<Rect> basicVerices); vector<Rect> getVertices()const; Vertix getCenter() const; Vertix getVmin() const; Vertix getVmax() const; int getLength() const; int getWidht() const; void subFromAll(int x, int y); void scale(float factor); void reflectAbouty(); void print(); virtual void generateDrawingAsm(string fileName, string macroName) = 0; };
nporteschaikin/objc
DBObject/DBAdapter.h
// // DBAdapter.h // Flyer // // Created by <NAME> on 9/11/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <Foundation/Foundation.h> #import <sqlite3.h> @interface DBAdapter : NSObject + (DBAdapter *)dbAdapter; - (BOOL)executeQuery:(NSString *)queryString; - (NSArray *)recordsByQuery:(NSString *)queryString; - (NSNumber *)lastInsertRowId; @end
nporteschaikin/objc
DBObject/DBObjectAccessorHelper.h
<reponame>nporteschaikin/objc // // DBObjectAccessorHelper.h // Flyer // // Created by <NAME> on 9/18/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <Foundation/Foundation.h> #import "DBColumn.h" @interface DBObjectAccessorHelper : NSObject + (void)setAccessorForColumn:(DBColumn *)column; @end
nporteschaikin/objc
DBObject/DBObject.h
<filename>DBObject/DBObject.h // // DBObject.h // Flyer // // Created by <NAME> on 9/12/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <Foundation/Foundation.h> #import "DBColumn.h" #import "DBObjectFetcher.h" @interface DBObject : NSObject @property (strong, nonatomic, readonly) NSMutableSet *changedColumns; + (NSString *)tableName; + (NSSet *)columns; + (DBColumn *)columnNamed:(NSString *)columnName; + (DBColumn *)columnWithSetterSelector:(SEL)setterSelector; + (DBColumn *)columnWithGetterSelector:(SEL)getterSelector; + (DBColumn *)primaryKeyColumn; + (DBObjectFetcher *)objectFetcher; - (id)valueForColumn:(DBColumn *)column; - (void)setValue:(id)value forColumn:(DBColumn *)column; - (void)save; @end
nporteschaikin/objc
DBObject/DBObjectFetcher.h
<filename>DBObject/DBObjectFetcher.h // // DBObjectFetcher.h // Flyer // // Created by <NAME> on 9/17/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <Foundation/Foundation.h> @interface DBObjectFetcher : NSObject - (id)initWithDBObjectClass:(Class)DBObjectClass; - (NSArray *)fetch; - (void)setColumns:(id)arguments, ... NS_REQUIRES_NIL_TERMINATION; - (void)setWhere:(id)arguments, ... NS_REQUIRES_NIL_TERMINATION; - (void)setLimit:(NSNumber *)limit; - (void)setOffset:(NSNumber *)offset; @end
nporteschaikin/objc
DBObject/DBMigration.h
// // DBMigration.h // Flyer // // Created by <NAME> on 9/22/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <Foundation/Foundation.h> @interface DBMigration : NSObject @property (strong, nonatomic) NSString *upQuery; @property (strong, nonatomic) NSString *downQuery; - (id)initWithUp:(NSString *)upQuery withDown:(NSString *)downQuery; @end
nporteschaikin/objc
CoreDataManager/CoreDataManager.h
// // CoreDataManager.h // Here // // Created by <NAME> on 9/1/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <Foundation/Foundation.h> #import <CoreData/CoreData.h> @interface CoreDataManager : NSObject + (NSManagedObjectContext *) managedObjectContext; + (NSManagedObjectContext *) newManagedObjectContext; + (NSFetchRequest *)fetchRequestFromEntityByName:(NSString *)table batchSize:(NSInteger)batchSize; + (NSFetchRequest *)fetchRequestFromEntityByName:(NSString *)table matchedByPredicate:(NSPredicate *)predicate batchSize:(NSInteger)batchSize; + (NSFetchRequest *)fetchRequestFromEntityByName:(NSString *)table withSortDescriptors:(NSArray *)sortDescriptors batchSize:(NSInteger)batchSize; + (NSFetchRequest *)fetchRequestFromEntityByName:(NSString *)table matchedByPredicate:(NSPredicate *)predicate withSortDescriptors:(NSArray *)sortDescriptors batchSize:(NSInteger)batchSize; + (NSArray *)fetchFromEntityByName:(NSString *)table matchedByPredicate:(NSPredicate *)predicate withSortDescriptors:(NSArray *)sortDescriptors inContext:(NSManagedObjectContext *)context batchSize:(NSInteger)batchSize; + (NSArray *)fetchFromEntityByName:(NSString *)table matchedByPredicate:(NSPredicate *)predicate withSortDescriptors:(NSArray *)sortDescriptors batchSize:(NSInteger)batchSize; + (NSManagedObject *)newObjectInEntityByName:(NSString *)table inContext:(NSManagedObjectContext *)context; + (NSManagedObject *)newObjectInEntityByName:(NSString *)table; + (NSManagedObject *)newObjectInEntityByName:(NSString *)table withValues:(NSDictionary *)values inContext:(NSManagedObjectContext *)context; + (NSManagedObject *)newObjectInEntityByName:(NSString *)table withValues:(NSDictionary *)values; + (NSError *) saveContext:(NSManagedObjectContext *)context; + (NSError *) saveContext; @end
nporteschaikin/objc
DBObject/NSString+DBUppercaseFirst.h
// // NSString+DBUppercaseFirst.h // Flyer // // Created by <NAME> on 9/18/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <Foundation/Foundation.h> @interface NSString (DBUppercaseFirst) - (NSString *)stringWithUppercaseFirst; @end
nporteschaikin/objc
DBObject/DBMigrator.h
<filename>DBObject/DBMigrator.h<gh_stars>1-10 // // DBMigrator.h // Flyer // // Created by <NAME> on 9/22/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <Foundation/Foundation.h> #import "DBDatabase.h" #import "DBMigration.h" @interface DBMigrator : NSObject - (id)initWithDatabase:(DBDatabase *)database; - (void)insertMigration:(DBMigration *)migration atVersion:(int)version; - (void)migrate; @end
nporteschaikin/objc
DBObject/DBColumnFetcher.h
// // DBColumnFetcher.h // Flyer // // Created by <NAME> on 9/18/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <Foundation/Foundation.h> @interface DBColumnFetcher : NSObject - (id)initWithDBObjectClass:(Class)DBObjectClass; - (NSSet *)fetch; @end
nporteschaikin/objc
LocationController/LocationController.h
// // LocationController.h // Here // // Created by <NAME> on 9/4/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <Foundation/Foundation.h> #import <CoreLocation/CoreLocation.h> extern NSString * const LocationControllerDidUpdateLocationNotification; @interface LocationController : NSObject + (CLLocationManager *)sharedManager; @end
nporteschaikin/objc
DBObject/DBDatabase.h
<reponame>nporteschaikin/objc // // DBDatabase.h // Flyer // // Created by <NAME> on 9/22/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <Foundation/Foundation.h> @interface DBDatabase : NSObject + (DBDatabase *)sharedDatabase; - (id)initWithFileName:(NSString *)filename; - (BOOL)executeUpdate:(NSString *)query; - (NSArray *)executeQuery:(NSString *)query; - (NSNumber *)lastInsertPrimaryKey; @end
nporteschaikin/objc
CoreDataManager/NSManagedObject+Querying.h
// // NSManagedObject+Querying.h // Pluck // // Created by <NAME> on 8/29/14. // Copyright (c) 2014 Pluck. All rights reserved. // #import <Foundation/Foundation.h> #import <CoreData/CoreData.h> @interface NSManagedObject (Querying) + (NSFetchRequest *)fetchRequestMatchedByPredicate:(NSPredicate *)predicate withSortDescriptors:(NSArray *)sortDescriptors; + (NSArray *)findAllMatchedByPredicate:(NSPredicate *)predicate withSortDescriptors:(NSArray *)sortDescriptors inContext:(NSManagedObjectContext *)managedObjectContext; + (NSArray *)findAllMatchedByPredicate:(NSPredicate *)predicate withSortDescriptors:(NSArray *)sortDescriptors; + (NSManagedObject *)findOneByPredicate:(NSPredicate *)predicate withSortDescriptors:(NSArray *)sortDescriptors inContext:(NSManagedObjectContext *)managedObjectContext atIndex:(int)index; + (NSManagedObject *)findOneByPredicate:(NSPredicate *)predicate withSortDescriptors:(NSArray *)sortDescriptors atIndex:(int)index; + (NSManagedObject *)findFirstByPredicate:(NSPredicate *)predicate withSortDescriptors:(NSArray *)sortDescriptors inContext:(NSManagedObjectContext *)managedObjectContext; + (NSManagedObject *)findFirstByPredicate:(NSPredicate *)predicate withSortDescriptors:(NSArray *)sortDescriptors; @end
nporteschaikin/objc
DBObject/DBObjectInsert.h
// // DBObjectInsert.h // Flyer // // Created by <NAME> on 9/18/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <Foundation/Foundation.h> #import "DBObject.h" @interface DBObjectInsert : NSObject - (id)initWithDBObject:(DBObject *)dbObject; - (NSNumber *)execute; @end
nporteschaikin/objc
FetchedResultsControllerDataSource/FetchedResultsControllerDataSource.h
<reponame>nporteschaikin/objc<gh_stars>1-10 // // FetchedResultsControllerDataSource.h // Here // // Created by <NAME> on 9/1/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <UIKit/UIKit.h> #import <CoreData/CoreData.h> @protocol FetchedResultsControllerDataSourceDelegate - (void)configureCell:(id)cell withObject:(id)object; @end @interface FetchedResultsControllerDataSource : NSObject <UITableViewDataSource, NSFetchedResultsControllerDelegate> @property (nonatomic, weak) id<FetchedResultsControllerDataSourceDelegate> delegate; - (id)initWithTableView:(UITableView *)tableView fetchedResultsController:(NSFetchedResultsController *)fetchedResultsController reuseIdentifier:(NSString *)reuseIdentifier; @end
nporteschaikin/objc
DBObject/DBColumn.h
// // DBColumn.h // Flyer // // Created by <NAME> on 9/18/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <Foundation/Foundation.h> #import "NSString+DBUppercaseFirst.h" @interface DBColumn : NSObject @property (strong, nonatomic, readonly) Class DBObjectClass; @property (strong, nonatomic, readonly) NSString *name; @property (nonatomic, readonly) char *key; @property (strong, nonatomic, readonly) NSString *type; @property (nonatomic, readonly) BOOL isPrimaryKey; @property (nonatomic, readonly) SEL getterSelector; @property (nonatomic, readonly) SEL setterSelector; - (id)initWithDBObjectClass:(Class)DBObjectClass withName:(NSString *)name withType:(NSString *)type isPrimaryKey:(BOOL)isPrimaryKey; @end
Mano300/Swapping-of-2-numbers
swap 2 numbers.c
#include<stdio.h> int main() { int a=2,b=6; printf("before swap: %d %d\n",a,b); a=a+b; b=a-b; a=a-b; printf("After swap: %d %d",a,b); }
Foxbud/libaermre
include/public/aer/err.h
<reponame>Foxbud/libaermre /** * @file * * @brief Global error state of the MRE. * * @since 1.0.0 * * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef AER_ERR_H #define AER_ERR_H /* ----- PUBLIC TYPES ----- */ /* @deprecated Since 1.1.0. */ #define AER_OUT_OF_MEM AER_OUT_OF_MEM __attribute__((deprecated)) /** * @brief Possible values of ::aererr. * * @since 1.0.0 */ typedef enum AERErrCode { /** * @brief Flag that informs the MRE that the next public function call is * being error-checked. Functions will never report this error. * * @since 1.3.0 */ AER_TRY = -1, /** * @brief Function did not report an error. * * @deprecated Partially since 1.3.0. This symbol, itself, is not * deprecated, but setting ::aererr to it when error-checking a function * *is* deprecated. Instead, use ::AER_TRY. Functions will still report this * if they did not encounter any errors; this functionality is *not* * deprecated. * * @since 1.0.0 */ AER_OK = 0, /** * @brief Function received `NULL` pointer argument. * * @since 1.0.0 */ AER_NULL_ARG = 1, /** * @brief Function called at incorrect stage of runtime execution. * * @since 1.0.0 */ AER_SEQ_BREAK = 2, /** * @brief Function unable to allocate necessary memory required for proper * execution. * * @deprecated Since 1.1.0. * * @since 1.0.0 */ AER_OUT_OF_MEM = 3, /** * @brief Function called with an invalid index, ID or key. * * @since 1.0.0 */ AER_FAILED_LOOKUP = 4, /** * @brief Function unable to parse resource. * * @since 1.0.0 */ AER_FAILED_PARSE = 5, /** * @brief Function unable to read file. * * @since 1.0.0 */ AER_BAD_FILE = 6, /** * @brief Function encountered an invalid value or combination of values. * * @since 1.0.0 */ AER_BAD_VAL = 7 } AERErrCode; #undef AER_OUT_OF_MEM /* ----- PUBLIC GLOBALS ----- */ /** * @brief Error state of most recently called MRE function. * * @note Always reset this global to ::AER_TRY before calling the * function to be error-checked. * * @since 1.0.0 */ extern AERErrCode aererr; #endif /* AER_ERR_H */
Foxbud/libaermre
include/public/aer/rand.h
/** * @file * * @brief Utilities for generating pseudorandom numbers. * * @since 1.0.0 * * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef AER_RAND_H #define AER_RAND_H #include <stdbool.h> #include <stddef.h> #include <stdint.h> /* ----- PUBLIC TYPES ----- */ /** * @brief Opaque type for a self-managed pseudorandom number generator. * * Use this with the functions prefixed with `AERRandGen...` * * @since 1.0.0 */ typedef void AERRandGen; /* ----- PUBLIC FUNCTIONS ----- */ /** * @brief Get a pseudorandom unsigned integer on the interval [0, 2^64) using * the automatically-seeded global generator. * * @return Pseudorandom unsigned integer. * * @since 1.0.0 * * @sa AERRandGenUInt */ uint64_t AERRandUInt(void); /** * @brief Get a pseudorandom unsigned integer on the interval [min, max) using * the automatically-seeded global generator. * * This function has been carefully designed to avoid introducing any * distribution-related bias. For faster but potentially biased generation, * use modulo. * * @param[in] min Minimum possible value (inclusive). * @param[in] max Maximum possible value (exclusive). * * @return Pseudorandom unsigned integer or `0` if unsuccessful. * * @throw ::AER_BAD_VAL if argument `min` is greater than or equal to * argument `max`. * * @since 1.0.0 * * @sa AERRandGenUIntRange */ uint64_t AERRandUIntRange(uint64_t min, uint64_t max); /** * @brief Get a pseudorandom signed integer on the interval [-2^63, 2^63) using * the automatically-seeded global generator. * * @return Pseudorandom signed integer. * * @since 1.0.0 * * @sa AERRandGenInt */ int64_t AERRandInt(void); /** * @brief Get a pseudorandom signed integer on the interval [min, max) using the * automatically-seeded global generator. * * This function has been carefully designed to avoid introducing any * distribution-related bias. For faster but potentially biased generation, * use modulo. * * @param[in] min Minimum possible value (inclusive). * @param[in] max Maximum possible value (exclusive). * * @return Pseudorandom signed integer or `0` if unsuccessful. * * @throw ::AER_BAD_VAL if argument `min` is greater than or equal to * argument `max`. * * @since 1.0.0 * * @sa AERRandGenIntRange */ int64_t AERRandIntRange(int64_t min, int64_t max); /** * @brief Get a pseudorandom floating-point value on the interval [0.0f, 1.0f) * using the automatically-seeded global generator. * * @bug This function uses a method of obtaining floats from integers that is * now known to introduce slight distribution-related bias (see <a * href="https://hal.archives-ouvertes.fr/hal-02427338/file/fpnglib_iccs.pdf"> * *Generating Random Floating-Point Numbers by Dividing Integers: a Case Study* * by <NAME></a>). * This is unlikely to cause issues in the vast majority of usecases, but it * should be kept in mind. * * @return Pseudorandom floating-point value. * * @since 1.0.0 * * @sa AERRandGenFloat */ float AERRandFloat(void); /** * @brief Get a pseudorandom floating-point value on the interval [min, max) * using the automatically-seeded global generator. * * @bug This function uses a method of obtaining floats from integers that is * now known to introduce slight distribution-related bias (see <a * href="https://hal.archives-ouvertes.fr/hal-02427338/file/fpnglib_iccs.pdf"> * *Generating Random Floating-Point Numbers by Dividing Integers: a Case Study* * by <NAME></a>). * This is unlikely to cause issues in the vast majority of usecases, but it * should be kept in mind. * * @param[in] min Minimum possible value (inclusive). * @param[in] max Maximum possible value (exclusive). * * @return Pseudorandom floating-point value or `0.0f` if unsuccessful. * * @throw ::AER_BAD_VAL if argument `min` is greater than or equal to * argument `max`. * * @since 1.0.0 * * @sa AERRandGenFloatRange */ float AERRandFloatRange(float min, float max); /** * @brief Get a pseudorandom double floating-point value on the interval * [0.0, 1.0) using the automatically-seeded global generator. * * @bug This function uses a method of obtaining floats from integers that is * now known to introduce slight distribution-related bias (see <a * href="https://hal.archives-ouvertes.fr/hal-02427338/file/fpnglib_iccs.pdf"> * *Generating Random Floating-Point Numbers by Dividing Integers: a Case Study* * by <NAME></a>). * This is unlikely to cause issues in the vast majority of usecases, but it * should be kept in mind. * * @return Pseudorandom double floating-point value. * * @since 1.0.0 * * @sa AERRandGenDouble */ double AERRandDouble(void); /** * @brief Get a pseudorandom double floating-point value on the interval * [min, max) using the automatically-seeded global generator. * * @bug This function uses a method of obtaining floats from integers that is * now known to introduce slight distribution-related bias (see <a * href="https://hal.archives-ouvertes.fr/hal-02427338/file/fpnglib_iccs.pdf"> * *Generating Random Floating-Point Numbers by Dividing Integers: a Case Study* * by <NAME></a>). * This is unlikely to cause issues in the vast majority of usecases, but it * should be kept in mind. * * @param[in] min Minimum possible value (inclusive). * @param[in] max Maximum possible value (exclusive). * * @return Pseudorandom double floating-point value or `0.0` if unsuccessful. * * @throw ::AER_BAD_VAL if argument `min` is greater than or equal to * argument `max`. * * @since 1.0.0 * * @sa AERRandGenDoubleRange */ double AERRandDoubleRange(double min, double max); /** * @brief Get a pseudorandom boolean using the automatically-seeded global * generator. * * @return Pseudorandom boolean. * * @since 1.0.0 * * @sa AERRandGenBool */ bool AERRandBool(void); /** * @brief Shuffle an array of arbitrary elements using the automatically-seeded * global generator. * * @param[in] elemSize Size of each buffer element in bytes. * @param[in] bufSize Size of buffer in elements. * @param[in,out] elemBuf Buffer of elements to shuffle. * * @throw ::AER_BAD_VAL if argument `elemSize` is `0`. * @throw ::AER_NULL_ARG if argument `elemBuf` is `NULL`. * * @since 1.4.0 * * @sa AERRandGenShuffle */ void AERRandShuffle(size_t elemSize, size_t bufSize, void* elemBuf); /** * @brief Allocate and initialize a new self-managed pseudorandom number * generator. * * When no longer needed, free this generator using AERRandGenFree. * * @param[in] seed Initial generator seed. * * @return Newly allocated generator. * * @since 1.0.0 * * @sa AERRandGenFree */ AERRandGen* AERRandGenNew(uint64_t seed); /** * @brief Free a self-managed pseudorandom number generator allocated using * AERRandGenNew. * * @param[in] gen Generator of interest. * * @throw ::AER_NULL_ARG if argument `gen` is `NULL`. * * @since 1.0.0 * * @sa AERRandGenNew */ void AERRandGenFree(AERRandGen* gen); /** * @brief Re-seed a self-managed pseudorandom number generator. * * @param[in] gen Generator of interest. * @param[in] seed New generator seed. * * @throw ::AER_NULL_ARG if argument `gen` is `NULL`. * * @since 1.0.0 */ void AERRandGenSeed(AERRandGen* gen, uint64_t seed); /** * @brief Get a pseudorandom unsigned integer on the interval [0, 2^64) using * a self-managed generator. * * @param[in] gen Generator of interest. * * @return Pseudorandom unsigned integer or `0` if unsuccessful. * * @throw ::AER_NULL_ARG if argument `gen` is `NULL`. * * @since 1.0.0 * * @sa AERRandUInt */ uint64_t AERRandGenUInt(AERRandGen* gen); /** * @brief Get a pseudorandom unsigned integer on the interval [min, max) using * a self-managed generator. * * This function has been carefully designed to avoid introducing any * distribution-related bias. For faster but potentially biased generation, * use modulo. * * @param[in] gen Generator of interest. * @param[in] min Minimum possible value (inclusive). * @param[in] max Maximum possible value (exclusive). * * @return Pseudorandom unsigned integer or `0` if unsuccessful. * * @throw ::AER_NULL_ARG if argument `gen` is `NULL`. * @throw ::AER_BAD_VAL if argument `min` is greater than or equal to * argument `max`. * * @since 1.0.0 * * @sa AERRandUIntRange */ uint64_t AERRandGenUIntRange(AERRandGen* gen, uint64_t min, uint64_t max); /** * @brief Get a pseudorandom signed integer on the interval [-2^63, 2^63) using * a self-managed generator. * * @param[in] gen Generator of interest. * * @return Pseudorandom signed integer or `0` if unsuccessful. * * @throw ::AER_NULL_ARG if argument `gen` is `NULL`. * * @since 1.0.0 * * @sa AERRandInt */ int64_t AERRandGenInt(AERRandGen* gen); /** * @brief Get a pseudorandom signed integer on the interval [min, max) using a * self-managed generator. * * This function has been carefully designed to avoid introducing any * distribution-related bias. For faster but potentially biased generation, * use modulo. * * @param[in] gen Generator of interest. * @param[in] min Minimum possible value (inclusive). * @param[in] max Maximum possible value (exclusive). * * @return Pseudorandom signed integer or `0` if unsuccessful. * * @throw ::AER_NULL_ARG if argument `gen` is `NULL`. * @throw ::AER_BAD_VAL if argument `min` is greater than or equal to * argument `max`. * * @since 1.0.0 * * @sa AERRandIntRange */ int64_t AERRandGenIntRange(AERRandGen* gen, int64_t min, int64_t max); /** * @brief Get a pseudorandom floating-point value on the interval [0.0f, 1.0f) * using a self-managed generator. * * @bug This function uses a method of obtaining floats from integers that is * now known to introduce slight distribution-related bias (see <a * href="https://hal.archives-ouvertes.fr/hal-02427338/file/fpnglib_iccs.pdf"> * *Generating Random Floating-Point Numbers by Dividing Integers: a Case Study* * by <NAME></a>). * This is unlikely to cause issues in the vast majority of usecases, but it * should be kept in mind. * * @param[in] gen Generator of interest. * * @return Pseudorandom floating-point value or `0.0f` if unsuccessful. * * @throw ::AER_NULL_ARG if argument `gen` is `NULL`. * * @since 1.0.0 * * @sa AERRandFloat */ float AERRandGenFloat(AERRandGen* gen); /** * @brief Get a pseudorandom floating-point value on the interval [min, max) * using a self-managed generator. * * @bug This function uses a method of obtaining floats from integers that is * now known to introduce slight distribution-related bias (see <a * href="https://hal.archives-ouvertes.fr/hal-02427338/file/fpnglib_iccs.pdf"> * *Generating Random Floating-Point Numbers by Dividing Integers: a Case Study* * by <NAME></a>). * This is unlikely to cause issues in the vast majority of usecases, but it * should be kept in mind. * * @param[in] gen Generator of interest. * @param[in] min Minimum possible value (inclusive). * @param[in] max Maximum possible value (exclusive). * * @return Pseudorandom floating-point value or `0.0f` if unsuccessful. * * @throw ::AER_NULL_ARG if argument `gen` is `NULL`. * @throw ::AER_BAD_VAL if argument `min` is greater than or equal to * argument `max`. * * @since 1.0.0 * * @sa AERRandFloatRange */ float AERRandGenFloatRange(AERRandGen* gen, float min, float max); /** * @brief Get a pseudorandom double floating-point value on the interval * [0.0, 1.0) using a self-managed generator. * * @bug This function uses a method of obtaining floats from integers that is * now known to introduce slight distribution-related bias (see <a * href="https://hal.archives-ouvertes.fr/hal-02427338/file/fpnglib_iccs.pdf"> * *Generating Random Floating-Point Numbers by Dividing Integers: a Case Study* * by <NAME></a>). * This is unlikely to cause issues in the vast majority of usecases, but it * should be kept in mind. * * @param[in] gen Generator of interest. * * @return Pseudorandom double floating-point value or `0.0` if unsuccessful. * * @throw ::AER_NULL_ARG if argument `gen` is `NULL`. * * @since 1.0.0 * * @sa AERRandDouble */ double AERRandGenDouble(AERRandGen* gen); /** * @brief Get a pseudorandom double floating-point value on the interval * [min, max) using a self-managed generator. * * @bug This function uses a method of obtaining floats from integers that is * now known to introduce slight distribution-related bias (see <a * href="https://hal.archives-ouvertes.fr/hal-02427338/file/fpnglib_iccs.pdf"> * *Generating Random Floating-Point Numbers by Dividing Integers: a Case Study* * by <NAME></a>). * This is unlikely to cause issues in the vast majority of usecases, but it * should be kept in mind. * * @param[in] gen Generator of interest. * @param[in] min Minimum possible value (inclusive). * @param[in] max Maximum possible value (exclusive). * * @return Pseudorandom double floating-point value or `0.0` if unsuccessful. * * @throw ::AER_NULL_ARG if argument `gen` is `NULL`. * @throw ::AER_BAD_VAL if argument `min` is greater than or equal to * argument `max`. * * @since 1.0.0 * * @sa AERRandDoubleRange */ double AERRandGenDoubleRange(AERRandGen* gen, double min, double max); /** * @brief Get a pseudorandom boolean using a self-managed generator. * * @param[in] gen Generator of interest. * * @return Pseudorandom boolean or `false` if unsuccessful. * * @throw ::AER_NULL_ARG if argument `gen` is `NULL`. * * @since 1.0.0 * * @sa AERRandBool */ bool AERRandGenBool(AERRandGen* gen); /** * @brief Shuffle an array of arbitrary elements using a self-managed generator. * * @param[in] gen Generator of interest. * @param[in] elemSize Size of each buffer element in bytes. * @param[in] bufSize Size of buffer in elements. * @param[in,out] elemBuf Buffer of elements to shuffle. * * @throw ::AER_BAD_VAL if argument `elemSize` is `0`. * @throw ::AER_NULL_ARG if either argument `gen` or `elemBuf` is `NULL`. * * @since 1.4.0 * * @sa AERRandShuffle */ void AERRandGenShuffle(AERRandGen* gen, size_t elemSize, size_t bufSize, void* elemBuf); #endif /* AER_RAND_H */
Foxbud/libaermre
src/mod.c
/** * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #define _GNU_SOURCE /* Required for `dladdr` and `Dl_info`. */ #include <assert.h> #include <dlfcn.h> #include <stddef.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "foxutils/arraymacs.h" #include "foxutils/mapmacs.h" #include "aer/err.h" #include "aer/mod.h" #include "internal/log.h" #include "internal/mod.h" #include "internal/option.h" /* ----- PRIVATE MACROS ----- */ #define FormatLibname(name, bufSize, buf) \ snprintf((buf), (bufSize), MOD_LIBNAME_FMT, (name)) /* ----- PRIVATE CONSTANTS ----- */ static const char* MOD_LIBNAME_FMT = "lib%s.so"; static const char* DEF_MOD_NAMES[] = {"define_mod", "definemod", "defineMod", "DefineMod"}; /* ----- INTERNAL CONSTANTS ----- */ const int32_t MOD_NULL = -1; /* ----- PRIVATE GLOBALS ----- */ static Mod* mods = NULL; static FoxMap modMemMap = {0}; static FoxArray gameStepListeners = {0}; static FoxArray gamePauseListeners = {0}; static FoxArray gameSaveListeners = {0}; static FoxArray gameLoadListeners = {0}; static FoxArray roomChangeListeners = {0}; /* ----- PRIVATE FUNCTIONS ----- */ static void ModInit(Mod* mod, int32_t idx, const char* name) { LogInfo("Loading mod \"%s\"...", name); /* Set index. */ mod->idx = idx; /* Set name. */ mod->name = name; /* Load library. */ char libname[128]; FormatLibname(name, 128, libname); void* libHandle = dlopen(libname, RTLD_NOW); if (!(mod->libHandle = libHandle)) { LogErr( "While loading mod \"%s\", could not load corresponding library " "\"%s\".\n" "If you are using this mod, make sure its directory is in " "the \"LD_LIBRARY_PATH\" environment variable.\n" "If you are developing this mod, make sure all of the symbols it " "references are defined.", name, libname); abort(); } /* Load mod definition function. */ void (*defMod)(AERModDef*); size_t numDefModNames = sizeof(DEF_MOD_NAMES) / sizeof(const char*); for (uint32_t idx = 0; idx < numDefModNames; idx++) { defMod = dlsym(libHandle, DEF_MOD_NAMES[idx]); if (defMod) break; } if (!defMod) { /* TODO Create dedicated string concatenation function. */ /* Efficiently concatenate all valid def mod function names. */ char defModNamesBuf[256]; uint32_t charIdxOut = 0; for (uint32_t nameIdx = 0; nameIdx < numDefModNames; nameIdx++) { /* Prevent buffer overflow. */ if (charIdxOut == sizeof(defModNamesBuf) - 1) break; defModNamesBuf[charIdxOut++] = ' '; const char* name = DEF_MOD_NAMES[nameIdx]; uint32_t charIdxIn = 0; char charCur = name[charIdxIn]; while (charCur != '\0') { /* Prevent buffer overflow. */ if (charIdxOut == sizeof(defModNamesBuf) - 1) break; defModNamesBuf[charIdxOut++] = charCur; charCur = name[++charIdxIn]; } } defModNamesBuf[charIdxOut] = '\0'; /* Display error. */ LogErr( "While loading mod \"%s\", could not find mod definition function " "with one of the following names:%s.", name, defModNamesBuf); abort(); } AERModDef def = {0}; /* Record mod memory map. */ Dl_info memInfo; if (dladdr(defMod, &memInfo) == 0 || memInfo.dli_fbase == NULL) { LogErr( "While loading mod \"%s\", could not determine mod library's base " "address.", name); abort(); } *FoxMapMInsert(void*, int32_t, &modMemMap, memInfo.dli_fbase) = idx; /* Call mod definition function. */ defMod(&def); /* Record registration callbacks. */ mod->registerSprites = def.registerSprites; mod->registerFonts = def.registerFonts; mod->registerObjects = def.registerObjects; mod->registerObjectListeners = def.registerObjectListeners; /* Record pseudoevent listeners. */ if (def.gameStepListener) { *FoxArrayMPush(void*, &gameStepListeners) = def.gameStepListener; } if (def.gamePauseListener) { *FoxArrayMPush(void*, &gamePauseListeners) = def.gamePauseListener; } if (def.gameSaveListener) { *FoxArrayMPush(void*, &gameSaveListeners) = def.gameSaveListener; } if (def.gameLoadListener) { *FoxArrayMPush(void*, &gameLoadListeners) = def.gameLoadListener; } if (def.roomChangeListener) { *FoxArrayMPush(void*, &roomChangeListeners) = def.roomChangeListener; } /* Record mod library management callbacks. */ mod->constructor = def.constructor; mod->destructor = def.destructor; LogInfo("Successfully loaded mod \"%s\".", name); return; } static void ModDeinit(Mod* mod) { LogInfo("Unloading mod \"%s\"...", mod->name); dlclose(mod->libHandle); const char* name = mod->name; *mod = (Mod){0}; LogInfo("Successfully unloaded mod \"%s\".", name); return; } /* ----- INTERNAL FUNCTIONS ----- */ size_t ModManGetNumMods(void) { return opts.numModNames; } Mod* ModManGetMod(int32_t modIdx) { assert(modIdx >= 0 && (size_t)modIdx < opts.numModNames); return mods + modIdx; } Mod* ModManGetOwningMod(void* sym) { assert(sym); Dl_info memInfo; dladdr(sym, &memInfo); int32_t* modIdx = FoxMapMIndex(void*, int32_t, &modMemMap, memInfo.dli_fbase); if (modIdx) { return mods + *modIdx; } return NULL; } void ModManExecuteGameStepListeners(void) { size_t numListeners = FoxArrayMSize(void*, &gameStepListeners); for (uint32_t idx = 0; idx < numListeners; idx++) { void (*listener)(void) = *FoxArrayMIndex(void*, &gameStepListeners, idx); listener(); } return; } void ModManExecuteGamePauseListeners(bool paused) { size_t numListeners = FoxArrayMSize(void*, &gamePauseListeners); for (uint32_t idx = 0; idx < numListeners; idx++) { void (*listener)(bool) = *FoxArrayMIndex(void*, &gamePauseListeners, idx); listener(paused); } return; } void ModManExecuteGameSaveListeners(int32_t curSlotIdx) { size_t numListeners = FoxArrayMSize(void*, &gameSaveListeners); for (uint32_t idx = 0; idx < numListeners; idx++) { void (*listener)(int32_t) = *FoxArrayMIndex(void*, &gameSaveListeners, idx); listener(curSlotIdx); } return; } void ModManExecuteGameLoadListeners(int32_t curSlotIdx) { size_t numListeners = FoxArrayMSize(void*, &gameLoadListeners); for (uint32_t idx = 0; idx < numListeners; idx++) { void (*listener)(int32_t) = *FoxArrayMIndex(void*, &gameLoadListeners, idx); listener(curSlotIdx); } return; } void ModManExecuteRoomChangeListeners(int32_t newRoomIdx, int32_t prevRoomIdx) { size_t numListeners = FoxArrayMSize(void*, &roomChangeListeners); for (uint32_t idx = 0; idx < numListeners; idx++) { void (*listener)(int32_t, int32_t) = *FoxArrayMIndex(void*, &roomChangeListeners, idx); listener(newRoomIdx, prevRoomIdx); } return; } void ModManLoadMods(void) { LogInfo("Loading mods..."); /* Allocate mod array. */ mods = malloc(opts.numModNames * sizeof(Mod)); /* Load mod libraries. */ for (uint32_t idx = 0; idx < opts.numModNames; idx++) { Mod* mod = mods + idx; ModInit(mod, idx, opts.modNames[idx]); if (mod->constructor) { mod->constructor(); } } LogInfo("Done. Loaded %zu mod(s).", opts.numModNames); } void ModManUnloadMods(void) { LogInfo("Unloading mods..."); /* Destruct mods in reverse order. */ for (uint32_t idx = 0; idx < opts.numModNames; idx++) { int32_t modIdx = (int32_t)(opts.numModNames - idx - 1); Mod* mod = mods + modIdx; if (mod->destructor) { mod->destructor(); } ModDeinit(mod); } LogInfo("Done. Unloaded %zu mod(s).", opts.numModNames); return; } void ModManConstructor(void) { LogInfo("Initializing mod manager..."); FoxMapMInit(void*, int32_t, &modMemMap); FoxArrayMInit(void*, &gameStepListeners); FoxArrayMInit(void*, &gamePauseListeners); FoxArrayMInit(void*, &gameSaveListeners); FoxArrayMInit(void*, &gameLoadListeners); FoxArrayMInit(void*, &roomChangeListeners); LogInfo("Done initializing mod manager.", opts.numModNames); return; } void ModManDestructor(void) { LogInfo("Deinitializing mod manager..."); free(mods); FoxMapMDeinit(void*, int32_t, &modMemMap); FoxArrayMDeinit(void*, &gameStepListeners); FoxArrayMDeinit(void*, &gamePauseListeners); FoxArrayMDeinit(void*, &gameSaveListeners); FoxArrayMDeinit(void*, &gameLoadListeners); FoxArrayMDeinit(void*, &roomChangeListeners); LogInfo("Done deinitializing mod manager."); return; }
Foxbud/libaermre
src/sprite.c
/** * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <assert.h> #include <stdlib.h> #include <string.h> #include "foxutils/stringmapmacs.h" #include "aer/sprite.h" #include "internal/core.h" #include "internal/err.h" #include "internal/export.h" #include "internal/hld.h" #include "internal/log.h" #include "internal/mod.h" /* ----- PRIVATE GLOBALS ----- */ static FoxMap spriteNames = {0}; /* ----- INTERNAL FUNCTIONS ----- */ void SpriteManBuildNameTable(void) { size_t numSprites = hldvars.spriteTable->size; for (uint32_t spriteIdx = 0; spriteIdx < numSprites; spriteIdx++) { HLDSprite* sprite = HLDSpriteLookup(spriteIdx); assert(sprite); *FoxMapMInsert(const char*, int32_t, &spriteNames, sprite->name) = spriteIdx; } return; } void SpriteManConstructor(void) { LogInfo("Initializing sprite module..."); FoxStringMapMInit(int32_t, &spriteNames); LogInfo("Done initializing sprite module."); return; } void SpriteManDestructor(void) { LogInfo("Deinitializing sprite module..."); /* Deinitialize name table. */ FoxMapMDeinit(const char*, int32_t, &spriteNames); spriteNames = (FoxMap){0}; LogInfo("Done deinitializing sprite module."); return; } /* ----- PUBLIC FUNCTIONS ----- */ AER_EXPORT int32_t AERSpriteRegister(const char* name, const char* filename, size_t numFrames, uint32_t origX, uint32_t origY) { #define errRet AER_SPRITE_NULL EnsureArg(name); const char* modName = ModManGetCurrentMod()->name; LogInfo("Registering sprite \"%s\" for mod \"%s\"...", name, modName); EnsureStageStrict(STAGE_SPRITE_REG); EnsureArg(filename); EnsureMin(numFrames, 1); Ensure(!FoxMapMIndex(const char*, int32_t, &spriteNames, name), AER_BAD_VAL); int32_t spriteIdx = hldfuncs.actionSpriteAdd(CoreGetAbsAssetPath(modName, filename), numFrames, 0, 0, 0, 0, origX, origY); HLDSprite* sprite = HLDSpriteLookup(spriteIdx); Ensure(sprite, AER_BAD_FILE); *FoxMapMInsert(const char*, int32_t, &spriteNames, name) = spriteIdx; /* The engine expects a freeable (dynamically allocated) string for name. */ char* tmpName = malloc(strlen(name) + 1); assert(tmpName); sprite->name = strcpy(tmpName, name); LogInfo("Successfully registered sprite to index %i.", spriteIdx); Ok(spriteIdx); #undef errRet } AER_EXPORT void AERSpriteReplace(int32_t spriteIdx, const char* filename, size_t numFrames, uint32_t origX, uint32_t origY) { #define errRet HLDSprite* oldSprite = HLDSpriteLookup(spriteIdx); EnsureLookup(oldSprite); const char* modName = ModManGetCurrentMod()->name; LogInfo("Replacing sprite \"%s\" for mod \"%s\"...", oldSprite->name, modName); EnsureStageStrict(STAGE_SPRITE_REG); EnsureArg(filename); EnsureMin(numFrames, 1); hldfuncs.actionSpriteReplace(spriteIdx, CoreGetAbsAssetPath(modName, filename), numFrames, 0, 0, 0, 0, origX, origY); /* TODO Check if replacement was successful. */ LogInfo("Successfully replaced sprite at index %i.", spriteIdx); Ok(); #undef errRet } AER_EXPORT size_t AERSpriteGetNumRegistered(void) { #define errRet 0 EnsureStage(STAGE_SPRITE_REG); Ok(hldvars.spriteTable->size); #undef errRet } AER_EXPORT int32_t AERSpriteGetByName(const char* name) { #define errRet AER_SPRITE_NULL EnsureStage(STAGE_SPRITE_REG); EnsureArg(name); int32_t* spriteIdx = FoxMapMIndex(const char*, int32_t, &spriteNames, name); EnsureLookup(spriteIdx); Ok(*spriteIdx); #undef errRet } AER_EXPORT const char* AERSpriteGetName(int32_t spriteIdx) { #define errRet NULL EnsureStage(STAGE_SPRITE_REG); HLDSprite* sprite = HLDSpriteLookup(spriteIdx); EnsureLookup(sprite); Ok(sprite->name); #undef errRet } AER_EXPORT size_t AERSpriteGetNumFrames(int32_t spriteIdx) { #define errRet 0 EnsureStage(STAGE_SPRITE_REG); HLDSprite* sprite = HLDSpriteLookup(spriteIdx); EnsureLookup(sprite); Ok(sprite->numImages); #undef errRet } AER_EXPORT void AERSpriteGetSize(int32_t spriteIdx, size_t* width, size_t* height) { #define errRet EnsureStage(STAGE_SPRITE_REG); EnsureArg(width || height); HLDSprite* sprite = HLDSpriteLookup(spriteIdx); EnsureLookup(sprite); if (width) { *width = sprite->size.x; } if (height) { *height = sprite->size.y; } Ok(); #undef errRet } AER_EXPORT void AERSpriteGetOrigin(int32_t spriteIdx, int32_t* x, int32_t* y) { #define errRet EnsureStage(STAGE_SPRITE_REG); EnsureArg(x || y); HLDSprite* sprite = HLDSpriteLookup(spriteIdx); EnsureLookup(sprite); if (x) { *x = sprite->origin.x; } if (y) { *y = sprite->origin.y; } Ok(); #undef errRet } AER_EXPORT void AERSpriteSetOrigin(int32_t spriteIdx, int32_t x, int32_t y) { #define errRet EnsureStage(STAGE_SPRITE_REG); HLDSprite* sprite = HLDSpriteLookup(spriteIdx); EnsureLookup(sprite); sprite->origin = (HLDVecIntegral){.x = x, .y = y}; Ok(); #undef errRet }
Foxbud/libaermre
src/option.c
<reponame>Foxbud/libaermre<filename>src/option.c /** * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <assert.h> #include <stdlib.h> #include "aer/conf.h" #include "aer/err.h" #include "internal/log.h" #include "internal/option.h" /* ----- INTERNAL GLOBALS ----- */ Options opts = {0}; /* ----- INTERNAL FUNCTIONS ----- */ void OptionConstructor(void) { LogInfo("Initializing options..."); const char* key = NULL; /* Required keys. */ key = "mods"; aererr = AER_TRY; opts.numModNames = AERConfGetStrings(key, 0, NULL); opts.modNames = malloc(opts.numModNames * sizeof(const char*)); assert(opts.modNames); aererr = AER_TRY; AERConfGetStrings(key, opts.numModNames, opts.modNames); switch (aererr) { case AER_OK: LogInfo("Found required configuration key \"%s\".", key); break; case AER_FAILED_PARSE: LogErr( "Required configuration key \"%s\" must be an array of " "strings.", key); abort(); default: LogErr("Required configuration key \"%s\" is undefined.", key); abort(); } /* Optional keys. */ key = "error.promote_unhandled"; aererr = AER_TRY; opts.promoteUnhandledErrors = AERConfGetBool(key); switch (aererr) { case AER_OK: LogInfo( "Found optional configuration key \"%s\" with value \"%i\".", key, opts.promoteUnhandledErrors); break; case AER_FAILED_PARSE: LogErr("Optional configuration key \"%s\" must be a boolean.", key); abort(); default: LogInfo( "Optional configuration key \"%s\" is undefined. Using default " "value \"%i\".", key, (opts.promoteUnhandledErrors = false)); } LogInfo("Done initializing options."); return; } void OptionDestructor(void) { LogInfo("Deinitializing options..."); /* Mod names. */ free(opts.modNames); opts = (Options){0}; LogInfo("Done deinitializing options."); return; }
Foxbud/libaermre
include/private/internal/object.h
<filename>include/private/internal/object.h /** * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef INTERNAL_OBJECT_H #define INTERNAL_OBJECT_H #include <stdbool.h> #include <stddef.h> #include <stdint.h> #include "foxutils/array.h" /* ----- INTERNAL FUNCTIONS ----- */ FoxArray* ObjectManGetDirectChildren(int32_t objIdx); FoxArray* ObjectManGetAllChildren(int32_t objIdx); void ObjectManBuildNameTable(void); void ObjectManBuildInheritanceTrees(void); void ObjectManConstructor(void); void ObjectManDestructor(void); #endif /* INTERNAL_OBJECT_H */
Foxbud/libaermre
include/public/aer/log.h
/** * @file * * @brief Logging utilities. * * @since 1.0.0 * * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef AER_LOG_H #define AER_LOG_H /* ----- PUBLIC FUNCTIONS ----- */ /** * @brief Log an informational message to the console. * * @param[in] fmt `printf` style format string. * @param[in] ... Variadic arguments to substitute into format string. * * @throw ::AER_NULL_ARG if argument `fmt` is `NULL`. * * @since 1.0.0 */ void AERLogInfo(const char* fmt, ...); /** * @brief Log a warning message to the console. * * @param[in] fmt `printf` style format string. * @param[in] ... Variadic arguments to substitute into format string. * * @throw ::AER_NULL_ARG if argument `fmt` is `NULL`. * * @since 1.0.0 */ void AERLogWarn(const char* fmt, ...); /** * @brief Log an error message to the console. * * @note A call to this function should be proceeded by a call to `abort`. * * @param[in] fmt `printf` style format string. * @param[in] ... Variadic arguments to substitute into format string. * * @throw ::AER_NULL_ARG if argument `fmt` is `NULL`. * * @since 1.0.0 */ void AERLogErr(const char* fmt, ...); #endif /* AER_LOG_H */
Foxbud/libaermre
include/public/aer/instance.h
/** * @file * * @brief Utilities for querying and manipulating game instances. * * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef AER_INSTANCE_H #define AER_INSTANCE_H #include <stdbool.h> #include <stddef.h> #include <stdint.h> /* ----- PUBLIC TYPES ----- */ /** * @brief Opaque type for instance of an object. * * @since 1.0.0 * * @sa object.h */ typedef void AERInstance; /** * @brief A dynamic member variable of an instance. * * @since 1.0.0 */ typedef union AERLocal { bool b; uint64_t u; int64_t i; float f; double d; void* p; } AERLocal; /* ----- PUBLIC FUNCTIONS ----- */ /** * @brief Query all instances in the current room. * * @warning Argument `instBuf` must be large enough to hold at least * `bufSize` elements. * * @note Argument `bufSize` may be `0` in which case argument `instBuf` may * be `NULL`. This may be used to efficiently query the total number of * instances in the current room. * * @param[in] bufSize Maximum number of elements to write to argument * `instBuf`. * @param[out] instBuf Buffer to write instances to. * * @return Total number of instances in current room or `0` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `instBuf` is `NULL` and argument * `bufSize` is greater than `0`. * * @since 1.0.0 */ size_t AERInstanceGetAll(size_t bufSize, AERInstance** instBuf); /** * @brief Query all instances of an object in the current room. * * @warning Argument `instBuf` must be large enough to hold at least * `bufSize` elements. * * @note Argument `bufSize` may be `0` in which case argument `instBuf` may * be `NULL`. This may be used to efficiently query the total number of * instances of an object in the current room. * * @param[in] objIdx Object to get instances of. * @param[in] recursive Whether to query instances of given object only * (`false`) or both given object and direct and indirect children of given * object (`true`). * @param[in] bufSize Maximum number of elements to write to argument * `instBuf`. * @param[out] instBuf Buffer to write instances to. * * @return Total number of instances of object in current room or `0` if * unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `instBuf` is `NULL` and argument * `bufSize` is greater than `0`. * @throw ::AER_FAILED_LOOKUP if argument `objIdx` is an invalid object. * * @since 1.0.0 */ size_t AERInstanceGetByObject(int32_t objIdx, bool recursive, size_t bufSize, AERInstance** instBuf); /** * @brief Query the instance with a specific ID in the current room. * * @param[in] instId Instance ID. * * @return Instance with provided ID or `NULL` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_FAILED_LOOKUP if argument `instId` is an invalid instance. * * @since 1.0.0 * * @sa AERInstanceGetId */ AERInstance* AERInstanceGetById(int32_t instId); /** * @brief Create an instance of an object. * * @param[in] objIdx Object to create an instance of. * @param[in] x Horizontal position at which to create instance. * @param[in] y Vertical position at which to create instance. * * @return New instance or `NULL` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_FAILED_LOOKUP if argument `objIdx` is an invalid object. * * @since 1.0.0 * * @sa AERObjectAttachCreateListener */ AERInstance* AERInstanceCreate(int32_t objIdx, float x, float y); /** * @brief Convert an instance of one object into an instance of another * object in-place. * * @warning Once this function has been called on and instance, no further * queries or actions should be performed on this instance until the next * in-game step. * * Under the hood, this function creates a new instance of the new object, * copies various properties such as position from the old instance to the * new instance, and then finally destroys the old instance. * * @param[in] inst Instance of interest. * @param[in] newObjIdx Object to convert argument `inst` into. * @param[in] doEvents If `true`, then the engine will call the destroy * event of the old instance and the create event of the new instance. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * @throw ::AER_FAILED_LOOKUP if argument `newObjIdx` is an invalid object. * * @since 1.0.0 * * @sa AERObjectAttachCreateListener * @sa AERObjectAttachDestroyListener */ void AERInstanceChange(AERInstance* inst, int32_t newObjIdx, bool doEvents); /** * @brief Destroy an instance and call its destroy event. * * @param[in] inst Instance of interest. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.0.0 * * @sa AERInstanceDelete * @sa AERObjectAttachDestroyListener */ void AERInstanceDestroy(AERInstance* inst); /** * @brief Destroy an instance but do **not** call its destroy event. * * @param[in] inst Instance of interest. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.0.0 * * @sa AERInstanceDestroy * @sa AERObjectAttachDestroyListener */ void AERInstanceDelete(AERInstance* inst); /** * @brief Query the render depth of an instance. * * @param[in] inst Instance of interest. * * @return Render depth or `0.0f` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.0.0 */ float AERInstanceGetDepth(AERInstance* inst); /** * @brief Set the render depth of an instance. * * @param[in] inst Instance of interest. * @param[in] depth Render depth. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.0.0 */ void AERInstanceSetDepth(AERInstance* inst, float depth); /** * @brief Set the render depth of an instance based on its position in the * current room. * * @param[in] inst Instance of interest. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.0.0 */ void AERInstanceSyncDepth(AERInstance* inst); /** * @brief Query the ID of an instance. * * @note A valid reference to an ::AERInstance one step may become invalid * in a future step. To keep track of a specific instance across steps, * use its ID. * * @param[in] inst Instance of interest. * * @return Instance ID or `-1` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.0.0 * * @sa AERInstanceGetById */ int32_t AERInstanceGetId(AERInstance* inst); /** * @brief Query the object of an instance. * * @param[in] inst Instance of interest. * * @return Object index or ::AER_OBJECT_NULL if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.0.0 */ int32_t AERInstanceGetObject(AERInstance* inst); /** * @brief Query whether or not an instance is deactivated. * * @param[in] inst Instance of interest. * * @return Whether or not instance is deactivated or `false` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.3.0 */ bool AERInstanceGetDeactivated(AERInstance* inst); /** * @brief Set the deactivation state of an instance. * * @param[in] inst Instance of interest. * @param[in] deactivated Deactivation state. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.3.0 */ void AERInstanceSetDeactivated(AERInstance* inst, bool deactivated); /** * @brief Query the persistence of an instance. * * @param[in] inst Instance of interest. * * @return Persistence or `false` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.3.0 */ bool AERInstanceGetPersistent(AERInstance* inst); /** * @brief Set the persistence of an instance. * * @param[in] inst Instance of interest. * @param[in] persistent Persistence. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.3.0 */ void AERInstanceSetPersistent(AERInstance* inst, bool persistent); /** * @brief Query the position of an instance in the current room. * * If only one component of the position is needed, then the argument for the * unneeded component may be `NULL`. * * @param[in] inst Instance of interest. * @param[out] x Horizontal position. * @param[out] y Vertical position. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL` or both arguments * `x` and `y` are `NULL`. * * @since 1.0.0 */ void AERInstanceGetPosition(AERInstance* inst, float* x, float* y); /** * @brief Set the position of an instance in the current room. * * @param[in] inst Instance of interest. * @param[in] x Horizontal position. * @param[in] y Vertical position. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.0.0 * * @sa AERInstanceAddPosition */ void AERInstanceSetPosition(AERInstance* inst, float x, float y); /** * @brief Add to the existing position of an instance in the current room. * * This is effectively a relative translation. * * @param[in] inst Instance of interest. * @param[in] x Relative horizontal position. * @param[in] y Relative vertical position. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.1.0 * * @sa AERInstanceSetPosition */ void AERInstanceAddPosition(AERInstance* inst, float x, float y); /** * @brief Query the axis-aligned bounding box of an instance. * * The bounding box of an instance describes the bounding volume of an * instance's sprite or mask. It is relative to the room's origin. * * If not all four of the components of the bounding box are needed, then the * arguments for the unneeded components may be `NULL`. * * @param[in] inst Instance of interest. * @param[out] left X-intercept of the left side of the bounding box. * @param[out] top Y-intercept of the top side of the bounding box. * @param[out] right X-intercept of the right side of the bounding box. * @param[out] bottom Y-intercept of the bottom side of the bounding box. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL` or all four arguments * `left`, `top`, `right` and `bottom` are `NULL`. * * @since 1.0.0 */ void AERInstanceGetBoundingBox(AERInstance* inst, float* left, float* top, float* right, float* bottom); /** * @brief Query the friction of an instance. * * @subsubsection InstFriction Instance Friction * * The friction of an instance determines how much it decelerates by each step. * * @param[in] inst Instance of interest. * * @return Friction or `0.0f` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.0.0 */ float AERInstanceGetFriction(AERInstance* inst); /** * @brief Set the friction of an instance. * * For more information about friction, see @ref InstFriction. * * @param[in] inst Instance of interest. * @param[in] friction Friction. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.0.0 */ void AERInstanceSetFriction(AERInstance* inst, float friction); /** * @brief Query the motion of an instance. * * If only one component of the motion is needed, then the argument for the * unneeded component may be `NULL`. * * @param[in] inst Instance of interest. * @param[out] x Horizontal motion. * @param[out] y Vertical motion. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL` or both arguments * `x` and `y` are `NULL`. * * @since 1.0.0 */ void AERInstanceGetMotion(AERInstance* inst, float* x, float* y); /** * @brief Set the motion of an instance. * * @param[in] inst Instance of interest. * @param[in] x Horizontal motion. * @param[in] y Vertical motion. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.0.0 * * @sa AERInstanceAddMotion */ void AERInstanceSetMotion(AERInstance* inst, float x, float y); /** * @brief Add to the existing motion of an instance. * * @param[in] inst Instance of interest. * @param[in] x Relative horizontal motion. * @param[in] y Relative vertical motion. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.0.0 * * @sa AERInstanceSetMotion */ void AERInstanceAddMotion(AERInstance* inst, float x, float y); /** * @brief Query the collision mask of an instance. * * @param[in] inst Instance of interest. * * @return Collision mask index or ::AER_SPRITE_NULL if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.0.0 */ int32_t AERInstanceGetMask(AERInstance* inst); /** * @brief Set the collision mask of an instance. * * By default, an instance will use its sprite as its collision mask. * In this case, the instance's mask should be set to ::AER_SPRITE_NULL. * * @param[in] inst Instance of interest. * @param[in] maskIdx Collision mask index. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * @throw ::AER_FAILED_LOOKUP if argument `maskIdx` is an invalid sprite. * * @since 1.0.0 */ void AERInstanceSetMask(AERInstance* inst, int32_t maskIdx); /** * @brief Query the visibility of an instance. * * @param[in] inst Instance of interest. * * @return Visibility or `false` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.1.0 */ bool AERInstanceGetVisible(AERInstance* inst); /** * @brief Set the visibility of an instance. * * @param[in] inst Instance of interest. * @param[in] tangible Visibility. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.1.0 */ void AERInstanceSetVisible(AERInstance* inst, bool visible); /** * @brief Query the sprite of an instance. * * @param[in] inst Instance of interest. * * @return Sprite index or ::AER_SPRITE_NULL if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.0.0 */ int32_t AERInstanceGetSprite(AERInstance* inst); /** * @brief Set the sprite of an instance. * * @param[in] inst Instance of interest. * @param[in] spriteIdx Sprite index. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * @throw ::AER_FAILED_LOOKUP if argument `spriteIdx` is an invalid sprite. * * @since 1.0.0 */ void AERInstanceSetSprite(AERInstance* inst, int32_t spriteIdx); /** * @brief Query the current frame of sprite animation of an instance. * * @subsubsection SpriteFrame Sprite Animation Frame * * The current sprite animation frame of an instance is stored as a * floating-point value rather than an integer because it also encodes * progress to the next frame. * * The integer portion of this value represents the current frame. The * fractional portion represents progress towards the next frame. * * @param[in] inst Instance of interest. * * @return Frame of sprite animation or `-1.0f` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.0.0 * * @sa AERObjectAttachAnimationEndListener */ float AERInstanceGetSpriteFrame(AERInstance* inst); /** * @brief Set the current frame of sprite animation of an instance. * * For more information about the meaning of the sprite frame, see * @ref SpriteFrame. * * @param[in] inst Instance of interest. * @param[in] frame Frame of sprite animation. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.0.0 * * @sa AERObjectAttachAnimationEndListener */ void AERInstanceSetSpriteFrame(AERInstance* inst, float frame); /** * @brief Query the sprite animation speed of an instance. * * @param[in] inst Instance of interest. * * @return Sprite animation speed or `-1.0f` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.0.0 * * @sa AERObjectAttachAnimationEndListener */ float AERInstanceGetSpriteSpeed(AERInstance* inst); /** * @brief Set the sprite animation speed of an instance. * * @param[in] inst Instance of interest. * @param[in] speed Sprite animation speed. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * @throw ::AER_BAD_VAL if argument `speed` is less than `0.0f`. * * @since 1.0.0 * * @sa AERObjectAttachAnimationEndListener */ void AERInstanceSetSpriteSpeed(AERInstance* inst, float speed); /** * @brief Query the sprite alpha (transparency) of an instance. * * @param[in] inst Instance of interest. * * @return Sprite alpha or `-1.0f` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.0.0 */ float AERInstanceGetSpriteAlpha(AERInstance* inst); /** * @brief Set the sprite alpha (transparency) of an instance. * * @param[in] inst Instance of interest. * @param[in] alpha Sprite alpha. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * @throw ::AER_BAD_VAL if argument `alpha` is less than `0.0f` or greater * than `1.0f`. * * @since 1.0.0 */ void AERInstanceSetSpriteAlpha(AERInstance* inst, float alpha); /** * @brief Query the sprite offset angle of an instance. * * @param[in] inst Instance of interest. * * @return Sprite offset angle in degrees or `0.0f` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.0.0 */ float AERInstanceGetSpriteAngle(AERInstance* inst); /** * @brief Set the sprite offset angle of an instance. * * @param[in] inst Instance of interest. * @param[in] angle Sprite offset angle in degrees. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.0.0 */ void AERInstanceSetSpriteAngle(AERInstance* inst, float angle); /** * @brief Query the sprite scale of an instance. * * If only one component of the scale is needed, then the argument for the * unneeded component may be `NULL`. * * @param[in] inst Instance of interest. * @param[out] x Horizontal scale. * @param[out] y Vertical scale. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL` or both arguments * `x` and `y` are `NULL`. * * @since 1.0.0 */ void AERInstanceGetSpriteScale(AERInstance* inst, float* x, float* y); /** * @brief Set the sprite scale of an instance. * * @note The components of the scale may be negative to mirror the sprite * about an axis. * * @param[in] inst Instance of interest. * @param[in] x Horizontal scale. * @param[in] y Vertical scale. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.0.0 */ void AERInstanceSetSpriteScale(AERInstance* inst, float x, float y); /** * @brief Query the sprite blend color of an instance. * * @param[in] inst Instance of interest. * * @return Sprite blend color or `0` if unsuccessful. See @ref DrawColors for * more infomation. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.1.0 */ uint32_t AERInstanceGetSpriteBlend(AERInstance* inst); /** * @brief Set the sprite blend color of an instance. * * @param[in] inst Instance of interest. * @param[in] color Sprite blend color. See @ref DrawColors for more * information. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.1.0 */ void AERInstanceSetSpriteBlend(AERInstance* inst, uint32_t color); /** * @brief Query the tangibility of an instance. * * @subsubsection Tangibility Instance Tangibility * * The tangibility of an instance represents whether or not the player can * collide with it. This property is only meaningful for instances of * ::AER_OBJECT_PATHFINDOBSTACLE and its children. * * @param[in] inst Instance of interest. * * @return Tangibility or `false` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.0.0 */ bool AERInstanceGetTangible(AERInstance* inst); /** * @brief Set the tangibility of an instance. * * For more information about instance tangibility, see @ref Tangibility. * * @param[in] inst Instance of interest. * @param[in] tangible Tangibility. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * * @since 1.0.0 */ void AERInstanceSetTangible(AERInstance* inst, bool tangible); /** * @brief Query the state of an alarm of an instance. * * @param[in] inst Instance of interest. * @param[in] alarmIdx Alarm index. * * @return Number of alarm steps or `-1` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * @throw ::AER_FAILED_LOOKUP if argument `alarmIdx` is greater than `11`. * * @since 1.0.0 * * @sa AERObjectAttachAlarmListener */ int32_t AERInstanceGetAlarm(AERInstance* inst, uint32_t alarmIdx); /** * @brief Set the state of an alarm of an instance. * * @param[in] inst Instance of interest. * @param[in] alarmIdx Alarm index. * @param[in] numSteps Number of alarm steps. Set to `-1` to disable the * alarm without triggering the corresponding alarm event. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL`. * @throw ::AER_FAILED_LOOKUP if argument `alarmIdx` is greater than `11`. * * @since 1.0.0 * * @sa AERObjectAttachAlarmListener */ void AERInstanceSetAlarm(AERInstance* inst, uint32_t alarmIdx, int32_t numSteps); /** * @brief Query the names of all vanilla local variables of an instance. * * @warning Argument `nameBuf` must be large enough to hold at least * `bufSize` elements. * * @note Argument `bufSize` may be `0` in which case argument `nameBuf` may * be `NULL`. This may be used to efficiently query the total number of * vanilla locals that an instance has. * * @param[in] inst Instance of interest. * @param[in] bufSize Maximum number of elements to write to argument * `nameBuf`. * @param[out] nameBuf Buffer to write names to. * * @return Total number of vanilla locals that the instance has or `0` if * unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `inst` is `NULL` or argument * `instBuf` is `NULL` and argument `bufSize` is greater than `0`. * * @since 1.0.0 * * @sa AERInstanceGetHLDLocal * @sa @ref CommonLocals */ size_t AERInstanceGetHLDLocals(AERInstance* inst, size_t bufSize, const char** nameBuf); /** * @brief Get a reference to a specific vanilla local variable of an instance. * * @warning The reference returned by this function should be considered highly * unstable. * * @param[in] inst Instance of interest. * @param[in] name Name of vanilla local. * * @return Reference to vanilla local or `NULL` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if either argument `inst` or `name` is `NULL`. * @throw ::AER_FAILED_LOOKUP if instance does not have a vanilla local with * given name. * * @since 1.0.0 * * @sa AERInstanceGetHLDLocals * @sa @ref CommonLocals */ AERLocal* AERInstanceGetHLDLocal(AERInstance* inst, const char* name); /** * @brief Create a new mod local variable for an instance. * * @warning The reference returned by this function should be considered highly * unstable. * * @subsubsection ModLocalNamespace Namespace of Mod Local Variables * * When an instance is given a mod local in the public namespace, this local is * accessible by all mods loaded. If, on the other hand, the local is created in * a private namespace, then only the mod that created it can access and destroy * it. * * Multiple mods may each assign a private mod local with the same name to the * same instance without interfering with one another. * * @param[in] inst Instance of interest. * @param[in] name Name of mod local. Must be 24 characters or less (not * including null-character). * @param[in] public Whether to use the public or private local namespace. For * more information see @ref ModLocalNamespace. * @param[in] destructor Callback function executed when local is destroyed. May * be `NULL` if local does not need special cleanup. * * @return Reference to newly created mod local or `NULL` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if either argument `inst` or `name` is `NULL`. * @throw ::AER_BAD_VAL if argument `name` is greater than 24 characters in * length (not including null-character). * @throw ::AER_FAILED_LOOKUP if instance already has a mod local with given * name in given namespace. * * @since 1.0.0 */ AERLocal* AERInstanceCreateModLocal(AERInstance* inst, const char* name, bool public, void (*destructor)(AERLocal* local)); /** * @brief Destroy a mod local variable and call its destructor. * * @param[in] inst Instance of interest. * @param[in] name Name of mod local. Must be 24 characters or less (not * including null-character). * @param[in] public Whether to use the public or private local namespace. For * more information see @ref ModLocalNamespace. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if either argument `inst` or `name` is `NULL`. * @throw ::AER_BAD_VAL if argument `name` is greater than 24 characters in * length (not including null-character). * @throw ::AER_FAILED_LOOKUP if instance does not have a mod local with given * name in given namespace. * * @since 1.0.0 * * @sa AERInstanceDeleteModLocal */ void AERInstanceDestroyModLocal(AERInstance* inst, const char* name, bool public); /** * @brief Destroy a mod local variable but do **not** call its destructor. * * @param[in] inst Instance of interest. * @param[in] name Name of mod local. Must be 24 characters or less (not * including null-character). * @param[in] public Whether to use the public or private local namespace. For * more information see @ref ModLocalNamespace. * * @return Value of deleted local or `(AERLocal){0}` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if either argument `inst` or `name` is `NULL`. * @throw ::AER_BAD_VAL if argument `name` is greater than 24 characters in * length (not including null-character). * @throw ::AER_FAILED_LOOKUP if instance does not have a mod local with given * name in given namespace. * * @since 1.0.0 * * @sa AERInstanceDestroyModLocal */ AERLocal AERInstanceDeleteModLocal(AERInstance* inst, const char* name, bool public); /** * @brief Get a reference to a specific mod local variable of an instance. * * @param[in] inst Instance of interest. * @param[in] name Name of mod local. Must be 24 characters or less (not * including null-character). * @param[in] public Whether to use the public or private local namespace. For * more information see @ref ModLocalNamespace. * * @return Reference to mod local or `NULL` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if either argument `inst` or `name` is `NULL`. * @throw ::AER_BAD_VAL if argument `name` is greater than 24 characters in * length (not including null-character). * @throw ::AER_FAILED_LOOKUP if instance does not have a mod local with given * name in given namespace. * * @since 1.0.0 */ AERLocal* AERInstanceGetModLocal(AERInstance* inst, const char* name, bool public); #endif /* AER_INSTANCE_H */
Foxbud/libaermre
include/private/internal/mod.h
<reponame>Foxbud/libaermre /** * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef INTERNAL_MOD_H #define INTERNAL_MOD_H #include <stdbool.h> #include <stddef.h> #include <stdint.h> #include "foxutils/array.h" #include "internal/hld.h" /* ----- INTERNAL MACROS ----- */ #define ModManGetCurrentMod() \ ModManGetOwningMod( \ __builtin_extract_return_addr(__builtin_return_address(0))) /* ----- INTERNAL TYPES ----- */ typedef struct Mod { void* libHandle; int32_t idx; const char* name; void (*constructor)(void); void (*destructor)(void); void (*registerSprites)(void); void (*registerFonts)(void); void (*registerObjects)(void); void (*registerObjectListeners)(void); } Mod; /* ----- INTERNAL CONSTANTS ----- */ extern const int32_t MOD_NULL; /* ----- INTERNAL FUNCTIONS ----- */ size_t ModManGetNumMods(void); Mod* ModManGetMod(int32_t modIdx); Mod* ModManGetOwningMod(void* sym); void ModManExecuteGameStepListeners(void); void ModManExecuteGamePauseListeners(bool paused); void ModManExecuteGameSaveListeners(int32_t curSlotIdx); void ModManExecuteGameLoadListeners(int32_t curSlotIdx); void ModManExecuteRoomChangeListeners(int32_t newRoomIdx, int32_t prevRoomIdx); void ModManLoadMods(void); void ModManUnloadMods(void); void ModManConstructor(void); void ModManDestructor(void); #endif /* INTERNAL_MOD_H */
Foxbud/libaermre
src/conf.c
/** * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <assert.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "foxutils/arraymacs.h" #include "foxutils/math.h" #include "foxutils/stringmapmacs.h" #include "toml.h" #include "aer/conf.h" #include "internal/conf.h" #include "internal/err.h" #include "internal/export.h" #include "internal/log.h" #include "internal/mod.h" /* ----- PRIVATE MACROS ----- */ #define GetAbsKey(key) \ ({ \ char GetAbsKey_buf[192]; \ Mod* GetAbsKey_mod = ModManGetCurrentMod(); \ const char* GetAbsKey_modName = \ GetAbsKey_mod ? GetAbsKey_mod->name : INTERNAL_CONF_NAME; \ if ((size_t)snprintf(GetAbsKey_buf, sizeof(GetAbsKey_buf), "%s.%s", \ GetAbsKey_modName, \ (key)) >= sizeof(GetAbsKey_buf)) { \ if (GetAbsKey_mod) { \ LogErr( \ "Key overflow while constructing configuration key " \ "for " \ "mod " \ "\"%s\". Key must be less than %zu characters in " \ "length, " \ "but key was \"%s\".", \ GetAbsKey_modName, sizeof(GetAbsKey_buf), GetAbsKey_buf); \ } else { \ LogErr( \ "Key overflow while constructing internal " \ "configuration key. " \ "Key must be less than %zu characters in length, " \ "but key was \"%s\".", \ sizeof(GetAbsKey_buf), GetAbsKey_buf); \ } \ abort(); \ } \ GetAbsKey_buf; \ }) #define EnsureTypeScalar(entry, expType) \ do { \ ConfEntry* EnsureTypeScalar_entry = (entry); \ Ensure((EnsureTypeScalar_entry->type == (expType) && \ !EnsureTypeScalar_entry->isArray), \ AER_FAILED_PARSE); \ } while (0) #define EnsureTypeArr(entry, expType) \ do { \ ConfEntry* EnsureTypeArr_entry = (entry); \ ConfType EnsureTypeArr_type = EnsureTypeArr_entry->type; \ Ensure(((EnsureTypeArr_type == (expType) || \ EnsureTypeArr_type == CONF_NULL) && \ EnsureTypeArr_entry->isArray), \ AER_FAILED_PARSE); \ } while (0) /* ----- PRIVATE TYPES ----- */ typedef enum ConfType { CONF_NULL, CONF_BOOL, CONF_INT, CONF_DOUBLE, CONF_STRING } ConfType; typedef struct ConfEntry { bool isArray; ConfType type; union { bool b; int64_t i; double d; char* s; FoxArray* a; } value; } ConfEntry; /* ----- PRIVATE CONSTANTS ----- */ static const char* CONF_FILE = "aer/conf.toml"; static const char* INTERNAL_CONF_NAME = "mre"; /* ----- PRIVATE GLOBALS ----- */ static FoxMap conf = {0}; static char workingKey[128]; static FoxArray workingBreaks = {0}; /* ----- PRIVATE FUNCTIONS ----- */ static void PushKey(const char* key) { uint32_t keyIdx = 0; uint32_t workingIdx = 0; if (!FoxArrayMEmpty(uint32_t, &workingBreaks)) { workingIdx = *FoxArrayMPeek(uint32_t, &workingBreaks); workingKey[workingIdx++] = '.'; } do { if (workingIdx >= sizeof(workingKey)) { workingKey[sizeof(workingKey) - 1] = '\0'; LogErr( "Key overflow while parsing configuration data. " "Key must be less than %zu characters in length, " "but key was \"%s\".", sizeof(workingKey), workingKey); abort(); } } while ((workingKey[workingIdx++] = key[keyIdx++]) != '\0'); *FoxArrayMPush(uint32_t, &workingBreaks) = workingIdx - 1; return; } static void PopKey(void) { FoxArrayMPop(uint32_t, &workingBreaks); if (!FoxArrayMEmpty(uint32_t, &workingBreaks)) workingKey[*FoxArrayMPeek(uint32_t, &workingBreaks)] = '\0'; return; } static void ParseValueFromTable(toml_table_t* table, const char* key) { /* Create configuration entry. */ ConfEntry* entry = FoxMapMInsert(const char*, ConfEntry, &conf, workingKey); entry->isArray = false; toml_datum_t datum; /* Boolean. */ if ((datum = toml_bool_in(table, key)).ok) { entry->type = CONF_BOOL; entry->value.b = datum.u.b; } /* Integer. */ else if ((datum = toml_int_in(table, key)).ok) { entry->type = CONF_INT; entry->value.i = datum.u.i; } /* Double. */ else if ((datum = toml_double_in(table, key)).ok) { entry->type = CONF_DOUBLE; entry->value.d = datum.u.d; } /* String. */ else if ((datum = toml_string_in(table, key)).ok) { entry->type = CONF_STRING; entry->value.s = datum.u.s; } /* Invalid. */ else { LogErr( "Configuration key \"%s\" was not a supported type. " "Supported types are boolean, integer, double, string and array.", workingKey); abort(); } return; } static toml_datum_t ParseValueFromArray(toml_array_t* array, uint32_t idx, ConfType* type) { toml_datum_t result; /* Boolean. */ if ((result = toml_bool_at(array, idx)).ok) *type = CONF_BOOL; /* Integer. */ else if ((result = toml_int_at(array, idx)).ok) *type = CONF_INT; /* Double. */ else if ((result = toml_double_at(array, idx)).ok) *type = CONF_DOUBLE; /* String. */ else if ((result = toml_string_at(array, idx)).ok) *type = CONF_STRING; /* Invalid. */ else { LogErr( "Array at configuration key \"%s\" " "had unsupported type at index %zu. " "Supported array types are boolean, integer, double and string.", workingKey, idx); abort(); } return result; } static void ParseArray(toml_array_t* array) { /* Create configuration entry. */ ConfEntry* entry = FoxMapMInsert(const char*, ConfEntry, &conf, workingKey); entry->isArray = true; ConfType entType = CONF_NULL; FoxArray* entArr = NULL; /* Parse each array index. */ size_t numElems = toml_array_nelem(array); for (uint32_t idx = 0; idx < numElems; idx++) { toml_datum_t datum = ParseValueFromArray(array, idx, &entType); /* Initialize entry array on first iteration. */ if (idx == 0) { switch (entType) { case CONF_BOOL: entArr = FoxArrayMNewExt(bool, numElems); break; case CONF_INT: entArr = FoxArrayMNewExt(int64_t, numElems); break; case CONF_DOUBLE: entArr = FoxArrayMNewExt(double, numElems); break; case CONF_STRING: entArr = FoxArrayMNewExt(char*, numElems); break; default: break; } } /* Add value to entry array. */ switch (entType) { case CONF_BOOL: *FoxArrayMPush(bool, entArr) = datum.u.b; break; case CONF_INT: *FoxArrayMPush(int64_t, entArr) = datum.u.i; break; case CONF_DOUBLE: *FoxArrayMPush(double, entArr) = datum.u.d; break; case CONF_STRING: *FoxArrayMPush(char*, entArr) = datum.u.s; break; default: break; } } /* Copy data to entry. */ entry->type = entType; entry->value.a = entArr; return; } static void ParseTable(toml_table_t* table) { /* Parse each table key. */ const char* key; toml_table_t* nextTable; toml_array_t* nextArray; for (uint32_t idx = 0;; idx++) { if (!(key = toml_key_in(table, idx))) break; PushKey(key); /* Table. */ if ((nextTable = toml_table_in(table, key))) ParseTable(nextTable); /* Array. */ else if ((nextArray = toml_array_in(table, key))) ParseArray(nextArray); /* Value. */ else ParseValueFromTable(table, key); PopKey(); } return; } static bool ConfEntryDeinitCallback(ConfEntry* entry, void* ctx) { (void)ctx; ConfType type = entry->type; if (entry->isArray && type != CONF_NULL) { FoxArray* array = entry->value.a; if (type == CONF_STRING) { size_t numStrings = FoxArrayMSize(char*, array); for (uint32_t idx = 0; idx < numStrings; idx++) { free(FoxArrayMPop(char*, array)); } } FoxArrayFree(array); } else if (type == CONF_STRING) { free(entry->value.s); } *entry = (ConfEntry){0}; return true; } /* ----- INTERNAL FUNCTIONS ----- */ void ConfConstructor(void) { LogInfo("Initializing configuration module..."); /* Initialize globals. */ FoxStringMapMInit(ConfEntry, &conf); FoxArrayMInit(uint32_t, &workingBreaks); /* Open configuration file. */ FILE* fp; if (!(fp = fopen(CONF_FILE, "r"))) { LogErr("Could not open configuration file \"%s\".", CONF_FILE); abort(); } /* Parse file. */ char errBuf[256]; toml_table_t* data = toml_parse_file(fp, errBuf, sizeof(errBuf)); fclose(fp); if (!data) { LogErr( "Could not parse configuration file. " "Reported error: \"%s\".", errBuf); abort(); } /* Parse data. */ ParseTable(data); /* Cleanup. */ toml_free(data); LogInfo("Done initializing configuration module."); return; } void ConfDestructor(void) { LogInfo("Deinitializing configuration module..."); FoxMapMForEachElement(const char*, ConfEntry, &conf, ConfEntryDeinitCallback, NULL); FoxMapMDeinit(const char*, ConfEntry, &conf); FoxArrayMDeinit(uint32_t, &workingBreaks); LogInfo("Done deinitializing configuration module."); return; } /* ----- PUBLIC FUNCTIONS ----- */ AER_EXPORT bool AERConfGetBool(const char* key) { #define errRet false EnsureArg(key); char* absKey = GetAbsKey(key); ConfEntry* entry = FoxMapMIndex(const char*, ConfEntry, &conf, absKey); EnsureLookup(entry); EnsureTypeScalar(entry, CONF_BOOL); Ok(entry->value.b); #undef errRet } AER_EXPORT size_t AERConfGetBools(const char* key, size_t bufSize, bool* boolBuf) { #define errRet 0 EnsureArg(key); EnsureArgBuf(boolBuf, bufSize); char* absKey = GetAbsKey(key); ConfEntry* entry = FoxMapMIndex(const char*, ConfEntry, &conf, absKey); EnsureLookup(entry); EnsureTypeArr(entry, CONF_BOOL); if (entry->type == CONF_NULL) Ok(0); FoxArray* array = entry->value.a; size_t numElems = FoxArrayMSize(bool, array); size_t numToWrite = FoxMin(bufSize, numElems); for (unsigned int idx = 0; idx < numToWrite; idx++) boolBuf[idx] = *FoxArrayMIndex(bool, array, idx); Ok(numElems); #undef errRet } AER_EXPORT int64_t AERConfGetInt(const char* key) { #define errRet 0 EnsureArg(key); char* absKey = GetAbsKey(key); ConfEntry* entry = FoxMapMIndex(const char*, ConfEntry, &conf, absKey); EnsureLookup(entry); EnsureTypeScalar(entry, CONF_INT); Ok(entry->value.i); #undef errRet } AER_EXPORT size_t AERConfGetInts(const char* key, size_t bufSize, int64_t* intBuf) { #define errRet 0 EnsureArg(key); EnsureArgBuf(intBuf, bufSize); char* absKey = GetAbsKey(key); ConfEntry* entry = FoxMapMIndex(const char*, ConfEntry, &conf, absKey); EnsureLookup(entry); EnsureTypeArr(entry, CONF_INT); if (entry->type == CONF_NULL) Ok(0); FoxArray* array = entry->value.a; size_t numElems = FoxArrayMSize(int64_t, array); size_t numToWrite = FoxMin(bufSize, numElems); for (unsigned int idx = 0; idx < numToWrite; idx++) intBuf[idx] = *FoxArrayMIndex(int64_t, array, idx); Ok(numElems); #undef errRet } AER_EXPORT double AERConfGetDouble(const char* key) { #define errRet 0.0 EnsureArg(key); char* absKey = GetAbsKey(key); ConfEntry* entry = FoxMapMIndex(const char*, ConfEntry, &conf, absKey); EnsureLookup(entry); EnsureTypeScalar(entry, CONF_DOUBLE); Ok(entry->value.d); #undef errRet } AER_EXPORT size_t AERConfGetDoubles(const char* key, size_t bufSize, double* doubleBuf) { #define errRet 0 EnsureArg(key); EnsureArgBuf(doubleBuf, bufSize); char* absKey = GetAbsKey(key); ConfEntry* entry = FoxMapMIndex(const char*, ConfEntry, &conf, absKey); EnsureLookup(entry); EnsureTypeArr(entry, CONF_DOUBLE); if (entry->type == CONF_NULL) Ok(0); FoxArray* array = entry->value.a; size_t numElems = FoxArrayMSize(double, array); size_t numToWrite = FoxMin(bufSize, numElems); for (unsigned int idx = 0; idx < numToWrite; idx++) doubleBuf[idx] = *FoxArrayMIndex(double, array, idx); Ok(numElems); #undef errRet } AER_EXPORT const char* AERConfGetString(const char* key) { #define errRet NULL EnsureArg(key); char* absKey = GetAbsKey(key); ConfEntry* entry = FoxMapMIndex(const char*, ConfEntry, &conf, absKey); EnsureLookup(entry); EnsureTypeScalar(entry, CONF_STRING); Ok(entry->value.s); #undef errRet } AER_EXPORT size_t AERConfGetStrings(const char* key, size_t bufSize, const char** strBuf) { #define errRet 0 EnsureArg(key); EnsureArgBuf(strBuf, bufSize); char* absKey = GetAbsKey(key); ConfEntry* entry = FoxMapMIndex(const char*, ConfEntry, &conf, absKey); EnsureLookup(entry); EnsureTypeArr(entry, CONF_STRING); if (entry->type == CONF_NULL) Ok(0); FoxArray* array = entry->value.a; size_t numElems = FoxArrayMSize(char*, array); size_t numToWrite = FoxMin(bufSize, numElems); for (unsigned int idx = 0; idx < numToWrite; idx++) strBuf[idx] = *FoxArrayMIndex(char*, array, idx); Ok(numElems); #undef errRet }
Foxbud/libaermre
src/input.c
<reponame>Foxbud/libaermre /** * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <stddef.h> #include <string.h> #include "aer/input.h" #include "internal/core.h" #include "internal/err.h" #include "internal/export.h" #include "internal/input.h" /* ----- PUBLIC CONSTANTS ----- */ AER_EXPORT const char AER_DISPLAY_KEYS[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ' ', '!', '"', 0, '$', '%', '&', 0, '(', ')', '*', '+', 0, 0, 0, 0, '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', 0, '<', 0, '>', '?', '@', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0, 0, 0, '^', '_', 0, '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '*', '+', 0, '-', '.', '/', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '{', '|', '}', '~', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ';', '=', ',', '-', '.', '/', '\'', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '[', '\\', ']', '#', '`'}; /* ----- PRIVATE GLOBALS ----- */ static bool keysPressedTable[0x100]; static bool keysHeldTable[0x100]; static bool keysReleasedTable[0x100]; static bool mouseButtonsPressedTable[0x3]; static bool mouseButtonsHeldTable[0x3]; static bool mouseButtonsReleasedTable[0x3]; static uint32_t mousePosX, mousePosY; /* ----- INTERNAL FUNCTIONS ----- */ void InputManRecordUserInput(void) { /* Keyboard. */ memcpy(keysPressedTable, *hldvars.keysPressedTable, sizeof(keysPressedTable)); memcpy(keysHeldTable, *hldvars.keysHeldTable, sizeof(keysHeldTable)); memcpy(keysReleasedTable, *hldvars.keysReleasedTable, sizeof(keysReleasedTable)); /* Mouse. */ memcpy(mouseButtonsPressedTable, *hldvars.mouseButtonsPressedTable, sizeof(mouseButtonsPressedTable)); memcpy(mouseButtonsHeldTable, *hldvars.mouseButtonsHeldTable, sizeof(mouseButtonsHeldTable)); memcpy(mouseButtonsReleasedTable, *hldvars.mouseButtonsReleasedTable, sizeof(mouseButtonsReleasedTable)); mousePosX = *hldvars.mousePosX; mousePosY = *hldvars.mousePosY; return; } /* ----- PUBLIC FUNCTIONS ----- */ AER_EXPORT const bool* AERInputGetKeysPressed(void) { #define errRet NULL EnsureStage(STAGE_ACTION); Ok(keysPressedTable); #undef errRet } AER_EXPORT const bool* AERInputGetKeysHeld(void) { #define errRet NULL EnsureStage(STAGE_ACTION); Ok(keysHeldTable); #undef errRet } AER_EXPORT const bool* AERInputGetKeysReleased(void) { #define errRet NULL EnsureStage(STAGE_ACTION); Ok(keysReleasedTable); #undef errRet } AER_EXPORT const bool* AERInputGetMouseButtonsPressed(void) { #define errRet NULL EnsureStage(STAGE_ACTION); Ok(mouseButtonsPressedTable); #undef errRet } AER_EXPORT const bool* AERInputGetMouseButtonsHeld(void) { #define errRet NULL EnsureStage(STAGE_ACTION); Ok(mouseButtonsHeldTable); #undef errRet } AER_EXPORT const bool* AERInputGetMouseButtonsReleased(void) { #define errRet NULL EnsureStage(STAGE_ACTION); Ok(mouseButtonsReleasedTable); #undef errRet } AER_EXPORT void AERInputGetMousePositionRaw(uint32_t* x, uint32_t* y) { #define errRet EnsureStage(STAGE_ACTION); EnsureArg(x || y); if (x) *x = mousePosX; if (y) *y = mousePosY; Ok(); #undef errRet } AER_EXPORT __attribute__((alias("AERInputGetMousePositionRaw"))) void AERInputGetMousePosition(uint32_t* x, uint32_t* y); AER_EXPORT void AERInputGetMousePositionVirtual(float* x, float* y) { #define errRet EnsureStage(STAGE_ACTION); EnsureArg(x || y); if (x) *x = (float)hldfuncs.actionMouseGetX(0); if (y) *y = (float)hldfuncs.actionMouseGetY(0); Ok(); #undef errRet }
Foxbud/libaermre
include/private/internal/event.h
/** * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef INTERNAL_EVENT_H #define INTERNAL_EVENT_H #include "aer/event.h" #include "aer/instance.h" #include "internal/hld.h" /* ----- INTERNAL TYPES ----- */ typedef struct __attribute__((packed)) EventKey { HLDEventType type; int32_t num; int32_t objIdx; } EventKey; /* ----- INTERNAL GLOBALS ----- */ extern EventKey currentEvent; /* ----- INTERNAL FUNCTIONS ----- */ void EventManRegisterEventListener(HLDObject* obj, EventKey key, bool (*listener)(AEREvent*, AERInstance*, AERInstance*)); void EventManMaskSubscriptionArrays(void); void EventManSortSubscriptionArrays(void); void EventManConstructor(void); void EventManDestructor(void); #endif /* INTERNAL_EVENT_H */
Foxbud/libaermre
include/public/aer/save.h
<filename>include/public/aer/save.h /** * @file * * @brief Utilities for querying and manipulating save file data. * * @subsubsection SaveKeyNamespacing Save Key Namespacing * * Each mod is given its own, unique namespace within the save file. That means * two or more mods can use the same key without interfering with each other. * That also means it is not possible to query/manipulate vanilla keys or * the keys of other mods. * * @note The functions in this module automatically apply to the current save * slot. * * @since 1.2.0 * * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef AER_SAVE_H #define AER_SAVE_H #include <stddef.h> #include <stdint.h> /* ----- PUBLIC FUNCTIONS ----- */ /** * @brief Query the index of the currently active save slot. * * @bug When a save has not yet been loaded (such as is the case at the title * screen), this function returns `0`. * * @return Save slot index or `-1` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * * @since 1.2.0 */ int32_t AERSaveGetCurrentSlot(void); /** * @brief Query the keys of all values in the save file (belonging to the * calling mod). * * For information about key namespacing see @ref SaveKeyNamespacing. * * @warning The references returned by this function should be considered highly * unstable. Consider deepcopying them if needed for later. * * @warning Argument `keyBuf` must be large enough to hold at least * `bufSize` elements. * * @note Argument `bufSize` may be `0` in which case argument `keyBuf` may * be `NULL`. This may be used to efficiently query the total number of * keys contained in the save file (belonging to the calling mod). * * @param[in] bufSize Maximum number of elements to write to argument * `keyBuf`. * @param[out] keyBuf Buffer to write keys to. * * @return Total number of keys contained in save file or `0` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `keyBuf` is `NULL` and argument `bufSize` * is greater than `0`. * * @since 1.2.0 */ size_t AERSaveGetKeys(size_t bufSize, const char** keyBuf); /** * @brief Erase a value from the save file. * * For information about key namespacing see @ref SaveKeyNamespacing. * * @note Changes will take effect at next save point. * * @param[in] key Save key. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `key` is `NULL`. * @throw ::AER_FAILED_LOOKUP if argument `key` is an invalid save key. * * @since 1.2.0 */ void AERSaveDestroy(const char* key); /** * @brief Query a double value from the save file. * * For information about key namespacing see @ref SaveKeyNamespacing. * * @param[in] key Save key. * * @return Value of the key or `0.0` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `key` is `NULL`. * @throw ::AER_FAILED_LOOKUP if argument `key` is an invalid save key. * @throw ::AER_FAILED_PARSE if key does not contain a double value. * * @since 1.2.0 * * @sa AERSaveSetDouble */ double AERSaveGetDouble(const char* key); /** * @brief Set a double value in the save file. * * This function can both create new and update existing entries in the save * file (regardless of type). * * For information about key namespacing see @ref SaveKeyNamespacing. * * @note Changes will take effect at next save point. * * @param[in] key Save key. * @param[in] value Double save value. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `key` is `NULL`. * @throw ::AER_BAD_VAL if argument `value` is `Inf`, `-Inf` or `NaN`. * * @since 1.2.0 * * @sa AERSaveGetDouble */ void AERSaveSetDouble(const char* key, double value); /** * @brief Query a string value from the save file. * * For information about key namespacing see @ref SaveKeyNamespacing. * * @warning The reference returned by this function should be considered highly * unstable. Consider deepcopying it if needed for later. * * @param[in] key Save key. * * @return Value of the key or `NULL` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `key` is `NULL`. * @throw ::AER_FAILED_LOOKUP if argument `key` is an invalid save key. * @throw ::AER_FAILED_PARSE if key does not contain a string value. * * @since 1.2.0 * * @sa AERSaveSetString */ const char* AERSaveGetString(const char* key); /** * @brief Set a string value in the save file. * * This function can both create new and update existing entries in the save * file (regardless of type). * * For information about key namespacing see @ref SaveKeyNamespacing. * * @note Changes will take effect at next save point. * * @param[in] key Save key. * @param[in] value String save value. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if either argument `key` or `value` is `NULL`. * * @since 1.2.0 * * @sa AERSaveGetString */ void AERSaveSetString(const char* key, const char* value); #endif /* AER_SAVE_H */
Foxbud/libaermre
src/draw.c
#include "aer/draw.h" #include "internal/core.h" #include "internal/err.h" #include "internal/export.h" #include "internal/hld.h" /* ----- PRIVATE MACROS ----- */ #define WrapString(str) \ ({ \ const char* WrapString_str = (str); \ uint32_t WrapString_idx; \ for (WrapString_idx = 0; WrapString_idx < sizeof(textBuf) - 1; \ WrapString_idx++) { \ char WrapString_curChar = WrapString_str[WrapString_idx]; \ if (WrapString_curChar == '\0') \ break; \ textBuf[WrapString_idx] = WrapString_curChar; \ } \ textBuf[WrapString_idx] = '\0'; \ textBuf; \ }) /* ----- PRIVATE GLOBALS ----- */ static char textBuf[8 * 1024]; /* ----- PUBLIC FUNCTIONS ----- */ AER_EXPORT float AERDrawGetCurrentAlpha(void) { #define errRet -1.0f EnsureStage(STAGE_ACTION); Ok(hldfuncs.actionDrawGetAlpha()); #undef errRet } AER_EXPORT void AERDrawSetCurrentAlpha(float alpha) { #define errRet EnsureStage(STAGE_ACTION); EnsureProba(alpha); hldfuncs.actionDrawSetAlpha(alpha); Ok(); #undef errRet } AER_EXPORT void AERDrawSprite(int32_t spriteIdx, uint32_t frame, float x, float y, float scale, uint32_t blend) { #define errRet EnsureStageStrict(STAGE_DRAW); HLDSprite* sprite = HLDSpriteLookup(spriteIdx); EnsureLookup(sprite); EnsureMaxExc(frame, sprite->numImages); HLDVecIntegral spriteSize = sprite->size; hldfuncs.actionDrawSpriteGeneral(sprite, frame, 0.0f, 0.0f, spriteSize.x, spriteSize.y, x, y, scale, scale, 0.0f, blend, blend, blend, blend, 1.0f); Ok(); #undef errRet } AER_EXPORT void AERDrawSpriteAdv(int32_t spriteIdx, uint32_t frame, int32_t left, int32_t top, int32_t width, int32_t height, float x, float y, float scaleX, float scaleY, float angle, uint32_t blendNW, uint32_t blendNE, uint32_t blendSE, uint32_t blendSW, float alpha) { #define errRet EnsureStageStrict(STAGE_DRAW); HLDSprite* sprite = HLDSpriteLookup(spriteIdx); EnsureLookup(sprite); EnsureMaxExc(frame, sprite->numImages); EnsureProba(alpha); hldfuncs.actionDrawSpriteGeneral( sprite, frame, (float)left, (float)top, (float)width, (float)height, x, y, scaleX, scaleY, angle, blendNW, blendNE, blendSE, blendSW, alpha); Ok(); #undef errRet } AER_EXPORT void AERDrawLine(float x1, float y1, float x2, float y2, uint32_t color) { #define errRet EnsureStageStrict(STAGE_DRAW); hldfuncs.actionDrawLine(x1, y1, x2, y2, 1.0f, color, color); Ok(); #undef errRet } AER_EXPORT void AERDrawLineAdv(float x1, float y1, float x2, float y2, float width, uint32_t color1, uint32_t color2) { #define errRet EnsureStageStrict(STAGE_DRAW); hldfuncs.actionDrawLine(x1, y1, x2, y2, width, color1, color2); Ok(); #undef errRet } AER_EXPORT void AERDrawEllipse(float left, float top, float right, float bottom, uint32_t color, bool outline) { #define errRet EnsureStageStrict(STAGE_DRAW); hldfuncs.actionDrawEllipse(left, top, right, bottom, color, color, outline); Ok(); } AER_EXPORT void AERDrawEllipseAdv(float left, float top, float right, float bottom, uint32_t colorCenter, uint32_t colorEdge, bool outline) { #define errRet EnsureStageStrict(STAGE_DRAW); hldfuncs.actionDrawEllipse(left, top, right, bottom, colorCenter, colorEdge, outline); Ok(); } AER_EXPORT void AERDrawTriangle(float x1, float y1, float x2, float y2, float x3, float y3, uint32_t color, bool outline) { #define errRet EnsureStageStrict(STAGE_DRAW); hldfuncs.actionDrawTriangle(x1, y1, x2, y2, x3, y3, color, color, color, outline); Ok(); #undef errRet } AER_EXPORT void AERDrawTriangleAdv(float x1, float y1, float x2, float y2, float x3, float y3, uint32_t color1, uint32_t color2, uint32_t color3, bool outline) { #define errRet EnsureStageStrict(STAGE_DRAW); hldfuncs.actionDrawTriangle(x1, y1, x2, y2, x3, y3, color1, color2, color3, outline); Ok(); #undef errRet } AER_EXPORT void AERDrawRectangle(float left, float top, float right, float bottom, uint32_t color, bool outline) { #define errRet EnsureStageStrict(STAGE_DRAW); hldfuncs.actionDrawRectangle(left, top, right, bottom, color, color, color, color, outline); Ok(); #undef errRet } AER_EXPORT void AERDrawRectangleAdv(float left, float top, float right, float bottom, uint32_t colorNW, uint32_t colorNE, uint32_t colorSE, uint32_t colorSW, bool outline) { #define errRet EnsureStageStrict(STAGE_DRAW); hldfuncs.actionDrawRectangle(left, top, right, bottom, colorNW, colorNE, colorSE, colorSW, outline); Ok(); #undef errRet } AER_EXPORT void AERDrawText(const char* text, float x, float y, uint32_t width, float scale, uint32_t color) { #define errRet EnsureStageStrict(STAGE_DRAW); EnsureArg(text); hldfuncs.actionDrawText(x, y, WrapString(text), -1, width, scale, scale, 0.0f, color, color, color, color, 1.0f); Ok(); #undef errRet } AER_EXPORT void AERDrawTextAdv(const char* text, float x, float y, int32_t height, uint32_t width, float scaleX, float scaleY, float angle, uint32_t colorNW, uint32_t colorNE, uint32_t colorSE, uint32_t colorSW, float alpha) { #define errRet EnsureStageStrict(STAGE_DRAW); EnsureArg(text); EnsureProba(alpha); hldfuncs.actionDrawText(x, y, WrapString(text), height, width, scaleX, scaleY, angle, colorNW, colorNE, colorSE, colorSW, alpha); Ok(); #undef errRet }
Foxbud/libaermre
include/public/aer/object.h
/** * @file * * @brief Utilities for querying and manipulating game objects. * * @subsubsection ObjListeners Object Event Listeners * * An object event listener is a callback function with the signature: * * @code{.c} * bool listener(AEREvent *event, AERInstance *target, AERInstance *other); * @endcode * * Whenever the event in question occurs for an instance of the given object, * the MRE executes this callback, passing in the instance that triggered the * event through the argument `target`. For all events except collisions, * argument `other` is simply set to the same value as argument `target`. For * collision events, argument `other` is set to the instance that the target * instance collided with to trigger the event. * * The argument `event` contains the context necessary for "handling" the event. * Its `handle` member represents the next mod event listener attached to the * currently executing object event, and its `next` member represets the event * context that should be passed to `handle`. However, if the current listener * happens to be the last in the chain, then calling `handle` will execute the * vanilla listener for this event. Regardless, it should not matter to the * current event listener which of these is the case. * * This means that each listener in the chain is given the option of whether or * not to actually handle the event. If a listener chooses not to call `handle`, * then all listeners attached to that same object event with lower priority * will not be executed. Furthermore, the original vanilla listener will not be * executed. * * That is why listeners return a boolean value. It represents whether or not * the event was handled. If `true`, that means all event listeners in the chain * called the `handle` functions they were passed and the original vanilla * listener was called. If `false`, that means that some event listener in the * chain chose not to handle the event. * * This callback scheme was designed to maximize mod compatability, but for that * to work, mod listeners should follow this general pattern: * * @code{.c} * bool listener(AEREvent *event, AERInstance *target, AERInstance *other) { * // Code without side effects that (un)conditionally cancels the event. * if (thisCondition || thatCondition) * // `event->handle` not called, so return `false`. * return false; * * // Call next listener in chain. * if (!event->handle(event->next, target, other)) * // Event not handled, so cease futher processing and return `false`. * return false; * * // Code with side effects that does not cancel event. * SomeFunction(target); * * // If at this point, `event->handle` returned true, so return true. * return true; * } * @endcode * * *Special thanks to <NAME> for help design this section of the API.* * * @since 1.0.0 * * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef AER_OBJECT_H #define AER_OBJECT_H #include <stdbool.h> #include <stddef.h> #include <stdint.h> #include "aer/event.h" #include "aer/instance.h" /* ----- PUBLIC TYPES ----- */ /** * @brief Vanilla objects. * * @since 1.0.0 */ typedef enum AERObjectIndex { /** * @brief Flag which represents either no object or an invalid object * depending on context. */ AER_OBJECT_NULL = -1, AER_OBJECT_MASTERCLASS = 0x0, AER_OBJECT_DOORSTOVISIT = 0x1, AER_OBJECT_PAUSEDELAYOBJ = 0x2, /** * @brief Container for general information about the current save file. * * @sa @ref ObjPageAnalytics */ AER_OBJECT_ANALYTICS = 0x3, AER_OBJECT_BACKGROUND = 0x4, AER_OBJECT_STUCKBOX = 0x5, AER_OBJECT_BATTERYCHARGER = 0x6, AER_OBJECT_BG = 0x7, AER_OBJECT_BGSCENERY = 0x8, AER_OBJECT_BULLET = 0x9, AER_OBJECT_BURSTSHOT = 0xa, AER_OBJECT_CONFIRMWINDOW = 0xb, AER_OBJECT_DATA = 0xc, AER_OBJECT_DECOR = 0xd, AER_OBJECT_DECORSHADOW = 0xe, AER_OBJECT_DECORXRAYBLOCK = 0xf, AER_OBJECT_DECORXRAYSHADOWBLOCK = 0x10, /** * @brief Base object from which all enemys inherit. * * @sa @ref ObjPageEnemy */ AER_OBJECT_ENEMY = 0x11, AER_OBJECT_ENEMYHITMASK = 0x12, AER_OBJECT_FOREGROUND = 0x13, AER_OBJECT_GAMEEXITER = 0x14, AER_OBJECT_HAZARD = 0x15, AER_OBJECT_JUMPLEDGE = 0x16, AER_OBJECT_LIBRARY = 0x17, AER_OBJECT_MANTLEABLE = 0x18, AER_OBJECT_MOVINGBLOCK = 0x19, AER_OBJECT_MUSIC = 0x1a, AER_OBJECT_OBJWINDOW = 0x1b, AER_OBJECT_PARTICLE = 0x1c, /** * @brief All "solid" objects must either directly or indirectly inherit * from this object. */ AER_OBJECT_PATHFINDOBSTACLE = 0x1d, AER_OBJECT_PROJECTILEBLOCKCOLLIDER = 0x1e, AER_OBJECT_SCENERY = 0x1f, AER_OBJECT_SCREEN = 0x20, AER_OBJECT_SIMPLEEFFECT = 0x21, AER_OBJECT_SIMPLEEFFECTGUI = 0x22, AER_OBJECT_STATESCENERY = 0x23, AER_OBJECT_RECESSINGSCENERY = 0x24, AER_OBJECT_TIMELIMIT = 0x25, AER_OBJECT_MENUS = 0x26, AER_OBJECT_CREDITS = 0x27, AER_OBJECT_TITLEHLD = 0x28, AER_OBJECT_PAXCHALLENGERESULTS = 0x29, AER_OBJECT_THANKYOUSCREEN = 0x2a, AER_OBJECT_TITLESCREEN = 0x2b, AER_OBJECT_WAITER = 0x2c, AER_OBJECT_BOSSRUSHLEADERBOARDSAVER = 0x2d, AER_OBJECT_EDITOROBJ = 0x2e, AER_OBJECT_SPAWNER = 0x2f, AER_OBJECT_LEVELBOUNDARY = 0x30, AER_OBJECT_FOLDER_EDITOROBJS = 0x31, AER_OBJECT_HOARDE = 0x32, AER_OBJECT_CHARMAKER = 0x33, AER_OBJECT_CHARVICTORY = 0x34, AER_OBJECT_NEWREGIONSOUNDEVENT = 0x35, AER_OBJECT_ALLHOARDESBEATEN = 0x36, AER_OBJECT_BONUSHOARDEBEATEN = 0x37, /** * @brief Door that takes the drifter to a new room. * * @sa @ref ObjPageDoor */ AER_OBJECT_DOOR = 0x38, AER_OBJECT_TITLEDOOR = 0x39, AER_OBJECT_EDITORCHECKPOINT = 0x3a, /** * @brief A rectangular area that detects collisions with a set object type. * * @sa @ref ObjPageRegion */ AER_OBJECT_REGION = 0x3b, AER_OBJECT_REGIONWALL = 0x3c, AER_OBJECT_BOSSWALL = 0x3d, AER_OBJECT_BOOMBOX = 0x3e, AER_OBJECT_AMBIENCE = 0x3f, AER_OBJECT_CAMERACUE = 0x40, AER_OBJECT_CAMERALOCK = 0x41, AER_OBJECT_CASERESETTER = 0x42, AER_OBJECT_EMPTYOBJECT = 0x43, AER_OBJECT_TRUEATINTERVAL = 0x44, AER_OBJECT_PERMASTATE = 0x45, AER_OBJECT_COLLECTIBLECHECK = 0x46, AER_OBJECT_PLAYERHASMAPCHECK = 0x47, AER_OBJECT_WELLCHECK = 0x48, AER_OBJECT_ROOMVISITED = 0x49, AER_OBJECT_BOSSCHECK = 0x4a, AER_OBJECT_ONETIMETRUE = 0x4b, AER_OBJECT_PARALLAXOBJ = 0x4c, AER_OBJECT_NOCOMBAT = 0x4d, AER_OBJECT_NOSHOOT = 0x4e, AER_OBJECT_NOWARP = 0x4f, AER_OBJECT_EDITORBLOOMER = 0x50, AER_OBJECT_EDITORSCREENSHAKE = 0x51, AER_OBJECT_EDITORSOUND = 0x52, AER_OBJECT_EDITORCUTSCENE = 0x53, AER_OBJECT_TUTORIALBUTTONPROMPT = 0x54, AER_OBJECT_TUTORIALINFINITESLIME = 0x55, AER_OBJECT_EDITORWAYPOINT = 0x56, AER_OBJECT_NOTE = 0x57, AER_OBJECT_SPECIALWAYPOINT = 0x58, AER_OBJECT_DRIFTERDEATH = 0x59, AER_OBJECT_GLOWINGEYES = 0x5a, AER_OBJECT_BLOODSPRAYER = 0x5b, AER_OBJECT_ENEMYHPCHECKER = 0x5c, AER_OBJECT_BOSSRUSH = 0x5d, AER_OBJECT_BOSSRUSHCHECKPOINT = 0x5e, AER_OBJECT_BOSSRUSHBOSSCHECK = 0x5f, AER_OBJECT_FOLDER_ENDE = 0x60, AER_OBJECT_AMBIENTSOUND = 0x61, AER_OBJECT_GAUNTLETDOOR = 0x62, AER_OBJECT_CRISSCROSS = 0x63, AER_OBJECT_OVERTRIGGER = 0x64, AER_OBJECT_UNDERTRIGGER = 0x65, AER_OBJECT_DOORBOTTOM = 0x66, AER_OBJECT_GRASS = 0x67, AER_OBJECT_HALSPAWNER = 0x68, AER_OBJECT_MIDDOOR = 0x69, AER_OBJECT_PUDDLE = 0x6a, /** * @brief Objects that release energy when destroyed. */ AER_OBJECT_DESTRUCTABLE = 0x6b, AER_OBJECT_PHASECRYSTALMAKER = 0x6c, AER_OBJECT_CRYSTALDESTRUCTABLE = 0x6d, AER_OBJECT_MULTIHITCRYSTAL = 0x6e, AER_OBJECT_ORGANTUBETINY = 0x6f, AER_OBJECT_ORGANTUBETHIN = 0x70, AER_OBJECT_ORGANTUBESMALL = 0x71, AER_OBJECT_COLLECTIBLE = 0x72, AER_OBJECT_COLLECTIBLECOLUMN = 0x73, AER_OBJECT_FOLDER_ITEMS = 0x74, AER_OBJECT_CRATE = 0x75, AER_OBJECT_CRATEBIG = 0x76, AER_OBJECT_MULTIHITCRATE = 0x77, AER_OBJECT_BARREL = 0x78, AER_OBJECT_EXPLODINGBARREL = 0x79, AER_OBJECT_GEARBITCRATE = 0x7a, AER_OBJECT_GEARBIT = 0x7b, AER_OBJECT_MAP = 0x7c, AER_OBJECT_HEALTHKIT = 0x7d, AER_OBJECT_DRIFTERBONES_KEY = 0x7e, AER_OBJECT_DRIFTERBONES_WEAPON = 0x7f, AER_OBJECT_DRIFTERBONES_OUTFIT = 0x80, AER_OBJECT_MODULESOCKET = 0x81, AER_OBJECT_LIBRARIANTABLET = 0x82, AER_OBJECT_LIBRARYCASE = 0x83, AER_OBJECT_LIBRARYWALL = 0x84, AER_OBJECT_LIBRARYWALLFINAL = 0x85, AER_OBJECT_FOLDER_ENDD = 0x86, AER_OBJECT_DRIFTERBONES = 0x87, AER_OBJECT_BATTERYREFILLER = 0x88, AER_OBJECT_HEALTHPLANT = 0x89, AER_OBJECT_FOLDER_ENVIRO = 0x8a, AER_OBJECT_BUTTON = 0x8b, AER_OBJECT_BOSSRUSHLEADERBOARD = 0x8c, AER_OBJECT_HIGHSCOREBOARD = 0x8d, AER_OBJECT_SMALLHIGHSCOREBOARD = 0x8e, AER_OBJECT_TOGGLESWITCH = 0x8f, AER_OBJECT_RAILGUNSWITCH = 0x90, AER_OBJECT_TERMINAL = 0x91, AER_OBJECT_WARPPAD = 0x92, AER_OBJECT_STAIRSRIGHT = 0x93, AER_OBJECT_STAIRSLEFT = 0x94, AER_OBJECT_SMALLSTAIRSRIGHT = 0x95, AER_OBJECT_SMALLSTAIRSLEFT = 0x96, AER_OBJECT_STAIRSUP = 0x97, AER_OBJECT_SMALLSTAIRSUP = 0x98, AER_OBJECT_JUMPPAD = 0x99, AER_OBJECT_INVISIBLEPLATFORM = 0x9a, AER_OBJECT_LIGHT = 0x9b, AER_OBJECT_ROOMDOOR = 0x9c, AER_OBJECT_DIAMONDDOOR = 0x9d, AER_OBJECT_VANISHINGDOOR = 0x9e, AER_OBJECT_TELEVATOR = 0x9f, AER_OBJECT_BIGBOSSDOOR = 0xa0, AER_OBJECT_DRIFTERVAULTDOOR = 0xa1, AER_OBJECT_MODULEDOOR = 0xa2, AER_OBJECT_SHORTWARP = 0xa3, AER_OBJECT_TELEPORTER = 0xa4, AER_OBJECT_UPGRADESWORD = 0xa5, AER_OBJECT_UPGRADEDASH = 0xa6, AER_OBJECT_UPGRADEHEALTHPACK = 0xa7, AER_OBJECT_UPGRADESPECIAL = 0xa8, AER_OBJECT_UPGRADEWEAPON = 0xa9, AER_OBJECT_APARTMENTDIAGRAM = 0xaa, AER_OBJECT_APARTMENTLIGHTSWITCH = 0xab, AER_OBJECT_APARTMENTMIRROR = 0xac, AER_OBJECT_CAPECHOOSER = 0xad, AER_OBJECT_COMPANIONSHELLCHOOSER = 0xae, AER_OBJECT_SWORDCHOOSER = 0xaf, AER_OBJECT_STAMINARECHARGER = 0xb0, AER_OBJECT_CHAINDASHSCOREBOARD = 0xb1, AER_OBJECT_CHAINDASHSCOREBOARDPRO = 0xb2, AER_OBJECT_WELLTOWER = 0xb3, AER_OBJECT_WATERFLOOR = 0xb4, AER_OBJECT_SNOWFLOOR = 0xb5, AER_OBJECT_WATERFALLREGION = 0xb6, AER_OBJECT_TITANHEART = 0xb7, AER_OBJECT_TITANEYE = 0xb8, AER_OBJECT_GOOCIRCLE = 0xb9, AER_OBJECT_SOCCERBALL = 0xba, AER_OBJECT_SOCCERSCOREBOARD = 0xbb, AER_OBJECT_ABYSSDOOR = 0xbc, AER_OBJECT_ABYSSDOORPILLAR = 0xbd, AER_OBJECT_FOLDER_END3 = 0xbe, AER_OBJECT_SNOWPILE = 0xbf, AER_OBJECT_VINEBOTTOM = 0xc0, AER_OBJECT_INTERACTIVEOBJ = 0xc1, AER_OBJECT_SCENERYLIGHT = 0xc2, AER_OBJECT_DOORINTERACTIVESYSTEM = 0xc3, AER_OBJECT_SWITCHPARENT = 0xc4, AER_OBJECT_FLOORBUTTON = 0xc5, AER_OBJECT_SWITCHPILLAR = 0xc6, AER_OBJECT_TIMEDSWITCHPILLAR = 0xc7, AER_OBJECT_SLOWSWITCH = 0xc8, AER_OBJECT_SPLITTINGDOOR = 0xc9, AER_OBJECT_SINKINGDOOR = 0xca, AER_OBJECT_TOWER = 0xcb, AER_OBJECT_DANGER = 0xcc, AER_OBJECT_ACIDPARENT = 0xcd, AER_OBJECT_LASERHAZARD = 0xce, AER_OBJECT_ACIDPOOL = 0xcf, AER_OBJECT_ACIDPOOLSHRINK = 0xd0, AER_OBJECT_FOLDER_HAZARDS = 0xd1, AER_OBJECT_POPUPTURRET = 0xd2, AER_OBJECT_CRUSHBLOCK = 0xd3, AER_OBJECT_MOVINGPLATFORM = 0xd4, AER_OBJECT_RISINGPLATFORM = 0xd5, AER_OBJECT_DROPPLATFORM = 0xd6, AER_OBJECT_SICKAREA = 0xd7, AER_OBJECT_PHASEMINE = 0xd8, AER_OBJECT_FLAMEPOLE = 0xd9, AER_OBJECT_FLAMEVENT = 0xda, AER_OBJECT_FLAMETHROWER = 0xdb, AER_OBJECT_LINKMINE = 0xdc, AER_OBJECT_FOLDER_ENDH = 0xdd, AER_OBJECT_SINKINGPLATFORM = 0xde, AER_OBJECT_SHALLOWPLATFORM = 0xdf, AER_OBJECT_WARPBLOCKTRAP = 0xe0, AER_OBJECT_TIMEPOLE = 0xe1, AER_OBJECT_TURRET = 0xe2, AER_OBJECT_TIMESLOWER = 0xe3, AER_OBJECT_FLAMEJET = 0xe4, AER_OBJECT_TURRETLASER = 0xe5, AER_OBJECT_TURRETORB = 0xe6, AER_OBJECT_PHASEDROPPLATFORM = 0xe7, AER_OBJECT_MINE = 0xe8, AER_OBJECT_OTTERBODY = 0xe9, AER_OBJECT_ACIDLAKE = 0xea, AER_OBJECT_PHASEPLATFORM = 0xeb, AER_OBJECT_DESTRUCTOR = 0xec, AER_OBJECT_ENEMYSHOUT = 0xed, AER_OBJECT_OTHERCOMPANION = 0xee, AER_OBJECT_ENEMYBOMB = 0xef, AER_OBJECT_GOALBOMB = 0xf0, AER_OBJECT_CULTCHARGE = 0xf1, AER_OBJECT_ENEMYWEAPONCOL = 0xf2, AER_OBJECT_CRYSTALSPIKE = 0xf3, AER_OBJECT_TIMEPHASEBULLET = 0xf4, AER_OBJECT_NINJASTAR = 0xf5, AER_OBJECT_LASERSHOT = 0xf6, AER_OBJECT_ENEMYSHOT = 0xf7, AER_OBJECT_ROCKET = 0xf8, AER_OBJECT_ENEMYBULLET = 0xf9, AER_OBJECT_MAGICMISSILE = 0xfa, AER_OBJECT_HALDRIFTER = 0xfb, AER_OBJECT_DEADHALLUCINATION = 0xfc, AER_OBJECT_HALDIRK = 0xfd, AER_OBJECT_ENEMYPLOPPER = 0xfe, AER_OBJECT_TESTENEMY = 0xff, AER_OBJECT_PARRYPRINCE = 0x100, AER_OBJECT_TANUKISPEAR = 0x101, AER_OBJECT_CRYSTALSPIDER = 0x102, AER_OBJECT_ALPHAWOLF = 0x103, AER_OBJECT_NINJAFROG = 0x104, AER_OBJECT_JARFROG = 0x105, AER_OBJECT_STRIDER = 0x106, AER_OBJECT_SWOOPNSPIT = 0x107, AER_OBJECT_GARBAGEPLANT = 0x108, AER_OBJECT_DROPBIRD = 0x109, AER_OBJECT_DIVEBOMB = 0x10a, AER_OBJECT_CRAB = 0x10b, AER_OBJECT_CRABMAN = 0x10c, AER_OBJECT_BURSTBIRD = 0x10d, AER_OBJECT_SUMMONBLOCKBIRD = 0x10e, AER_OBJECT_FOLDER_ENEMYG = 0x10f, AER_OBJECT_DIRK = 0x110, AER_OBJECT_RIFLEDIRK = 0x111, AER_OBJECT_MISSILEDIRK = 0x112, AER_OBJECT_SLIME = 0x113, AER_OBJECT_LEAPER = 0x114, AER_OBJECT_SPIDER = 0x115, AER_OBJECT_DIRKOMMANDER = 0x116, AER_OBJECT_PUNCHINGBAG = 0x117, AER_OBJECT_WEAKPUNCHINGBAG = 0x118, AER_OBJECT_REGPUNCHINGBAG = 0x119, AER_OBJECT_FOLDER_ENEMYW = 0x11a, AER_OBJECT_TANUKISWORD = 0x11b, AER_OBJECT_TANUKIGUN = 0x11c, AER_OBJECT_SMALLCRYSTALSPIDER = 0x11d, AER_OBJECT_CRYSTALBABY = 0x11e, AER_OBJECT_WOLF = 0x11f, AER_OBJECT_FOLDER_ENEMYE = 0x120, AER_OBJECT_NINJASTARFROG = 0x121, AER_OBJECT_SPIRALBOMBFROG = 0x122, AER_OBJECT_GRUMPSHROOM = 0x123, AER_OBJECT_MELTY = 0x124, AER_OBJECT_FOLDER_ENEMYN = 0x125, AER_OBJECT_GHOSTBEAMBIRD = 0x126, AER_OBJECT_CULTBIRD = 0x127, AER_OBJECT_BIRDMAN = 0x128, AER_OBJECT_FOLDER_ENEMYS = 0x129, AER_OBJECT_SOUTHDRONE = 0x12a, AER_OBJECT_ROBODOG = 0x12b, AER_OBJECT_BLADIRK = 0x12c, AER_OBJECT_FOLDER_END = 0x12d, AER_OBJECT_FOLDER_BOSSES = 0x12e, AER_OBJECT_HALBOSS = 0x12f, AER_OBJECT_CLEANER = 0x130, AER_OBJECT_OLDGENERAL = 0x131, AER_OBJECT_JERKPOPE = 0x132, AER_OBJECT_MARKSCYTHE = 0x133, AER_OBJECT_BENNYARROW = 0x134, AER_OBJECT_BULLETBAKER = 0x135, AER_OBJECT_ALUCARDMODULESOCKET = 0x136, AER_OBJECT_COUNTALUCARD = 0x137, AER_OBJECT_TANUKICRYSTAL = 0x138, AER_OBJECT_FOLDER_END5 = 0x139, AER_OBJECT_GEARBITSPAWNER = 0x13a, AER_OBJECT_HALEXPLOSION = 0x13b, AER_OBJECT_HALARM = 0x13c, AER_OBJECT_DIAMONDEYE = 0x13d, AER_OBJECT_EMBERDIAMOND = 0x13e, AER_OBJECT_EMBERARM = 0x13f, AER_OBJECT_EMBERARMPIECE = 0x140, AER_OBJECT_EMBERLASER = 0x141, AER_OBJECT_GUNSLINGER = 0x142, AER_OBJECT_CRYSTALQUEEN = 0x143, AER_OBJECT_SPIDEREGG = 0x144, AER_OBJECT_ALUCARDDRONE = 0x145, AER_OBJECT_ARROWSTRIKE = 0x146, AER_OBJECT_SCYTHE = 0x147, AER_OBJECT_WARPTRAVELER = 0x148, AER_OBJECT_DIAMONDSPIDER = 0x149, AER_OBJECT_CRYSTALSPIKEMAKER = 0x14a, AER_OBJECT_CRYSTALWALLMAKER = 0x14b, AER_OBJECT_DIAMONDSPIDERLEG = 0x14c, AER_OBJECT_BOSSGEARBITSPAWNER = 0x14d, AER_OBJECT_BLOODPICKUP = 0x14e, AER_OBJECT_COMPANIONSUIT = 0x14f, AER_OBJECT_BETACAPEPICKUP = 0x150, AER_OBJECT_POWERUP = 0x151, AER_OBJECT_POWDRONE = 0x152, AER_OBJECT_POWBUBBLEDRONE = 0x153, AER_OBJECT_POWSTUNDRONE = 0x154, AER_OBJECT_FOLDER_NPC = 0x155, AER_OBJECT_WAYPOINT = 0x156, AER_OBJECT_LIZARDFAMILY = 0x157, AER_OBJECT_CHANTBIRD = 0x158, AER_OBJECT_NPCGENERIC = 0x159, AER_OBJECT_NPCALTDRIFTER = 0x15a, AER_OBJECT_NPC = 0x15b, AER_OBJECT_CITIZEN = 0x15c, AER_OBJECT_BUFFALO = 0x15d, AER_OBJECT_BADASSDRIFTER = 0x15e, AER_OBJECT_BADASSINAPARTMENT = 0x15f, AER_OBJECT_BADASSINOFFICE = 0x160, AER_OBJECT_FOLDER_END2 = 0x161, AER_OBJECT_NPCCUSTOMBASE = 0x162, AER_OBJECT_FOLDER_WILDLIFE = 0x163, AER_OBJECT_DIRKGOALIE = 0x164, AER_OBJECT_EMBERFOX = 0x165, AER_OBJECT_ABYSSDOG = 0x166, AER_OBJECT_JARFROGCARRY = 0x167, AER_OBJECT_FROGDRAGOTTER = 0x168, AER_OBJECT_TADPOLE = 0x169, AER_OBJECT_FLY = 0x16a, AER_OBJECT_TINYFLY = 0x16b, AER_OBJECT_EEL = 0x16c, AER_OBJECT_SNAIL = 0x16d, AER_OBJECT_BIRDMANFLYAWAY = 0x16e, AER_OBJECT_FISH = 0x16f, AER_OBJECT_DOG = 0x170, AER_OBJECT_SQUIRREL = 0x171, AER_OBJECT_DEER = 0x172, AER_OBJECT_ROBIN = 0x173, AER_OBJECT_CROW = 0x174, AER_OBJECT_HALBIRD = 0x175, AER_OBJECT_HERON = 0x176, AER_OBJECT_WILDDRONE = 0x177, AER_OBJECT_SQUIDBOT = 0x178, AER_OBJECT_SCORPBOT = 0x179, AER_OBJECT_BIRD = 0x17a, AER_OBJECT_BIRDBLACK = 0x17b, AER_OBJECT_FOLDER_ENDW = 0x17c, AER_OBJECT_WILDLIFE = 0x17d, AER_OBJECT_WEATHEROBJ = 0x17e, AER_OBJECT_BLACKRAIN = 0x17f, AER_OBJECT_FOLDER_FX = 0x180, AER_OBJECT_COLORREGION = 0x181, AER_OBJECT_SCREENDUST = 0x182, AER_OBJECT_TINYDUST = 0x183, AER_OBJECT_RAINBOWGLITTER = 0x184, AER_OBJECT_PULSER = 0x185, AER_OBJECT_WATERSPARKLE = 0x186, AER_OBJECT_RAINBOWBGDUST = 0x187, AER_OBJECT_SNOWMAKER = 0x188, AER_OBJECT_SLOWSNOW = 0x189, AER_OBJECT_RAINMAKER = 0x18a, AER_OBJECT_LEAKYRAIN = 0x18b, AER_OBJECT_LEAKYRAINPART = 0x18c, AER_OBJECT_BLACKRAINMAKER = 0x18d, AER_OBJECT_CLOUDS = 0x18e, AER_OBJECT_FGMIST = 0x18f, AER_OBJECT_LIGHTNING = 0x190, AER_OBJECT_FOLDER_ENDWEATH = 0x191, AER_OBJECT_CLOUDWRAP = 0x192, AER_OBJECT_RAIN = 0x193, AER_OBJECT_SNOW = 0x194, AER_OBJECT_DUSTPART = 0x195, AER_OBJECT_DASHBLOCK = 0x196, AER_OBJECT_BLOCK = 0x197, AER_OBJECT_SOFTBLOCK = 0x198, AER_OBJECT_BLOCK2 = 0x199, AER_OBJECT_BLOCKPATHFINDLESS = 0x19a, AER_OBJECT_PARTBLOCK = 0x19b, AER_OBJECT_OVERWALL = 0x19c, AER_OBJECT_UNDERWALL = 0x19d, AER_OBJECT_SAFEPLATFORM = 0x19e, AER_OBJECT_PROTECTIONPLATFORM = 0x19f, /** * @brief A gun used by the drifter. An instance is permanently loaded for * each gun you have picked up. * * @sa @ref ObjPageSecondary */ AER_OBJECT_SECONDARY = 0x1a0, AER_OBJECT_ROOMMAPDATA = 0x1a1, AER_OBJECT_DRAWPOINT = 0x1a2, AER_OBJECT_DRAWLINE = 0x1a3, AER_OBJECT_DRAWCIRCLE = 0x1a4, AER_OBJECT_DRAWOVAL = 0x1a5, AER_OBJECT_DRAWTEXT = 0x1a6, /** * @brief The drifter's melee attack. * * @sa @ref ObjPageAttackCol */ AER_OBJECT_ATTACKCOL = 0x1a7, AER_OBJECT_HITCOLLIDER = 0x1a8, /** * @brief Player character. */ AER_OBJECT_CHAR = 0x1a9, AER_OBJECT_DECOY = 0x1aa, AER_OBJECT_PHANTOMSLASH = 0x1ab, AER_OBJECT_CHARHITMASK = 0x1ac, AER_OBJECT_DEADCHAR = 0x1ad, AER_OBJECT_DEADP2 = 0x1ae, AER_OBJECT_GHOST = 0x1af, AER_OBJECT_ALTCOMPANION = 0x1b0, AER_OBJECT_ORB = 0x1b1, AER_OBJECT_ROLLYPOLLY = 0x1b2, AER_OBJECT_ROLLYROCKET = 0x1b3, AER_OBJECT_CRYSTALLANCE = 0x1b4, AER_OBJECT_CRYSTALMARKER = 0x1b5, AER_OBJECT_CRYSTALMAKER = 0x1b6, AER_OBJECT_CRYSTAL = 0x1b7, AER_OBJECT_DIAMONDBULLET = 0x1b8, AER_OBJECT_BYUUBLOCKCOLLIDER = 0x1b9, AER_OBJECT_BOMB = 0x1ba, AER_OBJECT_LEAPFLAME = 0x1bb, AER_OBJECT_RAILLASER = 0x1bc, AER_OBJECT_CANNONCHUNK = 0x1bd, AER_OBJECT_WARPHAMMER = 0x1be, AER_OBJECT_HOLOAIMER = 0x1bf, AER_OBJECT_CHARFIRESHADOW = 0x1c0, AER_OBJECT_BLASTSHOCKWAVE = 0x1c1, AER_OBJECT_BLAST = 0x1c2, AER_OBJECT_BOUNCESPARK = 0x1c3, AER_OBJECT_DROPLET = 0x1c4, AER_OBJECT_DUSTPILLAR = 0x1c5, AER_OBJECT_FADEDEBRI = 0x1c6, AER_OBJECT_BREAKDEBRI = 0x1c7, AER_OBJECT_SPINDEBRI = 0x1c8, AER_OBJECT_FIRE = 0x1c9, AER_OBJECT_FLAG = 0x1ca, AER_OBJECT_FOOTPRINT = 0x1cb, AER_OBJECT_GRASSCLIPPING = 0x1cc, AER_OBJECT_IMAGEFADE = 0x1cd, AER_OBJECT_IMAGESTAY = 0x1ce, AER_OBJECT_IMAGEPART = 0x1cf, AER_OBJECT_MEATBLAST = 0x1d0, AER_OBJECT_SHATTER = 0x1d1, AER_OBJECT_SNAPFX = 0x1d2, AER_OBJECT_SPARKFLASH = 0x1d3, AER_OBJECT_SPARKSHOWER = 0x1d4, AER_OBJECT_SPLASH = 0x1d5, AER_OBJECT_TELEPORTERFX = 0x1d6, AER_OBJECT_BLOODPART = 0x1d7, AER_OBJECT_BLOODSPRAY = 0x1d8, AER_OBJECT_BLOODSTAIN = 0x1d9, AER_OBJECT_VIRUSSTAIN = 0x1da, AER_OBJECT_GIBLET = 0x1db, AER_OBJECT_FRIEDGIB = 0x1dc, AER_OBJECT_TELEPORTFX = 0x1dd, AER_OBJECT_GOGGLETRAIL = 0x1de, AER_OBJECT_DASHDIAMOND = 0x1df, AER_OBJECT_BURNTGROUND = 0x1e0, AER_OBJECT_DEATHDUST = 0x1e1, AER_OBJECT_SMOKESMALL = 0x1e2, AER_OBJECT_SMOKE = 0x1e3, AER_OBJECT_ROCKETSPLIT = 0x1e4, AER_OBJECT_EXPLOSIONPARTICLE = 0x1e5, AER_OBJECT_DUSTDASH = 0x1e6, AER_OBJECT_MISSILESMOKE = 0x1e7, AER_OBJECT_PARRYFLASH = 0x1e8, AER_OBJECT_RUNDUST = 0x1e9, AER_OBJECT_SHIELDDUST = 0x1ea, AER_OBJECT_IMPACTDUST = 0x1eb, AER_OBJECT_SMOKESPAWN = 0x1ec, AER_OBJECT_DUSTBALL = 0x1ed, AER_OBJECT_SLIMETRAIL = 0x1ee, AER_OBJECT_SLIMEPART = 0x1ef, AER_OBJECT_TWOFRAMEDEATH = 0x1f0, AER_OBJECT_BIRDMANTUMBLE = 0x1f1, AER_OBJECT_MUZZLEFLASH = 0x1f2, AER_OBJECT_ZELISKAEMMITTER = 0x1f3, AER_OBJECT_RAILLASERFADE = 0x1f4, AER_OBJECT_SHIELDPUSHSMALL = 0x1f5, AER_OBJECT_SHIELDPUSHMEDIUM = 0x1f6, AER_OBJECT_SHIELDPUSHLARGE = 0x1f7, AER_OBJECT_MASTERMUFFLER = 0x1f8, AER_OBJECT_XPSOUND = 0x1f9, AER_OBJECT_MISSILEHALF = 0x1fa, AER_OBJECT_FIREONGROUND = 0x1fb, AER_OBJECT_EXECUTEDELAYEDOBJ = 0x1fc, AER_OBJECT_OBJCTTVIDEOPLAYER = 0x1fd } AERObjectIndex; /* ----- PUBLIC FUNCTIONS ----- */ /** * @brief Register a custom object. * * @param[in] name Name of new object. * @param[in] parentIdx Object from which to inherit. * @param[in] spriteIdx Default sprite for instances of this object. * @param[in] maskIdx Default collision mask for instances of this object. * @param[in] depth Default render depth for instances of this object. * @param[in] visible Default visibility for instances of this object. * @param[in] collisions Whether or not collision checking is enabled for all * instances of this object. * @param[in] persistent Default persistence for instances of this object. * * @return Index of new object or ::AER_OBJECT_NULL if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside object registration stage. * @throw ::AER_NULL_ARG if argument `name` is `NULL`. * @throw ::AER_FAILED_LOOKUP if argument `parentIdx` is an invalid object * or either argument `spriteIdx` or `maskIdx` is an invalid sprite. * @throw ::AER_BAD_VAL if argument `name` already in use by another object. * * @since 1.0.0 * * @sa AERModDef::registerObjects */ int32_t AERObjectRegister(const char* name, int32_t parentIdx, int32_t spriteIdx, int32_t maskIdx, int32_t depth, bool visible, bool collisions, bool persistent); /** * @brief Query the total number of vanilla and mod objects registered. * * @return Number of objects or `0` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called before start of object registration stage. * * @since 1.0.0 */ size_t AERObjectGetNumRegistered(void); /** * @brief Query the object with a specific name. * * @param[in] name Name of object. * * @return Object index or ::AER_OBJECT_NULL if unsuccessful. * * @throw ::AER_SEQ_BREAK if called before start of object registration stage. * @throw ::AER_NULL_ARG if argument `name` is `NULL`. * @throw ::AER_FAILED_LOOKUP if no object with name given by argument `name`. * * @since 1.1.0 */ int32_t AERObjectGetByName(const char* name); /** * @brief Query the name of an object. * * @param[in] objIdx Object of interest. * * @return Name of object of `NULL` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called before start of object registration stage. * @throw ::AER_FAILED_LOOKUP if argument `objIdx` is an invalid object. * * @since 1.0.0 */ const char* AERObjectGetName(int32_t objIdx); /** * @brief Query the parent of an object. * * @param[in] objIdx Object of interest. * * @return Parent object's index or ::AER_OBJECT_NULL if unsuccessful. * * @throw ::AER_SEQ_BREAK if called before start of object registration stage. * @throw ::AER_FAILED_LOOKUP if argument `objIdx` is an invalid object. * * @since 1.0.0 */ int32_t AERObjectGetParent(int32_t objIdx); /** * @brief Query the children of an object. * * @warning Argument `objBuf` must be large enough to hold at least * `bufSize` elements. * * @note Argument `bufSize` may be `0` in which case argument `objBuf` may * be `NULL`. This may be used to efficiently query the total number of * children of the object. * * @param[in] objIdx Object of interest. * @param[in] recursive Whether to query only direct (`false`) or both direct * and indirect (`true`) children. * @param[in] bufSize Maximum number of elements to write to argument * `objBuf`. * @param[out] objBuf Buffer to write object indexes to. * * @return Total number of child objects or `0` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called before start of object registration stage. * @throw ::AER_NULL_ARG if argument `objBuf` is `NULL` and argument * `bufSize` is greater than `0`. * @throw ::AER_FAILED_LOOKUP if argument `objIdx` is an invalid object. * * @since 1.0.0 */ size_t AERObjectGetChildren(int32_t objIdx, bool recursive, size_t bufSize, int32_t* objBuf); /** * @brief Query whether or not an object has collision checking enabled. * * @param[in] objIdx Object of interest. * * @return Whether object has collision checking enabled or `false` if * unsuccessful. * * @throw ::AER_SEQ_BREAK if called before start of object registration stage. * @throw ::AER_FAILED_LOOKUP if argument `objIdx` is an invalid object. * * @since 1.0.0 */ bool AERObjectGetCollisions(int32_t objIdx); /** * @brief Set whether or not an object has collision checking enabled. * * @param[in] objIdx Object of interest. * @param[in] collisions Whether or not to enable collision checking. * * @throw ::AER_SEQ_BREAK if called before start of object registration stage. * @throw ::AER_FAILED_LOOKUP if argument `objIdx` is an invalid object. * * @since 1.0.0 */ void AERObjectSetCollisions(int32_t objIdx, bool collisions); /** * @brief Query the default persistence of an object. * * @param[in] objIdx Object of interest. * * @return Default persistence or `false` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called before start of object registration stage. * @throw ::AER_FAILED_LOOKUP if argument `objIdx` is an invalid object. * * @since 1.3.0 */ bool AERObjectGetPersistent(int32_t objIdx); /** * @brief Set the default persistence of an object. * * @param[in] objIdx Object of interest. * @param[in] persistent Default persistence. * * @throw ::AER_SEQ_BREAK if called before start of object registration stage. * @throw ::AER_FAILED_LOOKUP if argument `objIdx` is an invalid object. * * @since 1.3.0 */ void AERObjectSetPersistent(int32_t objIdx, bool persistent); /** * @brief Query the default visibility of an object. * * @param[in] objIdx Object of interest. * * @return Default visibility or `false` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called before start of object registration stage. * @throw ::AER_FAILED_LOOKUP if argument `objIdx` is an invalid object. * * @since 1.3.0 */ bool AERObjectGetVisible(int32_t objIdx); /** * @brief Set the default visibility of an object. * * @param[in] objIdx Object of interest. * @param[in] visible Default visibility. * * @throw ::AER_SEQ_BREAK if called before start of object registration stage. * @throw ::AER_FAILED_LOOKUP if argument `objIdx` is an invalid object. * * @since 1.3.0 */ void AERObjectSetVisible(int32_t objIdx, bool visible); /** * @brief Attach a creation event listener to an object. * * This event listener is called whenever an instance of the object * is created. * * @note There are certain conditions under which an instance may be * created without triggering a creation event. * * @param[in] objIdx Object of interest. * @param[in] listener Callback function executed when target event occurs. * For more information see @ref ObjListeners. * * @throw ::AER_SEQ_BREAK if called outside listener registration stage. * @throw ::AER_NULL_ARG if argument `listener` is `NULL`. * @throw ::AER_FAILED_LOOKUP if argument `objIdx` is an invalid object. * * @since 1.0.0 * * @sa AERModDef::registerObjectListeners * @sa AERInstanceCreate */ void AERObjectAttachCreateListener(int32_t objIdx, bool (*listener)(AEREvent* event, AERInstance* target, AERInstance* other)); /** * @brief Attach a destruction event listener to an object. * * This event listener is called whenever an instance of the object * is destroyed. * * @note There are certain conditions under which an instance may be * destroyed without triggering a destruction event. * * @param[in] objIdx Object of interest. * @param[in] listener Callback function executed when target event occurs. * For more information see @ref ObjListeners. * * @throw ::AER_SEQ_BREAK if called outside listener registration stage. * @throw ::AER_NULL_ARG if argument `listener` is `NULL`. * @throw ::AER_FAILED_LOOKUP if argument `objIdx` is an invalid object. * * @since 1.0.0 * * @sa AERModDef::registerObjectListeners * @sa AERInstanceDestroy * @sa AERInstanceDelete */ void AERObjectAttachDestroyListener(int32_t objIdx, bool (*listener)(AEREvent* event, AERInstance* target, AERInstance* other)); /** * @brief Attach an alarm event listener to an object. * * This event listener is called whenever the target alarm of an * instance of the object reaches `0` (after which the alarm will be set to * `-1`, disabling it until manually set again). * * @param[in] objIdx Object of interest. * @param[in] alarmIdx Alarm to watch. * @param[in] listener Callback function executed when target event occurs. * For more information see @ref ObjListeners. * * @throw ::AER_SEQ_BREAK if called outside listener registration stage. * @throw ::AER_NULL_ARG if argument `listener` is `NULL`. * @throw ::AER_FAILED_LOOKUP if argument `objIdx` is an invalid object or if * argument `alarmIdx` is not on the interval [0, 11]. * * @since 1.0.0 * * @sa AERModDef::registerObjectListeners * @sa AERInstanceGetAlarm * @sa AERInstanceSetAlarm */ void AERObjectAttachAlarmListener(int32_t objIdx, uint32_t alarmIdx, bool (*listener)(AEREvent* event, AERInstance* target, AERInstance* other)); /** * @brief Attach a step event listener to an object. * * This event listener is called once in the middle of every step * for each instance of the object. * * @param[in] objIdx Object of interest. * @param[in] listener Callback function executed when target event occurs. * For more information see @ref ObjListeners. * * @throw ::AER_SEQ_BREAK if called outside listener registration stage. * @throw ::AER_NULL_ARG if argument `listener` is `NULL`. * @throw ::AER_FAILED_LOOKUP if argument `objIdx` is an invalid object. * * @since 1.0.0 * * @sa AERModDef::registerObjectListeners */ void AERObjectAttachStepListener(int32_t objIdx, bool (*listener)(AEREvent* event, AERInstance* target, AERInstance* other)); /** * @brief Attach a pre-step event listener to an object. * * This event listener is called once at the start of every step * for each instance of the object. * * @note The listener is called *after* AERModDef::gameStepListener. * * @param[in] objIdx Object of interest. * @param[in] listener Callback function executed when target event occurs. * For more information see @ref ObjListeners. * * @throw ::AER_SEQ_BREAK if called outside listener registration stage. * @throw ::AER_NULL_ARG if argument `listener` is `NULL`. * @throw ::AER_FAILED_LOOKUP if argument `objIdx` is an invalid object. * * @since 1.0.0 * * @sa AERModDef::registerObjectListeners */ void AERObjectAttachPreStepListener(int32_t objIdx, bool (*listener)(AEREvent* event, AERInstance* target, AERInstance* other)); /** * @brief Attach a post-step event listener to an object. * * This event listener is called once at the end of every step * for each instance of the object. * * @param[in] objIdx Object of interest. * @param[in] listener Callback function executed when target event occurs. * For more information see @ref ObjListeners. * * @throw ::AER_SEQ_BREAK if called outside listener registration stage. * @throw ::AER_NULL_ARG if argument `listener` is `NULL`. * @throw ::AER_FAILED_LOOKUP if argument `objIdx` is an invalid object. * * @since 1.0.0 * * @sa AERModDef::registerObjectListeners */ void AERObjectAttachPostStepListener(int32_t objIdx, bool (*listener)(AEREvent* event, AERInstance* target, AERInstance* other)); /** * @brief Attach a collision event listener to an object. * * This event listener is called when a collision occurs between * instances of the target object and the other object. * * @note In order for the listener to be called, **both** the target object and * the other object must have collisions enabled. * * @param[in] targetObjIdx Object of interest. * @param[in] otherObjIdx Other object. * @param[in] listener Callback function executed when target event occurs. * For more information see @ref ObjListeners. * * @throw ::AER_SEQ_BREAK if called outside listener registration stage. * @throw ::AER_NULL_ARG if argument `listener` is `NULL`. * @throw ::AER_FAILED_LOOKUP if argument `targetObjIdx` or `otherObjIdx` * are invalid objects. * * @since 1.0.0 * * @sa AERModDef::registerObjectListeners * @sa AERObjectGetCollisions * @sa AERObjectSetCollisions */ void AERObjectAttachCollisionListener(int32_t targetObjIdx, int32_t otherObjIdx, bool (*listener)(AEREvent* event, AERInstance* target, AERInstance* other)); /** * @brief Attach an animation-end event listener to an object. * * This event listener is called whenever the animation frame of an instance * of the object loops back to `0.0f`. * * @param[in] objIdx Object of interest. * @param[in] listener Callback function executed when target event occurs. * For more information see @ref ObjListeners. * * @throw ::AER_SEQ_BREAK if called outside listener registration stage. * @throw ::AER_NULL_ARG if argument `listener` is `NULL`. * @throw ::AER_FAILED_LOOKUP if argument `objIdx` is an invalid object. * * @since 1.0.0 * * @sa AERModDef::registerObjectListeners * @sa AERInstanceGetSpriteFrame * @sa AERInstanceSetSpriteFrame * @sa AERInstanceGetSpriteSpeed * @sa AERInstanceSetSpriteSpeed */ void AERObjectAttachAnimationEndListener(int32_t objIdx, bool (*listener)(AEREvent* event, AERInstance* target, AERInstance* other)); /** * @brief Attach a draw event listener to an object. * * Draw events behave a bit differently from all the other types of events. The * biggest difference is that draw events are **not** inherited. * * The draw event is one of the more performance taxing events in the engine, so * it would be a good idea to treat it as a "read-only" event. That is to say * that draw listeners should not change any game state, only read state and * draw to the screen. * * @param[in] objIdx Object of interest. * @param[in] listener Callback function executed when target event occurs. * For more information see @ref ObjListeners. * * @throw ::AER_SEQ_BREAK if called outside listener registration stage. * @throw ::AER_NULL_ARG if argument `listener` is `NULL`. * @throw ::AER_FAILED_LOOKUP if argument `objIdx` is an invalid object. * * @since 1.1.0 * * @sa AERModDef::registerObjectListeners * @sa draw.h */ void AERObjectAttachDrawListener(int32_t objIdx, bool (*listener)(AEREvent* event, AERInstance* target, AERInstance* other)); /** * @brief Attach a GUI-draw event listener to an object. * * The GUI-draw event is similar to the normal draw event, but it draws * directly to the screen-space after all of the normal draw events. * * @param[in] objIdx Object of interest. * @param[in] listener Callback function executed when target event occurs. * For more information see @ref ObjListeners. * * @throw ::AER_SEQ_BREAK if called outside listener registration stage. * @throw ::AER_NULL_ARG if argument `listener` is `NULL`. * @throw ::AER_FAILED_LOOKUP if argument `objIdx` is an invalid object. * * @since 1.1.0 * * @sa AERModDef::registerObjectListeners * @sa draw.h */ void AERObjectAttachGUIDrawListener(int32_t objIdx, bool (*listener)(AEREvent* event, AERInstance* target, AERInstance* other)); #endif /* AER_OBJECT_H */
Foxbud/libaermre
include/public/aer/core.h
<gh_stars>1-10 /** * @file * * @brief Uncategorized functions for querying and manipulating game state. * * @since 1.0.0 * * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef AER_CORE_H #define AER_CORE_H #include <stdbool.h> #include <stdint.h> /* ----- PUBLIC FUNCTIONS ----- */ /** * @brief Query the number of steps (ticks) elapsed since the start * of the game. * * @return Number of steps or `0` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * * @since 1.0.0 */ uint32_t AERGetNumSteps(void); /** * @brief Query the pause state of the game. * * @return `true` if game is paused or `false` if unsuccessful or game is not * paused. * * @throw ::AER_SEQ_BREAK if called outside action stage. * * @since 1.0.0 * * @sa AERModDef::gamePauseListener */ bool AERGetPaused(void); #endif /* AER_CORE_H */
Foxbud/libaermre
include/public/aer/conf.h
/** * @file * * @brief Utilities for parsing configuration data. * * *Special thanks to <NAME> for helping design this section of the API.* * * @since 1.0.0 * * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef AER_CONF_H #define AER_CONF_H #include <stdbool.h> #include <stddef.h> #include <stdint.h> /* ----- PUBLIC FUNCTIONS ----- */ /** * @brief Parse a boolean value from the configuration data. * * @param[in] key Configuration key. * * @return Value of the key or `false` if unsuccessful. * * @throw ::AER_NULL_ARG if argument `key` is `NULL`. * @throw ::AER_FAILED_LOOKUP if argument `key` is an invalid configuration * key. * @throw ::AER_FAILED_PARSE if key does not contain a boolean value. * * @since 1.0.0 * * @sa AERConfManGetBools */ bool AERConfGetBool(const char* key); /** * @brief Parse an array of boolean values from the configuration data. * * @warning Argument `boolBuf` must be large enough to hold at least * `bufSize` elements. * * @note Argument `bufSize` may be `0` in which case argument `boolBuf` may * be `NULL`. This may be used to efficiently query the total number of * booleans contained in the configuration data. * * @param[in] key Configuration key. * @param[in] bufSize Maximum number of elements to write to argument * `boolBuf`. * @param[out] boolBuf Buffer to write booleans to. * * @return Total number of booleans contained in configuration data or `0` * if unsuccessful. * * @throw ::AER_NULL_ARG if argument `key` is `NULL` or argument `boolBuf` * is `NULL` and argument `bufSize` is greater than `0`. * @throw ::AER_FAILED_LOOKUP if argument `key` is an invalid configuration * key. * @throw ::AER_FAILED_PARSE if key does not contain boolean values. * * @since 1.0.0 * * @sa AERConfManGetBool */ size_t AERConfGetBools(const char* key, size_t bufSize, bool* boolBuf); /** * @brief Parse an integer value from the configuration data. * * @param[in] key Configuration key. * * @return Value of the key or `0` if unsuccessful. * * @throw ::AER_NULL_ARG if argument `key` is `NULL`. * @throw ::AER_FAILED_LOOKUP if argument `key` is an invalid configuration * key. * @throw ::AER_FAILED_PARSE if key does not contain an integer value. * * @since 1.0.0 * * @sa AERConfManGetInts */ int64_t AERConfGetInt(const char* key); /** * @brief Parse an array of integer values from the configuration data. * * @warning Argument `intBuf` must be large enough to hold at least * `bufSize` elements. * * @note Argument `bufSize` may be `0` in which case argument `intBuf` may * be `NULL`. This may be used to efficiently query the total number of * integers contained in the configuration data. * * @param[in] key Configuration key. * @param[in] bufSize Maximum number of elements to write to argument * `intBuf`. * @param[out] intBuf Buffer to write integers to. * * @return Total number of integers contained in configuration data or `0` * if unsuccessful. * * @throw ::AER_NULL_ARG if argument `key` is `NULL` or argument `intBuf` * is `NULL` and argument `bufSize` is greater than `0`. * @throw ::AER_FAILED_LOOKUP if argument `key` is an invalid configuration * key. * @throw ::AER_FAILED_PARSE if key does not contain integer values. * * @since 1.0.0 * * @sa AERConfManGetInt */ size_t AERConfGetInts(const char* key, size_t bufSize, int64_t* intBuf); /** * @brief Parse a double value from the configuration data. * * @param[in] key Configuration key. * * @return Value of the key or `0.0` if unsuccessful. * * @throw ::AER_NULL_ARG if argument `key` is `NULL`. * @throw ::AER_FAILED_LOOKUP if argument `key` is an invalid configuration * key. * @throw ::AER_FAILED_PARSE if key does not contain a double value. * * @since 1.0.0 * * @sa AERConfManGetDoubles */ double AERConfGetDouble(const char* key); /** * @brief Parse an array of double values from the configuration data. * * @warning Argument `doubleBuf` must be large enough to hold at least * `bufSize` elements. * * @note Argument `bufSize` may be `0` in which case argument `doubleBuf` may * be `NULL`. This may be used to efficiently query the total number of * doubles contained in the configuration data. * * @param[in] key Configuration key. * @param[in] bufSize Maximum number of elements to write to argument * `doubleBuf`. * @param[out] doubleBuf Buffer to write doubles to. * * @return Total number of doubles contained in configuration data or `0` * if unsuccessful. * * @throw ::AER_NULL_ARG if argument `key` is `NULL` or argument `doubleBuf` * is `NULL` and argument `bufSize` is greater than `0`. * @throw ::AER_FAILED_LOOKUP if argument `key` is an invalid configuration * key. * @throw ::AER_FAILED_PARSE if key does not contain double values. * * @since 1.0.0 * * @sa AERConfManGetDouble */ size_t AERConfGetDoubles(const char* key, size_t bufSize, double* doubleBuf); /** * @brief Parse a string from the configuration data. * * @param[in] key Configuration key. * * @return Value of the key or `NULL` if unsuccessful. * * @throw ::AER_NULL_ARG if argument `key` is `NULL`. * @throw ::AER_FAILED_LOOKUP if argument `key` is an invalid configuration * key. * @throw ::AER_FAILED_PARSE if key does not contain a string. * * @since 1.0.0 * * @sa AERConfManGetStrings */ const char* AERConfGetString(const char* key); /** * @brief Parse an array of strings from the configuration data. * * @warning Argument `strBuf` must be large enough to hold at least * `bufSize` elements. * * @note Argument `bufSize` may be `0` in which case argument `strBuf` may * be `NULL`. This may be used to efficiently query the total number of * strings contained in the configuration data. * * @param[in] key Configuration key. * @param[in] bufSize Maximum number of elements to write to argument * `strBuf`. * @param[out] strBuf Buffer to write strings to. * * @return Total number of strings contained in configuration data or `0` * if unsuccessful. * * @throw ::AER_NULL_ARG if argument `key` is `NULL` or argument `strBuf` * is `NULL` and argument `bufSize` is greater than `0`. * @throw ::AER_FAILED_LOOKUP if argument `key` is an invalid configuration * key. * @throw ::AER_FAILED_PARSE if key does not contain strings. * * @since 1.0.0 * * @sa AERConfManGetString */ size_t AERConfGetStrings(const char* key, size_t bufSize, const char** strBuf); #endif /* AER_CONF_H */
Foxbud/libaermre
src/room.c
/** * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <assert.h> #include "foxutils/stringmapmacs.h" #include "aer/room.h" #include "internal/core.h" #include "internal/err.h" #include "internal/export.h" #include "internal/hld.h" #include "internal/room.h" /* ----- PRIVATE GLOBALS ----- */ static FoxMap roomNames = {0}; /* ----- INTERNAL GLOBALS ----- */ int32_t roomIndexPrevious = AER_ROOM__INIT; /* ----- INTERNAL FUNCTIONS ----- */ void RoomManBuildNameTable(void) { size_t numRooms = hldvars.roomTable->size; for (uint32_t roomIdx = 0; roomIdx < numRooms; roomIdx++) { HLDRoom* room = HLDRoomLookup(roomIdx); assert(room); *FoxMapMInsert(const char*, int32_t, &roomNames, room->name) = roomIdx; } return; } void RoomManConstructor(void) { LogInfo("Initializing room module..."); FoxStringMapMInit(int32_t, &roomNames); LogInfo("Done initializing room module."); return; } void RoomManDestructor(void) { LogInfo("Deinitializing room module..."); /* Deinitialize name table. */ FoxMapMDeinit(const char*, int32_t, &roomNames); roomNames = (FoxMap){0}; LogInfo("Done deinitializing room module."); return; } /* ----- PUBLIC FUNCTIONS ----- */ AER_EXPORT int32_t AERRoomGetCurrent(void) { #define errRet AER_ROOM_NULL EnsureStage(STAGE_ACTION); Ok(*hldvars.roomIndexCurrent); #undef errRet } AER_EXPORT void AERRoomGoto(int32_t roomIdx) { #define errRet EnsureStage(STAGE_ACTION); EnsureLookup(HLDRoomLookup(roomIdx)); hldfuncs.actionRoomGoto(roomIdx, 0); Ok(); #undef errRet } AER_EXPORT int32_t AERRoomGetByName(const char* name) { #define errRet AER_ROOM_NULL EnsureStage(STAGE_ACTION); EnsureArg(name); int32_t* roomIdx = FoxMapMIndex(const char*, int32_t, &roomNames, name); EnsureLookup(roomIdx); Ok(*roomIdx); #undef errRet } AER_EXPORT const char* AERRoomGetName(int32_t roomIdx) { #define errRet NULL EnsureStage(STAGE_ACTION); HLDRoom* room = HLDRoomLookup(roomIdx); EnsureLookup(room); Ok(room->name); #undef errRet }
Foxbud/libaermre
include/private/internal/core.h
/** * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef INTERNAL_CORE_H #define INTERNAL_CORE_H /* ----- INTERNAL TYPES ----- */ typedef enum CoreStage { STAGE_INIT, STAGE_SPRITE_REG, STAGE_FONT_REG, STAGE_OBJECT_REG, STAGE_LISTENER_REG, STAGE_ACTION, STAGE_DRAW } CoreStage; /* ----- INTERNAL GLOBALS ----- */ extern CoreStage stage; /* ----- INTERNAL FUNCTIONS ----- */ const char* CoreGetAbsAssetPath(const char* modName, const char* relAssetPath); #endif /* INTERNAL_CORE_H */
Foxbud/libaermre
include/private/internal/hld.h
<filename>include/private/internal/hld.h /** * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef INTERNAL_HLD_H #define INTERNAL_HLD_H #include <assert.h> #include <stdbool.h> #include <stddef.h> #include <stdint.h> #include <stdlib.h> /* ----- INTERNAL MACROS ----- */ #define HLDPrimitiveMakeUndefined(name) \ HLDPrimitive name = {.type = HLD_PRIMITIVE_UNDEFINED} #define HLDPrimitiveMakeReal(name, initVal) \ HLDPrimitive name = {.value.r = (initVal), .type = HLD_PRIMITIVE_REAL} #define HLDPrimitiveMakeStringS(name, str, len) \ HLDPrimitiveString name##InnerValue = { \ .chars = (str), .refs = 1, .length = (len)}; \ HLDPrimitive name = {.value.p = &name##InnerValue, \ .type = HLD_PRIMITIVE_STRING} #define HLDPrimitiveMakeStringH(name, str, len) \ HLDPrimitiveString* name##InnerValue = malloc(sizeof(HLDPrimitiveString)); \ assert(name##InnerValue); \ name##InnerValue->chars = (str); \ name##InnerValue->refs = 1; \ name##InnerValue->length = (len); \ HLDPrimitive name = {.value.p = name##InnerValue, \ .type = HLD_PRIMITIVE_STRING} #define HLDAPICallAdv(api, target, other, ...) \ ({ \ HLDPrimitive HLDAPICallAdv_argv[] = {__VA_ARGS__}; \ HLDPrimitiveMakeUndefined(HLDAPICallAdv_result); \ (api)(&HLDAPICallAdv_result, (target), (other), \ sizeof(HLDAPICallAdv_argv) / sizeof(HLDPrimitive), \ HLDAPICallAdv_argv); \ HLDAPICallAdv_result; \ }) #define HLDAPICall(api, ...) HLDAPICallAdv((api), NULL, NULL, ##__VA_ARGS__) #define HLDScriptCallAdv(script, target, other, ...) \ ({ \ HLDPrimitive* HLDScriptCallAdv_argv[] = {__VA_ARGS__}; \ HLDPrimitiveMakeUndefined(HLDScriptCallAdv_result); \ (script)((target), (other), &HLDScriptCallAdv_result, \ sizeof(HLDScriptCallAdv_argv) / sizeof(HLDPrimitive*), \ HLDScriptCallAdv_argv); \ HLDScriptCallAdv_result; \ }) #define HLDScriptCall(script, ...) \ HLDScriptCallAdv((script), NULL, NULL, ##__VA_ARGS__) #define HLDObjectLookup(objIdx) \ ((HLDObject*)HLDOpenHashTableLookup(*hldvars.objectTableHandle, (objIdx))) #define HLDInstanceLookup(instId) \ ((HLDInstance*)HLDOpenHashTableLookup(hldvars.instanceTable, (instId))) /* ----- INTERNAL TYPES ----- */ typedef enum HLDEventType { HLD_EVENT_CREATE, HLD_EVENT_DESTROY, HLD_EVENT_ALARM, HLD_EVENT_STEP, HLD_EVENT_COLLISION, HLD_EVENT_UNKNOWN_0, HLD_EVENT_UNKNOWN_1, HLD_EVENT_OTHER, HLD_EVENT_DRAW, HLD_EVENT_UNKNOWN_2, HLD_EVENT_UNKNOWN_3, HLD_EVENT_UNKNOWN_4, HLD_EVENT_UNKNOWN_5, HLD_EVENT_UNKNOWN_6, HLD_EVENT_UNKNOWN_7 } HLDEventType; typedef enum HLDEventStepType { HLD_EVENT_STEP_NORMAL, HLD_EVENT_STEP_PRE, HLD_EVENT_STEP_POST } HLDEventStepType; typedef enum HLDEventOtherType { HLD_EVENT_OTHER_ANIMATION_END = 7 } HLDEventOtherType; typedef enum HLDEventDrawType { HLD_EVENT_DRAW_NORMAL = 0, HLD_EVENT_DRAW_GUI_NORMAL = 64 } HLDEventDrawType; typedef struct HLDOpenHashItem { struct HLDOpenHashItem* prev; struct HLDOpenHashItem* next; int32_t key; void* value; } HLDOpenHashItem; typedef struct HLDOpenHashSlot { struct HLDOpenHashItem* first; struct HLDOpenHashItem* last; } HLDOpenHashSlot; typedef struct HLDOpenHashTable { struct HLDOpenHashSlot* slots; uint32_t keyMask; size_t numItems; } HLDOpenHashTable; typedef struct HLDClosedHashSlot { int32_t nameIdx; void* value; int32_t key; } HLDClosedHashSlot; typedef struct HLDClosedHashTable { size_t numSlots; size_t numItems; uint32_t keyMask; uint32_t field_C; struct HLDClosedHashSlot* slots; } HLDClosedHashTable; typedef struct HLDLookupTable { size_t size; uint32_t field_4; uint32_t field_8; void* elements; } HLDLookupTable; typedef struct HLDVecReal { float x; float y; } HLDVecReal; typedef struct HLDVecIntegral { int32_t x; int32_t y; } HLDVecIntegral; typedef struct HLDArrayPreSize { size_t size; void* elements; } HLDArrayPreSize; typedef struct HLDArrayPostSize { void* elements; size_t size; } HLDArrayPostSize; typedef enum HLDPrimitiveType { HLD_PRIMITIVE_REAL = 0x0, HLD_PRIMITIVE_STRING = 0x1, HLD_PRIMITIVE_ARRAY = 0x2, HLD_PRIMITIVE_PTR = 0x3, HLD_PRIMITIVE_VEC3 = 0x4, HLD_PRIMITIVE_UNDEFINED = 0x5, HLD_PRIMITIVE_OBJECT = 0x6, HLD_PRIMITIVE_INT32 = 0x7, HLD_PRIMITIVE_VEC4 = 0x8, HLD_PRIMITIVE_MATRIX = 0x9, HLD_PRIMITIVE_INT64 = 0xA, HLD_PRIMITIVE_ACCESSOR = 0xB, HLD_PRIMITIVE_NULL = 0xC, HLD_PRIMITIVE_BOOL = 0xD, HLD_PRIMITIVE_ITERATOR = 0xE, } HLDPrimitiveType; typedef union __attribute__((aligned(4))) HLDPrimitiveValue { uint32_t raw[3]; double r; void* p; int32_t i32; int64_t i64; bool b; } HLDPrimitiveValue; typedef struct HLDPrimitive { HLDPrimitiveValue value; HLDPrimitiveType type; } HLDPrimitive; typedef struct HLDPrimitiveString { const char* chars; size_t refs; size_t length; } HLDPrimitiveString; typedef struct __attribute__((aligned(4))) HLDPrimitiveArray { uint32_t field_0; struct HLDArrayPreSize* subArrays; void* field_8; uint32_t field_C; size_t numSubArrays; } HLDPrimitiveArray; typedef struct HLDEventSubscribers { int32_t* objects; uint32_t field_4; } HLDEventSubscribers; typedef struct HLDNamedFunction { const char* name; void* function; } HLDNamedFunction; typedef struct HLDNodeDLL { struct HLDNodeDLL* next; struct HLDNodeDLL* prev; void* item; } HLDNodeDLL; typedef struct HLDBoundingBox { int32_t left; int32_t top; int32_t right; int32_t bottom; } HLDBoundingBox; typedef struct HLDEvent { void* classDef; struct HLDEvent* eventNext; uint32_t field_8; uint32_t field_C; void* field_10; uint32_t field_14; uint32_t field_18; uint32_t field_1C; uint32_t field_20; uint32_t field_24; uint32_t field_28; uint32_t field_2C; uint32_t field_30; uint32_t field_34; uint32_t field_38; uint32_t field_3C; uint32_t field_40; uint32_t field_44; uint32_t field_48; uint32_t field_4C; uint32_t field_50; uint32_t field_54; void* field_58; const char* name; uint32_t handlerIndex; struct HLDNamedFunction* handler; uint32_t field_68; uint32_t field_6C; uint32_t field_70; uint32_t field_74; uint32_t field_78; uint32_t field_7C; } HLDEvent; typedef struct HLDEventWrapper { void* classDef; struct HLDEvent* event; void* field_08; uint32_t field_0C; } HLDEventWrapper; typedef struct HLDObject { struct { uint8_t solid : 1; uint8_t visible : 1; uint8_t persistent : 1; uint8_t : 1; uint8_t collisions : 1; uint8_t : 3; } flags; uint8_t field_1; uint8_t field_2; uint8_t field_3; int32_t spriteIndex; uint32_t depth; int32_t parentIndex; int32_t maskIndex; const char* name; int32_t index; uint32_t physics; uint32_t field_20; uint32_t field_24; uint32_t field_28; uint32_t field_2C; uint32_t field_30; uint32_t field_34; uint32_t field_38; uint32_t field_3C; uint32_t field_40; uint32_t field_44; struct HLDObject* parent; struct HLDArrayPreSize eventListeners[15]; struct HLDNodeDLL* instanceFirst; struct HLDNodeDLL* instanceLast; uint32_t numInstances; uint32_t field_D0; uint32_t field_D4; uint32_t field_D8; } HLDObject; typedef struct HLDInstance { void* classDef; uint32_t field_4; uint32_t field_8; uint32_t field_C; uint32_t field_10; uint32_t field_14; uint8_t field_18; uint8_t field_19; uint8_t field_1A; uint8_t field_1B; uint32_t field_1C; uint32_t field_20; uint32_t field_24; uint32_t tangible; uint32_t field_2C; uint32_t field_30; HLDClosedHashTable* locals; uint8_t field_38; bool visible; bool solid; bool persistent; bool marked; bool deactivated; uint8_t field_3E; uint8_t field_3F; uint32_t field_40; uint32_t field_44; uint32_t field_48; uint32_t id; int32_t objectIndex; struct HLDObject* object; uint32_t field_58; uint32_t field_5C; int32_t spriteIndex; float imageIndex; float imageSpeed; struct HLDVecReal imageScale; float imageAngle; float imageAlpha; uint32_t imageBlend; int32_t maskIndex; uint32_t field_84; struct HLDVecReal pos; struct HLDVecReal posStart; struct HLDVecReal posPrev; float direction; float speed; float friction; float gravityDir; float gravity; float speedX; float speedY; struct HLDBoundingBox bbox; int32_t alarms[12]; int32_t pathIndex; float pathPos; float pathPosPrev; uint32_t field_108; uint32_t field_10C; uint32_t field_110; uint32_t field_114; uint32_t field_118; uint32_t field_11C; uint32_t field_120; uint32_t field_124; uint32_t field_128; uint32_t field_12C; uint8_t field_130; uint8_t field_131; uint8_t field_132; uint8_t field_133; uint32_t field_134; uint32_t field_138; uint32_t field_13C; uint32_t field_140; uint32_t field_144; bool field_148; uint8_t field_149; uint8_t field_14A; uint8_t field_14B; struct HLDInstance* instanceNext; struct HLDInstance* instancePrev; float depth; uint32_t field_158; uint32_t lastUpdate; uint32_t field_160; uint32_t field_164; uint32_t field_168; uint32_t field_16C; uint32_t field_170; uint32_t field_174; uint32_t field_178; uint32_t field_17C; uint32_t field_180; } HLDInstance; typedef struct HLDView { bool visible; uint8_t field_1; uint8_t field_2; uint8_t field_3; HLDVecReal posRoom; HLDVecReal sizeRoom; HLDVecIntegral posPort; HLDVecIntegral sizePort; float angle; HLDVecIntegral border; HLDVecIntegral speed; int32_t objectIndex; int32_t surfaceId; int32_t camera; } HLDView; typedef struct HLDRoom { uint32_t field_0; struct HLDRoom* self; uint32_t field_8; uint32_t field_C; uint32_t field_10; uint32_t field_14; uint32_t field_18; uint32_t field_1C; uint32_t field_20; uint32_t field_24; uint32_t field_28; uint32_t field_2C; uint32_t field_30; uint32_t field_34; uint32_t field_38; uint32_t field_3C; uint32_t field_40; uint32_t field_44; HLDView* views[8]; uint32_t field_68; uint32_t field_6C; uint32_t field_70; uint32_t field_74; uint32_t field_78; uint32_t field_7C; struct HLDInstance* instanceFirst; struct HLDInstance* instanceLast; int32_t numInstances; uint32_t field_8C; uint32_t field_90; uint32_t field_94; uint32_t field_98; uint32_t field_9C; uint32_t field_A0; uint32_t field_A4; uint32_t field_A8; uint32_t field_AC; uint32_t field_B0; uint32_t field_B4; uint32_t field_B8; uint32_t field_BC; uint32_t field_C0; uint32_t field_C4; uint32_t field_C8; const char* name; uint32_t field_D0; uint32_t field_D4; uint32_t field_D8; uint32_t field_DC; uint32_t field_E0; uint32_t field_E4; uint32_t field_E8; uint32_t field_EC; uint32_t field_F0; uint32_t field_F4; uint32_t field_F8; uint32_t field_FC; uint32_t field_100; uint32_t field_104; uint32_t field_108; uint32_t field_10C; uint32_t field_110; uint32_t field_114; uint32_t field_118; uint32_t field_11C; uint32_t field_120; } HLDRoom; typedef struct HLDSprite { void* classDef; uint32_t field_4; uint32_t field_8; uint32_t field_C; uint32_t field_10; uint32_t field_14; uint32_t numImages; struct HLDVecIntegral size; struct HLDVecIntegral origin; uint32_t field_2C; uint32_t field_30; uint32_t field_34; uint32_t field_38; uint32_t field_3C; uint32_t field_40; uint32_t field_44; uint32_t field_48; uint32_t field_4C; uint32_t field_50; uint32_t field_54; uint32_t field_58; const char* name; uint32_t index; uint32_t field_64; uint32_t field_68; float speed; uint32_t field_70; uint32_t field_74; uint32_t field_78; uint32_t field_7C; uint32_t field_80; uint32_t field_84; } HLDSprite; typedef struct HLDFont { void* classDef; const char* fontname; size_t size; bool bold; bool italic; uint8_t field_E; uint8_t field_F; uint32_t field_10; uint32_t field_14; int32_t first; int32_t last; uint32_t field_20; uint32_t field_24; uint32_t field_28; uint32_t field_2C; uint32_t field_30; uint32_t field_34; uint32_t field_38; uint32_t field_3C; uint32_t field_40; uint32_t field_44; uint32_t field_48; uint32_t field_4C; uint32_t field_50; uint32_t field_54; uint32_t field_58; uint32_t field_5C; uint32_t field_60; uint32_t field_64; uint32_t field_68; uint32_t field_6C; uint32_t field_70; uint32_t field_74; uint32_t field_78; uint32_t field_7C; uint32_t field_80; uint32_t field_84; uint32_t field_88; uint32_t field_8C; } HLDFont; /* Builtin GML function signature. */ typedef void (*HLDAPICallback)(HLDPrimitive* result, HLDInstance* target, HLDInstance* other, size_t argc, HLDPrimitive* argv); /* Custom Heart Machine function signature. */ typedef HLDPrimitive* (*HLDScriptCallback)(HLDInstance* target, HLDInstance* other, HLDPrimitive* result, size_t argc, HLDPrimitive** argv); /* * This struct holds pointers to global variables in the Game Maker * engine. These pointers are passed into the MRE from the hooks injected * into the game's executable. */ typedef struct __attribute__((packed)) HLDVariables { /* Allocated GML hash tables. */ HLDArrayPostSize* maps; /* Number of steps since start of the game. */ int32_t* numSteps; /* Tables of booleans where each index represents a key code. */ bool (*keysPressedTable)[0x100]; bool (*keysHeldTable)[0x100]; bool (*keysReleasedTable)[0x100]; /* Tables of booleans where each index represents a mouse button. */ bool (*mouseButtonsPressedTable)[0x3]; bool (*mouseButtonsHeldTable)[0x3]; bool (*mouseButtonsReleasedTable)[0x3]; /* Mouse cursor position in pixels. */ uint32_t* mousePosX; uint32_t* mousePosY; /* Array of all registered rooms. */ HLDArrayPreSize* roomTable; /* Index of currently active room. */ int32_t* roomIndexCurrent; /* Actual room object of currently active room. */ HLDRoom** roomCurrent; /* Array of all registered sprites. */ HLDArrayPreSize* spriteTable; /* Array of all registered fonts. */ HLDArrayPreSize* fontTable; /* Index of currently active font. */ int32_t* fontIndexCurrent; /* Actual font object of currently active font. */ HLDFont** fontCurrent; /* Hash table of all registered objects. */ HLDOpenHashTable** objectTableHandle; /* Hash table of all in-game instances. */ HLDOpenHashTable* instanceTable; /* Lookup table of all instance local variable names. */ HLDLookupTable* instanceLocalTable; /* * As an optimization, the engine only checks for alarm events on objects * listed (or "subscribed") in these arrays. */ size_t (*alarmEventSubscriberCounts)[12]; HLDEventSubscribers (*alarmEventSubscribers)[12]; /* Same as above, but for step events. */ size_t (*stepEventSubscriberCounts)[3]; HLDEventSubscribers (*stepEventSubscribers)[3]; /* Addresses necessary for creating new events. */ void* eventClass; void* eventWrapperClass; /* * Not certain what this address even references, but the custom events * won't work unless some of their fields point to this address. */ void* unknownEventAddress; } HLDVariables; /* * This struct holds pointers to functions in the Game Maker * engine. These pointers are passed into the MRE from the hooks injected * into the game's executable. */ typedef struct __attribute__((packed)) HLDFunctions { /* Mouse x position relative to current room. */ int32_t (*actionMouseGetX)(int32_t unknown0); /* Mouse y position relative to current room. */ int32_t (*actionMouseGetY)(int32_t unknown0); /* Go to room. */ void (*actionRoomGoto)(int32_t roomIdx, int32_t unknown0); /* Register a new sprite. */ int32_t (*actionSpriteAdd)(const char* fname, size_t imgNum, int32_t unknown0, int32_t unknown1, int32_t unknown2, int32_t unknown3, uint32_t origX, uint32_t origY); /* Overwrite an existing sprite with a new one. */ void (*actionSpriteReplace)(int32_t spriteIdx, const char* fname, size_t imgNum, int32_t unknown0, int32_t unknown1, int32_t unknown2, int32_t unknown3, uint32_t origX, uint32_t origY); /* Register a new font. */ int32_t (*actionFontAdd)(const char* fname, size_t size, bool bold, bool italic, int32_t first, int32_t last); /* Register a new object. */ int32_t (*actionObjectAdd)(void); /* Trigger an event as if it occurred "naturally." */ int32_t (*actionEventPerform)(HLDInstance* target, HLDInstance* other, int32_t targetObjIdx, uint32_t eventType, int32_t eventNum); /* Get the current global draw alpha. */ float (*actionDrawGetAlpha)(void); /* Set the current global draw alpha. */ void (*actionDrawSetAlpha)(float alpha); /* Draw a sprite to the screen. */ void (*actionDrawSpriteGeneral)(HLDSprite* sprite, uint32_t imgNum, float left, float top, float width, float height, float x, float y, float scaleX, float scaleY, float angle, uint32_t blendNW, uint32_t blendNE, uint32_t blendSE, uint32_t blendSW, float alpha); /* Draw a line to the screen. */ void (*actionDrawLine)(float x1, float y1, float x2, float y2, float width, uint32_t color1, uint32_t color2); /* Draw an ellipse to the screen. */ void (*actionDrawEllipse)(float left, float top, float right, float bottom, uint32_t colorCenter, uint32_t colorEdge, bool outline); /* Draw a triangle to the screen. */ void (*actionDrawTriangle)(float x1, float y1, float x2, float y2, float x3, float y3, uint32_t color1, uint32_t color2, uint32_t color3, bool outline); /* Draw a rectangle to the screen. */ void (*actionDrawRectangle)(float left, float top, float right, float bottom, uint32_t colorNW, uint32_t colorNE, uint32_t colorSE, uint32_t colorSW, bool outline); /* Draw a string to the screen. */ void (*actionDrawText)(float x, float y, const char* text, int32_t height, uint32_t width, float scaleX, float scaleY, float angle, uint32_t colorNW, uint32_t colorNE, uint32_t colorSE, uint32_t colorSW, float alpha); /* Draw an instance's sprite. */ void (*actionDrawSelf)(HLDInstance* inst); /* Set the currently active draw font. */ void (*actionDrawSetFont)(int32_t fontIdx); /* Spawn a new instance of an object. */ HLDInstance* (*actionInstanceCreate)(int32_t objIdx, float posX, float posY); /* Change the object type of an instance. */ void (*actionInstanceChange)(HLDInstance* inst, int32_t newObjIdx, bool doEvents); /* Destroy an instance. */ void (*actionInstanceDestroy)(HLDInstance* inst0, HLDInstance* inst1, int32_t objIdx, bool doEvent); /* Set instance's position (and update bounding box accordingly). */ void (*Instance_setPosition)(HLDInstance* inst, float x, float y); /* Set instance's mask index. */ void (*Instance_setMaskIndex)(HLDInstance* inst, int32_t maskIndex); /* Set an instance's direction and speed based on its motion vector. */ void (*Instance_setMotionPolarFromCartesian)(HLDInstance* inst); /* Create a new GML map. Parameters: NULL. */ HLDAPICallback API_dsMapCreate; /* Retrieve value from a GML map. Parameters: id, key. */ HLDAPICallback API_dsMapFindValue; /* Set a GML map key to value. Parameters: id, key, val. */ HLDAPICallback API_dsMapSet; /* * Add a GML map to another GML map for JSON representation. * Parameters: id, key, val. */ HLDAPICallback API_dsMapAddMap; /* * Custom Heart Machine function that sets an instance's draw depth based * on its y position and the current room's height. */ HLDScriptCallback Script_Setdepth; } HLDFunctions; /* ----- INTERNAL GLOBALS ----- */ extern HLDVariables hldvars; extern HLDFunctions hldfuncs; /* ----- INTERNAL FUNCTIONS ----- */ HLDView* HLDViewLookup(uint32_t viewIdx); HLDSprite* HLDSpriteLookup(int32_t spriteIdx); HLDFont* HLDFontLookup(int32_t fontIdx); HLDRoom* HLDRoomLookup(int32_t roomIdx); void* HLDOpenHashTableLookup(HLDOpenHashTable* table, int32_t key); void* HLDClosedHashTableLookup(HLDClosedHashTable* table, int32_t key); HLDEvent* HLDEventNew(HLDNamedFunction* handler); HLDEventWrapper* HLDEventWrapperNew(HLDEvent* event); void HLDRecordEngineRefs(HLDVariables* vars, HLDFunctions* funcs); #endif /* INTERNAL_HLD_H */
Foxbud/libaermre
include/public/aer/sprite.h
<filename>include/public/aer/sprite.h /** * @file * * @brief Utilities for querying and manipulating sprites. * * @since 1.0.0 * * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef AER_SPRITE_H #define AER_SPRITE_H #include <stddef.h> #include <stdint.h> /* ----- PUBLIC TYPES ----- */ /* @deprecated Since 1.2.0. */ #define AER_SPRITE_SPRITE3368 AER_SPRITE_SPRITE3368 __attribute__((deprecated)) /* @deprecated Since 1.2.0. */ #define AER_SPRITE_SPRITE3369 AER_SPRITE_SPRITE3369 __attribute__((deprecated)) /* @deprecated Since 1.2.0. */ #define AER_SPRITE_SPRITE3370 AER_SPRITE_SPRITE3370 __attribute__((deprecated)) /** * @brief Vanilla sprites. * * @since 1.0.0 */ typedef enum AERSpriteIndex { /** * @brief Flag which represents either no sprite or an invalid sprite * depending on context. */ AER_SPRITE_NULL = -1, AER_SPRITE_CRAZYBGCOLORS = 0x0, AER_SPRITE_POINT = 0x1, AER_SPRITE_PINKBLOCK = 0x2, AER_SPRITE_WHITEPIXEL = 0x3, AER_SPRITE_3VERTPIXELSCENTERED = 0x4, AER_SPRITE_WHITEPIXELFADE = 0x5, AER_SPRITE_WHITELINE8 = 0x6, AER_SPRITE_BLACKPIXEL = 0x7, AER_SPRITE_2WHITEPIXELS = 0x8, AER_SPRITE_WHITEBLOCK = 0x9, AER_SPRITE_BLOCK16 = 0xa, AER_SPRITE_NONE = 0xb, AER_SPRITE_DISTORTIONBASE = 0xc, AER_SPRITE_BGPARALLAXBATTLEROOM02CLOUD = 0xd, AER_SPRITE_BGTESTGRID = 0xe, AER_SPRITE_BGCOLORS = 0xf, AER_SPRITE_BGINFLOOR = 0x10, AER_SPRITE_BGINPRLX1 = 0x11, AER_SPRITE_BGINFLOORDREGS = 0x12, AER_SPRITE_BGIN01BROKENSHALLOWSDODGE = 0x13, AER_SPRITE_BGIN01BROKENSHALLOWSHARDLIGHT = 0x14, AER_SPRITE_BGIN01BROKENSHALLOWSOVERLAY = 0x15, AER_SPRITE_BGIN02TUTORIALDODGE = 0x16, AER_SPRITE_BGIN02TUTORIALOVERLAY = 0x17, AER_SPRITE_BGIN03TUTCOMBATDODGE = 0x18, AER_SPRITE_BGIN03TUTCOMBATOVERLAY = 0x19, AER_SPRITE_BGINBACKERTABLETDODGE = 0x1a, AER_SPRITE_BGINBACKERTABLETOVERLAY = 0x1b, AER_SPRITE_BGINDRIFTERFIREDODGE = 0x1c, AER_SPRITE_BGINDRIFTERFIREOVERLAY = 0x1d, AER_SPRITE_BGINHALUCINATIONDEATHDODGE = 0x1e, AER_SPRITE_BGINHALUCINATIONDEATHOVERLAY = 0x1f, AER_SPRITE_BGINHORIZONCLIFFDODGE = 0x20, AER_SPRITE_BGINHORIZONCLIFFOVERLAY = 0x21, AER_SPRITE_BGCFLOORDREGS = 0x22, AER_SPRITE_BGCFLOORWORKSHOP = 0x23, AER_SPRITE_BGCPRLXDREGS = 0x24, AER_SPRITE_BGCSURFFLOOR = 0x25, AER_SPRITE_BGCFLOORTEMP = 0x26, AER_SPRITE_BGBATTLEROOM02DODGE = 0x27, AER_SPRITE_BGBATTLEROOM02OVERLAY = 0x28, AER_SPRITE_BGCBACKERTABLETXDODGE = 0x29, AER_SPRITE_BGCBACKERTABLETXOVERLAY = 0x2a, AER_SPRITE_BGCCENTRALDODGE = 0x2b, AER_SPRITE_BGCCENTRALOVERLAY = 0x2c, AER_SPRITE_BGCDREGSEDODGE = 0x2d, AER_SPRITE_BGCDREGSEOVERLAY = 0x2e, AER_SPRITE_BGCDREGSNDODGE = 0x2f, AER_SPRITE_BGCDREGSNOVERLAY = 0x30, AER_SPRITE_BGCDREGSSDODGE = 0x31, AER_SPRITE_BGCDREGSSOVERLAY = 0x32, AER_SPRITE_BGCDREGSWDODGE = 0x33, AER_SPRITE_BGCDREGSWOVERLAY = 0x34, AER_SPRITE_BGCDRIFTERWORKSHOPDODGE = 0x35, AER_SPRITE_BGCDRIFTERWORKSHOPOVERLAY = 0x36, AER_SPRITE_BGCVENAPOTHDODGE = 0x37, AER_SPRITE_BGCVENAPOTHOVERLAY = 0x38, AER_SPRITE_BGCVENDASHDODGE = 0x39, AER_SPRITE_BGCVENDASHOVERLAY = 0x3a, AER_SPRITE_BGCVENGUNDODGE = 0x3b, AER_SPRITE_BGCVENGUNOVERLAY = 0x3c, AER_SPRITE_BGCVENSDOJODODGE = 0x3d, AER_SPRITE_BGCVENSDOJOOVERLAY = 0x3e, AER_SPRITE_BGCVENSPECDODGE = 0x3f, AER_SPRITE_BGCVENSPECOVERLAY = 0x40, AER_SPRITE_BGPAXARENA1DODGE = 0x41, AER_SPRITE_BGPAXARENA1OVERLAY = 0x42, AER_SPRITE_BGPAXARENA2HARDLIGHT = 0x43, AER_SPRITE_BGPAXARENA2OVERLAY = 0x44, AER_SPRITE_BGPAXARENAALLDODGE = 0x45, AER_SPRITE_BGPAXARENAALLOVERLAY = 0x46, AER_SPRITE_BGPAXARENAEDODGE = 0x47, AER_SPRITE_BGPAXARENAEOVERLAY = 0x48, AER_SPRITE_BGPAXARENAWDODGE = 0x49, AER_SPRITE_BGPAXARENAWOVERLAY = 0x4a, AER_SPRITE_BGPAXSTAGINGDODGE = 0x4b, AER_SPRITE_BGPAXSTAGINGOVERLAY = 0x4c, AER_SPRITE_BGTELEVATORSHAFTDODGE = 0x4d, AER_SPRITE_BGTELEVATORSHAFTOVERLAY = 0x4e, AER_SPRITE_BGNSURFFLOOR = 0x4f, AER_SPRITE_BGNFLOORLAB2 = 0x50, AER_SPRITE_BGNINTERFLOOR = 0x51, AER_SPRITE_BGNSNOWFLOOR = 0x52, AER_SPRITE_BGNPRLXLAB1 = 0x53, AER_SPRITE_BGNPRLXLAB2 = 0x54, AER_SPRITE_BGNPRLXLIBRARY = 0x55, AER_SPRITE_BGNPRLXMOONBG = 0x56, AER_SPRITE_BGNPRLXBROKENBG = 0x57, AER_SPRITE_BGNCCLIFFCAMPFIREDODGE = 0x58, AER_SPRITE_BGNCCLIFFCAMPFIREOVERLAY = 0x59, AER_SPRITE_BGNCCRUSHARENADODGE = 0x5a, AER_SPRITE_BGNCCRUSHARENAOVERLAY = 0x5b, AER_SPRITE_BGNCNPCHATCHERYDODGE = 0x5c, AER_SPRITE_BGNCNPCHATCHERYOVERLAY = 0x5d, AER_SPRITE_BGNLALTARTHRONEDODGE = 0x5e, AER_SPRITE_BGNLALTARTHRONEOVERLAY = 0x5f, AER_SPRITE_BGNLCAVEVAULTDODGE = 0x60, AER_SPRITE_BGNLCAVEVAULTOVERLAY = 0x61, AER_SPRITE_BGNLCRUSHBACKLOOPDODGE = 0x62, AER_SPRITE_BGNLCRUSHBACKLOOPOVERLAY = 0x63, AER_SPRITE_BGNLCRUSHTRANSITIONDODGE = 0x64, AER_SPRITE_BGNLCRUSHTRANSITIONOVERLAY = 0x65, AER_SPRITE_BGNLCRUSHWARPHALLDODGE = 0x66, AER_SPRITE_BGNLCRUSHWARPHALLOVERLAY = 0x67, AER_SPRITE_BGNLDROPARENADODGE = 0x68, AER_SPRITE_BGNLDROPARENAOVERLAY = 0x69, AER_SPRITE_BGNLDROPPITSDODGE = 0x6a, AER_SPRITE_BGNLDROPPITSOVERLAY = 0x6b, AER_SPRITE_BGNLDROPSPIRALOPENDODGE = 0x6c, AER_SPRITE_BGNLDROPSPIRALOPENHARDLIGHT = 0x6d, AER_SPRITE_BGNLDROPSPIRALOPENOVERLAY = 0x6e, AER_SPRITE_BGNLEDROPBLOCKCULTFIGHTDODGE = 0x6f, AER_SPRITE_BGNLEDROPBLOCKCULTFIGHTOVERLAY = 0x70, AER_SPRITE_BGNLENTRANCEPATHDODGE = 0x71, AER_SPRITE_BGNLENTRANCEPATHOVERLAY = 0x72, AER_SPRITE_BGNLGAPHALLWAYDODGE = 0x73, AER_SPRITE_BGNLGAPHALLWAYOVERLAY = 0x74, AER_SPRITE_BGNLGAPOPENINGDODGE = 0x75, AER_SPRITE_BGNLGAPOPENINGOVERLAY = 0x76, AER_SPRITE_BGNLRISINGARENADODGE = 0x77, AER_SPRITE_BGNLRISINGARENAOVERLAY = 0x78, AER_SPRITE_BGNLSHRINEPATH2VAULTDODGE = 0x79, AER_SPRITE_BGNLSHRINEPATH2VAULTOVERLAY = 0x7a, AER_SPRITE_BGNLSTAIRASCENTDODGE = 0x7b, AER_SPRITE_BGNLSTAIRASCENTOVERLAY = 0x7c, AER_SPRITE_BGNLTOBROKENSHALLOWSDODGE = 0x7d, AER_SPRITE_BGNLTOBROKENSHALLOWSOVERLAY = 0x7e, AER_SPRITE_BGNLWARPROOMDODGE = 0x7f, AER_SPRITE_BGNLWARPROOMOVERLAY = 0x80, AER_SPRITE_BGNXAFTERTITANHARDLIGHT = 0x81, AER_SPRITE_BGNXAFTERTITANOVERLAY = 0x82, AER_SPRITE_BGNXCATHEDRALENTRANCEDODGE = 0x83, AER_SPRITE_BGNXCATHEDRALENTRANCEOVERLAY = 0x84, AER_SPRITE_BGNXCATHEDRALHALLDODGE = 0x85, AER_SPRITE_BGNXCATHEDRALHALLHARDLIGHT = 0x86, AER_SPRITE_BGNXCATHEDRALHALLOVERLAY = 0x87, AER_SPRITE_BGNXCAVE01DODGE = 0x88, AER_SPRITE_BGNXCAVE01HARDLIGHT = 0x89, AER_SPRITE_BGNXCAVE01OVERLAY = 0x8a, AER_SPRITE_BGNXGAPWIDEDODGE = 0x8b, AER_SPRITE_BGNXGAPWIDEOVERLAY = 0x8c, AER_SPRITE_BGNXJERKPOPEDODGE = 0x8d, AER_SPRITE_BGNXJERKPOPEOVERLAY = 0x8e, AER_SPRITE_BGNXLIBRARYTABLETDODGE = 0x8f, AER_SPRITE_BGNXLIBRARYTABLETOVERLAY = 0x90, AER_SPRITE_BGNXMOONCOURTYARDHARDLIGHT = 0x91, AER_SPRITE_BGNXMOONCOURTYARDOVERLAY = 0x92, AER_SPRITE_BGNXNORTHHALLDODGE = 0x93, AER_SPRITE_BGNXNORTHHALLOVERLAY = 0x94, AER_SPRITE_BGNXSHRINEPATH2DODGE = 0x95, AER_SPRITE_BGNXSHRINEPATH2OVERLAY = 0x96, AER_SPRITE_BGNXSHRINEPATHDODGE = 0x97, AER_SPRITE_BGNXSHRINEPATHOVERLAY = 0x98, AER_SPRITE_BGNXSPIRALSTAIRCASEDODGE = 0x99, AER_SPRITE_BGNXSPIRALSTAIRCASEOVERLAY = 0x9a, AER_SPRITE_BGNXSTAIRS03DODGE = 0x9b, AER_SPRITE_BGNXSTAIRS03OVERLAY = 0x9c, AER_SPRITE_BGNXTITANVISTADODGE = 0x9d, AER_SPRITE_BGNXTITANVISTAOVERLAY = 0x9e, AER_SPRITE_BGNXTOWERLOCKDODGE = 0x9f, AER_SPRITE_BGNXTOWERLOCKOVERLAY = 0xa0, AER_SPRITE_BGGAUNTLET12800 = 0xa1, AER_SPRITE_BGPARALLAXDARK = 0xa2, AER_SPRITE_BGSLABFLOOR = 0xa3, AER_SPRITE_BGSPRLX1 = 0xa4, AER_SPRITE_BGSPRLX2 = 0xa5, AER_SPRITE_BGSPRLXBOTS = 0xa6, AER_SPRITE_BGSPRLXCLOUDS = 0xa7, AER_SPRITE_BGSPRLXTITAN = 0xa8, AER_SPRITE_BGSSURFFLOOR = 0xa9, AER_SPRITE_SCNGAUNTLETPARALLAXOBJ = 0xaa, AER_SPRITE_TITANBIRDHANG = 0xab, AER_SPRITE_TITANBIRDLARGE = 0xac, AER_SPRITE_TITANBIRDMEDIUM = 0xad, AER_SPRITE_TITANBIRDPECK = 0xae, AER_SPRITE_TITANBIRDSMAL = 0xaf, AER_SPRITE_BGCHACORNERDODGE = 0xb0, AER_SPRITE_BGCHACORNEROVERLAY = 0xb1, AER_SPRITE_BGCHAPILLARBIRDDODGE = 0xb2, AER_SPRITE_BGCHAPILLARBIRDOVERLAY = 0xb3, AER_SPRITE_BGCHBDIRKDELUGEDODGE = 0xb4, AER_SPRITE_BGCHBDIRKDELUGEOVERLAY = 0xb5, AER_SPRITE_BGCHBDIRKDEMOLITIONDODGE = 0xb6, AER_SPRITE_BGCHBDIRKDEMOLITIONOVERLAY = 0xb7, AER_SPRITE_BGCHBFPSDODGE = 0xb8, AER_SPRITE_BGCHBFPSOVERLAY = 0xb9, AER_SPRITE_BGCHBGUNPILLARSDODGE = 0xba, AER_SPRITE_BGCHBGUNPILLARSOVERLAY = 0xbb, AER_SPRITE_BGCHBLADEBOTLOTDODGE = 0xbc, AER_SPRITE_BGCHBLADEBOTLOTOVERLAY = 0xbd, AER_SPRITE_BGCHBLEAPERFALLDODGE = 0xbe, AER_SPRITE_BGCHBLEAPERFALLOVERLAY = 0xbf, AER_SPRITE_BGCHBMADDASHDODGE = 0xc0, AER_SPRITE_BGCHBMADDASHOVERLAY = 0xc1, AER_SPRITE_BGCHBPODSDODGE = 0xc2, AER_SPRITE_BGCHBPODSOVERLAY = 0xc3, AER_SPRITE_BGCHCBIGGGNSDODGE = 0xc4, AER_SPRITE_BGCHCBIGGGNSOVERLAY = 0xc5, AER_SPRITE_BGCHCENDHALLDODGE = 0xc6, AER_SPRITE_BGCHCENDHALLOVERLAY = 0xc7, AER_SPRITE_BGCHCGATEBLOCKDODGE = 0xc8, AER_SPRITE_BGCHCGATEBLOCKOVERLAY = 0xc9, AER_SPRITE_BGCHCSPAWNGROUNDDODGE = 0xca, AER_SPRITE_BGCHCSPAWNGROUNDOVERLAY = 0xcb, AER_SPRITE_BGCHCSPIRALDODGE = 0xcc, AER_SPRITE_BGCHCSPIRALOVERLAY = 0xcd, AER_SPRITE_BGCHCTEMPLATEDODGE = 0xce, AER_SPRITE_BGCHCTEMPLATEOVERLAY = 0xcf, AER_SPRITE_BGCHCTESTINGDODGE = 0xd0, AER_SPRITE_BGCHCTESTINGOVERLAY = 0xd1, AER_SPRITE_BGCHCTURNHALLDODGE = 0xd2, AER_SPRITE_BGCHCTURNHALLOVERLAY = 0xd3, AER_SPRITE_BGCHTABIGONEDODGE = 0xd4, AER_SPRITE_BGCHTABIGONEOVERLAY = 0xd5, AER_SPRITE_BGCHTLONGESTROADDODGE = 0xd6, AER_SPRITE_BGCHTLONGESTROADOVERLAY = 0xd7, AER_SPRITE_BGGAUNTLETOVERLAY = 0xd8, AER_SPRITE_BGGAUNTLET1280OVERLAY = 0xd9, AER_SPRITE_BGGAUNTLETLINKUPDODGE = 0xda, AER_SPRITE_BGGAUNTLETLINKUPOVERLAY = 0xdb, AER_SPRITE_BGSBENNYARROWDODGE = 0xdc, AER_SPRITE_BGSBENNYARROWOVERLAY = 0xdd, AER_SPRITE_BGSBULLETBAKERDODGE = 0xde, AER_SPRITE_BGSBULLETBAKEROVERLAY = 0xdf, AER_SPRITE_BGSCOUNTACULARDDODGE = 0xe0, AER_SPRITE_BGSCOUNTACULARDOVERLAY = 0xe1, AER_SPRITE_BGSGAUNTLETELEVATORDODGE = 0xe2, AER_SPRITE_BGSGAUNTLETELEVATOROVERLAY = 0xe3, AER_SPRITE_BGSGAUNTLETTITANFINALEDODGE = 0xe4, AER_SPRITE_BGSGAUNTLETTITANFINALEOVERLAY = 0xe5, AER_SPRITE_BGSMARKSCYTHEDODGE = 0xe6, AER_SPRITE_BGSMARKSCYTHEOVERLAY = 0xe7, AER_SPRITE_BGSTABIGONEDODGE = 0xe8, AER_SPRITE_BGSTABIGONEOVERLAY = 0xe9, AER_SPRITE_BGSTBIRDSTANDOFFDODGE = 0xea, AER_SPRITE_BGSTBIRDSTANDOFFOVERLAY = 0xeb, AER_SPRITE_BGSXSOUTHOPENINGDODGE = 0xec, AER_SPRITE_BGSXSOUTHOPENINGOVERLAY = 0xed, AER_SPRITE_BGSXTOWERSOUTHDODGE = 0xee, AER_SPRITE_BGSXTOWERSOUTHOVERLAY = 0xef, AER_SPRITE_BGESURFFLOOR = 0xf0, AER_SPRITE_BGELABFLOOR = 0xf1, AER_SPRITE_BGEABOGTEMPLECAMPHARDLIGHT = 0xf2, AER_SPRITE_BGEABOGTEMPLECAMPOVERLAY = 0xf3, AER_SPRITE_BGEADOCKFIGHTLABHARDLIGHT = 0xf4, AER_SPRITE_BGEADOCKFIGHTLABOVERLAY = 0xf5, AER_SPRITE_BGEAEASTOPENINGDODGE = 0xf6, AER_SPRITE_BGEAEASTOPENINGOVERLAY = 0xf7, AER_SPRITE_BGEAFROGBOSSHARDLIGHT = 0xf8, AER_SPRITE_BGEAFROGBOSSOVERLAY = 0xf9, AER_SPRITE_BGEAWATERTUNNELDODGE = 0xfa, AER_SPRITE_BGEAWATERTUNNELHARDLIGHT = 0xfb, AER_SPRITE_BGEAWATERTUNNELOVERLAY = 0xfc, AER_SPRITE_BGEBBOGSTREETDODGE = 0xfd, AER_SPRITE_BGEBBOGSTREETOVERLAY = 0xfe, AER_SPRITE_BGEBDEADOTTERWALKDODGE = 0xff, AER_SPRITE_BGEBDEADOTTERWALKHARDLIGHT = 0x100, AER_SPRITE_BGEBDEADOTTERWALKOVERLAY = 0x101, AER_SPRITE_BGEBFLAMEPITLABDODGE = 0x102, AER_SPRITE_BGEBFLAMEPITLABOVERLAY = 0x103, AER_SPRITE_BGEBMELTYLEAPERARENADODGE = 0x104, AER_SPRITE_BGEBMELTYLEAPERARENAOVERLAY = 0x105, AER_SPRITE_BGEBUNDEROTTERMELTYMASHDODGE = 0x106, AER_SPRITE_BGEBUNDEROTTERMELTYMASHOVERLAY = 0x107, AER_SPRITE_BGECBIGBOGLABDODGE = 0x108, AER_SPRITE_BGECBIGBOGLABOVERLAY = 0x109, AER_SPRITE_BGECDOCKSLABDODGE = 0x10a, AER_SPRITE_BGECDOCKSLABOVERLAY = 0x10b, AER_SPRITE_BGECEASTLOOPDODGE = 0x10c, AER_SPRITE_BGECEASTLOOPOVERLAY = 0x10d, AER_SPRITE_BGECLOOPLABDODGE = 0x10e, AER_SPRITE_BGECLOOPLABOVERLAY = 0x10f, AER_SPRITE_BGECNPCDRUGDENDODGE = 0x110, AER_SPRITE_BGECNPCDRUGDENOVERLAY = 0x111, AER_SPRITE_BGECPLAZAACCESSLABDODGE = 0x112, AER_SPRITE_BGECPLAZAACCESSLABHARDLIGHT = 0x113, AER_SPRITE_BGECPLAZAACCESSLABOVERLAY = 0x114, AER_SPRITE_BGECPLAZATODOCKSDODGE = 0x115, AER_SPRITE_BGECPLAZATODOCKSOVERLAY = 0x116, AER_SPRITE_BGECPLAZATOLOOPDODGE = 0x117, AER_SPRITE_BGECPLAZATOLOOPOVERLAY = 0x118, AER_SPRITE_BGECSWORDBRIDGEDODGE = 0x119, AER_SPRITE_BGECSWORDBRIDGEHARDLIGHT = 0x11a, AER_SPRITE_BGECSWORDBRIDGEOVERLAY = 0x11b, AER_SPRITE_BGECTEMPLEISHVAULTDODGE = 0x11c, AER_SPRITE_BGECTEMPLEISHVAULTOVERLAY = 0x11d, AER_SPRITE_BGECTHEPLAZADODGE = 0x11e, AER_SPRITE_BGECTHEPLAZAOVERLAY = 0x11f, AER_SPRITE_BGELELEVATORENTRANCEFLAMEDUNGEONHARDLIGHT = 0x120, AER_SPRITE_BGELELEVATORENTRANCEFLAMEDUNGEONOVERLAY = 0x121, AER_SPRITE_BGELFLAMEELEVATOREXITDODGE = 0x122, AER_SPRITE_BGELFLAMEELEVATOREXITOVERLAY = 0x123, AER_SPRITE_BGELFLAMETRANSITIONDODGE = 0x124, AER_SPRITE_BGELFLAMETRANSITIONOVERLAY = 0x125, AER_SPRITE_BGELFROGARENADODGE = 0x126, AER_SPRITE_BGELFROGARENAOVERLAY = 0x127, AER_SPRITE_BGELMEGAHUGELABDODGE = 0x128, AER_SPRITE_BGELMEGAHUGELABHARDLIGHT = 0x129, AER_SPRITE_BGELMEGAHUGELABOVERLAY = 0x12a, AER_SPRITE_BGEVDOCKSBRIDGEDODGE = 0x12b, AER_SPRITE_BGEVDOCKSBRIDGEOVERLAY = 0x12c, AER_SPRITE_BGEXDOCKSCAMPFIREDODGE = 0x12d, AER_SPRITE_BGEXDOCKSCAMPFIREOVERLAY = 0x12e, AER_SPRITE_BGEXTITANSINKDODGE = 0x12f, AER_SPRITE_BGEXTITANSINKOVERLAY = 0x130, AER_SPRITE_BGEXTOWEREASTDODGE = 0x131, AER_SPRITE_BGEXTOWEREASTOVERLAY = 0x132, AER_SPRITE_BGWSURFACEFLOOR = 0x133, AER_SPRITE_BGWSURFFLOOR2 = 0x134, AER_SPRITE_BGWLABFLOOR = 0x135, AER_SPRITE_BGWPRLX01SURFACE = 0x136, AER_SPRITE_BGWPRLXLAB1 = 0x137, AER_SPRITE_BGWPRLXCRYSTALLAKE = 0x138, AER_SPRITE_BGWACRYSTALDESCENTDODGE = 0x139, AER_SPRITE_BGWACRYSTALDESCENTOVERLAY = 0x13a, AER_SPRITE_BGWADEADWOODROOMPRINTDODGE = 0x13b, AER_SPRITE_BGWADEADWOODROOMPRINTOVERLAY = 0x13c, AER_SPRITE_BGWAENTRANCEROOMPRINTDODGE = 0x13d, AER_SPRITE_BGWAENTRANCEROOMPRINTOVERLAY = 0x13e, AER_SPRITE_BGWAENTSWITCHROOMPRINTDODGE = 0x13f, AER_SPRITE_BGWAENTSWITCHROOMPRINTOVERLAY = 0x140, AER_SPRITE_BGWAGROTTOBUFFINTRODODGE = 0x141, AER_SPRITE_BGWAGROTTOBUFFINTROOVERLAY = 0x142, AER_SPRITE_BGWAGROTTOXROOMPRINTDODGE = 0x143, AER_SPRITE_BGWAGROTTOXROOMPRINTOVERLAY = 0x144, AER_SPRITE_BGWAMULTIENTRANCELABDODGE = 0x145, AER_SPRITE_BGWAMULTIENTRANCELABHARDLIGHT = 0x146, AER_SPRITE_BGWAMULTIENTRANCELABOVERLAY = 0x147, AER_SPRITE_BGWATITANFALLSDODGE = 0x148, AER_SPRITE_BGWATITANFALLSOVERLAY = 0x149, AER_SPRITE_BGWATOWERROOMPRINTDODGE = 0x14a, AER_SPRITE_BGWATOWERROOMPRINTOVERLAY = 0x14b, AER_SPRITE_BGWATOWERENTERDODGE = 0x14c, AER_SPRITE_BGWATOWERENTEROVERLAY = 0x14d, AER_SPRITE_BGWAVALEDODGE = 0x14e, AER_SPRITE_BGWAVALEOVERLAY = 0x14f, AER_SPRITE_BGWBBIGBATTLEDODGE = 0x150, AER_SPRITE_BGWBBIGBATTLEOVERLAY = 0x151, AER_SPRITE_BGWBCHARGERSROOMPRINTDODGE = 0x152, AER_SPRITE_BGWBCHARGERSROOMPRINTOVERLAY = 0x153, AER_SPRITE_BGWBTANUKITROUBLEDODGE = 0x154, AER_SPRITE_BGWBTANUKITROUBLEOVERLAY = 0x155, AER_SPRITE_BGWBTANUKITROUBLEROOMPRINTDODGE = 0x156, AER_SPRITE_BGWBTANUKITROUBLEROOMPRINTOVERLAY = 0x157, AER_SPRITE_BGWBTREETREACHERYDODGE = 0x158, AER_SPRITE_BGWBTREETREACHERYOVERLAY = 0x159, AER_SPRITE_BGWCBIGMEADOWDODGE = 0x15a, AER_SPRITE_BGWCBIGMEADOWOVERLAY = 0x15b, AER_SPRITE_BGWCBIGMEADOWVAULTDODGE = 0x15c, AER_SPRITE_BGWCBIGMEADOWVAULTHARDLIGHT = 0x15d, AER_SPRITE_BGWCBIGMEADOWVAULTOVERLAY = 0x15e, AER_SPRITE_BGWCCLIFFSIDECELLSREDUXDODGE = 0x15f, AER_SPRITE_BGWCCLIFFSIDECELLSREDUXOVERLAY = 0x160, AER_SPRITE_BGWCCRYSTALLAKEDODGE = 0x161, AER_SPRITE_BGWCCRYSTALLAKEOVERLAY = 0x162, AER_SPRITE_BGWCCRYSTALLAKEVAULTDODGE = 0x163, AER_SPRITE_BGWCCRYSTALLAKEVAULTHARDLIGHT = 0x164, AER_SPRITE_BGWCCRYSTALLAKEVAULTOVERLAY = 0x165, AER_SPRITE_BGWCGROTTONPCDODGE = 0x166, AER_SPRITE_BGWCGROTTONPCOVERLAY = 0x167, AER_SPRITE_BGWCMEADOWOODCAVECROSSINGDODGE = 0x168, AER_SPRITE_BGWCMEADOWOODCAVECROSSINGOVERLAY = 0x169, AER_SPRITE_BGWCMEADOWOODCORNERDODGE = 0x16a, AER_SPRITE_BGWCMEADOWOODCORNEROVERLAY = 0x16b, AER_SPRITE_BGWCMINILABROOMPRINTDODGE = 0x16c, AER_SPRITE_BGWCMINILABROOMPRINTOVERLAY = 0x16d, AER_SPRITE_BGWCPRISONHALDODGE = 0x16e, AER_SPRITE_BGWCPRISONHALOVERLAY = 0x16f, AER_SPRITE_BGWCPRISONHALLENDDODGE = 0x170, AER_SPRITE_BGWCPRISONHALLENDOVERLAY = 0x171, AER_SPRITE_BGWCRUINCLEARINGDODGE = 0x172, AER_SPRITE_BGWCRUINCLEARINGOVERLAY = 0x173, AER_SPRITE_BGWCSIMPLEPATHDODGE = 0x174, AER_SPRITE_BGWCSIMPLEPATHOVERLAY = 0x175, AER_SPRITE_BGWCTHINFORESTDODGE = 0x176, AER_SPRITE_BGWCTHINFORESTOVERLAY = 0x177, AER_SPRITE_BGWCTHINFORESTLOWDODGE = 0x178, AER_SPRITE_BGWCTHINFORESTLOWOVERLAY = 0x179, AER_SPRITE_BGWCTHINFORESTLOWSECRETDODGE = 0x17a, AER_SPRITE_BGWCTHINFORESTLOWSECRETOVERLAY = 0x17b, AER_SPRITE_BGWCWINDINGWOODDODGE = 0x17c, AER_SPRITE_BGWCWINDINGWOODOVERLAY = 0x17d, AER_SPRITE_BGWLPRISONHALVAULTDODGE = 0x17e, AER_SPRITE_BGWLPRISONHALVAULTHARDLIGHT = 0x17f, AER_SPRITE_BGWLPRISONHALVAULTOVERLAY = 0x180, AER_SPRITE_BGWLWESTDRIFTERVAULTDODGE = 0x181, AER_SPRITE_BGWLWESTDRIFTERVAULTOVERLAY = 0x182, AER_SPRITE_BGWTSLOWLABDODGE = 0x183, AER_SPRITE_BGWTSLOWLABHARDLIGHT = 0x184, AER_SPRITE_BGWTSLOWLABOVERLAY = 0x185, AER_SPRITE_BGWTTHEWOODDODGE = 0x186, AER_SPRITE_BGWTTHEWOODOVERLAY = 0x187, AER_SPRITE_BGWXBOSSDODGE = 0x188, AER_SPRITE_BGWXBOSSOVERLAY = 0x189, AER_SPRITE_BGAFLOORINTERIOR = 0x18a, AER_SPRITE_BGALABFLOOR = 0x18b, AER_SPRITE_BGPARALLAX02 = 0x18c, AER_SPRITE_APRLX03 = 0x18d, AER_SPRITE_BGAELEVATORBG02 = 0x18e, AER_SPRITE_BGAELEVATORBG = 0x18f, AER_SPRITE_BGADOWNWARDDODGE = 0x190, AER_SPRITE_BGADOWNWARDOVERLAY = 0x191, AER_SPRITE_BGAELEVATORSHAFTUPPERDODGE = 0x192, AER_SPRITE_BGAELEVATORSHAFTUPPEROVERLAY = 0x193, AER_SPRITE_BGAEMBERROOMDODGE = 0x194, AER_SPRITE_BGAEMBERROOMOVERLAY = 0x195, AER_SPRITE_DIAMONDSPIDERBULLETMASK = 0x196, AER_SPRITE_DIAMONDSPIDERBODY = 0x197, AER_SPRITE_DIAMONDSPIDERLEG = 0x198, AER_SPRITE_DIAMONDSPIDERLINK = 0x199, AER_SPRITE_SPIDEREGG = 0x19a, AER_SPRITE_DIAMONDSPIDEREYE = 0x19b, AER_SPRITE_TANUKIGENERALDIE = 0x19c, AER_SPRITE_TANUKIGENERALYOUNGSLASH = 0x19d, AER_SPRITE_TANUKIGENERALYOUNGRUN = 0x19e, AER_SPRITE_TANUKIGENERALOLDSLASH = 0x19f, AER_SPRITE_TANUKIGENERALSLASHMASKSIDE = 0x1a0, AER_SPRITE_TANUKIGENERALSLASHMASKDOWN = 0x1a1, AER_SPRITE_TANUKIGENERALOLDWALK = 0x1a2, AER_SPRITE_TANUKIGENERALOLDSHOCKWAVE = 0x1a3, AER_SPRITE_TANUKIGENERALOLDAWAKEN = 0x1a4, AER_SPRITE_TANUKIGENERALOLDSHOOT = 0x1a5, AER_SPRITE_TANUKIGENERALYOUNGSHOOT = 0x1a6, AER_SPRITE_TGMASK = 0x1a7, AER_SPRITE_TANUKIGENERALFLOORMASK = 0x1a8, AER_SPRITE_TGARM = 0x1a9, AER_SPRITE_TG = 0x1aa, AER_SPRITE_TGFLOORMASK = 0x1ab, AER_SPRITE_GUNSLINGERFLOORMASK = 0x1ac, AER_SPRITE_GUNSLINGERARM = 0x1ad, AER_SPRITE_GUNSLINGERSHOOTLEFT = 0x1ae, AER_SPRITE_GUNSLINGERRISE = 0x1af, AER_SPRITE_GUNSLINGERFALL = 0x1b0, AER_SPRITE_GUNSLINGERSHOOTFRONT = 0x1b1, AER_SPRITE_GUNSLINGERDASH = 0x1b2, AER_SPRITE_GUNSLINGERIDLE = 0x1b3, AER_SPRITE_GUNSLINGERLEFT = 0x1b4, AER_SPRITE_GUNSLINGERRIGHT = 0x1b5, AER_SPRITE_CLEANERIDLE = 0x1b6, AER_SPRITE_CLEANERSWORDGROUNDMASK = 0x1b7, AER_SPRITE_CLEANERBULLETMASK = 0x1b8, AER_SPRITE_CLEANERSWEEP = 0x1b9, AER_SPRITE_CLEANERSHADOW = 0x1ba, AER_SPRITE_CLEANERJARTOSS = 0x1bb, AER_SPRITE_CLEANERBARF = 0x1bc, AER_SPRITE_CLEANERDEAD = 0x1bd, AER_SPRITE_CLEANERHOP = 0x1be, AER_SPRITE_CLEANERMADHOP = 0x1bf, AER_SPRITE_CLEANEREAT = 0x1c0, AER_SPRITE_CLEANERVULNERABLE = 0x1c1, AER_SPRITE_CUBEPARTMED = 0x1c2, AER_SPRITE_CUBEPARTSMALL = 0x1c3, AER_SPRITE_BIRDSACRIFICE = 0x1c4, AER_SPRITE_JERKPOPE = 0x1c5, AER_SPRITE_JERKPOPEIDLE = 0x1c6, AER_SPRITE_JERKPOPEDEATH = 0x1c7, AER_SPRITE_JERKPOPERAISE = 0x1c8, AER_SPRITE_JERKPOPECAST = 0x1c9, AER_SPRITE_JERKPOPETELEPORT = 0x1ca, AER_SPRITE_JERKPOPEBULLETMASK = 0x1cb, AER_SPRITE_JERKPOPEGROUNDMASK = 0x1cc, AER_SPRITE_MARKSCYTHEIDLE = 0x1cd, AER_SPRITE_MARKSCYTHEINTRO = 0x1ce, AER_SPRITE_MARKSCYTHEMELEE = 0x1cf, AER_SPRITE_MARKSCYTHEMELEEHITBOX = 0x1d0, AER_SPRITE_MARKSCYTHETHROWCIRCLE = 0x1d1, AER_SPRITE_MARKSCYTHEHOP = 0x1d2, AER_SPRITE_MARKSCYTHECATCH = 0x1d3, AER_SPRITE_MARKSCYTHETHROW = 0x1d4, AER_SPRITE_MARKSCYTHESCYTHE = 0x1d5, AER_SPRITE_SCYTHESPIN = 0x1d6, AER_SPRITE_MARKSCYTHEEMPTY = 0x1d7, AER_SPRITE_MARKSCYTHEDEATH = 0x1d8, AER_SPRITE_BENNYARROWDEATH = 0x1d9, AER_SPRITE_BENNYARROW = 0x1da, AER_SPRITE_BENNYARROWRUN = 0x1db, AER_SPRITE_BENNYARROWABTSHOOT = 0x1dc, AER_SPRITE_BENNYARROWSHOOT = 0x1dd, AER_SPRITE_BENNYARROWHURTMASK = 0x1de, AER_SPRITE_BENNYARROWBOW = 0x1df, AER_SPRITE_BENNYARROWAIRSTRIKE = 0x1e0, AER_SPRITE_BENNYARROWMINEACTIVE = 0x1e1, AER_SPRITE_BENNYARROWMINESET = 0x1e2, AER_SPRITE_BENNYARROWMINEDEACTIVATE = 0x1e3, AER_SPRITE_BENNYARROWMINEINAIR = 0x1e4, AER_SPRITE_ARROW = 0x1e5, AER_SPRITE_ARROWLANDING = 0x1e6, AER_SPRITE_ARROWSPLOSION = 0x1e7, AER_SPRITE_BULLETBAKERDEBRIS = 0x1e8, AER_SPRITE_BULLETBAKERDEATH = 0x1e9, AER_SPRITE_BULLETBAKER = 0x1ea, AER_SPRITE_BULLETBAKERPHASECHANGE = 0x1eb, AER_SPRITE_BULLETBAKERDASH = 0x1ec, AER_SPRITE_BULLETBAKERSUMMON = 0x1ed, AER_SPRITE_BULLETBAKERBULLET = 0x1ee, AER_SPRITE_BULLETBAKERORB = 0x1ef, AER_SPRITE_BULETBAKERBLADEFADE = 0x1f0, AER_SPRITE_BULLETBAKERBULLETSUMMON = 0x1f1, AER_SPRITE_ALUCARDDEATH = 0x1f2, AER_SPRITE_ALUCARDINTRO = 0x1f3, AER_SPRITE_ALUCARDINTROALTDRIFTER = 0x1f4, AER_SPRITE_ALUCARDDRONEAPPEAR = 0x1f5, AER_SPRITE_ALUCARDSKATEBACKWARDS = 0x1f6, AER_SPRITE_ALUCARDSKATEFORWARDS = 0x1f7, AER_SPRITE_ALUCARDDRONESPAWN = 0x1f8, AER_SPRITE_COUNTALUCARD = 0x1f9, AER_SPRITE_COUNTALUCARDWALK = 0x1fa, AER_SPRITE_COUNTALUCARDDASH = 0x1fb, AER_SPRITE_COUNTALUCARDSEND = 0x1fc, AER_SPRITE_COUNTDRONE = 0x1fd, AER_SPRITE_COUNTBULLET = 0x1fe, AER_SPRITE_COUNTDRONEDEAD = 0x1ff, AER_SPRITE_COUNTDRONEDECAPBOTTOM = 0x200, AER_SPRITE_COUNTDRONEDECAPTOP = 0x201, AER_SPRITE_CHARGEUP = 0x202, AER_SPRITE_HALBULLET = 0x203, AER_SPRITE_EMBERLASERSTART = 0x204, AER_SPRITE_EMBERLASERMID = 0x205, AER_SPRITE_EMBERLASEREND = 0x206, AER_SPRITE_EMBERLASERCHARGE = 0x207, AER_SPRITE_EMBERLASERFIRE = 0x208, AER_SPRITE_EMBERDIAMOND = 0x209, AER_SPRITE_EMBERDIAMONDMASK = 0x20a, AER_SPRITE_EMBERARM = 0x20b, AER_SPRITE_HALARMTURRET = 0x20c, AER_SPRITE_HALHITSPARK = 0x20d, AER_SPRITE_HALDAMAGEMUZZLE = 0x20e, AER_SPRITE_CRYSTALCRACK = 0x20f, AER_SPRITE_BLACKWISP = 0x210, AER_SPRITE_HALCRESCENT = 0x211, AER_SPRITE_HALBEAMINNERFX = 0x212, AER_SPRITE_HALBEAMMUZZLE = 0x213, AER_SPRITE_HALBEAMOUTERFX = 0x214, AER_SPRITE_CHASERWHIP = 0x215, AER_SPRITE_HALCHARGETELEGRAPH = 0x216, AER_SPRITE_HALBEAM = 0x217, AER_SPRITE_HALBEAMHITSPARK = 0x218, AER_SPRITE_DIAMONDEYE = 0x219, AER_SPRITE_DIAMONDEYEDASH = 0x21a, AER_SPRITE_DIAMONDEYEDEATH = 0x21b, AER_SPRITE_DIAMONDEYEPARTICLE = 0x21c, AER_SPRITE_DIAMONDEYETELL = 0x21d, AER_SPRITE_DIAMONDEYESHOCKWAVE = 0x21e, AER_SPRITE_DIAMONDEYEATTACK = 0x21f, AER_SPRITE_HALBOSSBEAM = 0x220, AER_SPRITE_HALBOSSCHARGE = 0x221, AER_SPRITE_HALBOSSCHARGELINGER = 0x222, AER_SPRITE_HALBOSSSHOOT = 0x223, AER_SPRITE_HALBOSSCHARGEPARTICLESMALL = 0x224, AER_SPRITE_HALBOSSCHARGEPARTICLESWIRL = 0x225, AER_SPRITE_HALBOSSCHARGEPROJECTILE = 0x226, AER_SPRITE_HALBOSSCHARGEHITSPARK = 0x227, AER_SPRITE_HALBOSSAPPEAR = 0x228, AER_SPRITE_HALBOSS = 0x229, AER_SPRITE_HALBOSSMOVE = 0x22a, AER_SPRITE_HALBOSSWOUNDED = 0x22b, AER_SPRITE_HALBOSSFINALSTRIKE = 0x22c, AER_SPRITE_HALBOSSFINALSTRIKEALT = 0x22d, AER_SPRITE_HALBOSSARMATTACK = 0x22e, AER_SPRITE_HALBOSSFLOAT = 0x22f, AER_SPRITE_HALBOSSDASH = 0x230, AER_SPRITE_HALBOSSDASHMASK = 0x231, AER_SPRITE_HALBOSSHURTMASK = 0x232, AER_SPRITE_HALBOSSMASK = 0x233, AER_SPRITE_BLACKDUST = 0x234, AER_SPRITE_BBLCFOREIGNERSTORY = 0x235, AER_SPRITE_BBLCSICKSTORY = 0x236, AER_SPRITE_BBLCWESTWOLVESSTORY = 0x237, AER_SPRITE_BBLCBADASSSTORY = 0x238, AER_SPRITE_BBLNNPC = 0x239, AER_SPRITE_BBLSNPC = 0x23a, AER_SPRITE_BBLENPC = 0x23b, AER_SPRITE_BBLWNPC = 0x23c, AER_SPRITE_BBLNBOSS = 0x23d, AER_SPRITE_BBLSBOSS = 0x23e, AER_SPRITE_BBLEBOSS = 0x23f, AER_SPRITE_BBLWBOSS = 0x240, AER_SPRITE_BUBBLEFRAME = 0x241, AER_SPRITE_GHOST = 0x242, AER_SPRITE_GHOSTP2 = 0x243, AER_SPRITE_ALTCOMPANION = 0x244, AER_SPRITE_COMPANIONSHIELDSUIT = 0x245, AER_SPRITE_COMPANIONMACHINEGUN = 0x246, AER_SPRITE_GHOSTPINGHEALTH = 0x247, AER_SPRITE_GHOSTPINGHEAL = 0x248, AER_SPRITE_GHOSTPINGENERGY = 0x249, AER_SPRITE_GHOSTPINGSPECIAL = 0x24a, AER_SPRITE_GHOSTPINGINTERACT = 0x24b, AER_SPRITE_GHOSTPINGSECRET = 0x24c, AER_SPRITE_GHOSTPINGMAP = 0x24d, AER_SPRITE_GHOSTPINGBUTTON = 0x24e, AER_SPRITE_GHOSTMAPINTERACTDATALOOP = 0x24f, AER_SPRITE_GHOSTMAPINTERACTPULSELOOP = 0x250, AER_SPRITE_GHOSTDATA = 0x251, AER_SPRITE_SHIELDREACT = 0x252, AER_SPRITE_SHIELDPUSHLARGE = 0x253, AER_SPRITE_SHIELDPUSHMED = 0x254, AER_SPRITE_SHIELDPUSHSMALL = 0x255, AER_SPRITE_SHIELDINACTIVE = 0x256, AER_SPRITE_SHIELDSELF = 0x257, AER_SPRITE_CHARSHIELDPUSHSIDE = 0x258, AER_SPRITE_CHARSHIELDPUSHFRONT = 0x259, AER_SPRITE_CHARSHIELDPUSHBACK = 0x25a, AER_SPRITE_HEAVYSWORDMASKE = 0x25b, AER_SPRITE_PUNCHMASKE = 0x25c, AER_SPRITE_SWORDMASK180STRIKEBACK = 0x25d, AER_SPRITE_SWORDMASK180STRIKEFRONT = 0x25e, AER_SPRITE_SWORDMASK180STRIKESIDE = 0x25f, AER_SPRITE_SWORDMASKCOMBOBACK = 0x260, AER_SPRITE_SWORDMASKCOMBOFRONT = 0x261, AER_SPRITE_SWORDMASKCOMBOSIDE = 0x262, AER_SPRITE_SWORDMASKDEFLECTBACK = 0x263, AER_SPRITE_SWORDMASKDEFLECTFRONT = 0x264, AER_SPRITE_SWORDMASKDEFLECTSIDE = 0x265, AER_SPRITE_SWORDMASKDOWN = 0x266, AER_SPRITE_SWORDMASKDOWN12 = 0x267, AER_SPRITE_SWORDMASKDOWN8 = 0x268, AER_SPRITE_SWORDMASKE = 0x269, AER_SPRITE_SWORDMASKHEAVYE = 0x26a, AER_SPRITE_SWORDMASKHEAVYN = 0x26b, AER_SPRITE_SWORDMASKHEAVYS = 0x26c, AER_SPRITE_SWORDMASKN = 0x26d, AER_SPRITE_SWORDMASKS = 0x26e, AER_SPRITE_SWORDMASKSIDE = 0x26f, AER_SPRITE_SWORDMASKSIDE12 = 0x270, AER_SPRITE_SWORDMASKSIDE8 = 0x271, AER_SPRITE_SWORDMASKUP = 0x272, AER_SPRITE_SWORDMASKUP12 = 0x273, AER_SPRITE_SWORDMASKUP8 = 0x274, AER_SPRITE_PHANTOMSWORDSLASH1 = 0x275, AER_SPRITE_PHANTOMSWORDSLASH2 = 0x276, AER_SPRITE_CHARPHANTOMSLASHE = 0x277, AER_SPRITE_CHARPHANTOMBLUR = 0x278, AER_SPRITE_CHARPHANTOMSLASHSHADOW = 0x279, AER_SPRITE_CHARPUNCHE = 0x27a, AER_SPRITE_CHARHEAVYSWORDE = 0x27b, AER_SPRITE_CHARHEAVYSWORDN = 0x27c, AER_SPRITE_CHARHEAVYSWORDS = 0x27d, AER_SPRITE_CHARBASICSWORDE = 0x27e, AER_SPRITE_CHARBASICSWORDN = 0x27f, AER_SPRITE_CHARBASICSWORDS = 0x280, AER_SPRITE_CHARDOWNATK = 0x281, AER_SPRITE_CHARDOWNATK8 = 0x282, AER_SPRITE_CHARSIDEATK = 0x283, AER_SPRITE_CHARSIDEATK8 = 0x284, AER_SPRITE_CHARUPATK = 0x285, AER_SPRITE_CHARUPATK8 = 0x286, AER_SPRITE_CHARDOWNATK12 = 0x287, AER_SPRITE_CHARSIDEATK12 = 0x288, AER_SPRITE_CHARUPATK12 = 0x289, AER_SPRITE_CHARCOMBOFRONT = 0x28a, AER_SPRITE_CHARCOMBOSIDE = 0x28b, AER_SPRITE_CHARCOMBOBACK = 0x28c, AER_SPRITE_CHARDEFLECTFRONT = 0x28d, AER_SPRITE_CHARDEFLECTSIDE = 0x28e, AER_SPRITE_CHARDEFLECTBACK = 0x28f, AER_SPRITE_CHARAOEBLAST = 0x290, AER_SPRITE_CHARPISTOLUP = 0x291, AER_SPRITE_CHARPISTOLUPSIDE = 0x292, AER_SPRITE_CHARPISTOLSIDE = 0x293, AER_SPRITE_CHARPISTOLDOWNSIDE = 0x294, AER_SPRITE_CHARPISTOLDOWN = 0x295, AER_SPRITE_CHARRIFLEUP = 0x296, AER_SPRITE_CHARRIFLEUPSIDE = 0x297, AER_SPRITE_CHARRIFLESIDE = 0x298, AER_SPRITE_CHARRIFLEDOWNSIDE = 0x299, AER_SPRITE_CHARRIFLEDOWN = 0x29a, AER_SPRITE_CHARTHROWSIDE = 0x29b, AER_SPRITE_CHARTHROWFRONT = 0x29c, AER_SPRITE_CHARTHROWBACK = 0x29d, AER_SPRITE_CHARTHROWNEWSIDE = 0x29e, AER_SPRITE_CHARTHROWNEWFRONT = 0x29f, AER_SPRITE_CHARTHROWNEWBACK = 0x2a0, AER_SPRITE_CHARSHOVEFRONT = 0x2a1, AER_SPRITE_CHARSHOVESIDE = 0x2a2, AER_SPRITE_CHARSHOVEBACK = 0x2a3, AER_SPRITE_WEAPONASSEMBLE = 0x2a4, AER_SPRITE_SHOTGUNASSEMBLEFLASH = 0x2a5, AER_SPRITE_RAILGUNASSEMBLEFLASH = 0x2a6, AER_SPRITE_AIMSHOTGUNSIDE = 0x2a7, AER_SPRITE_AIMSHOTGUNDOWN = 0x2a8, AER_SPRITE_PISTOLASSEMBLEFLASH = 0x2a9, AER_SPRITE_AIMPISTOLSIDE = 0x2aa, AER_SPRITE_PISTOLAIM = 0x2ab, AER_SPRITE_PISTOLGOLDEN = 0x2ac, AER_SPRITE_PISTOLAIMBRONZE = 0x2ad, AER_SPRITE_ZELISKAAIM = 0x2ae, AER_SPRITE_ZELISKAAIMBRONZE = 0x2af, AER_SPRITE_DIAMONDSHOTGUNAIM = 0x2b0, AER_SPRITE_DIAMONDSHOTGUNAIMBRONZE = 0x2b1, AER_SPRITE_DIAMONDBLUNDERBUSSAIM = 0x2b2, AER_SPRITE_DIAMONDBLUNDERBUSSAIMBRONZE = 0x2b3, AER_SPRITE_RAILGUNAIM = 0x2b4, AER_SPRITE_RAILGUNAIMBRONZE = 0x2b5, AER_SPRITE_INSTARAILGUNAIM = 0x2b6, AER_SPRITE_INSTARAILGUNAIMBRONZE = 0x2b7, AER_SPRITE_EXPLOSIVERAILGUNAIM = 0x2b8, AER_SPRITE_BURSTRIFLEAIM = 0x2b9, AER_SPRITE_DIAMONDSWIRLAIM = 0x2ba, AER_SPRITE_CHARAIMS = 0x2bb, AER_SPRITE_CHARAIME = 0x2bc, AER_SPRITE_CHARAIMN = 0x2bd, AER_SPRITE_AIMRAILGUNSIDE = 0x2be, AER_SPRITE_AIMRAILGUNDOWN = 0x2bf, AER_SPRITE_AIMMECHCANNONDOWN = 0x2c0, AER_SPRITE_AIMMECHCANNONSIDE = 0x2c1, AER_SPRITE_MECHCANNONASSEMBLEFLASH = 0x2c2, AER_SPRITE_AIMPISTOLDOWN = 0x2c3, AER_SPRITE_AIMRAILGUN = 0x2c4, AER_SPRITE_CHARWARP = 0x2c5, AER_SPRITE_CHARP2SPAWN = 0x2c6, AER_SPRITE_CHARP2DEATH = 0x2c7, AER_SPRITE_CHARP2DISMISS = 0x2c8, AER_SPRITE_CHARP2DEATHFX = 0x2c9, AER_SPRITE_CHARP2SPAWNFX = 0x2ca, AER_SPRITE_CHARP2SPAWNFX2 = 0x2cb, AER_SPRITE_DRIFTERNOD = 0x2cc, AER_SPRITE_DRIFTERNODSIDE = 0x2cd, AER_SPRITE_DRIFTERWRAP = 0x2ce, AER_SPRITE_DRIFTERWRAPSIDE = 0x2cf, AER_SPRITE_DRIFTERCAPEFLAP = 0x2d0, AER_SPRITE_DRIFTERCAPEFLAPSIDE = 0x2d1, AER_SPRITE_DRIFTERTOSS = 0x2d2, AER_SPRITE_DRIFTERTOSSSIDE = 0x2d3, AER_SPRITE_CHARFIRESHADOW = 0x2d4, AER_SPRITE_HALSTABBGCOLS = 0x2d5, AER_SPRITE_HALFADECOLS = 0x2d6, AER_SPRITE_HALEVENTLOOM = 0x2d7, AER_SPRITE_HALEVENTBEAM = 0x2d8, AER_SPRITE_HALEVENTBULLET = 0x2d9, AER_SPRITE_HALEVENTSTAB = 0x2da, AER_SPRITE_HALEVENTSLAM = 0x2db, AER_SPRITE_ADPHANTOMSHADOW = 0x2dc, AER_SPRITE_ADPHANTOMSLASH = 0x2dd, AER_SPRITE_ADWARPARRIVE = 0x2de, AER_SPRITE_ADWARPDEPART = 0x2df, AER_SPRITE_ADCAPEFLAP = 0x2e0, AER_SPRITE_ADCAPEFLAPSIDE = 0x2e1, AER_SPRITE_ADNOD = 0x2e2, AER_SPRITE_ADNODSIDE = 0x2e3, AER_SPRITE_ADTOSS = 0x2e4, AER_SPRITE_ADTOSSSIDE = 0x2e5, AER_SPRITE_ADWRAP = 0x2e6, AER_SPRITE_ADWRAPSIDE = 0x2e7, AER_SPRITE_ADPHANTOMBLUR = 0x2e8, AER_SPRITE_ADMELEE = 0x2e9, AER_SPRITE_ADHEAVYSTRIKEE = 0x2ea, AER_SPRITE_ADHEAVYSTRIKEN = 0x2eb, AER_SPRITE_ADHEAVYSTRIKES = 0x2ec, AER_SPRITE_ADTEETERE = 0x2ed, AER_SPRITE_ADTEETERN = 0x2ee, AER_SPRITE_ADTEETERS = 0x2ef, AER_SPRITE_ADSTARTLEDAWAKE = 0x2f0, AER_SPRITE_ADJUMPDOWN = 0x2f1, AER_SPRITE_ADSHIELDPUSHE = 0x2f2, AER_SPRITE_ADSHIELDPUSHN = 0x2f3, AER_SPRITE_ADSHIELDPUSHS = 0x2f4, AER_SPRITE_ADDASHATKE = 0x2f5, AER_SPRITE_ADDASHATKN = 0x2f6, AER_SPRITE_ADDASHATKS = 0x2f7, AER_SPRITE_ADDASHE = 0x2f8, AER_SPRITE_ADDASHN = 0x2f9, AER_SPRITE_ADDASHS = 0x2fa, AER_SPRITE_ADLAND = 0x2fb, AER_SPRITE_ADWALLDASH = 0x2fc, AER_SPRITE_ADSIT = 0x2fd, AER_SPRITE_ADSTUNNED = 0x2fe, AER_SPRITE_ADTHROWN = 0x2ff, AER_SPRITE_ADSTUMBLECOUGH = 0x300, AER_SPRITE_ADDROPPINGDOWN = 0x301, AER_SPRITE_ADVICTORY = 0x302, AER_SPRITE_ADATTACKN = 0x303, AER_SPRITE_ADATTACKS = 0x304, AER_SPRITE_ADATTACKE = 0x305, AER_SPRITE_ADSTANDSIDE = 0x306, AER_SPRITE_ADSTANDBACK = 0x307, AER_SPRITE_ADSTANDFRONT = 0x308, AER_SPRITE_ADAIME = 0x309, AER_SPRITE_ADAIMN = 0x30a, AER_SPRITE_ADAIMS = 0x30b, AER_SPRITE_ADWALKSIDE = 0x30c, AER_SPRITE_ADWALKFRONT = 0x30d, AER_SPRITE_ADWALKBACK = 0x30e, AER_SPRITE_ADRUNE = 0x30f, AER_SPRITE_ADRUNN = 0x310, AER_SPRITE_ADRUNS = 0x311, AER_SPRITE_ADHEAL = 0x312, AER_SPRITE_ADSLEEP = 0x313, AER_SPRITE_ADDIE = 0x314, AER_SPRITE_ADCHILLINNPC = 0x315, AER_SPRITE_CHARSTUMBLEDEAD = 0x316, AER_SPRITE_CHARSTARTLEDAWAKE = 0x317, AER_SPRITE_CHARCOUGH = 0x318, AER_SPRITE_CHARSTUMBLECOUGH = 0x319, AER_SPRITE_CHARVICTORY = 0x31a, AER_SPRITE_SWORDVANISH = 0x31b, AER_SPRITE_CHARSTUMBLE = 0x31c, AER_SPRITE_CHARSIT = 0x31d, AER_SPRITE_CHARTHROWN = 0x31e, AER_SPRITE_CHARSTUNNED = 0x31f, AER_SPRITE_CHARHITMASK = 0x320, AER_SPRITE_CHARMASK = 0x321, AER_SPRITE_CHARSHADOW = 0x322, AER_SPRITE_CHARSHADOWSUNKBACK = 0x323, AER_SPRITE_CHARSHADOWSUNKFRONT = 0x324, AER_SPRITE_GODSHADOW = 0x325, AER_SPRITE_GODSHADOWSUNKBACK = 0x326, AER_SPRITE_GODSHADOWSUNKFRONT = 0x327, AER_SPRITE_DEADCHAR = 0x328, AER_SPRITE_REVIVECHAR = 0x329, AER_SPRITE_CHARWALLDASH = 0x32a, AER_SPRITE_PISTOLRELOAD = 0x32b, AER_SPRITE_SHOTGUNRELOAD = 0x32c, AER_SPRITE_CHARHITMASKCHEST = 0x32d, AER_SPRITE_CHARSHIELDBREAKSIDESWORD = 0x32e, AER_SPRITE_CHARSHIELDBREAKSIDE = 0x32f, AER_SPRITE_CHARSHIELDBREAKUP = 0x330, AER_SPRITE_CHARSHIELDBREAKDOWN = 0x331, AER_SPRITE_CHARCLASHN = 0x332, AER_SPRITE_CHARCLASHS = 0x333, AER_SPRITE_CHARCLASHE = 0x334, AER_SPRITE_CHARWALKBACK = 0x335, AER_SPRITE_CHARWALKFRONT = 0x336, AER_SPRITE_CHARWALKSIDE = 0x337, AER_SPRITE_CHAR = 0x338, AER_SPRITE_CHARBACK = 0x339, AER_SPRITE_CHARSIDE = 0x33a, AER_SPRITE_CHARSTANDFRONT = 0x33b, AER_SPRITE_CHARHEAL = 0x33c, AER_SPRITE_CHARSTANDSIDE = 0x33d, AER_SPRITE_CHARSTANDBACK = 0x33e, AER_SPRITE_CHARJUMPDOWN = 0x33f, AER_SPRITE_CHARDROPPINGDOWN = 0x340, AER_SPRITE_CHARDROPPINGSIDE = 0x341, AER_SPRITE_CHARLANDDOWN = 0x342, AER_SPRITE_CHARJUMPSIDE = 0x343, AER_SPRITE_CHARLANDSIDE = 0x344, AER_SPRITE_CHARDASHSIDE = 0x345, AER_SPRITE_CHARDASHFRONT = 0x346, AER_SPRITE_CHARDASHBACK = 0x347, AER_SPRITE_CHARAIRDASHSIDE = 0x348, AER_SPRITE_CHARAIRDASHFRONT = 0x349, AER_SPRITE_CHARAIRDASHBACK = 0x34a, AER_SPRITE_AIMDIAMONDS = 0x34b, AER_SPRITE_CHARFALLNEW = 0x34c, AER_SPRITE_CHARMODULERIP = 0x34d, AER_SPRITE_CHARWALLSLIDE = 0x34e, AER_SPRITE_CHARTEETER = 0x34f, AER_SPRITE_CHARTEETERUP = 0x350, AER_SPRITE_CHARTEETERDOWN = 0x351, AER_SPRITE_CHARWALLPUSH = 0x352, AER_SPRITE_CHARSLEEP = 0x353, AER_SPRITE_CHARWARPDEPART = 0x354, AER_SPRITE_CHARWARPARRIVE = 0x355, AER_SPRITE_DRIFTERPALETTE = 0x356, AER_SPRITE_BOSSCHECK = 0x357, AER_SPRITE_COLLECTIBLECHECK = 0x358, AER_SPRITE_WAYPOINT = 0x359, AER_SPRITE_DOORDIR = 0x35a, AER_SPRITE_DUSTBALL = 0x35b, AER_SPRITE_EDITORBLOOMER = 0x35c, AER_SPRITE_EDITORBOOMBOX = 0x35d, AER_SPRITE_EDITORBUTTONPROMPT = 0x35e, AER_SPRITE_EDITORCAMERACUE = 0x35f, AER_SPRITE_EDITORCAMLOCK = 0x360, AER_SPRITE_EDITORCHARVICTORY = 0x361, AER_SPRITE_EDITORCHECKPOINT = 0x362, AER_SPRITE_EDITORCOLORREGION = 0x363, AER_SPRITE_EDITORCUTSCENE = 0x364, AER_SPRITE_EDITORNOWARP = 0x365, AER_SPRITE_EDITORRESET = 0x366, AER_SPRITE_EDITORSCREENSHAKE = 0x367, AER_SPRITE_EDITORSNOWFLOOR = 0x368, AER_SPRITE_EDITORSOUND = 0x369, AER_SPRITE_EDITORTRUEATINTERVAL = 0x36a, AER_SPRITE_EDITORUPGRADEDASH = 0x36b, AER_SPRITE_EDITORUPGRADEHEALTHPACK = 0x36c, AER_SPRITE_EDITORUPGRADESPECIAL = 0x36d, AER_SPRITE_EDITORUPGRADESWORD = 0x36e, AER_SPRITE_EDITORUPGRADEWEAPON = 0x36f, AER_SPRITE_EDITORWATERFALLICON = 0x370, AER_SPRITE_EDITORWATERFLOOR = 0x371, AER_SPRITE_EMPTY = 0x372, AER_SPRITE_GAUNTLETDOOR = 0x373, AER_SPRITE_INFINITESLIME = 0x374, AER_SPRITE_ONETIMETRUE = 0x375, AER_SPRITE_PERMASTATE = 0x376, AER_SPRITE_REGIONICON = 0x377, AER_SPRITE_REGIONWALLICON = 0x378, AER_SPRITE_ROOMVISITED = 0x379, AER_SPRITE_SOUNDOBJ = 0x37a, AER_SPRITE_STAND = 0x37b, AER_SPRITE_TITLEDOOR = 0x37c, AER_SPRITE_TRANSDOOR = 0x37d, AER_SPRITE_WELLCHECK = 0x37e, AER_SPRITE_CAMPOS = 0x37f, AER_SPRITE_CLEAR = 0x380, AER_SPRITE_CURPOS = 0x381, AER_SPRITE_EDITORARROW = 0x382, AER_SPRITE_EDITORARROWON = 0x383, AER_SPRITE_EDITORCAM = 0x384, AER_SPRITE_EDITOREYEDROPPER = 0x385, AER_SPRITE_EDITORGRID = 0x386, AER_SPRITE_EDITORGRIDDOWN = 0x387, AER_SPRITE_EDITORGRIDON = 0x388, AER_SPRITE_EDITORGRIDUP = 0x389, AER_SPRITE_EDITORHELP = 0x38a, AER_SPRITE_EDITORHIGHLIGHTGEARBIT = 0x38b, AER_SPRITE_EDITORHIGHLIGHTCHECKPOINTS = 0x38c, AER_SPRITE_EDITORHIGHLIGHTHEALTH = 0x38d, AER_SPRITE_EDITORHIGHLIGHTBONES = 0x38e, AER_SPRITE_EDITORLOG = 0x38f, AER_SPRITE_EDITORLOGON = 0x390, AER_SPRITE_EDITORPLAYTEST = 0x391, AER_SPRITE_EDITORPLAYTESTON = 0x392, AER_SPRITE_EDITORSCNDS = 0x393, AER_SPRITE_EDITORSEPARATOR = 0x394, AER_SPRITE_EDITORSKETCH = 0x395, AER_SPRITE_EDITORSKETCHON = 0x396, AER_SPRITE_EDITORSNAP = 0x397, AER_SPRITE_EDITORSNAPON = 0x398, AER_SPRITE_EYECON = 0x399, AER_SPRITE_FILL = 0x39a, AER_SPRITE_GOD = 0x39b, AER_SPRITE_HALLUCINATIONPREVENTER = 0x39c, AER_SPRITE_LAYER = 0x39d, AER_SPRITE_LEVEL = 0x39e, AER_SPRITE_LEVELBOUNDARY = 0x39f, AER_SPRITE_NOCLIP = 0x3a0, AER_SPRITE_NOTE = 0x3a1, AER_SPRITE_OBJS = 0x3a2, AER_SPRITE_ONCAMPOS = 0x3a3, AER_SPRITE_ONCURPOS = 0x3a4, AER_SPRITE_ONEDITORCAM = 0x3a5, AER_SPRITE_ONEDITORHELP = 0x3a6, AER_SPRITE_ONEDITORSCNDS = 0x3a7, AER_SPRITE_ONGOD = 0x3a8, AER_SPRITE_ONLAYER = 0x3a9, AER_SPRITE_ONLEVEL = 0x3aa, AER_SPRITE_ONNOCLIP = 0x3ab, AER_SPRITE_ONOBJS = 0x3ac, AER_SPRITE_ONPLAY = 0x3ad, AER_SPRITE_ONROOMSETTING = 0x3ae, AER_SPRITE_ONSETTING = 0x3af, AER_SPRITE_ONTELE = 0x3b0, AER_SPRITE_PAUSE = 0x3b1, AER_SPRITE_RADIOBUTTON = 0x3b2, AER_SPRITE_ROOMSETTING = 0x3b3, AER_SPRITE_SAVE = 0x3b4, AER_SPRITE_SETTING = 0x3b5, AER_SPRITE_TELE = 0x3b6, AER_SPRITE_ZOOM1X = 0x3b7, AER_SPRITE_ZOOM2X = 0x3b8, AER_SPRITE_ZOOMFULL = 0x3b9, AER_SPRITE_ZOOMXX = 0x3ba, AER_SPRITE_ACIDPARTICLE = 0x3bb, AER_SPRITE_ACIDBUBBLES = 0x3bc, AER_SPRITE_ACIDBUBBLEM = 0x3bd, AER_SPRITE_ACIDSPLASHS = 0x3be, AER_SPRITE_VIRUSBLOODMED = 0x3bf, AER_SPRITE_VIRUSBLOODSMALL = 0x3c0, AER_SPRITE_BLOODSPIT = 0x3c1, AER_SPRITE_BLOODSPARKLARGE = 0x3c2, AER_SPRITE_BLOODSPARKMED = 0x3c3, AER_SPRITE_BLOODSPARKSMALL = 0x3c4, AER_SPRITE_BLOODSTAINS = 0x3c5, AER_SPRITE_BLOODSTAINSB = 0x3c6, AER_SPRITE_BLOODSTAINSSMALL = 0x3c7, AER_SPRITE_BLOODMEDFANWIDE = 0x3c8, AER_SPRITE_BLOODLARGEWHEEL = 0x3c9, AER_SPRITE_BLOODSMALLBLOOM = 0x3ca, AER_SPRITE_BLOODLARGEFAN = 0x3cb, AER_SPRITE_BLOODMEDFAN = 0x3cc, AER_SPRITE_BLOODMEDSPLIT = 0x3cd, AER_SPRITE_BLOODSPRAYALT = 0x3ce, AER_SPRITE_BLOODPART = 0x3cf, AER_SPRITE_BLOODPOOL = 0x3d0, AER_SPRITE_DEAD = 0x3d1, AER_SPRITE_GIBLET = 0x3d2, AER_SPRITE_COLUMNDEBRI = 0x3d3, AER_SPRITE_GLASSSHARD = 0x3d4, AER_SPRITE_TURRETDEBRI = 0x3d5, AER_SPRITE_CRATEDEBRI = 0x3d6, AER_SPRITE_PIPEDEBRIS = 0x3d7, AER_SPRITE_PLANTDEBRIS = 0x3d8, AER_SPRITE_DRIFTERTOSSEDSHELL = 0x3d9, AER_SPRITE_SHRUBDEBRIS = 0x3da, AER_SPRITE_SHRUBDEBRIS2 = 0x3db, AER_SPRITE_CRATECONTENTS = 0x3dc, AER_SPRITE_SKELETONBONES = 0x3dd, AER_SPRITE_POWDER = 0x3de, AER_SPRITE_BLOODSMOKE = 0x3df, AER_SPRITE_GRENADESMOKE = 0x3e0, AER_SPRITE_GRENADESMOKE2 = 0x3e1, AER_SPRITE_DASHDIAMOND = 0x3e2, AER_SPRITE_DUSTCLOUD = 0x3e3, AER_SPRITE_DUSTCLOUDEXPLODE = 0x3e4, AER_SPRITE_SMOKESMALL = 0x3e5, AER_SPRITE_MISSILETRAIL = 0x3e6, AER_SPRITE_SMOKE = 0x3e7, AER_SPRITE_STEPDUST = 0x3e8, AER_SPRITE_RUNDUST = 0x3e9, AER_SPRITE_DUSTDASH = 0x3ea, AER_SPRITE_IMPACTDUST = 0x3eb, AER_SPRITE_RPMISSILESMOKE = 0x3ec, AER_SPRITE_CRYSTALDUST = 0x3ed, AER_SPRITE_HYPEREXPLOSIONMEDIUM = 0x3ee, AER_SPRITE_RAILGUNBLAST = 0x3ef, AER_SPRITE_HYPEREXPLOSIONSMALL = 0x3f0, AER_SPRITE_GIBS = 0x3f1, AER_SPRITE_FLAMETHROWERFLAME = 0x3f2, AER_SPRITE_FLAMEPOLECANDLE = 0x3f3, AER_SPRITE_FLAMESPARK = 0x3f4, AER_SPRITE_FLAMEJETFLAME = 0x3f5, AER_SPRITE_BIGFLAMEJETFLAME = 0x3f6, AER_SPRITE_BIGFLAMEJETBASE = 0x3f7, AER_SPRITE_BIGFLAMEJETWARNING = 0x3f8, AER_SPRITE_BLOCKFIRE = 0x3f9, AER_SPRITE_SMALLFUME = 0x3fa, AER_SPRITE_TINYENERGYSIZZLE = 0x3fb, AER_SPRITE_TINYFLAMESIZZLE = 0x3fc, AER_SPRITE_FIREBOGFLAMESMALL = 0x3fd, AER_SPRITE_FIREBOGFLAMEMED = 0x3fe, AER_SPRITE_FIREBOGFLAMEMOVING = 0x3ff, AER_SPRITE_BURNTGROUND = 0x400, AER_SPRITE_GOOPRINT = 0x401, AER_SPRITE_BULLETBLAST = 0x402, AER_SPRITE_PARRYSPARK = 0x403, AER_SPRITE_CRITSPARK = 0x404, AER_SPRITE_STUNSPARK = 0x405, AER_SPRITE_STUNSPARKLE = 0x406, AER_SPRITE_LASERHITWALL = 0x407, AER_SPRITE_SHIELDRIPPLE = 0x408, AER_SPRITE_SHIELDSHATTER = 0x409, AER_SPRITE_SPARKFLASH = 0x40a, AER_SPRITE_DASHBREAKSPARKS = 0x40b, AER_SPRITE_LIGHTDEFAULT = 0x40c, AER_SPRITE_GHOSTLIGHT = 0x40d, AER_SPRITE_DRIFTERLIGHT = 0x40e, AER_SPRITE_SPARKLE = 0x40f, AER_SPRITE_TELEPORTIN = 0x410, AER_SPRITE_TELEPORTINFG = 0x411, AER_SPRITE_TINYGHOST = 0x412, AER_SPRITE_SWITCHSIGNAL = 0x413, AER_SPRITE_OUTLINEGRASS = 0x414, AER_SPRITE_OUTLINELABWALL = 0x415, AER_SPRITE_DARKNESS = 0x416, AER_SPRITE_ALMOSTDEADPATINA = 0x417, AER_SPRITE_DAMAGEPATINA = 0x418, AER_SPRITE_HEALTHPICKUPFOOTUI = 0x419, AER_SPRITE_WATERSPARKLE = 0x41a, AER_SPRITE_DROPLET = 0x41b, AER_SPRITE_WATERFALLWAVES = 0x41c, AER_SPRITE_WATERFALLWAVESBLANK = 0x41d, AER_SPRITE_WAVE = 0x41e, AER_SPRITE_BORDERWAVE = 0x41f, AER_SPRITE_PUDDLE = 0x420, AER_SPRITE_WATERFALLTOP = 0x421, AER_SPRITE_WATERFALLTILE = 0x422, AER_SPRITE_WATERFALLBOTTOM = 0x423, AER_SPRITE_WATERRIPPLEMD = 0x424, AER_SPRITE_WATERRIPPLESM = 0x425, AER_SPRITE_WATERSPLASHMD = 0x426, AER_SPRITE_WATERSPLASHSM = 0x427, AER_SPRITE_SPLASH = 0x428, AER_SPRITE_WEATHERICONMIST = 0x429, AER_SPRITE_PULSE = 0x42a, AER_SPRITE_WEATHERICONRAIN = 0x42b, AER_SPRITE_WEATHERICONSNOW = 0x42c, AER_SPRITE_WEATHERICONRAINBOWDUST = 0x42d, AER_SPRITE_GLITTER = 0x42e, AER_SPRITE_SCREENDUST = 0x42f, AER_SPRITE_BLACKRAIN = 0x430, AER_SPRITE_SNOWFOOTPRINT = 0x431, AER_SPRITE_SNOWPARTICLE = 0x432, AER_SPRITE_LIGHTNING4 = 0x433, AER_SPRITE_LIGHTNING3 = 0x434, AER_SPRITE_LIGHTNING2 = 0x435, AER_SPRITE_SNOW = 0x436, AER_SPRITE_LIGHTNING = 0x437, AER_SPRITE_BGCLOUDS = 0x438, AER_SPRITE_DUSTPART = 0x439, AER_SPRITE_GLOWINGEYES = 0x43a, AER_SPRITE_EARTHQUAKEDUST = 0x43b, AER_SPRITE_ROOFDEBRI = 0x43c, AER_SPRITE_ROOFDEBRIBREAK = 0x43d, AER_SPRITE_ENERGYRIPPLESM = 0x43e, AER_SPRITE_ROLLYPOLLYBLAST = 0x43f, AER_SPRITE_ENEMYSHADOW = 0x440, AER_SPRITE_PUNCHINGBAG = 0x441, AER_SPRITE_BOWLERROLL = 0x442, AER_SPRITE_HALDIRK = 0x443, AER_SPRITE_HALDIRKDEAD = 0x444, AER_SPRITE_BIGTENTACLE = 0x445, AER_SPRITE_ACIDFLY = 0x446, AER_SPRITE_ACIDFLYSPIT = 0x447, AER_SPRITE_PLANTYDEAD = 0x448, AER_SPRITE_PLANTYDECAPTOP = 0x449, AER_SPRITE_PLANTYDECAPBOTTOM = 0x44a, AER_SPRITE_MELTYMASK = 0x44b, AER_SPRITE_PLANTYRISE = 0x44c, AER_SPRITE_PLANTYFOOT = 0x44d, AER_SPRITE_PLANTYFOOT2 = 0x44e, AER_SPRITE_PLANTYMOVE = 0x44f, AER_SPRITE_PLANTYATTACKROOTS = 0x450, AER_SPRITE_PLANTYDEADROOTS = 0x451, AER_SPRITE_PLANTYATTACK = 0x452, AER_SPRITE_JARFROGRUMMAGE = 0x453, AER_SPRITE_JARFROGIDLE = 0x454, AER_SPRITE_JARFROGDECAPBOTTOM = 0x455, AER_SPRITE_JARFROGDECAPTOP = 0x456, AER_SPRITE_JARFROGDEAD = 0x457, AER_SPRITE_JARFROGHOP = 0x458, AER_SPRITE_JARFROGTOSS = 0x459, AER_SPRITE_JARFROGWALK = 0x45a, AER_SPRITE_STRIDERSTUN = 0x45b, AER_SPRITE_STRIDERIDLE = 0x45c, AER_SPRITE_STRIDERFLOORMASK = 0x45d, AER_SPRITE_STRIDERDECAPTOP = 0x45e, AER_SPRITE_STRIDERDECAPBOTTOM = 0x45f, AER_SPRITE_STRIDERDEAD = 0x460, AER_SPRITE_STRIDERWALK = 0x461, AER_SPRITE_STRIDERSWIM = 0x462, AER_SPRITE_THROWINGKNIFE = 0x463, AER_SPRITE_THROWINGKNIFEDISSAPEAR = 0x464, AER_SPRITE_BAREFROGHOPRIGHT = 0x465, AER_SPRITE_BAREFROGTHROW = 0x466, AER_SPRITE_BAREFROGHOPLEFT = 0x467, AER_SPRITE_NINJAFROGDEAD = 0x468, AER_SPRITE_NINJAFROGDECAPBOTTOM = 0x469, AER_SPRITE_NINJAFROGDECAPTOP = 0x46a, AER_SPRITE_NINJAFROGATTACK = 0x46b, AER_SPRITE_NINJAFROGJUMPBACK = 0x46c, AER_SPRITE_NINJAFROGHOPRIGHT = 0x46d, AER_SPRITE_NINJAFROGHOPLEFT = 0x46e, AER_SPRITE_NINJAFROGMASK = 0x46f, AER_SPRITE_FLAMEMITEWALK = 0x470, AER_SPRITE_FLAMEMITEEMERGE = 0x471, AER_SPRITE_FLAMEMITEHIDDEN = 0x472, AER_SPRITE_FLAMEMITEBURIED = 0x473, AER_SPRITE_FLAMEMITEATTACK = 0x474, AER_SPRITE_FLAMEMITEEXPLODE = 0x475, AER_SPRITE_FLAMEMITEEXPLOSION = 0x476, AER_SPRITE_GARBAGEPLANTDEAD = 0x477, AER_SPRITE_GARBAGEPLANT = 0x478, AER_SPRITE_GHOSTBEAMBIRDINTRO = 0x479, AER_SPRITE_GHOSTBEAMBIRDDECAPTOP = 0x47a, AER_SPRITE_GHOSTBEAMBIRDDEAD = 0x47b, AER_SPRITE_GHOSTBEAMBIRDDECAPBOTTOM = 0x47c, AER_SPRITE_GHOSTBEAMBIRDWALK = 0x47d, AER_SPRITE_GHOSTBEAMBIRDIDLE = 0x47e, AER_SPRITE_GHOSTBEAMBIRDSLAMSQUARE = 0x47f, AER_SPRITE_GHOSTBEAMSUMMONFX = 0x480, AER_SPRITE_GHOSTBEAMBIRDINVOKE = 0x481, AER_SPRITE_GHOSTBEAMBIRDSLAM = 0x482, AER_SPRITE_BLOCKSUMMONBIRDINVOKE = 0x483, AER_SPRITE_BURSTBIRDDEAD = 0x484, AER_SPRITE_BURSTBIRDDECAPBOTTOM = 0x485, AER_SPRITE_BURSTBIRDDECAPTOP = 0x486, AER_SPRITE_BURSTBIRDINVOKE = 0x487, AER_SPRITE_BURSTBIRDRUN = 0x488, AER_SPRITE_BURSTBIRDATTACK = 0x489, AER_SPRITE_BIRDMANTUMBLE = 0x48a, AER_SPRITE_BIRDMANSTAND = 0x48b, AER_SPRITE_BIRDMANDEAD = 0x48c, AER_SPRITE_BIRDMANDECAPBOTTOM = 0x48d, AER_SPRITE_BIRDMANDECAPTOP = 0x48e, AER_SPRITE_BIRDMANSTUN = 0x48f, AER_SPRITE_BIRDMANFLY = 0x490, AER_SPRITE_BIRDMANWALK = 0x491, AER_SPRITE_BIRDMANDIVE = 0x492, AER_SPRITE_BIRDMANSHADOW = 0x493, AER_SPRITE_CULTSUMMONFX = 0x494, AER_SPRITE_CULTBIRDIDLE = 0x495, AER_SPRITE_CULTBIRDINTRO = 0x496, AER_SPRITE_CULTBIRDREADY = 0x497, AER_SPRITE_CULTBIRDSTUNNED = 0x498, AER_SPRITE_CULTBIRDATTACK = 0x499, AER_SPRITE_CULTBIRDCROUCH = 0x49a, AER_SPRITE_CULTBIRDMOVE = 0x49b, AER_SPRITE_CULTBIRDSHIELD = 0x49c, AER_SPRITE_CULTBIRDSPEARHITSPARK = 0x49d, AER_SPRITE_CULTBIRDSPEARTELL = 0x49e, AER_SPRITE_GLOWSHIELD = 0x49f, AER_SPRITE_CULTBIRDDODGE = 0x4a0, AER_SPRITE_CULTBIRDSUMMON = 0x4a1, AER_SPRITE_CULTBIRDDEAD = 0x4a2, AER_SPRITE_CULTBIRDDECAPBODY = 0x4a3, AER_SPRITE_CULTBIRDDECAPHEAD = 0x4a4, AER_SPRITE_CULTSPIKE = 0x4a5, AER_SPRITE_CULTCHARGE = 0x4a6, AER_SPRITE_CULTSPEAR = 0x4a7, AER_SPRITE_CULTBIRDMARCHDARK = 0x4a8, AER_SPRITE_CRABDECAPTOP = 0x4a9, AER_SPRITE_CRABDECAPBOTTOM = 0x4aa, AER_SPRITE_CRABDEAD = 0x4ab, AER_SPRITE_CRABATTACK = 0x4ac, AER_SPRITE_CRAB = 0x4ad, AER_SPRITE_CRABMAN = 0x4ae, AER_SPRITE_CRABMANATTACK = 0x4af, AER_SPRITE_ALPHAWOLFGRABDRIFTER = 0x4b0, AER_SPRITE_ALPHAWOLFGRAB = 0x4b1, AER_SPRITE_ALPHAWOLF = 0x4b2, AER_SPRITE_WOLFDECAPBOTTOM = 0x4b3, AER_SPRITE_WOLFDECAPTOP = 0x4b4, AER_SPRITE_WOLFIDLE = 0x4b5, AER_SPRITE_WOLFDEAD = 0x4b6, AER_SPRITE_WOLFRUN = 0x4b7, AER_SPRITE_WOLFSTUN = 0x4b8, AER_SPRITE_WOLFATTACK = 0x4b9, AER_SPRITE_CRYSTALSPIKENE = 0x4ba, AER_SPRITE_CRYSTALSPIKEN = 0x4bb, AER_SPRITE_CRYSTALSPIKESE = 0x4bc, AER_SPRITE_CRYSTALSPIKES = 0x4bd, AER_SPRITE_TANUKIGROUNDMASK = 0x4be, AER_SPRITE_TANUKIHITMASK = 0x4bf, AER_SPRITE_TANUKISPEARDECAPTOP = 0x4c0, AER_SPRITE_TANUKICRYSTAL = 0x4c1, AER_SPRITE_TANUKISPEARWALK = 0x4c2, AER_SPRITE_TANUKISPEARDEAD = 0x4c3, AER_SPRITE_TANUKISPEARSTUN = 0x4c4, AER_SPRITE_TANUKISPEARDECAPBOTTOM = 0x4c5, AER_SPRITE_TANUKISPEARATTACK = 0x4c6, AER_SPRITE_TANUKISPEARATKCOL = 0x4c7, AER_SPRITE_TANUKISPEARFLICKER = 0x4c8, AER_SPRITE_TANUKIFLICKER = 0x4c9, AER_SPRITE_TANUKITARGETFLICKER = 0x4ca, AER_SPRITE_TANUKIRECOIL = 0x4cb, AER_SPRITE_TANUKIATTACK1 = 0x4cc, AER_SPRITE_TANUKIATTACK2 = 0x4cd, AER_SPRITE_TANUKIWALK = 0x4ce, AER_SPRITE_TANUKIWARRIORINTRO = 0x4cf, AER_SPRITE_TANUKIDEAD = 0x4d0, AER_SPRITE_TANUKIDECAPBOTTOM = 0x4d1, AER_SPRITE_TANUKISLASH = 0x4d2, AER_SPRITE_TANUKIDECAPTOP = 0x4d3, AER_SPRITE_TIMEPHASEBULLETHIT = 0x4d4, AER_SPRITE_TIMEPHASEBULLETTRAIL = 0x4d5, AER_SPRITE_TANUKIPISTOLFLICKER = 0x4d6, AER_SPRITE_TANUKIPISTOLDEAD = 0x4d7, AER_SPRITE_TANUKIPISTOLRECOIL = 0x4d8, AER_SPRITE_TANUKIPISTOLWALK = 0x4d9, AER_SPRITE_TANUKIPISTOLDECAPBOTTOM = 0x4da, AER_SPRITE_TANUKIPISTOLAIMDOWN = 0x4db, AER_SPRITE_TANUKIPISTOLAIMDOWNSIDE = 0x4dc, AER_SPRITE_TANUKIPISTOLAIMSIDE = 0x4dd, AER_SPRITE_TANUKIPISTOLAIMUPSIDE = 0x4de, AER_SPRITE_TANUKIPISTOLAIMUP = 0x4df, AER_SPRITE_TANUKIPISTOLDECAPTOP = 0x4e0, AER_SPRITE_CRYSTALBABYSTUN = 0x4e1, AER_SPRITE_CRYSTALBABYDEAD = 0x4e2, AER_SPRITE_CRYSTALBABYDECAPBOTTOM = 0x4e3, AER_SPRITE_CRYSTALBABYWALK = 0x4e4, AER_SPRITE_CRYSTALBABYATTACK = 0x4e5, AER_SPRITE_CRYSTALBABYSPIKE = 0x4e6, AER_SPRITE_SMALLCRYSTALSPIDERHIDE = 0x4e7, AER_SPRITE_MEDCRYSTALSPIDERWALK = 0x4e8, AER_SPRITE_MEDCRYSTALSPIDERSTUN = 0x4e9, AER_SPRITE_MEDCRYSTALSPIDERDEAD = 0x4ea, AER_SPRITE_MEDCRYSTALSPIDERDECAPBOTTOM = 0x4eb, AER_SPRITE_CRYSTALFRAGMENT = 0x4ec, AER_SPRITE_MEDCRYSTALSPIDERRUN = 0x4ed, AER_SPRITE_MEDCRYSTALSPIDERATTACK = 0x4ee, AER_SPRITE_SMALLCRYSTALSPIDERDEAD = 0x4ef, AER_SPRITE_SMALLCRYSTALSPIDERWALK = 0x4f0, AER_SPRITE_SMALLCRYSTALSPIDERATTACK = 0x4f1, AER_SPRITE_BLADIRKMASK = 0x4f2, AER_SPRITE_BLADIRKATKMASK = 0x4f3, AER_SPRITE_BLADIRKDECAPBOTTOM = 0x4f4, AER_SPRITE_BLADIRKDECAPTOP = 0x4f5, AER_SPRITE_BLADIRKDEATH = 0x4f6, AER_SPRITE_BLADIRKWALK = 0x4f7, AER_SPRITE_BLADIRKSTUN = 0x4f8, AER_SPRITE_BLADIRKATTACK = 0x4f9, AER_SPRITE_BLADIRKINTRO = 0x4fa, AER_SPRITE_BLADIRKSHOOT = 0x4fb, AER_SPRITE_ROBODOG = 0x4fc, AER_SPRITE_ROBODOGATTACK = 0x4fd, AER_SPRITE_SOUTHDRONE = 0x4fe, AER_SPRITE_DIRKSITBACK = 0x4ff, AER_SPRITE_DIRKSITFRONT = 0x500, AER_SPRITE_DIRKIDLE = 0x501, AER_SPRITE_DIRKDEAD = 0x502, AER_SPRITE_DIRKDECAPBOTTOM = 0x503, AER_SPRITE_DIRKDECAPTOP = 0x504, AER_SPRITE_DIRKDIELEG = 0x505, AER_SPRITE_DIRKDIESLICE = 0x506, AER_SPRITE_DIRKDIEDIAG = 0x507, AER_SPRITE_DIRK = 0x508, AER_SPRITE_DIRKRUN = 0x509, AER_SPRITE_DIRKMASK = 0x50a, AER_SPRITE_DIRKAFTER = 0x50b, AER_SPRITE_DIRKANTNEW = 0x50c, AER_SPRITE_DIRKATKNEW = 0x50d, AER_SPRITE_DIRKSTUN = 0x50e, AER_SPRITE_DIRKSTUNBACK = 0x50f, AER_SPRITE_FAKEDIRK = 0x510, AER_SPRITE_PUNCHINGBAGDEAD = 0x511, AER_SPRITE_DIRKBOMB = 0x512, AER_SPRITE_DIRKOMMANDERCHARGE = 0x513, AER_SPRITE_DIRKOMMANDERDEAD = 0x514, AER_SPRITE_DIRKOMMANDERDECAPBOTTOM = 0x515, AER_SPRITE_DIRKOMMANDERDECAPTOP = 0x516, AER_SPRITE_DIRKOMMANDERIDLE = 0x517, AER_SPRITE_DIRKOMMANDERJUMP = 0x518, AER_SPRITE_DIRKOMMANDERSHOOTSIDE = 0x519, AER_SPRITE_DIRKOMMANDERSHOOTUP = 0x51a, AER_SPRITE_DIRKOMMANDERDODGE = 0x51b, AER_SPRITE_DIRKOMMANDERSTUN = 0x51c, AER_SPRITE_DIRKOMMANDERSWING = 0x51d, AER_SPRITE_DIRKOMMANDERSWORDCOL = 0x51e, AER_SPRITE_DIRKOMMANDERWALK = 0x51f, AER_SPRITE_DIRKOMMANDERMASK = 0x520, AER_SPRITE_GOAT = 0x521, AER_SPRITE_GOATRISE = 0x522, AER_SPRITE_LEAPERMASK = 0x523, AER_SPRITE_LEAPERATTACK = 0x524, AER_SPRITE_LEAPERDECAPBOTTOM = 0x525, AER_SPRITE_LEAPERDECAPTOP = 0x526, AER_SPRITE_LEAPERDEATH = 0x527, AER_SPRITE_LEAPERSHADOW = 0x528, AER_SPRITE_LEAPERIDLE = 0x529, AER_SPRITE_LEAPERWALK = 0x52a, AER_SPRITE_LEAPERSLASH = 0x52b, AER_SPRITE_MISSILEDIRK = 0x52c, AER_SPRITE_MISSILEDIRKDODGE = 0x52d, AER_SPRITE_MISSILEDIRKSHOOTSIDE = 0x52e, AER_SPRITE_MISSILEDIRKATTACK = 0x52f, AER_SPRITE_MISSILEDIRKDEAD = 0x530, AER_SPRITE_MISSILEDIRKDECAPTOP = 0x531, AER_SPRITE_MISSILEDIRKDECAPBOTTOM = 0x532, AER_SPRITE_MISSILEDIRKGUN = 0x533, AER_SPRITE_MISSILEDIRKMASK = 0x534, AER_SPRITE_PARRYPRINCEMOVE = 0x535, AER_SPRITE_PARRYPRINCEMASK = 0x536, AER_SPRITE_PARRYPRINCEDODGE = 0x537, AER_SPRITE_PARRYPRINCEDEFENCE = 0x538, AER_SPRITE_PARRYPRINCESTUN = 0x539, AER_SPRITE_PARRYPRINCERECOVERY = 0x53a, AER_SPRITE_PARRYPRINCEANT = 0x53b, AER_SPRITE_PARRYPRINCEATTACK = 0x53c, AER_SPRITE_PARRYPRINCEDECAPTOP = 0x53d, AER_SPRITE_PARRYPRINCEDECAPBOTTOM = 0x53e, AER_SPRITE_PARRYPRINCEDEAD = 0x53f, AER_SPRITE_RIFLEDIRKIDLE = 0x540, AER_SPRITE_RIFLEDIRK = 0x541, AER_SPRITE_RIFLEDIRKDECAPTOP = 0x542, AER_SPRITE_RIFLEDIRKDECAPBOTTOM = 0x543, AER_SPRITE_RIFLEDIRKGUN = 0x544, AER_SPRITE_RIFLEDIRKATTACK = 0x545, AER_SPRITE_RIFLEDIRKDEAD = 0x546, AER_SPRITE_RIFLEDIRKSTUN = 0x547, AER_SPRITE_SLIMEMASK = 0x548, AER_SPRITE_SLIME = 0x549, AER_SPRITE_SLIMEATTACK = 0x54a, AER_SPRITE_ACIDSLIME = 0x54b, AER_SPRITE_SLIMEPART = 0x54c, AER_SPRITE_SLIMEONGROUND = 0x54d, AER_SPRITE_DARKTRAIL = 0x54e, AER_SPRITE_SPIDERATTACK = 0x54f, AER_SPRITE_SPIDERDECAPBOTTOM = 0x550, AER_SPRITE_SPIDERDECAPTOP = 0x551, AER_SPRITE_SPIDERDEAD = 0x552, AER_SPRITE_SPIDER = 0x553, AER_SPRITE_SOCCERBALL = 0x554, AER_SPRITE_APARTMENTDIAGRAM = 0x555, AER_SPRITE_APARTMENTDIAGRAMDESK = 0x556, AER_SPRITE_APARTMENTDIAGRAMPROJECTOR = 0x557, AER_SPRITE_APARTMENTLIGHTSWITCH = 0x558, AER_SPRITE_APARTMENTMIRRORFRAME = 0x559, AER_SPRITE_APARTMENTSWAPPERS = 0x55a, AER_SPRITE_SCOREBOARDFILL = 0x55b, AER_SPRITE_STAMINARECHARGER = 0x55c, AER_SPRITE_ABYSSDOOR = 0x55d, AER_SPRITE_ABYSSDOORBASE = 0x55e, AER_SPRITE_ABYSSDOORGLOW = 0x55f, AER_SPRITE_ABYSSDOORPILLAR = 0x560, AER_SPRITE_ABYSSDOORPILLARWEST = 0x561, AER_SPRITE_ABYSSDOORPILLARSOUTH = 0x562, AER_SPRITE_ABYSSDOORPILLAREAST = 0x563, AER_SPRITE_ABYSSDOORPILLARNORTH = 0x564, AER_SPRITE_FLOORBUTTON = 0x565, AER_SPRITE_FLOORBUTTONSUBTLE = 0x566, AER_SPRITE_BUTTONOLD = 0x567, AER_SPRITE_BUTTON = 0x568, AER_SPRITE_BUTTONMOVINGPLATFORM = 0x569, AER_SPRITE_BARREL = 0x56a, AER_SPRITE_BARRELEXPLODING = 0x56b, AER_SPRITE_COLLECTIBLECOLUMN = 0x56c, AER_SPRITE_GEARCRATE = 0x56d, AER_SPRITE_GEARCRATESTUMP = 0x56e, AER_SPRITE_HEALTHPLANT = 0x56f, AER_SPRITE_HEALTHPLANTCUT = 0x570, AER_SPRITE_LARGECRATE = 0x571, AER_SPRITE_MULTIHITCRATE = 0x572, AER_SPRITE_ORGANTUBEBASE = 0x573, AER_SPRITE_SMALLCRATE = 0x574, AER_SPRITE_WCRYSTALCLEANSTUMP = 0x575, AER_SPRITE_WCRYSTALROUGHSMSTUMP = 0x576, AER_SPRITE_WCRYSTALROUGHTALLSTUMP = 0x577, AER_SPRITE_WCRYSTALTRAPSTUMP = 0x578, AER_SPRITE_WCRYSTALTRAP2STUMP = 0x579, AER_SPRITE_WCRYSTALTRAP3STUMP = 0x57a, AER_SPRITE_WCRYSTALTRAP4STUMP = 0x57b, AER_SPRITE_WGEODEBIGSTUMP = 0x57c, AER_SPRITE_WGEODEBIG1STUMP = 0x57d, AER_SPRITE_WGEODEBIG2STUMP = 0x57e, AER_SPRITE_WGEODEHUGESTUMP = 0x57f, AER_SPRITE_WGEODEHUGE1STUMP = 0x580, AER_SPRITE_WGEODEHUGE2STUMP = 0x581, AER_SPRITE_DOORINTERACTIVEFLOORMAT = 0x582, AER_SPRITE_DOORLOCKEDICON = 0x583, AER_SPRITE_DOORUNLOCKEDICON = 0x584, AER_SPRITE_DOORFAIL = 0x585, AER_SPRITE_ROOMDOOREAST = 0x586, AER_SPRITE_ROOMDOORNORTH = 0x587, AER_SPRITE_ROOMDOORSOUTH = 0x588, AER_SPRITE_ROOMDOORWEST = 0x589, AER_SPRITE_MODULEDOOR1 = 0x58a, AER_SPRITE_MODULEDOOR3 = 0x58b, AER_SPRITE_MODULEDOOR4 = 0x58c, AER_SPRITE_MODULEDOOR8 = 0x58d, AER_SPRITE_TELEVATORPLATFORMABYSS = 0x58e, AER_SPRITE_TELEVATORHOLEABYSS = 0x58f, AER_SPRITE_TELEVATORDISSAPEAR = 0x590, AER_SPRITE_TELEVATORHOLE = 0x591, AER_SPRITE_TELEVATORHOLEMODULELAB = 0x592, AER_SPRITE_TELEVATORMASK = 0x593, AER_SPRITE_TELEVATORPLATFORM = 0x594, AER_SPRITE_TELEVATORPLATFORMMODULELAB = 0x595, AER_SPRITE_VANISHINGDOOR = 0x596, AER_SPRITE_VANISHINGDOOREDGES = 0x597, AER_SPRITE_VANISHINGDOOROPEN = 0x598, AER_SPRITE_BIGBOSSDOOR = 0x599, AER_SPRITE_GAUNTLETDOORN = 0x59a, AER_SPRITE_GAUNTLETDOORSIDE = 0x59b, AER_SPRITE_SPLITDOORBOTTOM = 0x59c, AER_SPRITE_SPLITDOORTOP = 0x59d, AER_SPRITE_VAULTDOOR = 0x59e, AER_SPRITE_VAULTDOORLIGHTS = 0x59f, AER_SPRITE_ABYSSDOOREFFECTSOVER = 0x5a0, AER_SPRITE_ABYSSDOOREFFECTSUNDER = 0x5a1, AER_SPRITE_VAULTDOORSLOTS = 0x5a2, AER_SPRITE_BOSSPILLARLOCKICONNORTH = 0x5a3, AER_SPRITE_BOSSPILLARLOCKICONEAST = 0x5a4, AER_SPRITE_BOSSPILLARLOCKICONSOUTH = 0x5a5, AER_SPRITE_BOSSPILLARLOCKICONWEST = 0x5a6, AER_SPRITE_DRIFTERBONES = 0x5a7, AER_SPRITE_DRIFTERBONESAURA = 0x5a8, AER_SPRITE_DRIFTERBONESBUGSLOOP = 0x5a9, AER_SPRITE_DRIFTERBONESBUGSSCATTER = 0x5aa, AER_SPRITE_JUMPTECH = 0x5ab, AER_SPRITE_JUMPPADOFF = 0x5ac, AER_SPRITE_JUMPPADON = 0x5ad, AER_SPRITE_RECESSINGBLOCKSEAL16 = 0x5ae, AER_SPRITE_RECESSINGBLOCKSEAL24 = 0x5af, AER_SPRITE_RECESSINGBLOCKSEAL32 = 0x5b0, AER_SPRITE_MPILLAROPEN = 0x5b1, AER_SPRITE_MODULESOCKETBASE = 0x5b2, AER_SPRITE_MODULESOCKETDESTROYED = 0x5b3, AER_SPRITE_MODULESOCKETBASEGLOW = 0x5b4, AER_SPRITE_MODULESOCKETPILLAR = 0x5b5, AER_SPRITE_ADMODULESOCKETPILLAR = 0x5b6, AER_SPRITE_DROPPLATFORM128 = 0x5b7, AER_SPRITE_DROPPLATFORM128WARNING = 0x5b8, AER_SPRITE_DROPPLATFORM32 = 0x5b9, AER_SPRITE_DROPPLATFORM32WARNING = 0x5ba, AER_SPRITE_DROPPLATFORM64 = 0x5bb, AER_SPRITE_DROPPLATFORM64WARNING = 0x5bc, AER_SPRITE_GINVISIBLEPLAT = 0x5bd, AER_SPRITE_GTOWERELEPLATFORM = 0x5be, AER_SPRITE_INVISIBLEPLATFORM32 = 0x5bf, AER_SPRITE_INVISIBLEPLATFORM48 = 0x5c0, AER_SPRITE_LABPLATFORM = 0x5c1, AER_SPRITE_MOVINGPLATFORM = 0x5c2, AER_SPRITE_RISINGPLATFORM = 0x5c3, AER_SPRITE_RISINGPLATFORMANIMATED = 0x5c4, AER_SPRITE_RISINGPLATFORMFRONTEAST = 0x5c5, AER_SPRITE_RISINGPLATFORMFRONTNORTH = 0x5c6, AER_SPRITE_RISINGPLATFORMFRONTSOUTH = 0x5c7, AER_SPRITE_RISINGPLATFORMFRONTWEST = 0x5c8, AER_SPRITE_RISINGPLATFORMFRONTGENERIC = 0x5c9, AER_SPRITE_RISINGPLATFORMLIGHTS = 0x5ca, AER_SPRITE_RISINGPLATFORMWARNING = 0x5cb, AER_SPRITE_RISINGPLATFORM32 = 0x5cc, AER_SPRITE_RISINGPLATFORM32ANIMATED = 0x5cd, AER_SPRITE_RISINGPLATFORM32FRONTEAST = 0x5ce, AER_SPRITE_RISINGPLATFORM32FRONTNORTH = 0x5cf, AER_SPRITE_RISINGPLATFORM32FRONTSOUTH = 0x5d0, AER_SPRITE_RISINGPLATFORM32FRONTWEST = 0x5d1, AER_SPRITE_RISINGPLATFORM32FRONTGENERIC = 0x5d2, AER_SPRITE_RISINGPLATFORM32LIGHTS = 0x5d3, AER_SPRITE_RISINGPLATFORM32WARNING = 0x5d4, AER_SPRITE_SNOWFLOORTILE = 0x5d5, AER_SPRITE_WPHASEPLATFORM = 0x5d6, AER_SPRITE_WATERFLOORTILE = 0x5d7, AER_SPRITE_SCNSSTITANEYE = 0x5d8, AER_SPRITE_SCNSSTITANEYETRUE = 0x5d9, AER_SPRITE_SCNSSTITANHEART = 0x5da, AER_SPRITE_SCNSSTITANHEARTTRUE = 0x5db, AER_SPRITE_STAIRSRIGHTABYSS = 0x5dc, AER_SPRITE_STAIRSRIGHTCENTRAL = 0x5dd, AER_SPRITE_STAIRSRIGHTCENTRALNEW = 0x5de, AER_SPRITE_STAIRSRIGHTCENTRALSMALL = 0x5df, AER_SPRITE_STAIRSRIGHTEAST = 0x5e0, AER_SPRITE_STAIRSRIGHTEASTSMALL = 0x5e1, AER_SPRITE_STAIRSRIGHTNORTH = 0x5e2, AER_SPRITE_STAIRSRIGHTNORTHSMALL = 0x5e3, AER_SPRITE_STAIRSRIGHTRAILABYSS = 0x5e4, AER_SPRITE_STAIRSRIGHTRAILBEHINDABYSS = 0x5e5, AER_SPRITE_STAIRSRIGHTRAILBEHINDCENTRAL = 0x5e6, AER_SPRITE_STAIRSRIGHTRAILBEHINDEAST = 0x5e7, AER_SPRITE_STAIRSRIGHTRAILBEHINDNORTH = 0x5e8, AER_SPRITE_STAIRSRIGHTRAILBEHINDSOUTH = 0x5e9, AER_SPRITE_STAIRSRIGHTRAILBEHINDWEST = 0x5ea, AER_SPRITE_STAIRSRIGHTRAILCENTRAL = 0x5eb, AER_SPRITE_STAIRSRIGHTRAILEAST = 0x5ec, AER_SPRITE_STAIRSRIGHTRAILMASK = 0x5ed, AER_SPRITE_STAIRSRIGHTRAILNORTH = 0x5ee, AER_SPRITE_STAIRSRIGHTRAILSOUTH = 0x5ef, AER_SPRITE_STAIRSRIGHTRAILWEST = 0x5f0, AER_SPRITE_STAIRSRIGHTRAILWHOLEMASK = 0x5f1, AER_SPRITE_STAIRSRIGHTSOUTH = 0x5f2, AER_SPRITE_STAIRSRIGHTWEST = 0x5f3, AER_SPRITE_STAIRSUPABYSSSMALL = 0x5f4, AER_SPRITE_STAIRSUPCENTRAL = 0x5f5, AER_SPRITE_STAIRSUPCENTRALSMALL = 0x5f6, AER_SPRITE_STAIRSUPEAST = 0x5f7, AER_SPRITE_STAIRSUPEASTSMALL = 0x5f8, AER_SPRITE_STAIRSUPNORTH = 0x5f9, AER_SPRITE_STAIRSUPNORTHSMALL = 0x5fa, AER_SPRITE_STAIRSUPSOUTH = 0x5fb, AER_SPRITE_STAIRSUPWEST = 0x5fc, AER_SPRITE_STIARSUPABYSS = 0x5fd, AER_SPRITE_SSTAIRSUP_0 = 0x5fe, AER_SPRITE_SSTAIRSUP_1 = 0x5ff, AER_SPRITE_SLOWSWITCHHOLE = 0x600, AER_SPRITE_SLOWSWITCHPILLAR = 0x601, AER_SPRITE_TERMINALHOLE = 0x602, AER_SPRITE_TERMINAL = 0x603, AER_SPRITE_SWITCHPILLAR = 0x604, AER_SPRITE_RAILGUNSWITCH = 0x605, AER_SPRITE_TIMEDSWITCHPILLAR = 0x606, AER_SPRITE_VENDINGMACHINE = 0x607, AER_SPRITE_WARPPADBASE = 0x608, AER_SPRITE_WARPPADFLASH = 0x609, AER_SPRITE_WARPPADGLOW = 0x60a, AER_SPRITE_WELLTOWEREAST = 0x60b, AER_SPRITE_WELLTOWEREASTGLOW = 0x60c, AER_SPRITE_WELLTOWERNORTH = 0x60d, AER_SPRITE_WELLTOWERNORTHGLOW = 0x60e, AER_SPRITE_WELLTOWERSOUTH = 0x60f, AER_SPRITE_WELLTOWERSOUTHGLOW = 0x610, AER_SPRITE_WELLTOWERSURFACEMASK = 0x611, AER_SPRITE_WELLTOWERWEST = 0x612, AER_SPRITE_WELLTOWERWESTGLOW = 0x613, AER_SPRITE_WELLTOWERMASK = 0x614, AER_SPRITE_CHALREGIONBORDER = 0x615, AER_SPRITE_CHALLENGEPIPON = 0x616, AER_SPRITE_CHALLENGEPIPOFF = 0x617, AER_SPRITE_HIGHSCOREBG = 0x618, AER_SPRITE_SOCCERSCOREBG = 0x619, AER_SPRITE_HIGHSCOREBGSMALL = 0x61a, AER_SPRITE_DANGERMODEICON = 0x61b, AER_SPRITE_MAPOBJ = 0x61c, AER_SPRITE_SHORTWARP = 0x61d, AER_SPRITE_TELEPORTER = 0x61e, AER_SPRITE_POPUPTURRET = 0x61f, AER_SPRITE_POPUPTURRETDEAD = 0x620, AER_SPRITE_POPUPTURRETHOLE = 0x621, AER_SPRITE_POPUPTURRETMASK = 0x622, AER_SPRITE_POPUPTURRETNEW = 0x623, AER_SPRITE_TONESTONE = 0x624, AER_SPRITE_ACID = 0x625, AER_SPRITE_ACIDPOOL32 = 0x626, AER_SPRITE_ACIDPOOL48 = 0x627, AER_SPRITE_CRUSHBLOCK = 0x628, AER_SPRITE_CRUSHBLOCKTRACKLIGHTSLR = 0x629, AER_SPRITE_CRUSHBLOCKTRACKLIGHTSUD = 0x62a, AER_SPRITE_CRUSHBLOCKTRACKDOCK = 0x62b, AER_SPRITE_CRUSHBLOCKTRACKH = 0x62c, AER_SPRITE_CRUSHBLOCKTRACKV = 0x62d, AER_SPRITE_FLAMEJET = 0x62e, AER_SPRITE_FLAMEPOLE = 0x62f, AER_SPRITE_FLAMETHROWER = 0x630, AER_SPRITE_MINE = 0x631, AER_SPRITE_PHASEDROPPLATFORM128 = 0x632, AER_SPRITE_PHASEDROPPLATFORM64 = 0x633, AER_SPRITE_PHASEMINE = 0x634, AER_SPRITE_SINKINGPLATFORM = 0x635, AER_SPRITE_SINKINGPLATFORMCLIFF = 0x636, AER_SPRITE_SOUTHMINE = 0x637, AER_SPRITE_TIMEPOLE = 0x638, AER_SPRITE_TIMESLOWERPYLON = 0x639, AER_SPRITE_TURRETORB = 0x63a, AER_SPRITE_BETACAPEPICKUP = 0x63b, AER_SPRITE_BETACAPENUDE = 0x63c, AER_SPRITE_BETACAPEMASK = 0x63d, AER_SPRITE_COLLECTIBLEPERCHGEM = 0x63e, AER_SPRITE_BUBBLEDRONE = 0x63f, AER_SPRITE_DRONE1 = 0x640, AER_SPRITE_STUNDRONE = 0x641, AER_SPRITE_BATTERYREFILLER = 0x642, AER_SPRITE_BLOODCOLLECT1 = 0x643, AER_SPRITE_BLOODCOLLECT2 = 0x644, AER_SPRITE_GEARBITDOUBLENEW = 0x645, AER_SPRITE_HEALTHKIT = 0x646, AER_SPRITE_HEALTHPLANTPICKUP = 0x647, AER_SPRITE_LIBRARIANCASE = 0x648, AER_SPRITE_LIBRARIANFINALPARAGRAPH = 0x649, AER_SPRITE_LIBRARIANTABLET = 0x64a, AER_SPRITE_LIBRARIANTEXTLOADING = 0x64b, AER_SPRITE_LIBRARIANTEXTS = 0x64c, AER_SPRITE_STEAK = 0x64d, AER_SPRITE_LIBRARYDRIFTERTYPE = 0x64e, AER_SPRITE_NPCTALKBUBBLE = 0x64f, AER_SPRITE_NPCMINIBUBBLE = 0x650, AER_SPRITE_JARFROGCARRY = 0x651, AER_SPRITE_SOCKIDIDLE = 0x652, AER_SPRITE_SOCKIDKICK = 0x653, AER_SPRITE_SOCKIDRUN = 0x654, AER_SPRITE_BDSETMAP = 0x655, AER_SPRITE_BDTYPING = 0x656, AER_SPRITE_BDWALKSOUTH = 0x657, AER_SPRITE_BDSTORYPANELS = 0x658, AER_SPRITE_BDSCENENORTH = 0x659, AER_SPRITE_BDSCENEWEST = 0x65a, AER_SPRITE_BDSCENEEAST = 0x65b, AER_SPRITE_BDSCENESOUTH = 0x65c, AER_SPRITE_BDCOUGH = 0x65d, AER_SPRITE_BDHEAVYCOUGH = 0x65e, AER_SPRITE_BDLOOKDOWN = 0x65f, AER_SPRITE_BDLOOKRIGHT = 0x660, AER_SPRITE_BDRAGGEDBREATHE = 0x661, AER_SPRITE_BDSLUMPHEAVYCOUGH = 0x662, AER_SPRITE_BDSLUMPLOOKUP = 0x663, AER_SPRITE_BDDEAD = 0x664, AER_SPRITE_BDDYING = 0x665, AER_SPRITE_BDCAPEONBODY = 0x666, AER_SPRITE_BDIDLE = 0x667, AER_SPRITE_BDCHAT = 0x668, AER_SPRITE_BDDOWN = 0x669, AER_SPRITE_BDRIGHT = 0x66a, AER_SPRITE_NPCAKASHECARYIDLEGRIND = 0x66b, AER_SPRITE_NPCBEAUIDLEBONK00 = 0x66c, AER_SPRITE_NPCBEAUIDLETAP = 0x66d, AER_SPRITE_NPCBKRCHELSEAIDLEPAT = 0x66e, AER_SPRITE_NPCBKRRICHIDLEDRINKCHAT = 0x66f, AER_SPRITE_NPCBLOOZERIDLESWIG = 0x670, AER_SPRITE_NPCBOOTSIDLEPOLISH = 0x671, AER_SPRITE_NPCBUTCHERIDLECHOP = 0x672, AER_SPRITE_NPCCASEYIDLESCRATCH = 0x673, AER_SPRITE_NPCCATIDLEMEOW = 0x674, AER_SPRITE_NPCCATIDLENAP = 0x675, AER_SPRITE_NPCCOSIGUARDIDLESNIFF = 0x676, AER_SPRITE_NPCEASTOTTERIDLEHAMMER = 0x677, AER_SPRITE_NPCFATSO = 0x678, AER_SPRITE_NPCLAKE = 0x679, AER_SPRITE_NPCLISAIDLEDISTRACTED = 0x67a, AER_SPRITE_NPCMUDKIDIDLEKICK = 0x67b, AER_SPRITE_NPCNORTHGRANNYBIRDIDLELOOK = 0x67c, AER_SPRITE_NPCNORTHGRANNYBIRDIDLESTROKE = 0x67d, AER_SPRITE_NPCRICHIDLESTRUM = 0x67e, AER_SPRITE_NPCROBOMONKIDLEBREEZE = 0x67f, AER_SPRITE_NPCROBOMONKIDLENOD = 0x680, AER_SPRITE_NPCSICKDRIFTERIDLECOUGH = 0x681, AER_SPRITE_NPCSOUTHLIZARDGRAMP = 0x682, AER_SPRITE_NPCTEDDYDASH = 0x683, AER_SPRITE_NPCTEDDYIDLESUP = 0x684, AER_SPRITE_NPCTOM = 0x685, AER_SPRITE_NPCSEANGUINIDLEANIM = 0x686, AER_SPRITE_NPCSEANGUINIDLETHINK = 0x687, AER_SPRITE_NPCWESTTANUKSON = 0x688, AER_SPRITE_NPCNBOSS = 0x689, AER_SPRITE_NPCNTALK1 = 0x68a, AER_SPRITE_NPCNIDLE1 = 0x68b, AER_SPRITE_NPCSBOSS = 0x68c, AER_SPRITE_NPCLIZARDFAMILY = 0x68d, AER_SPRITE_NPCLIZARDSITIDLE = 0x68e, AER_SPRITE_NPCLIZARDSITTALK = 0x68f, AER_SPRITE_NPCEBOSS = 0x690, AER_SPRITE_NPCEIDLE1 = 0x691, AER_SPRITE_NPCWBOSS = 0x692, AER_SPRITE_NPCWSOLDIER = 0x693, AER_SPRITE_NPCWOLDMANTAN = 0x694, AER_SPRITE_NPCOTTERCOLORS = 0x695, AER_SPRITE_NPCOTTERTALK = 0x696, AER_SPRITE_NPCOTTERWALK = 0x697, AER_SPRITE_NPCOTTERNO = 0x698, AER_SPRITE_NPCOTTERIDLE = 0x699, AER_SPRITE_NPCOTTERHI = 0x69a, AER_SPRITE_NPCOTTERYES = 0x69b, AER_SPRITE_NPCLIZARDCOLORS = 0x69c, AER_SPRITE_NPCLIZARDTALK = 0x69d, AER_SPRITE_NPCLIZARDHI = 0x69e, AER_SPRITE_NPCLIZARDIDLE = 0x69f, AER_SPRITE_NPCLIZARDNO = 0x6a0, AER_SPRITE_NPCLIZARDWALK = 0x6a1, AER_SPRITE_NPCLIZARDYES = 0x6a2, AER_SPRITE_NPCFROGCOLORS = 0x6a3, AER_SPRITE_NPCFROGTALK = 0x6a4, AER_SPRITE_NPCFROGHI = 0x6a5, AER_SPRITE_NPCFROGIDLE = 0x6a6, AER_SPRITE_NPCFROGNO = 0x6a7, AER_SPRITE_NPCFROGYES = 0x6a8, AER_SPRITE_NPCFROGWALK = 0x6a9, AER_SPRITE_NPCBIRDMANWALK = 0x6aa, AER_SPRITE_NPCBIRDMANIDLE = 0x6ab, AER_SPRITE_NPCBIRDMANCOLORS = 0x6ac, AER_SPRITE_NPCBIRDMANTALKHAPPY = 0x6ad, AER_SPRITE_NPCBIRDMANTALKNEUTRAL = 0x6ae, AER_SPRITE_NPCBIRDMANTALKSHRUG = 0x6af, AER_SPRITE_VENDORCOMPANION = 0x6b0, AER_SPRITE_VENDORREGISTER = 0x6b1, AER_SPRITE_NPCBUFFALOSMOKE = 0x6b2, AER_SPRITE_NPCBUFFALOTABLET = 0x6b3, AER_SPRITE_NPCBUFFALOGESTURE = 0x6b4, AER_SPRITE_NPCBUFFALOSCORE = 0x6b5, AER_SPRITE_HOBOCASEY = 0x6b6, AER_SPRITE_FOLDERGENERAL = 0x6b7, AER_SPRITE_GTELEVATORFLOOR = 0x6b8, AER_SPRITE_GSECRETS = 0x6b9, AER_SPRITE_GTABLETBASE = 0x6ba, AER_SPRITE_GSKITTERBUGS = 0x6bb, AER_SPRITE_SCNSKELETON = 0x6bc, AER_SPRITE_GHYPERLIGHTPLANT = 0x6bd, AER_SPRITE_GCONT = 0x6be, AER_SPRITE_GMECH1 = 0x6bf, AER_SPRITE_GMECH2 = 0x6c0, AER_SPRITE_GMECH7 = 0x6c1, AER_SPRITE_GMECH4 = 0x6c2, AER_SPRITE_GMECH3 = 0x6c3, AER_SPRITE_GMECH5 = 0x6c4, AER_SPRITE_SCNGAUNTLETOBJBENCCLUST02 = 0x6c5, AER_SPRITE_SCNGAUNTLETOBJBENCCLUST03 = 0x6c6, AER_SPRITE_SCNGAUNTLETOBJBENCCLUST01 = 0x6c7, AER_SPRITE_GEXITDOWN = 0x6c8, AER_SPRITE_GSHADOW32 = 0x6c9, AER_SPRITE_GSHADOW64 = 0x6ca, AER_SPRITE_EPARAFG = 0x6cb, AER_SPRITE_GMONUMENTS = 0x6cc, AER_SPRITE_GWELLFGBLOCK = 0x6cd, AER_SPRITE_BONFIREFLAME = 0x6ce, AER_SPRITE_BONFIRELIGHT = 0x6cf, AER_SPRITE_BSHALLOWSBOAT = 0x6d0, AER_SPRITE_INBSHALLOVERHANG = 0x6d1, AER_SPRITE_INBSHALLWALL = 0x6d2, AER_SPRITE_INBSHALLBEAMS = 0x6d3, AER_SPRITE_INBSHALLOWSTARP = 0x6d4, AER_SPRITE_INDEBRISM = 0x6d5, AER_SPRITE_INMECHS = 0x6d6, AER_SPRITE_INMECHXL = 0x6d7, AER_SPRITE_INMECHL = 0x6d8, AER_SPRITE_INMECHSIDE = 0x6d9, AER_SPRITE_INMECHCLIFFS = 0x6da, AER_SPRITE_INMECHCLIFFL = 0x6db, AER_SPRITE_BADASSSITBREATHE = 0x6dc, AER_SPRITE_GDRIFTERLAYDOWN = 0x6dd, AER_SPRITE_GSLEEPYDEADDRIFTER = 0x6de, AER_SPRITE_INTROBEACH = 0x6df, AER_SPRITE_INBROKENBOT = 0x6e0, AER_SPRITE_BSHALLOWSRIPPLE = 0x6e1, AER_SPRITE_BSHALLOWSRIPPLESTAMP = 0x6e2, AER_SPRITE_INBGCLIFFEDGE = 0x6e3, AER_SPRITE_IN01BROKENSHALLOWS = 0x6e4, AER_SPRITE_INSPBROKENBG = 0x6e5, AER_SPRITE_INSPHORIZONCLIFF = 0x6e6, AER_SPRITE_INSPHORIZONCLOUDS = 0x6e7, AER_SPRITE_INPINKHORBG = 0x6e8, AER_SPRITE_INSPHORBG2 = 0x6e9, AER_SPRITE_INTECHKEEPFG = 0x6ea, AER_SPRITE_INTECHKEEP = 0x6eb, AER_SPRITE_FOLDERLAB = 0x6ec, AER_SPRITE_WLABBLOCK16 = 0x6ed, AER_SPRITE_WLABBLOCK16B = 0x6ee, AER_SPRITE_WLABBLOCK16C = 0x6ef, AER_SPRITE_WLABBLOCK48FAT = 0x6f0, AER_SPRITE_WLABBLOCK64 = 0x6f1, AER_SPRITE_GUBERBLOCKS = 0x6f2, AER_SPRITE_GUBERBLOCKM = 0x6f3, AER_SPRITE_GUBERBLOCKL = 0x6f4, AER_SPRITE_WLABPILLAR16 = 0x6f5, AER_SPRITE_GPILLARSKINNY128 = 0x6f6, AER_SPRITE_GPILLARTOPLESS = 0x6f7, AER_SPRITE_WLABPILLAR32 = 0x6f8, AER_SPRITE_WLABWALL32 = 0x6f9, AER_SPRITE_WLABWALL64 = 0x6fa, AER_SPRITE_GWALL64OP01 = 0x6fb, AER_SPRITE_GWALL64TOP = 0x6fc, AER_SPRITE_GWALL128 = 0x6fd, AER_SPRITE_GWALL64OP = 0x6fe, AER_SPRITE_GWALLBANNER = 0x6ff, AER_SPRITE_WLABDOOR = 0x700, AER_SPRITE_GWALLFIN32 = 0x701, AER_SPRITE_GWALLFIN128 = 0x702, AER_SPRITE_GLABWALLTOPDEETS64 = 0x703, AER_SPRITE_GRAILLHOR = 0x704, AER_SPRITE_GRAILLHORCRUMBLE = 0x705, AER_SPRITE_GRAILLVER = 0x706, AER_SPRITE_GRAILLCORNER = 0x707, AER_SPRITE_SPRITE3337 = 0x708, AER_SPRITE_GRAILLENDR = 0x709, AER_SPRITE_WLABBLOCK08VERT = 0x70a, AER_SPRITE_WLABBLOCK08 = 0x70b, AER_SPRITE_GELEVATORBG = 0x70c, AER_SPRITE_GELEVATORBG2 = 0x70d, AER_SPRITE_GWALLDECDRIP = 0x70e, AER_SPRITE_GLLIGHTFLOORPINK = 0x70f, AER_SPRITE_SCNGAUNTLETFLOORLIGHTSTWO = 0x710, AER_SPRITE_SCNLABLIGHTSFLOOR = 0x711, AER_SPRITE_GLABFLOORSTAIN = 0x712, AER_SPRITE_SCNGAUNTLETDEBRIS = 0x713, AER_SPRITE_GCRUSHBLOCKTRACKS = 0x714, AER_SPRITE_SCNGAUNTLETFLOORGRATESM = 0x715, AER_SPRITE_GLGRATEM = 0x716, AER_SPRITE_SCNGAUNTLETFLOORGRATEBIG = 0x717, AER_SPRITE_GLEXITFLOORDARKSIDE = 0x718, AER_SPRITE_GLEXITFLOORDARKUP = 0x719, AER_SPRITE_GLEXITFLOORLIGHTSIDE = 0x71a, AER_SPRITE_SCNGAUNTLETDOORBG = 0x71b, AER_SPRITE_INFLOOREDGE = 0x71c, AER_SPRITE_INFLOOREDGE2 = 0x71d, AER_SPRITE_LABCLIFF16 = 0x71e, AER_SPRITE_LABCLIFF32 = 0x71f, AER_SPRITE_WLABCLIFFX = 0x720, AER_SPRITE_GCLIFF32F = 0x721, AER_SPRITE_GCLIFFUNDER = 0x722, AER_SPRITE_GLABTOPS = 0x723, AER_SPRITE_GLTOPPATCHBIG = 0x724, AER_SPRITE_SCNGAUNTLETCEILINGTOPVERT01 = 0x725, AER_SPRITE_SCNGAUNTLETCEILINGPIECER = 0x726, AER_SPRITE_GLFGBEAM01 = 0x727, AER_SPRITE_GLFGBEAM02 = 0x728, AER_SPRITE_GFGHEAD = 0x729, AER_SPRITE_GCEILINGBORDER = 0x72a, AER_SPRITE_GCEILINGBORDERANGLE = 0x72b, AER_SPRITE_SCNGAUNTLETCEILINGTOP32 = 0x72c, AER_SPRITE_SCNGAUNTLETCEILINGTOP64 = 0x72d, AER_SPRITE_FOLDERLABRARE = 0x72e, AER_SPRITE_GBOXSTACK = 0x72f, AER_SPRITE_GSTORAGEBOXES = 0x730, AER_SPRITE_ACHAIR = 0x731, AER_SPRITE_ATABLEHOLO = 0x732, AER_SPRITE_GSHELF = 0x733, AER_SPRITE_ASHELFTHIN = 0x734, AER_SPRITE_GNARROWLOCKERS01 = 0x735, AER_SPRITE_ASHELFTALL = 0x736, AER_SPRITE_GSHELVES01 = 0x737, AER_SPRITE_GBED01TOP = 0x738, AER_SPRITE_GBED01BOTT = 0x739, AER_SPRITE_GBED = 0x73a, AER_SPRITE_GRANDOMCOUCH = 0x73b, AER_SPRITE_GMACHS = 0x73c, AER_SPRITE_GMACHM = 0x73d, AER_SPRITE_GMACHL = 0x73e, AER_SPRITE_GMACHMEGA = 0x73f, AER_SPRITE_ACOMPTHIN = 0x740, AER_SPRITE_ACOMPFAT = 0x741, AER_SPRITE_GCOMPLONG = 0x742, AER_SPRITE_GBRACEDBOX = 0x743, AER_SPRITE_GLABDESK01 = 0x744, AER_SPRITE_GLABDESK02 = 0x745, AER_SPRITE_SPRIGLABDESK03 = 0x746, AER_SPRITE_GLABDESK03 = 0x747, AER_SPRITE_GLOWTABLE01 = 0x748, AER_SPRITE_GPIPECONNECT = 0x749, AER_SPRITE_GPIPETERMINATE = 0x74a, AER_SPRITE_GHLPIPESWALLVER = 0x74b, AER_SPRITE_GHLPIPEMWALLVER = 0x74c, AER_SPRITE_GHLPIPESFLOORVER = 0x74d, AER_SPRITE_GHLPIPEMFLOORVER = 0x74e, AER_SPRITE_GHLPIPESHOR = 0x74f, AER_SPRITE_GHLPIPEMHOR = 0x750, AER_SPRITE_GHLPIPEANGLE = 0x751, AER_SPRITE_GHLPIPEANGLECOLLISION = 0x752, AER_SPRITE_GLHLSTORAGEH01 = 0x753, AER_SPRITE_GLHLSTORAGEV01 = 0x754, AER_SPRITE_GLHLSTORAGEV02 = 0x755, AER_SPRITE_GLHLSTORAGEBIG = 0x756, AER_SPRITE_SCNGAUNTLETOBJBLOCKGRASSYBIG = 0x757, AER_SPRITE_SCNGAUNTLETOBJBLOCKGRASSYSMALL = 0x758, AER_SPRITE_GHLCONTAINL = 0x759, AER_SPRITE_GHLCONTAINU = 0x75a, AER_SPRITE_GMEGASTATUE = 0x75b, AER_SPRITE_SCNGAUNTLETDECEMBLEM = 0x75c, AER_SPRITE_GLSTAIRRAILUP = 0x75d, AER_SPRITE_GSTAIRBEAMS = 0x75e, AER_SPRITE_GSTAIRCHUNK = 0x75f, AER_SPRITE_SCNGAUNTLETTELEPORTPANEL = 0x760, AER_SPRITE_SPRITE2873 = 0x761, AER_SPRITE_FOLDERCENTRAL = 0x762, AER_SPRITE_CLEDGEGRASS = 0x763, AER_SPRITE_CMOSS = 0x764, AER_SPRITE_CVINEL = 0x765, AER_SPRITE_CVINEXL = 0x766, AER_SPRITE_CCUTSHRUB = 0x767, AER_SPRITE_CSHRUBS = 0x768, AER_SPRITE_CSHRUBL = 0x769, AER_SPRITE_CTREE01 = 0x76a, AER_SPRITE_CTREEBIG = 0x76b, AER_SPRITE_CPOT1 = 0x76c, AER_SPRITE_CCRATE4 = 0x76d, AER_SPRITE_CCRATE3 = 0x76e, AER_SPRITE_CCRATE1 = 0x76f, AER_SPRITE_CCRATE5 = 0x770, AER_SPRITE_CCRATE2 = 0x771, AER_SPRITE_CLAMP = 0x772, AER_SPRITE_CTECHS01 = 0x773, AER_SPRITE_CGENERATOR01 = 0x774, AER_SPRITE_CKART1 = 0x775, AER_SPRITE_CBARREL01 = 0x776, AER_SPRITE_CSIGNS = 0x777, AER_SPRITE_CSIGNVENDORS = 0x778, AER_SPRITE_CSIGNHANGER = 0x779, AER_SPRITE_CDECOR1 = 0x77a, AER_SPRITE_CROOFS = 0x77b, AER_SPRITE_CAWNING01 = 0x77c, AER_SPRITE_CROOFRAG = 0x77d, AER_SPRITE_CSIDETOP = 0x77e, AER_SPRITE_CROOFL = 0x77f, AER_SPRITE_CPATCHWORKROOF = 0x780, AER_SPRITE_CPATCHSIDE = 0x781, AER_SPRITE_CPOLE = 0x782, AER_SPRITE_CPIPESL = 0x783, AER_SPRITE_CPIPESS = 0x784, AER_SPRITE_SPRITE2859 = 0x785, AER_SPRITE_CSIDEBLOCKSIDE = 0x786, AER_SPRITE_CSIDEBLOCKSIDE1 = 0x787, AER_SPRITE_CSIDEBLOCKS = 0x788, AER_SPRITE_CSTAIRRAILUP = 0x789, AER_SPRITE_CGATEWAY = 0x78a, AER_SPRITE_CDEBRISS = 0x78b, AER_SPRITE_CDEBRIS = 0x78c, AER_SPRITE_CTELEVATORDREGS = 0x78d, AER_SPRITE_CSTAIRRAILSIDEBACKX = 0x78e, AER_SPRITE_CBUILDINGSEXTRA = 0x78f, AER_SPRITE_CBUILDINGDOOR = 0x790, AER_SPRITE_CVENENTRANCEFLOOR = 0x791, AER_SPRITE_CBUILDINGS = 0x792, AER_SPRITE_CBUILDINGM = 0x793, AER_SPRITE_CRUINVERT = 0x794, AER_SPRITE_CRUINSIDES = 0x795, AER_SPRITE_CRUINSIDEL = 0x796, AER_SPRITE_COUTERWALL1 = 0x797, AER_SPRITE_COUTERWALLPILLAR = 0x798, AER_SPRITE_CINWALL32 = 0x799, AER_SPRITE_CGRATES01 = 0x79a, AER_SPRITE_CSTREETTILE = 0x79b, AER_SPRITE_CSTREETTILE32 = 0x79c, AER_SPRITE_CFLOWER = 0x79d, AER_SPRITE_CGRASSSPROUT = 0x79e, AER_SPRITE_CLUSHFLOORS01 = 0x79f, AER_SPRITE_CLUSHFLOORL02 = 0x7a0, AER_SPRITE_CFLOORPATCHBIG04 = 0x7a1, AER_SPRITE_CFLOORPATCHBIG = 0x7a2, AER_SPRITE_CLUSHVERT = 0x7a3, AER_SPRITE_CLUSHFRONTS = 0x7a4, AER_SPRITE_CLUSHBACKGRASSS = 0x7a5, AER_SPRITE_CDUMMY = 0x7a6, AER_SPRITE_CSWAPSHELF = 0x7a7, AER_SPRITE_INBADASSLUGGAGE = 0x7a8, AER_SPRITE_CEXTERIOR = 0x7a9, AER_SPRITE_CEEXTERIORBASE = 0x7aa, AER_SPRITE_CAKASHBG = 0x7ab, AER_SPRITE_CBUTCHERBG = 0x7ac, AER_SPRITE_CSCOREBOARD = 0x7ad, AER_SPRITE_CCARPET = 0x7ae, AER_SPRITE_CBACKERRICHCARPET = 0x7af, AER_SPRITE_CRUGBIG = 0x7b0, AER_SPRITE_PBANNLOOPPRE00000 = 0x7b1, AER_SPRITE_CAPOTHCHART = 0x7b2, AER_SPRITE_CAPOTHSCROLLS = 0x7b3, AER_SPRITE_CAPOTHDRAWERS = 0x7b4, AER_SPRITE_CAPOTHPLANTS01 = 0x7b5, AER_SPRITE_CAPOTHPOTS01 = 0x7b6, AER_SPRITE_CAPOTHRUG = 0x7b7, AER_SPRITE_CAPOTHSHELVES = 0x7b8, AER_SPRITE_CDASHBIGSTACK = 0x7b9, AER_SPRITE_CDASHBOARDS = 0x7ba, AER_SPRITE_CDASHBOXES01 = 0x7bb, AER_SPRITE_CDASHCONSOLE = 0x7bc, AER_SPRITE_CDASHCOUNTER = 0x7bd, AER_SPRITE_CDASHMEGASHELVES = 0x7be, AER_SPRITE_CDASHSHELVES = 0x7bf, AER_SPRITE_CDASHSMALLSHELVES = 0x7c0, AER_SPRITE_CDASHSTOOL = 0x7c1, AER_SPRITE_CDOJODUMMY3 = 0x7c2, AER_SPRITE_CDOJOHANGING = 0x7c3, AER_SPRITE_CDOJOSMALLRACK = 0x7c4, AER_SPRITE_CDOJOMEDIUMRACK = 0x7c5, AER_SPRITE_CDOJOLARGERACK = 0x7c6, AER_SPRITE_CDOJOVERTRACK = 0x7c7, AER_SPRITE_CGUNCOUNTER = 0x7c8, AER_SPRITE_CGUNBOT = 0x7c9, AER_SPRITE_CGUNCASE = 0x7ca, AER_SPRITE_CGUNCASESMALL = 0x7cb, AER_SPRITE_CGUNRACK = 0x7cc, AER_SPRITE_CVENHEAD = 0x7cd, AER_SPRITE_CGUNTABLE = 0x7ce, AER_SPRITE_CMECHVEN = 0x7cf, AER_SPRITE_CSPECCONSOLESIDE = 0x7d0, AER_SPRITE_CSPECCORE = 0x7d1, AER_SPRITE_CSPECSHELFLARGE = 0x7d2, AER_SPRITE_CSPECSHELFSMALL = 0x7d3, AER_SPRITE_CSPECSIDETABLE = 0x7d4, AER_SPRITE_CSPECSOLENOID = 0x7d5, AER_SPRITE_CSPECWARP = 0x7d6, AER_SPRITE_CSPECWORKBENCH = 0x7d7, AER_SPRITE_FOUNTAIN = 0x7d8, AER_SPRITE_CELECTRIC02 = 0x7d9, AER_SPRITE_CELECTRICWIRE1 = 0x7da, AER_SPRITE_CELECTRICWIRE2 = 0x7db, AER_SPRITE_CBACKERTABLET = 0x7dc, AER_SPRITE_CBACKERTABELTNEON = 0x7dd, AER_SPRITE_CFLOWERTINY = 0x7de, AER_SPRITE_CGRASSIN = 0x7df, AER_SPRITE_CROCK32 = 0x7e0, AER_SPRITE_CROCKEMB1 = 0x7e1, AER_SPRITE_INSTAIRSCOVER = 0x7e2, AER_SPRITE_CRBGRASSCHUNK = 0x7e3, AER_SPRITE_CROCKBLOCKSML = 0x7e4, AER_SPRITE_CROCKBLOCKMED = 0x7e5, AER_SPRITE_CROCKBLOCKTHIN = 0x7e6, AER_SPRITE_CROCKBLOCKBIGS = 0x7e7, AER_SPRITE_CCLIFF16 = 0x7e8, AER_SPRITE_CCLIFF = 0x7e9, AER_SPRITE_CFALLENCLIFF = 0x7ea, AER_SPRITE_WATERSHIMMERFADE000 = 0x7eb, AER_SPRITE_CMECHEXPLODED = 0x7ec, AER_SPRITE_CFALLMECH = 0x7ed, AER_SPRITE_AKNEELBOT01 = 0x7ee, AER_SPRITE_AKNEELBOTBROKEN01 = 0x7ef, AER_SPRITE_AKNEELBOTSIDE01 = 0x7f0, AER_SPRITE_CROBOTCRUSH = 0x7f1, AER_SPRITE_CARTILLERYDOWN = 0x7f2, AER_SPRITE_CARTILLERYUP = 0x7f3, AER_SPRITE_CGIANTARTILLERY = 0x7f4, AER_SPRITE_CBEHEMOTH = 0x7f5, AER_SPRITE_CSPDROPSHIP = 0x7f6, AER_SPRITE_CSKULLS = 0x7f7, AER_SPRITE_CBONEPILE = 0x7f8, AER_SPRITE_CBUNKER01 = 0x7f9, AER_SPRITE_FOLDERNORTH = 0x7fa, AER_SPRITE_NCUTSHRUB = 0x7fb, AER_SPRITE_NOVERGTINY = 0x7fc, AER_SPRITE_NOVERGSUNDER = 0x7fd, AER_SPRITE_NOVERGS = 0x7fe, AER_SPRITE_NOVERGM = 0x7ff, AER_SPRITE_NOVERGU = 0x800, AER_SPRITE_NTREESM = 0x801, AER_SPRITE_NTREEL = 0x802, AER_SPRITE_NTREEXL = 0x803, AER_SPRITE_NTREESNOWSM = 0x804, AER_SPRITE_NRAILH = 0x805, AER_SPRITE_NRAILV = 0x806, AER_SPRITE_NSOCBLOCK32 = 0x807, AER_SPRITE_NSOCBLOCK32B = 0x808, AER_SPRITE_NSOCBLOCK32C = 0x809, AER_SPRITE_NSOCBLOCK48 = 0x80a, AER_SPRITE_NSOCBLOCK64 = 0x80b, AER_SPRITE_NBLOCK32 = 0x80c, AER_SPRITE_NBLOCK64 = 0x80d, AER_SPRITE_NPILLAR16 = 0x80e, AER_SPRITE_NBUILDINGXS = 0x80f, AER_SPRITE_NBUILDINGS = 0x810, AER_SPRITE_NBUILDINGM = 0x811, AER_SPRITE_NBUILDINGMSPECIAL = 0x812, AER_SPRITE_NBUILDINGL = 0x813, AER_SPRITE_NBUILDINGFGS = 0x814, AER_SPRITE_NRUINSFG1 = 0x815, AER_SPRITE_NORTHFLAG = 0x816, AER_SPRITE_NPILLAR32 = 0x817, AER_SPRITE_NPCNCLIMBERDEAD = 0x818, AER_SPRITE_NENTRANCEARCH = 0x819, AER_SPRITE_NBIRDETCHING = 0x81a, AER_SPRITE_NSTATUES = 0x81b, AER_SPRITE_NSTATUEL = 0x81c, AER_SPRITE_NBIRDHEAD = 0x81d, AER_SPRITE_NBIRDHEADPANEL = 0x81e, AER_SPRITE_NSTAIRRAILUP = 0x81f, AER_SPRITE_NSTAIRTOPSUP = 0x820, AER_SPRITE_NSTAIRTOPUP = 0x821, AER_SPRITE_NBROKENSTAIRS = 0x822, AER_SPRITE_NSTAIRTOPSIDE = 0x823, AER_SPRITE_NSTAIRSBROKENSIDE = 0x824, AER_SPRITE_SPRITE3386 = 0x825, AER_SPRITE_NSTAIRCHUNK = 0x826, AER_SPRITE_NROCKBLOCK16 = 0x827, AER_SPRITE_NROCKBLOCK48 = 0x828, AER_SPRITE_NROCKBLOCK64 = 0x829, AER_SPRITE_NROCKWALLLIP = 0x82a, AER_SPRITE_NROCKBIG01 = 0x82b, AER_SPRITE_NROCKBIG02 = 0x82c, AER_SPRITE_NROCKBIG03 = 0x82d, AER_SPRITE_NROCKDETAIL = 0x82e, AER_SPRITE_NROCKWALLDIAGTHIN = 0x82f, AER_SPRITE_NROCKWALLDIAG = 0x830, AER_SPRITE_NROCKWALL = 0x831, AER_SPRITE_NROCKWALL64 = 0x832, AER_SPRITE_NROCKWALL64ENTRANCE = 0x833, AER_SPRITE_NROCKWALL128 = 0x834, AER_SPRITE_NROCKBLOCKBIG = 0x835, AER_SPRITE_NCLIFFBOTTOMFLAT = 0x836, AER_SPRITE_NCLIFFBOTTOM = 0x837, AER_SPRITE_NCLIFFMIDDLE = 0x838, AER_SPRITE_NCLIFFMIDDLED = 0x839, AER_SPRITE_NRWFRONTE = 0x83a, AER_SPRITE_NRWTOPSIDE = 0x83b, AER_SPRITE_NRWCORNER = 0x83c, AER_SPRITE_NRWFACED1_0 = 0x83d, AER_SPRITE_NRWBOTTOMS = 0x83e, AER_SPRITE_NRWFCESIDE = 0x83f, AER_SPRITE_NRWFCESIDEX = 0x840, AER_SPRITE_NBGCLIFFEDGEX = 0x841, AER_SPRITE_NBGCLIFFEDGE2 = 0x842, AER_SPRITE_NRWDIAGFADE = 0x843, AER_SPRITE_NCLIFFLONGSIDES = 0x844, AER_SPRITE_NCLIFFLONGSIDE = 0x845, AER_SPRITE_NBGCOLORMOUNTAIN01 = 0x846, AER_SPRITE_NRWFRONTE1 = 0x847, AER_SPRITE_NRWCORNER1 = 0x848, AER_SPRITE_NRWCORNERTOP1 = 0x849, AER_SPRITE_NRWTOPSIDE1 = 0x84a, AER_SPRITE_NRWTIP1 = 0x84b, AER_SPRITE_NRWTIPCOLOR = 0x84c, AER_SPRITE_NRWTIPCOLOL = 0x84d, AER_SPRITE_NRWFCESIDE1 = 0x84e, AER_SPRITE_NRWBOTTOMS1 = 0x84f, AER_SPRITE_NRWFACED1_1 = 0x850, AER_SPRITE_NRWFACEL1 = 0x851, AER_SPRITE_NRBGRASSCHUNK1 = 0x852, AER_SPRITE_NROCKBLOCKUSML = 0x853, AER_SPRITE_NROCKBLOCKUMED = 0x854, AER_SPRITE_NROCKBLOCKTHIN = 0x855, AER_SPRITE_NROCKBLOCKUBIG = 0x856, AER_SPRITE_NFLOWERS = 0x857, AER_SPRITE_SCNGAUNTLETGRASS = 0x858, AER_SPRITE_GRASSDEBRIS = 0x859, AER_SPRITE_NFLOORMUSHROOM = 0x85a, AER_SPRITE_NFLDIRTS = 0x85b, AER_SPRITE_NFLDIRTM = 0x85c, AER_SPRITE_NFLDIRTL = 0x85d, AER_SPRITE_NTILE16 = 0x85e, AER_SPRITE_NTILE32 = 0x85f, AER_SPRITE_NFLOORDESIGN = 0x860, AER_SPRITE_NTILE16S = 0x861, AER_SPRITE_NTILE32S = 0x862, AER_SPRITE_NFLOORPATCHSMALL = 0x863, AER_SPRITE_NFLOORPATCHBIG = 0x864, AER_SPRITE_NLEDGEGRASS = 0x865, AER_SPRITE_NOVERHANG = 0x866, AER_SPRITE_NLEDGESNOW = 0x867, AER_SPRITE_NSNOWOVERHANG = 0x868, AER_SPRITE_NSNOWPILES = 0x869, AER_SPRITE_NSNOWPATCHSM = 0x86a, AER_SPRITE_NSNOWPATCHMED = 0x86b, AER_SPRITE_NSNOWPATCHLRG = 0x86c, AER_SPRITE_NSNOWPATCHMEDFLAT = 0x86d, AER_SPRITE_NPARALLAXFG = 0x86e, AER_SPRITE_NBGCLOUDSMALL = 0x86f, AER_SPRITE_NBGCLOUD = 0x870, AER_SPRITE_NBGCLOUDDARK = 0x871, AER_SPRITE_NCLOOUD02 = 0x872, AER_SPRITE_NCLOOUD03 = 0x873, AER_SPRITE_NEGG = 0x874, AER_SPRITE_NBURNTBRICKSS01 = 0x875, AER_SPRITE_NBURNTBRICKS02COPY = 0x876, AER_SPRITE_NRUINWALL = 0x877, AER_SPRITE_NRUINWALLSIDE = 0x878, AER_SPRITE_NSCORCHMARKS = 0x879, AER_SPRITE_NSCORCHMARKL = 0x87a, AER_SPRITE_NCULTISTCORNER = 0x87b, AER_SPRITE_NBLOODALTAR = 0x87c, AER_SPRITE_NSACRIFICE = 0x87d, AER_SPRITE_NBIRDEXECUTION = 0x87e, AER_SPRITE_NLIBRARYWALL01 = 0x87f, AER_SPRITE_NSPTITANVISTA = 0x880, AER_SPRITE_NSPTITANHAND = 0x881, AER_SPRITE_NSPTITANPARA01 = 0x882, AER_SPRITE_NSPTITANFIST = 0x883, AER_SPRITE_NSPCRASHED = 0x884, AER_SPRITE_NSPTOWERVISTABG = 0x885, AER_SPRITE_NCULTISTCRUSH = 0x886, AER_SPRITE_NDEADNEST = 0x887, AER_SPRITE_NBABYBIRD = 0x888, AER_SPRITE_NSPBOSSWALL = 0x889, AER_SPRITE_NNPC = 0x88a, AER_SPRITE_NMODULEWOLF02 = 0x88b, AER_SPRITE_NMODULEWOLF = 0x88c, AER_SPRITE_NMODULEBIRD_0 = 0x88d, AER_SPRITE_NMODULEBIRD_1 = 0x88e, AER_SPRITE_NMODULEBIRDWOLF = 0x88f, AER_SPRITE_NMODULESTATUE = 0x890, AER_SPRITE_FOLDERNLAB = 0x891, AER_SPRITE_NLF1Z = 0x892, AER_SPRITE_NFGOVERGS = 0x893, AER_SPRITE_NFGOVERGB = 0x894, AER_SPRITE_NFGBEAM = 0x895, AER_SPRITE_NFGVINE = 0x896, AER_SPRITE_NLWALLICE = 0x897, AER_SPRITE_NFGSTAT = 0x898, AER_SPRITE_NLICICLE01 = 0x899, AER_SPRITE_NLICETOPS = 0x89a, AER_SPRITE_NLICETOPL = 0x89b, AER_SPRITE_NTORCH = 0x89c, AER_SPRITE_NWALLGOLOW = 0x89d, AER_SPRITE_NLF2 = 0x89e, AER_SPRITE_NLPILLARSKINNY = 0x89f, AER_SPRITE_NLWALLANGLE = 0x8a0, AER_SPRITE_NLWALL16 = 0x8a1, AER_SPRITE_NLWALL32 = 0x8a2, AER_SPRITE_NLWALL64 = 0x8a3, AER_SPRITE_NLWALL128 = 0x8a4, AER_SPRITE_NLWALL64TOP1 = 0x8a5, AER_SPRITE_NLWALLENTRANCE = 0x8a6, AER_SPRITE_NLVEG16 = 0x8a7, AER_SPRITE_NLVEG24 = 0x8a8, AER_SPRITE_NLVEG32 = 0x8a9, AER_SPRITE_CULTBIRDSTATIC = 0x8aa, AER_SPRITE_NLIGHTBLOCK = 0x8ab, AER_SPRITE_NCHAIR01 = 0x8ac, AER_SPRITE_NTABLEFRONT = 0x8ad, AER_SPRITE_NCRATESHOVEL01 = 0x8ae, AER_SPRITE_NLOCKER01 = 0x8af, AER_SPRITE_NCANDLE = 0x8b0, AER_SPRITE_NINCENSE = 0x8b1, AER_SPRITE_NSHRINE = 0x8b2, AER_SPRITE_NBOOKSS = 0x8b3, AER_SPRITE_NBOOKS16 = 0x8b4, AER_SPRITE_NBOOKS32 = 0x8b5, AER_SPRITE_NBOOKSL = 0x8b6, AER_SPRITE_NMEGABOOK = 0x8b7, AER_SPRITE_NIRONTOMB = 0x8b8, AER_SPRITE_NITOMBOPEN = 0x8b9, AER_SPRITE_NITOMBGROUP = 0x8ba, AER_SPRITE_NSHRINEPEW = 0x8bb, AER_SPRITE_NSHRINECLOTH = 0x8bc, AER_SPRITE_NTAPESTRY64 = 0x8bd, AER_SPRITE_NTAPESTRY128 = 0x8be, AER_SPRITE_NLABWALLBOOKS = 0x8bf, AER_SPRITE_NLABWALLBOOKSTALL = 0x8c0, AER_SPRITE_NCATACOMBPILLAR = 0x8c1, AER_SPRITE_NCATACOMBPILLAR03 = 0x8c2, AER_SPRITE_NSARCOPHAGUS = 0x8c3, AER_SPRITE_NCATACOMBWALL = 0x8c4, AER_SPRITE_NOSSUARY = 0x8c5, AER_SPRITE_NBIRDSKELETON = 0x8c6, AER_SPRITE_NBIRDSKELETONNICHE = 0x8c7, AER_SPRITE_NFREEZER01 = 0x8c8, AER_SPRITE_NCANISTERL = 0x8c9, AER_SPRITE_NCANISTERM = 0x8ca, AER_SPRITE_NCANISTERS = 0x8cb, AER_SPRITE_NFURNACE = 0x8cc, AER_SPRITE_NGIANTVAT = 0x8cd, AER_SPRITE_NSTOVE01 = 0x8ce, AER_SPRITE_FLOORNLAB = 0x8cf, AER_SPRITE_NLTILEZ = 0x8d0, AER_SPRITE_NLEMBLEM = 0x8d1, AER_SPRITE_NCARPET = 0x8d2, AER_SPRITE_NLICEFLOORS01 = 0x8d3, AER_SPRITE_NLICEFLOORL01 = 0x8d4, AER_SPRITE_NLICEVERT01 = 0x8d5, AER_SPRITE_NLICEFRONTS01 = 0x8d6, AER_SPRITE_NLICECROSS01 = 0x8d7, AER_SPRITE_NLFLPATCHL = 0x8d8, AER_SPRITE_NLF5 = 0x8d9, AER_SPRITE_SPRITE3338 = 0x8da, AER_SPRITE_NRAILLCORNER = 0x8db, AER_SPRITE_NRAILLENDR = 0x8dc, AER_SPRITE_NRAILLHOR = 0x8dd, AER_SPRITE_NRAILLVER = 0x8de, AER_SPRITE_NLCLIFF16 = 0x8df, AER_SPRITE_NBGCLIFFEDGE = 0x8e0, AER_SPRITE_NCLIFF64 = 0x8e1, AER_SPRITE_NBGCLOUDLAB = 0x8e2, AER_SPRITE_FOLDERSOUTH = 0x8e3, AER_SPRITE_SBLOCKS = 0x8e4, AER_SPRITE_SBLOCKM = 0x8e5, AER_SPRITE_SBLOCKL = 0x8e6, AER_SPRITE_SRAILH = 0x8e7, AER_SPRITE_SXRAILLHOR = 0x8e8, AER_SPRITE_SXRAILLVER = 0x8e9, AER_SPRITE_SXRAILLCORNER = 0x8ea, AER_SPRITE_SXRAILLCORNER3 = 0x8eb, AER_SPRITE_SXRAILLENDR = 0x8ec, AER_SPRITE_SOVERGT = 0x8ed, AER_SPRITE_SOVERGS03 = 0x8ee, AER_SPRITE_SOVERGS = 0x8ef, AER_SPRITE_SOVERGSHALF = 0x8f0, AER_SPRITE_SOVERGM = 0x8f1, AER_SPRITE_STREESM01 = 0x8f2, AER_SPRITE_STREEM = 0x8f3, AER_SPRITE_STREEL = 0x8f4, AER_SPRITE_SENTRANCEARCH = 0x8f5, AER_SPRITE_SBONES01 = 0x8f6, AER_SPRITE_SMECHSS = 0x8f7, AER_SPRITE_SMECHSM = 0x8f8, AER_SPRITE_SMECHSL = 0x8f9, AER_SPRITE_SMECHSXL = 0x8fa, AER_SPRITE_SDEBRIS16 = 0x8fb, AER_SPRITE_SDEBRIS24 = 0x8fc, AER_SPRITE_SDEBRIS32 = 0x8fd, AER_SPRITE_SDEBRIS4801 = 0x8fe, AER_SPRITE_SDEBRIS4802 = 0x8ff, AER_SPRITE_SDEBRIS6401 = 0x900, AER_SPRITE_SDEBRIS6402 = 0x901, AER_SPRITE_SDEBRIS6403 = 0x902, AER_SPRITE_SDEBRISL = 0x903, AER_SPRITE_SDEBRISXL = 0x904, AER_SPRITE_SBULBS16 = 0x905, AER_SPRITE_SBULBS32 = 0x906, AER_SPRITE_SSANDPILE = 0x907, AER_SPRITE_SDIRTSQUARE = 0x908, AER_SPRITE_SDIRTSQUARELARGE = 0x909, AER_SPRITE_SDIRTBIGBLOCK = 0x90a, AER_SPRITE_SDIRTCORNER = 0x90b, AER_SPRITE_SDIRTEDGE = 0x90c, AER_SPRITE_SDIRTCUST = 0x90d, AER_SPRITE_SDIRTCUSTD = 0x90e, AER_SPRITE_SDIRTCUTCIRCLE = 0x90f, AER_SPRITE_SLEDGESAND = 0x910, AER_SPRITE_SOVERHANG = 0x911, AER_SPRITE_STILE16 = 0x912, AER_SPRITE_STILE32 = 0x913, AER_SPRITE_SCIRCUITS = 0x914, AER_SPRITE_SCIRCUITM = 0x915, AER_SPRITE_SCIRCUITL = 0x916, AER_SPRITE_SRBLOCKS = 0x917, AER_SPRITE_SRBLOCKM = 0x918, AER_SPRITE_SRBLOCKL = 0x919, AER_SPRITE_SROCKLEDGEHORIZ64 = 0x91a, AER_SPRITE_SROCKWALLDIAGS = 0x91b, AER_SPRITE_SROCKWALLDIAG = 0x91c, AER_SPRITE_SROCKWALL = 0x91d, AER_SPRITE_SROCKWALL64 = 0x91e, AER_SPRITE_SROCKWALLBLANK = 0x91f, AER_SPRITE_SROCKLEDGEVERT64 = 0x920, AER_SPRITE_SROCKBLOCKSMALL = 0x921, AER_SPRITE_SROCKBLOCKBIG = 0x922, AER_SPRITE_SROCKBLOCKUB = 0x923, AER_SPRITE_SRWFGCOVER = 0x924, AER_SPRITE_SROCKWALLLIP01 = 0x925, AER_SPRITE_SRWCORNER = 0x926, AER_SPRITE_SRWCORNERTOP = 0x927, AER_SPRITE_SRWTIP = 0x928, AER_SPRITE_SRWTOPSIDE = 0x929, AER_SPRITE_SRWTIPCOLOR = 0x92a, AER_SPRITE_SRWTIPCOLOL = 0x92b, AER_SPRITE_SRWFRONTE = 0x92c, AER_SPRITE_SRWFACED = 0x92d, AER_SPRITE_SRWFACEL = 0x92e, AER_SPRITE_SRWFCESIDE = 0x92f, AER_SPRITE_SRWFCESIDEX = 0x930, AER_SPRITE_SRWBOTTOMS = 0x931, AER_SPRITE_SCHUNKFACE = 0x932, AER_SPRITE_SCHUNKSIDEE = 0x933, AER_SPRITE_SCHUNKTOPSIDE = 0x934, AER_SPRITE_SCHUNKTOPLEDGE = 0x935, AER_SPRITE_SRWFRONTE1 = 0x936, AER_SPRITE_SRWCORNER2 = 0x937, AER_SPRITE_SRWTOPSIDE1 = 0x938, AER_SPRITE_SCLIFFUNDER = 0x939, AER_SPRITE_SCLIFFUNDERANGLE = 0x93a, AER_SPRITE_SRBGRASSCHUNK = 0x93b, AER_SPRITE_SROCKBLOCKUSML = 0x93c, AER_SPRITE_SROCKBLOCKUMED = 0x93d, AER_SPRITE_SROCKBLOCKTHIN = 0x93e, AER_SPRITE_SROCKBLOCKUBIG = 0x93f, AER_SPRITE_SBRIDGEPILLARL = 0x940, AER_SPRITE_SBRIDGEPILLARR = 0x941, AER_SPRITE_SBRIDGEPLATFORM = 0x942, AER_SPRITE_SLIZARDCAMP01 = 0x943, AER_SPRITE_SSPCRASHEDSHIPDOOR = 0x944, AER_SPRITE_SSPCRASHEDSHIP = 0x945, AER_SPRITE_SSPNPCROOM = 0x946, AER_SPRITE_SLIZARDBELT = 0x947, AER_SPRITE_SVIVISECTION = 0x948, AER_SPRITE_SWANDERERBOT = 0x949, AER_SPRITE_FOLDERSLAB = 0x94a, AER_SPRITE_FGS = 0x94b, AER_SPRITE_SFGBEAM = 0x94c, AER_SPRITE_SFGOVERGS = 0x94d, AER_SPRITE_SFGOVERGL = 0x94e, AER_SPRITE_SLBUSHTOPS1 = 0x94f, AER_SPRITE_SLBUSHTOP01 = 0x950, AER_SPRITE_SLVEGL01 = 0x951, AER_SPRITE_SFGVINE = 0x952, AER_SPRITE_SWALLVINE = 0x953, AER_SPRITE_SLFGBEAMS01 = 0x954, AER_SPRITE_SFGSTAT = 0x955, AER_SPRITE_STORCH = 0x956, AER_SPRITE_SLWALLDET = 0x957, AER_SPRITE_OBJ_0 = 0x958, AER_SPRITE_SLPILLARSKINNY = 0x959, AER_SPRITE_SLWALLANGLE = 0x95a, AER_SPRITE_SLWALL16 = 0x95b, AER_SPRITE_SLWALL32 = 0x95c, AER_SPRITE_SLWALL64 = 0x95d, AER_SPRITE_SLWALL128 = 0x95e, AER_SPRITE_SLWALL64TOP = 0x95f, AER_SPRITE_SLWALLENTRANCE = 0x960, AER_SPRITE_SPRITE3284 = 0x961, AER_SPRITE_SLCRATE = 0x962, AER_SPRITE_SPITBLOCK = 0x963, AER_SPRITE_SCHAIR01 = 0x964, AER_SPRITE_SLOCKER01 = 0x965, AER_SPRITE_SOPERATINGTABLE = 0x966, AER_SPRITE_SLDRAPEDCLOTH = 0x967, AER_SPRITE_STABLEFRONT = 0x968, AER_SPRITE_SSIDETABLE01 = 0x969, AER_SPRITE_SMONITOR = 0x96a, AER_SPRITE_SMONITORL = 0x96b, AER_SPRITE_SDIRKBONES = 0x96c, AER_SPRITE_SBONEZ = 0x96d, AER_SPRITE_SLEAPERBONES = 0x96e, AER_SPRITE_EBATTERY = 0x96f, AER_SPRITE_EBELTS = 0x970, AER_SPRITE_EBELTL = 0x971, AER_SPRITE_ELASERDRILL01 = 0x972, AER_SPRITE_EROBOTARM = 0x973, AER_SPRITE_SPANEL01 = 0x974, AER_SPRITE_SVENT = 0x975, AER_SPRITE_SLMECHS = 0x976, AER_SPRITE_SLMECHM = 0x977, AER_SPRITE_SLMECHL = 0x978, AER_SPRITE_SLMECHXL = 0x979, AER_SPRITE_GMECH6 = 0x97a, AER_SPRITE_SLMOREBITS = 0x97b, AER_SPRITE_SBOTFACTORY = 0x97c, AER_SPRITE_SBLADEBOTS = 0x97d, AER_SPRITE_BLADEBOTRACK = 0x97e, AER_SPRITE_SPARTSVAT01 = 0x97f, AER_SPRITE_ORGANTUBETINY = 0x980, AER_SPRITE_ORGANTUBESMALL = 0x981, AER_SPRITE_ORGANTUBETHIN = 0x982, AER_SPRITE_SBLUEMANVAT = 0x983, AER_SPRITE_SHALFDIRKVAT = 0x984, AER_SPRITE_SCNGAUNTLETORGANTUBEMD000 = 0x985, AER_SPRITE_SCNGAUNTLETORGANTUBELG000 = 0x986, AER_SPRITE_GVATSPECIALGUEST = 0x987, AER_SPRITE_SCNGAUNTLETVATBROKMED = 0x988, AER_SPRITE_SVATMEGABROKEN = 0x989, AER_SPRITE_SCNGAUNTLETVATBROKLARGE = 0x98a, AER_SPRITE_SVATSPILLS = 0x98b, AER_SPRITE_SCNGAUNTLETDECGUTWATER = 0x98c, AER_SPRITE_SVATPLATFORM01 = 0x98d, AER_SPRITE_SUNDERSIDEPOLE = 0x98e, AER_SPRITE_SLVEGS = 0x98f, AER_SPRITE_SLVEGM = 0x990, AER_SPRITE_SLVEGL = 0x991, AER_SPRITE_SRAILLCORNER = 0x992, AER_SPRITE_SRAILLENDR = 0x993, AER_SPRITE_SRAILLHOR = 0x994, AER_SPRITE_SRAILLVER = 0x995, AER_SPRITE_FIREPIT = 0x996, AER_SPRITE_SLIZARDPRESS = 0x997, AER_SPRITE_SMECHATTACK = 0x998, AER_SPRITE_SSHORTCIRCUIT = 0x999, AER_SPRITE_SMEGATUBE = 0x99a, AER_SPRITE_FLOOR_0 = 0x99b, AER_SPRITE_SLEMBLEM = 0x99c, AER_SPRITE_SLORANGECROSS = 0x99d, AER_SPRITE_SLORANGEFLOORS = 0x99e, AER_SPRITE_SLORANGEFLOORL = 0x99f, AER_SPRITE_SLORANGEFRONTS = 0x9a0, AER_SPRITE_SLORANGEVERT = 0x9a1, AER_SPRITE_SLFLPATCHM = 0x9a2, AER_SPRITE_SLFLPATCHL = 0x9a3, AER_SPRITE_SGRATES = 0x9a4, AER_SPRITE_SGRATEM = 0x9a5, AER_SPRITE_SGRATEL = 0x9a6, AER_SPRITE_SCABLESHOR = 0x9a7, AER_SPRITE_SCABLESVERT = 0x9a8, AER_SPRITE_SCABLESCORNER = 0x9a9, AER_SPRITE_CLIFF = 0x9aa, AER_SPRITE_SCLIFF16 = 0x9ab, AER_SPRITE_SCLIFF32 = 0x9ac, AER_SPRITE_SCLIFF64 = 0x9ad, AER_SPRITE_FOLDEREAST = 0x9ae, AER_SPRITE_ECUTSHRUBS = 0x9af, AER_SPRITE_EGROWTHBITS1 = 0x9b0, AER_SPRITE_ETREESM = 0x9b1, AER_SPRITE_ETREELG = 0x9b2, AER_SPRITE_ETREEWATERS = 0x9b3, AER_SPRITE_ETREEWATERLG01 = 0x9b4, AER_SPRITE_EGREENL01 = 0x9b5, AER_SPRITE_EGREENXL01 = 0x9b6, AER_SPRITE_EBLOCK8 = 0x9b7, AER_SPRITE_EBLOCK32 = 0x9b8, AER_SPRITE_EBLOCK48THIN_0 = 0x9b9, AER_SPRITE_EBLOCK48FAT_0 = 0x9ba, AER_SPRITE_EPILLAR16 = 0x9bb, AER_SPRITE_EPILLAR32 = 0x9bc, AER_SPRITE_EPILLARSUPER = 0x9bd, AER_SPRITE_EPILLARBROKEN = 0x9be, AER_SPRITE_EAQUADUCT = 0x9bf, AER_SPRITE_EARCH = 0x9c0, AER_SPRITE_EAQUADUCTVERT = 0x9c1, AER_SPRITE_EBENCHVERT = 0x9c2, AER_SPRITE_EBENCHHOR = 0x9c3, AER_SPRITE_ERAILLHOR = 0x9c4, AER_SPRITE_ERAILLVER = 0x9c5, AER_SPRITE_ERAILLCORNER = 0x9c6, AER_SPRITE_SPRITE3339 = 0x9c7, AER_SPRITE_ERAILLENDR = 0x9c8, AER_SPRITE_EWALL32 = 0x9c9, AER_SPRITE_SPRITE3315 = 0x9ca, AER_SPRITE_EWALL64 = 0x9cb, AER_SPRITE_EWALL128 = 0x9cc, AER_SPRITE_EENTRANCE = 0x9cd, AER_SPRITE_ESIDEENTRANCE = 0x9ce, AER_SPRITE_EROOFVERT = 0x9cf, AER_SPRITE_ETOPENTRANCE = 0x9d0, AER_SPRITE_EROOFSMALL = 0x9d1, AER_SPRITE_EROOFLARGE = 0x9d2, AER_SPRITE_ESTANBUILDING = 0x9d3, AER_SPRITE_ESTANBUILDINGDOOR = 0x9d4, AER_SPRITE_EBUILDINGSMALL = 0x9d5, AER_SPRITE_EBUILDINGSTANDARD = 0x9d6, AER_SPRITE_EBUILDINGMASSIVE = 0x9d7, AER_SPRITE_EFOUNTAIN = 0x9d8, AER_SPRITE_EWARP = 0x9d9, AER_SPRITE_ESTAIRCHUNK = 0x9da, AER_SPRITE_ESTAIRSPILLAR = 0x9db, AER_SPRITE_EFGGREEN = 0x9dc, AER_SPRITE_EPOLEHORIZ = 0x9dd, AER_SPRITE_EPOLEHORIZRAILS = 0x9de, AER_SPRITE_EDOCKSHORIZFRONT = 0x9df, AER_SPRITE_EDOCKSVERTFRONT = 0x9e0, AER_SPRITE_EDOCKSVERT = 0x9e1, AER_SPRITE_EDOCKSHORIZ = 0x9e2, AER_SPRITE_EBOAT = 0x9e3, AER_SPRITE_ETENT01 = 0x9e4, AER_SPRITE_ESTATUESTAND = 0x9e5, AER_SPRITE_ESTATUEMEGA = 0x9e6, AER_SPRITE_ESTATSMALL = 0x9e7, AER_SPRITE_ESTATUEBIG = 0x9e8, AER_SPRITE_EWATERBREAKBLOCK = 0x9e9, AER_SPRITE_EWATERBREAKBLOCKLONG = 0x9ea, AER_SPRITE_EWATERWALL32 = 0x9eb, AER_SPRITE_EWATERWALLEXTEND = 0x9ec, AER_SPRITE_EWATERWALL64 = 0x9ed, AER_SPRITE_EWATERWALLANGLE = 0x9ee, AER_SPRITE_EWATERWALLDIAG = 0x9ef, AER_SPRITE_EWATERWALLLANGLE = 0x9f0, AER_SPRITE_EWATERWALLL64 = 0x9f1, AER_SPRITE_EWATERWALLLHOR = 0x9f2, AER_SPRITE_EWATERWALLLHOR64 = 0x9f3, AER_SPRITE_EWATERWALLTOP = 0x9f4, AER_SPRITE_EWATERWALLLVERT64 = 0x9f5, AER_SPRITE_EWATERBREAKBLOCKCORNER = 0x9f6, AER_SPRITE_EWATERWALLCORNER = 0x9f7, AER_SPRITE_EWATERMISTCLOUD = 0x9f8, AER_SPRITE_EFLOORBIT = 0x9f9, AER_SPRITE_FLAMEPOLEFIRE = 0x9fa, AER_SPRITE_FLAMEVENTFIRE = 0x9fb, AER_SPRITE_FLAMEVENTFIRE2X = 0x9fc, AER_SPRITE_EMAW = 0x9fd, AER_SPRITE_EPOLETALL = 0x9fe, AER_SPRITE_ELIGHTRAY16 = 0x9ff, AER_SPRITE_ESTAINEDGLASS01 = 0xa00, AER_SPRITE_ESTAINEDGLASSLARGE = 0xa01, AER_SPRITE_OTTERBODY = 0xa02, AER_SPRITE_EFLOATINGOTTER = 0xa03, AER_SPRITE_DROWNEDOTTER = 0xa04, AER_SPRITE_WATERMISTSIDE00 = 0xa05, AER_SPRITE_WATERMISTBOTTOM00 = 0xa06, AER_SPRITE_EEDGEREG = 0xa07, AER_SPRITE_EUNDERSIDE = 0xa08, AER_SPRITE_EUNDERSIDEVERT = 0xa09, AER_SPRITE_EUNDERBROKEN = 0xa0a, AER_SPRITE_EUNDERBROKENS = 0xa0b, AER_SPRITE_ESTATGRAD = 0xa0c, AER_SPRITE_ESTATBIGGRAD = 0xa0d, AER_SPRITE_ESUNKENBIT = 0xa0e, AER_SPRITE_EBGREPEAT = 0xa0f, AER_SPRITE_EFLOWER = 0xa10, AER_SPRITE_EFLOORPAD1 = 0xa11, AER_SPRITE_EFLOORPADBIG = 0xa12, AER_SPRITE_EFLOORLEDGEGRASSVERT1 = 0xa13, AER_SPRITE_EOVERHANG = 0xa14, AER_SPRITE_EFLOORPATCHBIG = 0xa15, AER_SPRITE_EFLOORGRASS = 0xa16, AER_SPRITE_EFLOORGRASS32 = 0xa17, AER_SPRITE_EFLOORGRASS48 = 0xa18, AER_SPRITE_EFLOORDESIGN = 0xa19, AER_SPRITE_EFLOORTILESQ = 0xa1a, AER_SPRITE_EMISSINGTILES01 = 0xa1b, AER_SPRITE_EMISSINGTILESBIG01 = 0xa1c, AER_SPRITE_ERIVULET16 = 0xa1d, AER_SPRITE_WFALLEDGEN00 = 0xa1e, AER_SPRITE_WATERBORDERWAVE1X = 0xa1f, AER_SPRITE_EWATERFALLTHIN = 0xa20, AER_SPRITE_EWATERFALLTHIN02 = 0xa21, AER_SPRITE_WFALLSIDE = 0xa22, AER_SPRITE_HUGEBUILDINGWATER = 0xa23, AER_SPRITE_EOTTERSPIKE = 0xa24, AER_SPRITE_EOTTERIMPALED = 0xa25, AER_SPRITE_EOTTERPILEL = 0xa26, AER_SPRITE_FROGDRAGOTTER = 0xa27, AER_SPRITE_OTTERNAPPYIDLE00 = 0xa28, AER_SPRITE_OTTERDROWSYIDLE = 0xa29, AER_SPRITE_OTTERSMOKYPUFF00 = 0xa2a, AER_SPRITE_OTTERPUKEYIDLE00 = 0xa2b, AER_SPRITE_EOTTERCRUSH = 0xa2c, AER_SPRITE_ESPBROKENBRIDGE2 = 0xa2d, AER_SPRITE_ESETFOUNTAINS = 0xa2e, AER_SPRITE_ETITANTOP = 0xa2f, AER_SPRITE_ETITANPARALLAX01 = 0xa30, AER_SPRITE_ETITANPARALLAX02 = 0xa31, AER_SPRITE_EMODDEADFROG1 = 0xa32, AER_SPRITE_EMODDEADFROG2 = 0xa33, AER_SPRITE_EMUSHROOMGROWTH = 0xa34, AER_SPRITE_EMUSHOTTER = 0xa35, AER_SPRITE_EJAREXPLOSION = 0xa36, AER_SPRITE_EMODDEADFROG3 = 0xa37, AER_SPRITE_SPRIEMODULEDRIFTER = 0xa38, AER_SPRITE_EMODDEADFLOOR = 0xa39, AER_SPRITE_FOLDERELAB = 0xa3a, AER_SPRITE_ELRAILLHOR = 0xa3b, AER_SPRITE_SPRITE3285 = 0xa3c, AER_SPRITE_ELRAILLVER = 0xa3d, AER_SPRITE_ELRAILLCORNER = 0xa3e, AER_SPRITE_ELRAILLENDR = 0xa3f, AER_SPRITE_ELPILLARSKINNY = 0xa40, AER_SPRITE_ELWALLANGLE = 0xa41, AER_SPRITE_ELWALL16 = 0xa42, AER_SPRITE_ELWALL32 = 0xa43, AER_SPRITE_ELWALL64 = 0xa44, AER_SPRITE_ELWALL128 = 0xa45, AER_SPRITE_ELWALL64TOP = 0xa46, AER_SPRITE_ELWALLENTRANCE = 0xa47, AER_SPRITE_ELABWALLGLASS = 0xa48, AER_SPRITE_ELABWALLGLASS128 = 0xa49, AER_SPRITE_ELCLIFF = 0xa4a, AER_SPRITE_ELBGPIT = 0xa4b, AER_SPRITE_EPILLAR1604 = 0xa4c, AER_SPRITE_EBGCLIFFSINGLE = 0xa4d, AER_SPRITE_EBGCLIFF = 0xa4e, AER_SPRITE_ECLIFF6401 = 0xa4f, AER_SPRITE_EBGCLIFFANGLE = 0xa50, AER_SPRITE_ELWATERCLIFFCORNER01 = 0xa51, AER_SPRITE_ELWATERCLIFF01 = 0xa52, AER_SPRITE_ELWATERCLIFFSIDE01 = 0xa53, AER_SPRITE_ELABTOPVINE = 0xa54, AER_SPRITE_ELABTOPBUSH = 0xa55, AER_SPRITE_ELGREENL = 0xa56, AER_SPRITE_ELMUSHS1 = 0xa57, AER_SPRITE_ELMUSHL1 = 0xa58, AER_SPRITE_ELTREELG01 = 0xa59, AER_SPRITE_EGRATES = 0xa5a, AER_SPRITE_ELFLOORTILESQU = 0xa5b, AER_SPRITE_EFLOORSTAIN = 0xa5c, AER_SPRITE_ELFLOORPATCHBIG = 0xa5d, AER_SPRITE_ELLEDGEGRASS = 0xa5e, AER_SPRITE_ELOVERHANG = 0xa5f, AER_SPRITE_EFLOORBITG = 0xa60, AER_SPRITE_ELFLOORBIT = 0xa61, AER_SPRITE_ELFLPATCHL = 0xa62, AER_SPRITE_EVATFLAMEJAR = 0xa63, AER_SPRITE_FLAMEJARBASE = 0xa64, AER_SPRITE_EVATFLAMEJARL = 0xa65, AER_SPRITE_EVATFLAMEJARXL = 0xa66, AER_SPRITE_EBRANCHESL = 0xa67, AER_SPRITE_EMUSHROOM = 0xa68, AER_SPRITE_ELMUSH = 0xa69, AER_SPRITE_EMUSHS = 0xa6a, AER_SPRITE_EMUSHM = 0xa6b, AER_SPRITE_EMUSHL = 0xa6c, AER_SPRITE_EMUSHU1 = 0xa6d, AER_SPRITE_EGREENHOUSEL = 0xa6e, AER_SPRITE_EGREENHOUSES = 0xa6f, AER_SPRITE_EBEAKER = 0xa70, AER_SPRITE_EFLASK = 0xa71, AER_SPRITE_EGAS = 0xa72, AER_SPRITE_ECHAIR01 = 0xa73, AER_SPRITE_ETABLEFRONT = 0xa74, AER_SPRITE_ELOCKER01 = 0xa75, AER_SPRITE_EMARKERS = 0xa76, AER_SPRITE_EMARKERM = 0xa77, AER_SPRITE_EGLASSTUBE01 = 0xa78, AER_SPRITE_EVAT01 = 0xa79, AER_SPRITE_EVAT04 = 0xa7a, AER_SPRITE_EVAT05 = 0xa7b, AER_SPRITE_EVATM = 0xa7c, AER_SPRITE_EVATL = 0xa7d, AER_SPRITE_EVAT06 = 0xa7e, AER_SPRITE_EVATJARL = 0xa7f, AER_SPRITE_EVATJARXL = 0xa80, AER_SPRITE_EVAT02 = 0xa81, AER_SPRITE_EPIPETERMINATE = 0xa82, AER_SPRITE_EACIDHEADFRONT = 0xa83, AER_SPRITE_EACIDHEADSIDE = 0xa84, AER_SPRITE_EACIDPILLAR = 0xa85, AER_SPRITE_EWATERPIPESHORIZL01 = 0xa86, AER_SPRITE_EWATERPIPESVERTL = 0xa87, AER_SPRITE_EWATERPIPESXL = 0xa88, AER_SPRITE_EACIDPUMP = 0xa89, AER_SPRITE_EPIPESCORNER = 0xa8a, AER_SPRITE_EFURNACE = 0xa8b, AER_SPRITE_EMECHPARTS01 = 0xa8c, AER_SPRITE_EGENERATOR = 0xa8d, AER_SPRITE_EBROKENJAR = 0xa8e, AER_SPRITE_EOTTERJAIL = 0xa8f, AER_SPRITE_FOLDERWEST = 0xa90, AER_SPRITE_CUTSHRUB = 0xa91, AER_SPRITE_WSTUMP = 0xa92, AER_SPRITE_WTREEDOORSTUMP = 0xa93, AER_SPRITE_WTREEHOUSE = 0xa94, AER_SPRITE_WTREE00GENERAL = 0xa95, AER_SPRITE_WTREE01SM = 0xa96, AER_SPRITE_WTREE02FALLEN = 0xa97, AER_SPRITE_WTREE02LG = 0xa98, AER_SPRITE_WTREE03MASSIVE = 0xa99, AER_SPRITE_WTREEBITSRED = 0xa9a, AER_SPRITE_WTREETOP = 0xa9b, AER_SPRITE_WPHASEBLOCK08 = 0xa9c, AER_SPRITE_WPHASEBLOCK16 = 0xa9d, AER_SPRITE_WPHASEBLOCK48FAT = 0xa9e, AER_SPRITE_WPHASEBLOCK48THIN = 0xa9f, AER_SPRITE_WPHASEBLOCK64 = 0xaa0, AER_SPRITE_WPHASEBLOCKCOLLUMN2X = 0xaa1, AER_SPRITE_WROCKBLOCK08 = 0xaa2, AER_SPRITE_WROCKBLOCK16 = 0xaa3, AER_SPRITE_WROCKBLOCK48 = 0xaa4, AER_SPRITE_WROCKBLOCK64 = 0xaa5, AER_SPRITE_WPHASEWALLBASE = 0xaa6, AER_SPRITE_WPHASEWALLBASEBIG = 0xaa7, AER_SPRITE_WPHASEPILLAR16 = 0xaa8, AER_SPRITE_WPHASEPILLAR32 = 0xaa9, AER_SPRITE_WPHASERUINBASEVERT = 0xaaa, AER_SPRITE_WPHASERUINENTRANCE = 0xaab, AER_SPRITE_WPHASEWALLARCH = 0xaac, AER_SPRITE_WPHASEROOF64 = 0xaad, AER_SPRITE_WPHASEROOFHUGE = 0xaae, AER_SPRITE_WFLOORBRIDGE = 0xaaf, AER_SPRITE_WSTATUETANUKI = 0xab0, AER_SPRITE_WSTATUETANUKISIDE = 0xab1, AER_SPRITE_WSTATUETABLET = 0xab2, AER_SPRITE_WSTATUETANUKIHEAD = 0xab3, AER_SPRITE_WPOLETALL = 0xab4, AER_SPRITE_WPOLESHORT = 0xab5, AER_SPRITE_WPLANTER = 0xab6, AER_SPRITE_WPHASEFENCERAIL = 0xab7, AER_SPRITE_WLLANTERN = 0xab8, AER_SPRITE_WLHEADSTONES = 0xab9, AER_SPRITE_WLHEADSTONEM = 0xaba, AER_SPRITE_WLMARKERS = 0xabb, AER_SPRITE_WLMARKERL = 0xabc, AER_SPRITE_WLPOST32 = 0xabd, AER_SPRITE_WCRYSTALROUGHSM = 0xabe, AER_SPRITE_WCRYSTALCLEAN = 0xabf, AER_SPRITE_WCRYSTALROUGHTALL = 0xac0, AER_SPRITE_WCRYSTALTRAP = 0xac1, AER_SPRITE_WCRYSTALTRAP2 = 0xac2, AER_SPRITE_WCRYSTALTRAP3 = 0xac3, AER_SPRITE_WCRYSTALTRAP4 = 0xac4, AER_SPRITE_WGEODEBIG1 = 0xac5, AER_SPRITE_WGEODEBIG2 = 0xac6, AER_SPRITE_WGEODEBIG = 0xac7, AER_SPRITE_WGEODEHUGE = 0xac8, AER_SPRITE_WGEODEHUGE1 = 0xac9, AER_SPRITE_WGEODEHUGE2 = 0xaca, AER_SPRITE_WROCKWALL = 0xacb, AER_SPRITE_WROCKWALL64 = 0xacc, AER_SPRITE_WROCKWALLDIAG = 0xacd, AER_SPRITE_WROCKWALLLIP = 0xace, AER_SPRITE_WROCKBLOCKBIG = 0xacf, AER_SPRITE_WROCKLEDGEANGLE = 0xad0, AER_SPRITE_WROCKLEDGEHORIZ = 0xad1, AER_SPRITE_WROCKLEDGEHORIZ64 = 0xad2, AER_SPRITE_WROCKLEDGEVERTSMALL = 0xad3, AER_SPRITE_WROCKLEDGEVERT = 0xad4, AER_SPRITE_WROCKLEDGEVERT64 = 0xad5, AER_SPRITE_WROCKTOP = 0xad6, AER_SPRITE_WROCKWALLBLANK = 0xad7, AER_SPRITE_WROCKWALLDETAIL = 0xad8, AER_SPRITE_WBGCLIFFEDGE = 0xad9, AER_SPRITE_WRBGRASSCHUNK = 0xada, AER_SPRITE_WROCKBLOCKUSML = 0xadb, AER_SPRITE_WROCKBLOCKUMED = 0xadc, AER_SPRITE_WROCKBLOCKUM2 = 0xadd, AER_SPRITE_WROCKBLOCKUBIG = 0xade, AER_SPRITE_WGRASSTOP = 0xadf, AER_SPRITE_WFLOORLEDGEGRASSHORIZ = 0xae0, AER_SPRITE_WFLOORLEDGEGRASSVERT = 0xae1, AER_SPRITE_WFLOORROOTS = 0xae2, AER_SPRITE_WFLOORROOTSBIG = 0xae3, AER_SPRITE_WFLOORMOSSREDBIG = 0xae4, AER_SPRITE_WFLOORMOSSREDSMALL = 0xae5, AER_SPRITE_WFLOORPATCHBBIG = 0xae6, AER_SPRITE_WFLOORPATCHBSMALL = 0xae7, AER_SPRITE_WFLOORPATCHBBIG04 = 0xae8, AER_SPRITE_WFLOORTECHL = 0xae9, AER_SPRITE_WFLOORTECHS = 0xaea, AER_SPRITE_WFLOORFLOWERSMULTI = 0xaeb, AER_SPRITE_WFLOORSPLOTCHBIG = 0xaec, AER_SPRITE_WFLOORGRASSRED = 0xaed, AER_SPRITE_WFLOORMUSHROOM = 0xaee, AER_SPRITE_WFLOORGRASSSOLO = 0xaef, AER_SPRITE_WSTAIRTOPSUP = 0xaf0, AER_SPRITE_WSTAIRTOPSIDE = 0xaf1, AER_SPRITE_WSTAIRTOPUP = 0xaf2, AER_SPRITE_WFLOORTILESQUARE = 0xaf3, AER_SPRITE_WFLOORPHASEFOUNDATION = 0xaf4, AER_SPRITE_WSTREAM = 0xaf5, AER_SPRITE_WFLOORLEDGEGRASSRED = 0xaf6, AER_SPRITE_WFLOORPATCHREDBIG = 0xaf7, AER_SPRITE_WFLOORPATCHREDSMALL = 0xaf8, AER_SPRITE_WGODRAY = 0xaf9, AER_SPRITE_WGODRAYS = 0xafa, AER_SPRITE_WMEGARIBSBOT = 0xafb, AER_SPRITE_WMEGARIBSTOP = 0xafc, AER_SPRITE_GIANTBONES = 0xafd, AER_SPRITE_WCART01 = 0xafe, AER_SPRITE_WFIRE01 = 0xaff, AER_SPRITE_WWELL01 = 0xb00, AER_SPRITE_WRUINEDWALL01 = 0xb01, AER_SPRITE_WBASE = 0xb02, AER_SPRITE_WBONEWELL = 0xb03, AER_SPRITE_WTREEHIDEOUT = 0xb04, AER_SPRITE_WWARRIORSREST = 0xb05, AER_SPRITE_WTENT01 = 0xb06, AER_SPRITE_WSANDBAGS = 0xb07, AER_SPRITE_SPWNPCTREEHOUSE = 0xb08, AER_SPRITE_WCRYSTALTREEL = 0xb09, AER_SPRITE_WCRYSTALTREES = 0xb0a, AER_SPRITE_WWATCHTOWER = 0xb0b, AER_SPRITE_WTREETOWER = 0xb0c, AER_SPRITE_WTREEVILLAGE = 0xb0d, AER_SPRITE_WCRYSTALNEST01 = 0xb0e, AER_SPRITE_WCRYSTALMAW = 0xb0f, AER_SPRITE_WCRYSTALCANNON01 = 0xb10, AER_SPRITE_WSPTANUKIARMY = 0xb11, AER_SPRITE_WSPBLUEARMY = 0xb12, AER_SPRITE_WCRYSTALHUGE02 = 0xb13, AER_SPRITE_WSOLDIERCRYSTAL = 0xb14, AER_SPRITE_WCARDGAME = 0xb15, AER_SPRITE_WSPTITAN = 0xb16, AER_SPRITE_WMODULEDRIFTER = 0xb17, AER_SPRITE_WMODULETANUKI = 0xb18, AER_SPRITE_WMODULETREENUKI = 0xb19, AER_SPRITE_FOLDERWLAB = 0xb1a, AER_SPRITE_FG = 0xb1b, AER_SPRITE_WFGBEAM = 0xb1c, AER_SPRITE_WFGOVERGS = 0xb1d, AER_SPRITE_WFGOVERGB = 0xb1e, AER_SPRITE_WFGVINE = 0xb1f, AER_SPRITE_WREDVINE = 0xb20, AER_SPRITE_WLTREELG = 0xb21, AER_SPRITE_WLTREETOP = 0xb22, AER_SPRITE_WLCRYSTALHUGE = 0xb23, AER_SPRITE_WLCRYSTALBIG01 = 0xb24, AER_SPRITE_WLCRYSTALBIGSIDE = 0xb25, AER_SPRITE_WFGSTAT = 0xb26, AER_SPRITE_WTORCH = 0xb27, AER_SPRITE_WROCKDETAIL = 0xb28, AER_SPRITE_OBJ_1 = 0xb29, AER_SPRITE_WLVASES = 0xb2a, AER_SPRITE_WLURNL = 0xb2b, AER_SPRITE_WLCRATES = 0xb2c, AER_SPRITE_WLCRATETALL = 0xb2d, AER_SPRITE_WLCRATEL = 0xb2e, AER_SPRITE_WLSHELFL = 0xb2f, AER_SPRITE_WCHAIR01 = 0xb30, AER_SPRITE_WTABLEFRONT = 0xb31, AER_SPRITE_WLOCKER01 = 0xb32, AER_SPRITE_WLWEPSHELF = 0xb33, AER_SPRITE_WLIGHTBLOCK = 0xb34, AER_SPRITE_WLPILLARSKINNY = 0xb35, AER_SPRITE_LWWALLANGLE = 0xb36, AER_SPRITE_LWWALL16 = 0xb37, AER_SPRITE_LWWALL32 = 0xb38, AER_SPRITE_LWWALL64 = 0xb39, AER_SPRITE_LWWALL128 = 0xb3a, AER_SPRITE_FLOOR_1 = 0xb3b, AER_SPRITE_WLEMBLEM = 0xb3c, AER_SPRITE_WCARPET = 0xb3d, AER_SPRITE_WLVEG24 = 0xb3e, AER_SPRITE_WLLUSHCROSS = 0xb3f, AER_SPRITE_WLLUSHFLOORL = 0xb40, AER_SPRITE_WLLUSHFRONTS = 0xb41, AER_SPRITE_WLLUSHVERT = 0xb42, AER_SPRITE_SPR2277CLIFF = 0xb43, AER_SPRITE_WRAILLCORNER = 0xb44, AER_SPRITE_SPRITE3340 = 0xb45, AER_SPRITE_WRAILLENDR = 0xb46, AER_SPRITE_WRAILLHOR = 0xb47, AER_SPRITE_WRAILLVER = 0xb48, AER_SPRITE_WCLIFF16 = 0xb49, AER_SPRITE_WCLIFF32 = 0xb4a, AER_SPRITE_WCLIFF64 = 0xb4b, AER_SPRITE_WBGCLOUDLAB = 0xb4c, AER_SPRITE_FOLDERABYSS = 0xb4d, AER_SPRITE_AELEVATORBG = 0xb4e, AER_SPRITE_AELEVFG = 0xb4f, AER_SPRITE_AFG1 = 0xb50, AER_SPRITE_ALAMP = 0xb51, AER_SPRITE_ABLOCK1 = 0xb52, AER_SPRITE_ABLOCK2 = 0xb53, AER_SPRITE_ASERV1 = 0xb54, AER_SPRITE_ASERV2 = 0xb55, AER_SPRITE_ASERV3 = 0xb56, AER_SPRITE_ASERV4 = 0xb57, AER_SPRITE_ASERV5 = 0xb58, AER_SPRITE_AMONITORL = 0xb59, AER_SPRITE_ASCIENTIST = 0xb5a, AER_SPRITE_AEXCAVATOR = 0xb5b, AER_SPRITE_AFOXSTATUE = 0xb5c, AER_SPRITE_AGIANTWEST = 0xb5d, AER_SPRITE_AWALLBOT = 0xb5e, AER_SPRITE_AWALLBOT2 = 0xb5f, AER_SPRITE_ARWFRONTE = 0xb60, AER_SPRITE_ARWCORNER = 0xb61, AER_SPRITE_ARWTOPSIDE = 0xb62, AER_SPRITE_AMEGAWALL2 = 0xb63, AER_SPRITE_AMEGAWALL = 0xb64, AER_SPRITE_AWALLSIDE = 0xb65, AER_SPRITE_AWALLCHUNK = 0xb66, AER_SPRITE_AWALL1 = 0xb67, AER_SPRITE_ABRIDGEBIT2 = 0xb68, AER_SPRITE_ABRIDGEBIT1 = 0xb69, AER_SPRITE_ADOORFLOORBIT = 0xb6a, AER_SPRITE_AFLOORDESIGN1 = 0xb6b, AER_SPRITE_ACLIFF1 = 0xb6c, AER_SPRITE_AFLOORPATCHBIG = 0xb6d, AER_SPRITE_AEMBERDOOR = 0xb6e, AER_SPRITE_ASPLABZERO = 0xb6f, AER_SPRITE_AFINEYES1 = 0xb70, AER_SPRITE_AFINFGSINGLE = 0xb71, AER_SPRITE_AFINFGSHRUBS = 0xb72, AER_SPRITE_AFINFLOORSHADOWS = 0xb73, AER_SPRITE_AFINFLOOR = 0xb74, AER_SPRITE_AFINFLOOR2 = 0xb75, AER_SPRITE_AFINALDEADROOMBONES = 0xb76, AER_SPRITE_FOLDEROLD = 0xb77, AER_SPRITE_EBLOCK16 = 0xb78, AER_SPRITE_EBLOCK16B = 0xb79, AER_SPRITE_EBLOCK16C = 0xb7a, AER_SPRITE_EBLOCK48FAT_1 = 0xb7b, AER_SPRITE_EBLOCK64 = 0xb7c, AER_SPRITE_GIANTBOT = 0xb7d, AER_SPRITE_TUBE = 0xb7e, AER_SPRITE_EBLOCK48THIN_1 = 0xb7f, AER_SPRITE_ACIDBARREL = 0xb80, AER_SPRITE_SCNGAUNTLETSTATUESMALL = 0xb81, AER_SPRITE_ELABBLOCK16 = 0xb82, AER_SPRITE_ELABBLOCK48 = 0xb83, AER_SPRITE_ELABBLOCK48FAT = 0xb84, AER_SPRITE_ELABBLOCK48THIN = 0xb85, AER_SPRITE_SCNGAUNTLETOBJCUBE24X01 = 0xb86, AER_SPRITE_SCNGAUNTLETBENCHBLOCK = 0xb87, AER_SPRITE_SCNGAUNTLETCEILINGLIGHT = 0xb88, AER_SPRITE_SCNWOODCOLUMN = 0xb89, AER_SPRITE_SCNWOODCOLUMNBIG = 0xb8a, AER_SPRITE_WRROCK = 0xb8b, AER_SPRITE_MTNBUSH = 0xb8c, AER_SPRITE_CUTSHRUB2 = 0xb8d, AER_SPRITE_TORCH = 0xb8e, AER_SPRITE_SCNTEDDYALPHA = 0xb8f, AER_SPRITE_GBLOCK32 = 0xb90, AER_SPRITE_GBLOCK48 = 0xb91, AER_SPRITE_GBLOCK64 = 0xb92, AER_SPRITE_SCNGAUNTLETCUBELARGE = 0xb93, AER_SPRITE_SCNGAUNTLETCUBESMALL = 0xb94, AER_SPRITE_SCNGAUNTLETPILLARDIAMOND = 0xb95, AER_SPRITE_SCNGAUNTLETPILLARDIAMOND02 = 0xb96, AER_SPRITE_SCNGAUNTLETINVISIBLE = 0xb97, AER_SPRITE_SCNGAUNTLETINVISIBLE000 = 0xb98, AER_SPRITE_SCNGAUNTLETDEADDRIFTER = 0xb99, AER_SPRITE_SCNGAUNTLETTEMPEYEDEC = 0xb9a, AER_SPRITE_SCNGAUNTLETSPHEART = 0xb9b, AER_SPRITE_SCNGAUNTLETGRASSSIDE = 0xb9c, AER_SPRITE_SCNGAUNTLETVEGDECOR = 0xb9d, AER_SPRITE_SCNGAUNTLETMUSH = 0xb9e, AER_SPRITE_SCNGAUNTLETPIPEHOR01 = 0xb9f, AER_SPRITE_SCNGAUNTLETPIPEFATVERT01 = 0xba0, AER_SPRITE_SCNGAUNTLETPIPEANGLE01 = 0xba1, AER_SPRITE_SCNGAUNTLETPIPEEND = 0xba2, AER_SPRITE_SCNGAUNTLETOBJGUTPIPEHOR02 = 0xba3, AER_SPRITE_SCNGAUNTLETPIPESKINNYVERT01 = 0xba4, AER_SPRITE_ZFOLDERENDSCN = 0xba5, AER_SPRITE_WROCKLEDGEANGLECOLLISION = 0xba6, AER_SPRITE_ITEMSGUI = 0xba7, AER_SPRITE_SPECIALSGUI = 0xba8, AER_SPRITE_HUDBATTERYPIP6SHOT = 0xba9, AER_SPRITE_HUDBATTERYPIP5SHOT = 0xbaa, AER_SPRITE_HUDBATTERYPIP4SHOT = 0xbab, AER_SPRITE_HUDBATTERYPIP3SHOT = 0xbac, AER_SPRITE_HUDBATTERYPIP2SHOT = 0xbad, AER_SPRITE_HUDHEALTHPIP = 0xbae, AER_SPRITE_HUDHEALTHPIPEMPTY = 0xbaf, AER_SPRITE_HUDMEDBG = 0xbb0, AER_SPRITE_HUDMEDICON = 0xbb1, AER_SPRITE_HUDSPECIALBG = 0xbb2, AER_SPRITE_HUDSPECIALICON = 0xbb3, AER_SPRITE_HUDWEAPONBG = 0xbb4, AER_SPRITE_DOORINTERACTIVEPANELCLOSE = 0xbb5, AER_SPRITE_DOORINTERACTIVEPANELDATALOOP = 0xbb6, AER_SPRITE_DOORINTERACTIVEPANELOPEN = 0xbb7, AER_SPRITE_DOORINTERACTIVEPANELPULSELOOP = 0xbb8, AER_SPRITE_DOORINTERACTIVEPANELSCANLINES = 0xbb9, AER_SPRITE_INVDRIFTERKEYSBOX = 0xbba, AER_SPRITE_INVDRIFTERKEY = 0xbbb, AER_SPRITE_INVDRIFTERKEYICON = 0xbbc, AER_SPRITE_INVBG = 0xbbd, AER_SPRITE_INVBGLINEDRIFTER = 0xbbe, AER_SPRITE_INVBGLINEWEAPON = 0xbbf, AER_SPRITE_INVDRIFTER = 0xbc0, AER_SPRITE_ADINVDRIFTER = 0xbc1, AER_SPRITE_INVDRIFTERHIGHLIGHTBOX = 0xbc2, AER_SPRITE_INVGEAR = 0xbc3, AER_SPRITE_INVGEARBITBOX = 0xbc4, AER_SPRITE_INVGEARBITBOXWIDE = 0xbc5, AER_SPRITE_INVGEARBITMETER = 0xbc6, AER_SPRITE_INVGEARBITHIGHLIGHT = 0xbc7, AER_SPRITE_INVHEALTHPACKBOX = 0xbc8, AER_SPRITE_INVHEALTHPACKPIP = 0xbc9, AER_SPRITE_INVSPECIALPIP = 0xbca, AER_SPRITE_INVWEAPONPIP = 0xbcb, AER_SPRITE_INVLOADOUTGRIDFRAMES = 0xbcc, AER_SPRITE_INVSKILLBOX = 0xbcd, AER_SPRITE_INVSKILLICONS = 0xbce, AER_SPRITE_INVSPECIALBOX = 0xbcf, AER_SPRITE_INVWEP = 0xbd0, AER_SPRITE_INVWEPBOX = 0xbd1, AER_SPRITE_INVWEPLINES = 0xbd2, AER_SPRITE_INVWEPPIPS = 0xbd3, AER_SPRITE_INVMODULE4TH = 0xbd4, AER_SPRITE_INVMODULEBG = 0xbd5, AER_SPRITE_INVMODULEBGFULL = 0xbd6, AER_SPRITE_INVMODULEHIGHLIGHT = 0xbd7, AER_SPRITE_INVMODULEMETER = 0xbd8, AER_SPRITE_INVMODULEMETERFULLWORLD = 0xbd9, AER_SPRITE_INVMODULEPIPFULL = 0xbda, AER_SPRITE_INVMODULEREGION = 0xbdb, AER_SPRITE_INVMODULESLOT = 0xbdc, AER_SPRITE_INVMODULETRIANGLE = 0xbdd, AER_SPRITE_INVNAVLOADOUT = 0xbde, AER_SPRITE_INVNAVMAP = 0xbdf, AER_SPRITE_INVNAVFRAME = 0xbe0, AER_SPRITE_INVOUTFITCAPE = 0xbe1, AER_SPRITE_INVOUTFITCAPEAD = 0xbe2, AER_SPRITE_INVOUTFITBG = 0xbe3, AER_SPRITE_INVPREVIEWBOX = 0xbe4, AER_SPRITE_INVPREVIEWBOXSKILLS = 0xbe5, AER_SPRITE_INVPREVIEWBOXWEAPONS = 0xbe6, AER_SPRITE_INVPREVIEWLOADINGICON = 0xbe7, AER_SPRITE_INVPREVIEWHEAL = 0xbe8, AER_SPRITE_INVPREVIEWSKILLDASHABSORB = 0xbe9, AER_SPRITE_INVPREVIEWSKILLDASHATTACK = 0xbea, AER_SPRITE_INVPREVIEWSKILLDASHCHAIN = 0xbeb, AER_SPRITE_INVPREVIEWSKILLSWORDDEFLECT = 0xbec, AER_SPRITE_INVPREVIEWSKILLSWORDHEAVY = 0xbed, AER_SPRITE_INVPREVIEWSKILLSWORDPHANTOM = 0xbee, AER_SPRITE_INVPREVIEWSPECIAL = 0xbef, AER_SPRITE_INVPREVIEWWEAPONBLUNDERBUSS = 0xbf0, AER_SPRITE_INVPREVIEWWEAPONPISTOL = 0xbf1, AER_SPRITE_INVPREVIEWWEAPONRAILGUN = 0xbf2, AER_SPRITE_INVPREVIEWWEAPONRAILGUNBLAST = 0xbf3, AER_SPRITE_INVPREVIEWWEAPONSHOTGUN = 0xbf4, AER_SPRITE_INVPREVIEWWEAPONZELISKA = 0xbf5, AER_SPRITE_INVSTOREMEDUPGLINEBOX = 0xbf6, AER_SPRITE_INVSTORESKLUPGLINE1 = 0xbf7, AER_SPRITE_INVSTORESKLUPGLINE3 = 0xbf8, AER_SPRITE_INVSTORESKLUPGLINE2 = 0xbf9, AER_SPRITE_INVSTORESKLUPGLINE4 = 0xbfa, AER_SPRITE_INVSTORESKLUPGLINE5 = 0xbfb, AER_SPRITE_INVSTORESKLUPGLINE6 = 0xbfc, AER_SPRITE_INVSTORESPECUPGLINEBOX = 0xbfd, AER_SPRITE_INVSTOREWEPUPGLINE = 0xbfe, AER_SPRITE_INVVENDORDASH = 0xbff, AER_SPRITE_INVVENDORHEALTH = 0xc00, AER_SPRITE_INVVENDORSPECIAL = 0xc01, AER_SPRITE_INVVENDORSWORD = 0xc02, AER_SPRITE_INVVENDORWEAPON = 0xc03, AER_SPRITE_INVVENDORBG = 0xc04, AER_SPRITE_INVCANCELICON = 0xc05, AER_SPRITE_INVSELECTICON = 0xc06, AER_SPRITE_MAP = 0xc07, AER_SPRITE_MAPLAB = 0xc08, AER_SPRITE_MAPFULLSCREEN = 0xc09, AER_SPRITE_MAPABYSSBASE = 0xc0a, AER_SPRITE_MAPABYSSMODULE = 0xc0b, AER_SPRITE_MAPABYSSPILLAR = 0xc0c, AER_SPRITE_MAPARROWS = 0xc0d, AER_SPRITE_MAPDRIFTER = 0xc0e, AER_SPRITE_MAPMODULEMARKER = 0xc0f, AER_SPRITE_MAPOUTLINE = 0xc10, AER_SPRITE_MAPRETICULE = 0xc11, AER_SPRITE_MAPTOWER = 0xc12, AER_SPRITE_MAPTOWERLOCK = 0xc13, AER_SPRITE_MAPWARPPILLAR = 0xc14, AER_SPRITE_MAPZOOM = 0xc15, AER_SPRITE_MAPLABICON = 0xc16, AER_SPRITE_UIPAUSEHIGHLIGHTBOX = 0xc17, AER_SPRITE_MENUCURSOR = 0xc18, AER_SPRITE_ALTDRIFTERCAPE = 0xc19, AER_SPRITE_UICAPEICON = 0xc1a, AER_SPRITE_UISWORDICON = 0xc1b, AER_SPRITE_WEPWHEELBUTTONSOFFY = 0xc1c, AER_SPRITE_WEPWHEELBUTTONSOFFB = 0xc1d, AER_SPRITE_WEPWHEELBUTTONSONY = 0xc1e, AER_SPRITE_WEPWHEELBUTTONSONB = 0xc1f, AER_SPRITE_WEPWHEELCLOSEOFF = 0xc20, AER_SPRITE_WEPWHEELCLOSEON = 0xc21, AER_SPRITE_WEPWHEELBG = 0xc22, AER_SPRITE_WEPWHEELROLLOVER = 0xc23, AER_SPRITE_WEPWHEELL = 0xc24, AER_SPRITE_WEPWHEELR = 0xc25, AER_SPRITE_WEPWHEELSELECTB = 0xc26, AER_SPRITE_WEPWHEELSELECTY = 0xc27, AER_SPRITE_WEPWHEELTRIONSONY = 0xc28, AER_SPRITE_WEPWHEELTRIOFFSONY = 0xc29, AER_SPRITE_WEPWHEELCIRONSONY = 0xc2a, AER_SPRITE_WEPWHEELCIROFFSONY = 0xc2b, AER_SPRITE_WEPWHEELSELECTTRISONY = 0xc2c, AER_SPRITE_WEPWHEELSELECTCIRSONY = 0xc2d, AER_SPRITE_COLLECTUIPOPIN = 0xc2e, AER_SPRITE_UIWINDOWCOLLECTFLOURISH = 0xc2f, AER_SPRITE_MENDASHEDLINE = 0xc30, AER_SPRITE_MENARROWLEFT = 0xc31, AER_SPRITE_MENARROWCENTERED = 0xc32, AER_SPRITE_MENARROWRIGHT = 0xc33, AER_SPRITE_MENBTTNFRAME = 0xc34, AER_SPRITE_MENBTTNKBM = 0xc35, AER_SPRITE_MENBTTNPSDPAD = 0xc36, AER_SPRITE_MENBTTNPSL1 = 0xc37, AER_SPRITE_MENBTTNPSL2 = 0xc38, AER_SPRITE_MENBTTNPSO = 0xc39, AER_SPRITE_MENBTTNPSOPTIONS = 0xc3a, AER_SPRITE_MENBTTNPSR1 = 0xc3b, AER_SPRITE_MENBTTNPSR2 = 0xc3c, AER_SPRITE_MENBTTNPSSQR = 0xc3d, AER_SPRITE_MENBTTNPSSQUARE = 0xc3e, AER_SPRITE_MENBTTNPSSTICK = 0xc3f, AER_SPRITE_MENBTTNPSSHARE = 0xc40, AER_SPRITE_MENBTTNPSTOUCHPAD = 0xc41, AER_SPRITE_MENBTTNPSTRI = 0xc42, AER_SPRITE_MENBTTNPSX = 0xc43, AER_SPRITE_MENBTTNXBA = 0xc44, AER_SPRITE_MENBTTNXBB = 0xc45, AER_SPRITE_MENBTTNXBLB = 0xc46, AER_SPRITE_MENBTTNXBLT = 0xc47, AER_SPRITE_MENBTTNXBRB = 0xc48, AER_SPRITE_MENBTTNXBRT = 0xc49, AER_SPRITE_MENBTTNXBX = 0xc4a, AER_SPRITE_MENBTTNXBY = 0xc4b, AER_SPRITE_MENBTTNXBVIEW = 0xc4c, AER_SPRITE_MENDIAGRAMPS4 = 0xc4d, AER_SPRITE_MENFINISHEDGAMEBOX = 0xc4e, AER_SPRITE_MENFRAMEBIG = 0xc4f, AER_SPRITE_MENFRAMEREG = 0xc50, AER_SPRITE_MENPIP = 0xc51, AER_SPRITE_MENQUITBG = 0xc52, AER_SPRITE_MENSELECTBARBIG = 0xc53, AER_SPRITE_MENSELECTBARREG = 0xc54, AER_SPRITE_MENUBG = 0xc55, AER_SPRITE_KBMICON = 0xc56, AER_SPRITE_TEMPABOUT = 0xc57, AER_SPRITE_TEMPCONTROLS = 0xc58, AER_SPRITE_TEMPCONTROLSPS4 = 0xc59, AER_SPRITE_TEMPCONTROLSXBX = 0xc5a, AER_SPRITE_TEMPHOW = 0xc5b, AER_SPRITE_MENBTTNXBDPADU = 0xc5c, AER_SPRITE_UITEXTGRADIENT = 0xc5d, AER_SPRITE_BIGSKULLICON = 0xc5e, AER_SPRITE_BIGCROWNICON = 0xc5f, AER_SPRITE_SMALLSKULLICON = 0xc60, AER_SPRITE_COPYRIGHT = 0xc61, AER_SPRITE_UIGRIDSELECTOR = 0xc62, AER_SPRITE_UILOADOUTADD = 0xc63, AER_SPRITE_UILOADOUTSQUARE = 0xc64, AER_SPRITE_CHECKPOINTWARPICON = 0xc65, AER_SPRITE_CHECKPOINTSAVEICON = 0xc66, AER_SPRITE_SAVEICON = 0xc67, AER_SPRITE_GAMEMAKERTAG = 0xc68, AER_SPRITE_MUZZLEPISTOL = 0xc69, AER_SPRITE_MUZZLEPISTOLMASTER = 0xc6a, AER_SPRITE_MUZZLEBURSTRIFLE = 0xc6b, AER_SPRITE_BURSTPISTOLPERKMUZZLE = 0xc6c, AER_SPRITE_MUZZLEZELISKA = 0xc6d, AER_SPRITE_MUZZLEZELISKAPERK = 0xc6e, AER_SPRITE_HITSPARKZELISKA = 0xc6f, AER_SPRITE_ZELISKASMOKE1 = 0xc70, AER_SPRITE_ZELISKASMOKE2 = 0xc71, AER_SPRITE_ZELISKASMOKE3 = 0xc72, AER_SPRITE_ZELISKAPARTICLE = 0xc73, AER_SPRITE_MUZZLEPISTOLPERK = 0xc74, AER_SPRITE_MUZZLESHOTGUN = 0xc75, AER_SPRITE_MUZZLESHOTGUNGOLD = 0xc76, AER_SPRITE_MUZZLEBLUNDERBUSS = 0xc77, AER_SPRITE_MUZZLEBLUNDERBUSSPERK = 0xc78, AER_SPRITE_MUZZLETWINSHOT = 0xc79, AER_SPRITE_MUZZLETWINSHOTPERK = 0xc7a, AER_SPRITE_MUZZLESHOTGUNPERK = 0xc7b, AER_SPRITE_MUZZLESHOTGUNMASTER = 0xc7c, AER_SPRITE_GUNBACKLIGHT = 0xc7d, AER_SPRITE_GUNLIGHT = 0xc7e, AER_SPRITE_RIFLEBACKLIGHT = 0xc7f, AER_SPRITE_RIFLEMUZZLEFLASH = 0xc80, AER_SPRITE_TURRETBULLET = 0xc81, AER_SPRITE_TURRETBULLETFADE = 0xc82, AER_SPRITE_RPMISSILE = 0xc83, AER_SPRITE_MISSILEHALF = 0xc84, AER_SPRITE_ROCKET = 0xc85, AER_SPRITE_BULLET = 0xc86, AER_SPRITE_BIGBULLET = 0xc87, AER_SPRITE_BIGBULLETTAIL = 0xc88, AER_SPRITE_BIGBULLETGOLD = 0xc89, AER_SPRITE_BIGBULLETGOLDTAIL = 0xc8a, AER_SPRITE_BULLETDIRK = 0xc8b, AER_SPRITE_CULTBULLETMASK = 0xc8c, AER_SPRITE_BULLETPINKFADE = 0xc8d, AER_SPRITE_BULLETPINK = 0xc8e, AER_SPRITE_BULLETMASK = 0xc8f, AER_SPRITE_BULLET02 = 0xc90, AER_SPRITE_SNIPERBULLET = 0xc91, AER_SPRITE_MACHINEGUNBULLET = 0xc92, AER_SPRITE_PEASHOOTER = 0xc93, AER_SPRITE_LASER = 0xc94, AER_SPRITE_BYUUMURANG = 0xc95, AER_SPRITE_BYUUPART = 0xc96, AER_SPRITE_BYUUMERANGBLAST = 0xc97, AER_SPRITE_BYUUMURANGGHOST = 0xc98, AER_SPRITE_CRYSTALLANCE = 0xc99, AER_SPRITE_CRYSTALWEAPON = 0xc9a, AER_SPRITE_CRYSTAL = 0xc9b, AER_SPRITE_CRYSTALLARGE = 0xc9c, AER_SPRITE_CRYSTALSHARD = 0xc9d, AER_SPRITE_CRYSTALSHARDBLUE = 0xc9e, AER_SPRITE_CRYSTALINENEMY = 0xc9f, AER_SPRITE_ELECTRICFIELD = 0xca0, AER_SPRITE_DIAMONDBLUNDERSHOT = 0xca1, AER_SPRITE_DIAMONDBLUNDERSHOTDIE = 0xca2, AER_SPRITE_DIAMONDBLUNDERSHOTGOLD = 0xca3, AER_SPRITE_DIAMONDBLUNDERSHOTDIEGOLD = 0xca4, AER_SPRITE_DIAMONDBULLET = 0xca5, AER_SPRITE_DIAMONDBULLETBIG = 0xca6, AER_SPRITE_DIAMONDSWIRLSHOT = 0xca7, AER_SPRITE_DIAMONDBULLETENORMOUS = 0xca8, AER_SPRITE_DIAMONDCHARGESHOT = 0xca9, AER_SPRITE_SWIRLBULLETCHAIN = 0xcaa, AER_SPRITE_DIAMONDSWIRLGOLD = 0xcab, AER_SPRITE_DIAMONDSWIRLDEAD = 0xcac, AER_SPRITE_DIAMONDSWIRLDEADGOLD = 0xcad, AER_SPRITE_DIAMONDBREAK = 0xcae, AER_SPRITE_DIAMONDDEPOSIT = 0xcaf, AER_SPRITE_FLAMEJARFLASH = 0xcb0, AER_SPRITE_FLAMECURL = 0xcb1, AER_SPRITE_FLAMEONGROUND = 0xcb2, AER_SPRITE_LEAPFLAME = 0xcb3, AER_SPRITE_LEAPFLAME2 = 0xcb4, AER_SPRITE_LEAPFLAME3 = 0xcb5, AER_SPRITE_LEAPFLAMEBIG = 0xcb6, AER_SPRITE_LITTLEFLAME = 0xcb7, AER_SPRITE_HOLOAIMER = 0xcb8, AER_SPRITE_HOLOAIMERX = 0xcb9, AER_SPRITE_BOMB = 0xcba, AER_SPRITE_BIGBOMB = 0xcbb, AER_SPRITE_JACKOLANTERN = 0xcbc, AER_SPRITE_MECHCANNONEMITTER = 0xcbd, AER_SPRITE_MECHCANNONPULSE = 0xcbe, AER_SPRITE_MECHCANNONCHUNK = 0xcbf, AER_SPRITE_PISTOLTRACERSHOT = 0xcc0, AER_SPRITE_TRACERDIE = 0xcc1, AER_SPRITE_OOMACHINEGUNNBULLET = 0xcc2, AER_SPRITE_PISTOLFADE = 0xcc3, AER_SPRITE_PISTOLFADE2 = 0xcc4, AER_SPRITE_PISTOLSHOTFADE = 0xcc5, AER_SPRITE_PISTOLGOLD = 0xcc6, AER_SPRITE_PISTOLGOLDSHOTFADE = 0xcc7, AER_SPRITE_OOMACHINEGUNNBULLETBLUE = 0xcc8, AER_SPRITE_PISTOLBURSTSHOT = 0xcc9, AER_SPRITE_BURSTPISTOLPERKBULLET = 0xcca, AER_SPRITE_PISTOLSCUTTLERSHOT = 0xccb, AER_SPRITE_PISTOLBURST = 0xccc, AER_SPRITE_PISTOLBURSTSHRAPNEL = 0xccd, AER_SPRITE_PISTOLBURSTGOLD = 0xcce, AER_SPRITE_PISTOLSHOT = 0xccf, AER_SPRITE_HOLOCARTRIDGE = 0xcd0, AER_SPRITE_MUZZLERAILGUNBLAST = 0xcd1, AER_SPRITE_MUZZLERAILGUNBLASTPERK = 0xcd2, AER_SPRITE_RAILGUNBLASTPARTICLE = 0xcd3, AER_SPRITE_MUZZLERAILGUN = 0xcd4, AER_SPRITE_MUZZLERAILGUNPERK = 0xcd5, AER_SPRITE_RAILGUNPARTICLE = 0xcd6, AER_SPRITE_HITSPARKRAILGUN = 0xcd7, AER_SPRITE_MUZZLERAILGUNLIGHT = 0xcd8, AER_SPRITE_MUZZLERAILGUNLIGHTPERK = 0xcd9, AER_SPRITE_RAILGUNLIGHTPARTICLE = 0xcda, AER_SPRITE_HITSPARKLIGHTRAIL = 0xcdb, AER_SPRITE_RAILGUNBEAMBASE = 0xcdc, AER_SPRITE_RAILGUNBEAMBLAST = 0xcdd, AER_SPRITE_RAILGUNBEAMPERK = 0xcde, AER_SPRITE_RAILGUNBEAMMASTER = 0xcdf, AER_SPRITE_RAILGUNMUZZLEBASE = 0xce0, AER_SPRITE_RAILGUNMUZZLEPERK = 0xce1, AER_SPRITE_RAILGUNMUZZLEMASTER = 0xce2, AER_SPRITE_ROLLYPOLLY = 0xce3, AER_SPRITE_ROLLYPOLLYGOLD = 0xce4, AER_SPRITE_ROLLYPOLLYMASTER = 0xce5, AER_SPRITE_SHOVEDIAMONDLARGE = 0xce6, AER_SPRITE_SHOVEDIAMONDMED = 0xce7, AER_SPRITE_SHOVEDIAMONDSMALL = 0xce8, AER_SPRITE_SHOVEEXPLOSION = 0xce9, AER_SPRITE_SHOVEGLOVECONE = 0xcea, AER_SPRITE_SHOVEGLOVEWEAPON = 0xceb, AER_SPRITE_SHOVEHITSPARK = 0xcec, AER_SPRITE_SHOVEPERKBLAST = 0xced, AER_SPRITE_HYPERHAMMERPREP = 0xcee, AER_SPRITE_WARPHAMMERASSEMBLE = 0xcef, AER_SPRITE_WARPHAMMER = 0xcf0, AER_SPRITE_PROXMINE = 0xcf1, AER_SPRITE_UNDERMINE = 0xcf2, AER_SPRITE_ORB = 0xcf3, AER_SPRITE_TADPOLEMOVE = 0xcf4, AER_SPRITE_TADPOLEPEEK = 0xcf5, AER_SPRITE_TADPOLEIDLE = 0xcf6, AER_SPRITE_TADPOLEDIVE = 0xcf7, AER_SPRITE_FLYFLY = 0xcf8, AER_SPRITE_FLYIDLE = 0xcf9, AER_SPRITE_FLYWALK = 0xcfa, AER_SPRITE_SNAILIDLE = 0xcfb, AER_SPRITE_SNAILMOVE = 0xcfc, AER_SPRITE_SNAILSQUISH = 0xcfd, AER_SPRITE_HERONIDLE = 0xcfe, AER_SPRITE_HERONFLY = 0xcff, AER_SPRITE_EMBERFOXIDLE = 0xd00, AER_SPRITE_EMBERFOXNOHALO = 0xd01, AER_SPRITE_EMBERFOXS = 0xd02, AER_SPRITE_EMBERFOXN = 0xd03, AER_SPRITE_EMBERFOXE = 0xd04, AER_SPRITE_TINYFLY = 0xd05, AER_SPRITE_ROBINIDLE = 0xd06, AER_SPRITE_ROBINHOP = 0xd07, AER_SPRITE_ROBINFLY = 0xd08, AER_SPRITE_DOGWALK = 0xd09, AER_SPRITE_DOGBARK = 0xd0a, AER_SPRITE_DOGIDLE = 0xd0b, AER_SPRITE_DOGSNIFF = 0xd0c, AER_SPRITE_HALBIRDIDLE = 0xd0d, AER_SPRITE_HALBIRDFLY = 0xd0e, AER_SPRITE_CROWIDLE = 0xd0f, AER_SPRITE_CROWHOP = 0xd10, AER_SPRITE_CROWFLY = 0xd11, AER_SPRITE_DRONEBEEP = 0xd12, AER_SPRITE_DRONESCAN = 0xd13, AER_SPRITE_SCORPIDLE = 0xd14, AER_SPRITE_SCORPWALK = 0xd15, AER_SPRITE_SCORPBURROW = 0xd16, AER_SPRITE_SQUIDBOTFLOAT = 0xd17, AER_SPRITE_SQUIDBOTIDLE = 0xd18, AER_SPRITE_SQUIRRELWALK = 0xd19, AER_SPRITE_SQUIRRELIDLE = 0xd1a, AER_SPRITE_SUNKENOTTER = 0xd1b, AER_SPRITE_EEL = 0xd1c, AER_SPRITE_FISH = 0xd1d, AER_SPRITE_BIRDFLY = 0xd1e, AER_SPRITE_BIRDIDLE = 0xd1f, AER_SPRITE_BIRDHOP = 0xd20, AER_SPRITE_TINYSHADOW = 0xd21, AER_SPRITE_DEERIDLE = 0xd22, AER_SPRITE_DEERRUN = 0xd23, AER_SPRITE_RSYMBOL = 0xd24, AER_SPRITE_REFHALDRIFT = 0xd25, AER_SPRITE_HALBG = 0xd26, AER_SPRITE_ENEMYHPCHECKER = 0xd27, /** * @deprecated Since 1.2.0. */ AER_SPRITE_SPRITE3368 = 0xd28, /** * @deprecated Since 1.2.0. */ AER_SPRITE_SPRITE3369 = 0xd29, /** * @deprecated Since 1.2.0. */ AER_SPRITE_SPRITE3370 = 0xd2a } AERSpriteIndex; #undef AER_SPRITE_SPRITE3368 #undef AER_SPRITE_SPRITE3369 #undef AER_SPRITE_SPRITE3370 /* ----- PUBLIC FUNCTIONS ----- */ /** * @brief Register a custom sprite. * * @bug The coordinates defining the origin of a sprite may be negative despite * the fact that both arguments `origX` and `origY` are unsigned. They are being * left as unsigned to preserve API compatibility. To pass a negative value for * a component of the origin, cast it to `uint32_t`. * * @param[in] name Name to assign to sprite. * @param[in] filename Path to sprite file relative to asset directory. * @param[in] numFrames If animated sprite, number of animation frames. * If not animated, use `1`. * @param[in] origX Horizontal origin (center) of sprite. * @param[in] origY Vertical origin (center) of sprite. * * @return Index of new sprite or ::AER_SPRITE_NULL if unsuccessful. * * @throw ::AER_NULL_ARG if argument `name` or argument `filename` is * `NULL`. * @throw ::AER_SEQ_BREAK if called outside sprite registration stage. * @throw ::AER_BAD_VAL if argument `numFrames` is less than `1` or argument * `name` is already in use by another sprite. * @throw ::AER_BAD_FILE if argument `filename` does not point to valid file. * * @since 1.0.0 * * @sa AERSpriteReplace */ int32_t AERSpriteRegister(const char* name, const char* filename, size_t numFrames, uint32_t origX, uint32_t origY); /** * @brief Override a vanilla sprite with a custom sprite. * * @bug The coordinates defining the origin of a sprite may be negative despite * the fact that both arguments `origX` and `origY` are unsigned. They are being * left as unsigned to preserve API compatibility. To pass a negative value for * a component of the origin, cast it to `uint32_t`. * * @param[in] spriteIdx Index of vanilla sprite to override. * @param[in] filename Path to sprite file relative to asset directory. * @param[in] numFrames If animated sprite, number of animation frames. * If not animated, use `1`. * @param[in] origX Horizontal origin (center) of sprite. * @param[in] origY Vertical origin (center) of sprite. * * @throw ::AER_FAILED_LOOKUP if argument `spriteIdx` is an invalid sprite. * @throw ::AER_SEQ_BREAK if called outside sprite registration stage. * @throw ::AER_NULL_ARG if argument `filename` is `NULL`. * @throw ::AER_BAD_VAL if argument `numFrames` is less than `1`. * * @since 1.0.0 * * @sa AERSpriteRegister */ void AERSpriteReplace(int32_t spriteIdx, const char* filename, size_t numFrames, uint32_t origX, uint32_t origY); /** * @brief Query the total number of vanilla and mod sprites registered. * * @return Number of sprites or `0` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called before start of sprite registration stage. * * @since 1.0.0 */ size_t AERSpriteGetNumRegistered(void); /** * @brief Query the sprite with a specific name. * * @param[in] name Name of sprite. * * @return Sprite index or ::AER_SPRITE_NULL if unsuccessful. * * @throw ::AER_SEQ_BREAK if called before start of sprite registration stage. * @throw ::AER_NULL_ARG if argument `name` is `NULL`. * @throw ::AER_FAILED_LOOKUP if no sprite with name given by argument `name`. * * @since 1.3.0 */ int32_t AERSpriteGetByName(const char* name); /** * @brief Query the name of a sprite. * * @param[in] spriteIdx Sprite of interest. * * @return Name of sprite or `NULL` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called before start of sprite registration stage. * @throw ::AER_FAILED_LOOKUP if argument `spriteIdx` is an invalid sprite. * * @since 1.0.0 */ const char* AERSpriteGetName(int32_t spriteIdx); /** * @brief Query the number of animation frames of a sprite. * * @param[in] spriteIdx Sprite of interest. * * @return Number of animation frames or `0` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called before start of sprite registration stage. * @throw ::AER_FAILED_LOOKUP if argument `spriteIdx` is an invalid sprite. * * @since 1.4.0 */ size_t AERSpriteGetNumFrames(int32_t spriteIdx); /** * @brief Query the size of a sprite in pixels. * * If only one component of the size is needed, then the argument for the * unneeded component may be `NULL`. * * @param[in] spriteIdx Sprite of interest. * @param[out] width Width in pixels. * @param[out] height Height in pixels. * * @throw ::AER_SEQ_BREAK if called before start of sprite registration stage. * @throw ::AER_NULL_ARG if both arguments `width` and `height` are `NULL`. * @throw ::AER_FAILED_LOOKUP if argument `spriteIdx` is an invalid sprite. * * @since 1.4.0 */ void AERSpriteGetSize(int32_t spriteIdx, size_t* width, size_t* height); /** * @brief Query the origin (center) of a sprite in pixels. * * If only one component of the origin is needed, then the argument for the * unneeded component may be `NULL`. * * @param[in] spriteIdx Sprite of interest. * @param[out] x Horizontal origin in pixels. * @param[out] y Vertical origin in pixels. * * @throw ::AER_SEQ_BREAK if called before start of sprite registration stage. * @throw ::AER_NULL_ARG if both arguments `x` and `y` are `NULL`. * @throw ::AER_FAILED_LOOKUP if argument `spriteIdx` is an invalid sprite. * * @since 1.4.0 */ void AERSpriteGetOrigin(int32_t spriteIdx, int32_t* x, int32_t* y); /** * @brief Set the origin (center) of a sprite in pixels. * * @param[in] spriteIdx Sprite of interest. * @param[in] x Horizontal origin in pixels. * @param[in] y Vertical origin in pixels. * * @throw ::AER_SEQ_BREAK if called before start of sprite registration stage. * @throw ::AER_FAILED_LOOKUP if argument `spriteIdx` is an invalid sprite. * * @since 1.4.0 */ void AERSpriteSetOrigin(int32_t spriteIdx, int32_t x, int32_t y); #endif /* AER_SPRITE_H */
Foxbud/libaermre
src/object.c
<reponame>Foxbud/libaermre<filename>src/object.c /** * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <assert.h> #include <stdlib.h> #include <string.h> #include "foxutils/arraymacs.h" #include "foxutils/mapmacs.h" #include "foxutils/math.h" #include "foxutils/stringmapmacs.h" #include "aer/object.h" #include "aer/sprite.h" #include "internal/core.h" #include "internal/err.h" #include "internal/event.h" #include "internal/export.h" #include "internal/hld.h" #include "internal/log.h" #include "internal/mod.h" #include "internal/object.h" /* ----- PRIVATE GLOBALS ----- */ static FoxMap objTree = {0}; static FoxMap flatObjTree = {0}; static FoxMap objNames = {0}; /* ----- PRIVATE FUNCTIONS ----- */ static void ObjTreeGetAllChildren(FoxArray* directChildren, FoxArray* allChildren) { size_t numDirectChildren = FoxArrayMSize(int32_t, directChildren); for (uint32_t idx = 0; idx < numDirectChildren; idx++) { int32_t childIdx = *FoxArrayMIndex(int32_t, directChildren, idx); *FoxArrayMPush(int32_t, allChildren) = childIdx; FoxArray* nextChildren = FoxMapMIndex(int32_t, FoxArray, &objTree, childIdx); if (nextChildren) ObjTreeGetAllChildren(nextChildren, allChildren); } return; } static bool ObjTreeBuildFlatObjTreeCallback(const int32_t* objIdx, FoxArray* directChildren, void* ctx) { (void)ctx; FoxArray* allChildren = FoxMapMInsert(int32_t, FoxArray, &flatObjTree, *objIdx); FoxArrayMInit(int32_t, allChildren); ObjTreeGetAllChildren(directChildren, allChildren); return true; } static bool ObjTreeChildrenDeinitCallback(FoxArray* children, void* ctx) { (void)ctx; FoxArrayMDeinit(int32_t, children); return true; } /* ----- INTERNAL FUNCTIONS ----- */ FoxArray* ObjectManGetDirectChildren(int32_t objIdx) { return FoxMapMIndex(int32_t, FoxArray, &objTree, objIdx); } FoxArray* ObjectManGetAllChildren(int32_t objIdx) { return FoxMapMIndex(int32_t, FoxArray, &flatObjTree, objIdx); } void ObjectManBuildNameTable(void) { size_t numObjs = (*hldvars.objectTableHandle)->numItems; for (uint32_t objIdx = 0; objIdx < numObjs; objIdx++) { HLDObject* obj = HLDObjectLookup(objIdx); assert(obj); *FoxMapMInsert(const char*, int32_t, &objNames, obj->name) = objIdx; } return; } void ObjectManBuildInheritanceTrees(void) { /* Build object tree. */ size_t numObjs = (*hldvars.objectTableHandle)->numItems; for (uint32_t objIdx = 0; objIdx < numObjs; objIdx++) { HLDObject* obj = HLDObjectLookup(objIdx); assert(obj); int32_t parentIdx = obj->parentIndex; FoxArray* directChildren = FoxMapMIndex(int32_t, FoxArray, &objTree, parentIdx); if (!directChildren) FoxArrayMInit( int32_t, (directChildren = FoxMapMInsert(int32_t, FoxArray, &objTree, parentIdx))); *FoxArrayMPush(int32_t, directChildren) = objIdx; } /* Build flat object tree. */ FoxMapMForEachPair(int32_t, FoxArray, &objTree, ObjTreeBuildFlatObjTreeCallback, NULL); return; } void ObjectManConstructor(void) { LogInfo("Initializing object module..."); FoxMapMInit(int32_t, FoxArray, &objTree); FoxMapMInit(int32_t, FoxArray, &flatObjTree); FoxStringMapMInit(int32_t, &objNames); LogInfo("Done initializing object module."); return; } void ObjectManDestructor(void) { LogInfo("Deinitializing object module..."); /* Deinitialize object tree. */ FoxMapMForEachElement(int32_t, FoxArray, &objTree, ObjTreeChildrenDeinitCallback, NULL); FoxMapMDeinit(int32_t, FoxArray, &objTree); objTree = (FoxMap){0}; /* Deinitialize flat object tree. */ FoxMapMForEachElement(int32_t, FoxArray, &flatObjTree, ObjTreeChildrenDeinitCallback, NULL); FoxMapMDeinit(int32_t, FoxArray, &flatObjTree); flatObjTree = (FoxMap){0}; /* Deinitialize name table. */ FoxMapMDeinit(const char*, int32_t, &objNames); objNames = (FoxMap){0}; LogInfo("Done deinitializing object module."); return; } /* ----- PUBLIC FUNCTIONS ----- */ AER_EXPORT int32_t AERObjectRegister(const char* name, int32_t parentIdx, int32_t spriteIdx, int32_t maskIdx, int32_t depth, bool visible, bool collisions, bool persistent) { #define errRet AER_OBJECT_NULL EnsureArg(name); LogInfo("Registering object \"%s\" for mod \"%s\"...", name, ModManGetCurrentMod()->name); EnsureStageStrict(STAGE_OBJECT_REG); HLDObject* parent = HLDObjectLookup(parentIdx); EnsureLookup(parent); EnsureLookup(spriteIdx == AER_SPRITE_NULL || HLDSpriteLookup(spriteIdx)); EnsureLookup(maskIdx == AER_SPRITE_NULL || HLDSpriteLookup(maskIdx)); Ensure(!FoxMapMIndex(const char*, int32_t, &objNames, name), AER_BAD_VAL); int32_t objIdx = hldfuncs.actionObjectAdd(); HLDObject* obj = HLDObjectLookup(objIdx); assert(obj); *FoxMapMInsert(const char*, int32_t, &objNames, name) = objIdx; /* The engine expects a freeable (dynamically allocated) string for name. */ char* tmpName = malloc(strlen(name) + 1); assert(tmpName); obj->name = strcpy(tmpName, name); obj->parentIndex = parentIdx; obj->parent = parent; obj->spriteIndex = spriteIdx; obj->maskIndex = maskIdx; obj->depth = depth; obj->flags.visible = visible; obj->flags.collisions = collisions; obj->flags.persistent = persistent; LogInfo("Successfully registered object to index %i.", objIdx); Ok(objIdx); #undef errRet } AER_EXPORT size_t AERObjectGetNumRegistered(void) { #define errRet 0 EnsureStage(STAGE_OBJECT_REG); Ok((*hldvars.objectTableHandle)->numItems); #undef errRet } AER_EXPORT int32_t AERObjectGetByName(const char* name) { #define errRet AER_OBJECT_NULL EnsureStage(STAGE_OBJECT_REG); EnsureArg(name); int32_t* objIdx = FoxMapMIndex(const char*, int32_t, &objNames, name); EnsureLookup(objIdx); Ok(*objIdx); #undef errRet } AER_EXPORT const char* AERObjectGetName(int32_t objIdx) { #define errRet NULL EnsureStage(STAGE_OBJECT_REG); HLDObject* obj = HLDObjectLookup(objIdx); EnsureLookup(obj); Ok(obj->name); #undef errRet } AER_EXPORT int32_t AERObjectGetParent(int32_t objIdx) { #define errRet AER_OBJECT_NULL EnsureStage(STAGE_OBJECT_REG); HLDObject* obj = HLDObjectLookup(objIdx); EnsureLookup(obj); Ok(obj->parentIndex); #undef errRet } AER_EXPORT size_t AERObjectGetChildren(int32_t objIdx, bool recursive, size_t bufSize, int32_t* objBuf) { #define errRet 0 EnsureStage(STAGE_OBJECT_REG); EnsureArgBuf(objBuf, bufSize); HLDObject* obj = HLDObjectLookup(objIdx); EnsureLookup(obj); FoxArray* children = FoxMapMIndex( int32_t, FoxArray, (recursive ? &flatObjTree : &objTree), objIdx); if (!children) Ok(0); size_t numChildren = FoxArrayMSize(int32_t, children); size_t numToWrite = FoxMin(numChildren, bufSize); for (uint32_t idx = 0; idx < numToWrite; idx++) objBuf[idx] = *FoxArrayMIndex(int32_t, children, idx); Ok(numChildren); #undef errRet } AER_EXPORT bool AERObjectGetCollisions(int32_t objIdx) { #define errRet false EnsureStage(STAGE_OBJECT_REG); HLDObject* obj = HLDObjectLookup(objIdx); EnsureLookup(obj); Ok(obj->flags.collisions); #undef errRet } AER_EXPORT void AERObjectSetCollisions(int32_t objIdx, bool collisions) { #define errRet EnsureStage(STAGE_OBJECT_REG); HLDObject* obj = HLDObjectLookup(objIdx); EnsureLookup(obj); obj->flags.collisions = collisions; Ok(); #undef errRet } AER_EXPORT bool AERObjectGetPersistent(int32_t objIdx) { #define errRet false EnsureStage(STAGE_OBJECT_REG); HLDObject* obj = HLDObjectLookup(objIdx); EnsureLookup(obj); Ok(obj->flags.persistent); #undef errRet } AER_EXPORT void AERObjectSetPersistent(int32_t objIdx, bool persistent) { #define errRet EnsureStage(STAGE_OBJECT_REG); HLDObject* obj = HLDObjectLookup(objIdx); EnsureLookup(obj); obj->flags.persistent = persistent; Ok(); #undef errRet } AER_EXPORT bool AERObjectGetVisible(int32_t objIdx) { #define errRet false EnsureStage(STAGE_OBJECT_REG); HLDObject* obj = HLDObjectLookup(objIdx); EnsureLookup(obj); Ok(obj->flags.visible); #undef errRet } AER_EXPORT void AERObjectSetVisible(int32_t objIdx, bool visible) { #define errRet EnsureStage(STAGE_OBJECT_REG); HLDObject* obj = HLDObjectLookup(objIdx); EnsureLookup(obj); obj->flags.visible = visible; Ok(); #undef errRet } AER_EXPORT void AERObjectAttachCreateListener(int32_t objIdx, bool (*listener)(AEREvent*, AERInstance*, AERInstance*)) { #define errRet LogInfo("Attaching create listener to object %i for mod \"%s\"...", objIdx, ModManGetCurrentMod()->name); EnsureStageStrict(STAGE_LISTENER_REG); EnsureArg(listener); HLDObject* obj = HLDObjectLookup(objIdx); EnsureLookup(obj); EventKey key = (EventKey){.type = HLD_EVENT_CREATE, .num = 0, .objIdx = objIdx}; EventManRegisterEventListener(obj, key, listener); LogInfo("Successfully attached create listener."); Ok(); #undef errRet } AER_EXPORT void AERObjectAttachDestroyListener(int32_t objIdx, bool (*listener)(AEREvent*, AERInstance*, AERInstance*)) { #define errRet LogInfo("Attaching destroy listener to object %i for mod \"%s\"...", objIdx, ModManGetCurrentMod()->name); EnsureStageStrict(STAGE_LISTENER_REG); EnsureArg(listener); HLDObject* obj = HLDObjectLookup(objIdx); EnsureLookup(obj); EventKey key = {.type = HLD_EVENT_DESTROY, .num = 0, .objIdx = objIdx}; EventManRegisterEventListener(obj, key, listener); LogInfo("Successfully attached destroy listener."); Ok(); #undef errRet } AER_EXPORT void AERObjectAttachAlarmListener(int32_t objIdx, uint32_t alarmIdx, bool (*listener)(AEREvent*, AERInstance*, AERInstance*)) { #define errRet LogInfo("Attaching alarm %u listener to object %i for mod \"%s\"...", alarmIdx, objIdx, ModManGetCurrentMod()->name); EnsureStageStrict(STAGE_LISTENER_REG); EnsureArg(listener); EnsureMax(alarmIdx, 11); HLDObject* obj = HLDObjectLookup(objIdx); EnsureLookup(obj); EventKey key = {.type = HLD_EVENT_ALARM, .num = alarmIdx, .objIdx = objIdx}; EventManRegisterEventListener(obj, key, listener); LogInfo("Successfully attached alarm %u listener.", alarmIdx); Ok(); #undef errRet } AER_EXPORT void AERObjectAttachStepListener(int32_t objIdx, bool (*listener)(AEREvent*, AERInstance*, AERInstance*)) { #define errRet LogInfo("Attaching step listener to object %i for mod \"%s\"...", objIdx, ModManGetCurrentMod()->name); EnsureStageStrict(STAGE_LISTENER_REG); EnsureArg(listener); HLDObject* obj = HLDObjectLookup(objIdx); EnsureLookup(obj); EventKey key = { .type = HLD_EVENT_STEP, .num = HLD_EVENT_STEP_NORMAL, .objIdx = objIdx}; EventManRegisterEventListener(obj, key, listener); LogInfo("Successfully attached step listener."); Ok(); #undef errRet } AER_EXPORT void AERObjectAttachPreStepListener(int32_t objIdx, bool (*listener)(AEREvent*, AERInstance*, AERInstance*)) { #define errRet LogInfo("Attaching pre-step listener to object %i for mod \"%s\"...", objIdx, ModManGetCurrentMod()->name); EnsureStageStrict(STAGE_LISTENER_REG); EnsureArg(listener); HLDObject* obj = HLDObjectLookup(objIdx); EnsureLookup(obj); EventKey key = { .type = HLD_EVENT_STEP, .num = HLD_EVENT_STEP_PRE, .objIdx = objIdx}; EventManRegisterEventListener(obj, key, listener); LogInfo("Successfully attached pre-step listener."); Ok(); #undef errRet } AER_EXPORT void AERObjectAttachPostStepListener( int32_t objIdx, bool (*listener)(AEREvent*, AERInstance*, AERInstance*)) { #define errRet LogInfo("Attaching post-step listener to object %i for mod \"%s\"...", objIdx, ModManGetCurrentMod()->name); EnsureStageStrict(STAGE_LISTENER_REG); EnsureArg(listener); HLDObject* obj = HLDObjectLookup(objIdx); EnsureLookup(obj); EventKey key = { .type = HLD_EVENT_STEP, .num = HLD_EVENT_STEP_POST, .objIdx = objIdx}; EventManRegisterEventListener(obj, key, listener); LogInfo("Successfully attached post-step listener."); Ok(); #undef errRet } AER_EXPORT void AERObjectAttachCollisionListener( int32_t targetObjIdx, int32_t otherObjIdx, bool (*listener)(AEREvent*, AERInstance*, AERInstance*)) { #define errRet LogInfo("Attaching %i collision listener to object %i for mod \"%s\"...", otherObjIdx, targetObjIdx, ModManGetCurrentMod()->name); EnsureStageStrict(STAGE_LISTENER_REG); EnsureArg(listener); EnsureLookup(HLDObjectLookup(otherObjIdx)); HLDObject* obj = HLDObjectLookup(targetObjIdx); EnsureLookup(obj); EventKey key = {.type = HLD_EVENT_COLLISION, .num = otherObjIdx, .objIdx = targetObjIdx}; EventManRegisterEventListener(obj, key, listener); LogInfo("Successfully attached %i collision listener.", otherObjIdx); Ok(); #undef errRet } AER_EXPORT void AERObjectAttachAnimationEndListener( int32_t objIdx, bool (*listener)(AEREvent*, AERInstance*, AERInstance*)) { #define errRet LogInfo("Attaching animation end listener to object %i for mod \"%s\"...", objIdx, ModManGetCurrentMod()->name); EnsureStageStrict(STAGE_LISTENER_REG); EnsureArg(listener); HLDObject* obj = HLDObjectLookup(objIdx); EnsureLookup(obj); EventKey key = {.type = HLD_EVENT_OTHER, .num = HLD_EVENT_OTHER_ANIMATION_END, .objIdx = objIdx}; EventManRegisterEventListener(obj, key, listener); LogInfo("Successfully attached animation end listener."); Ok(); #undef errRet } AER_EXPORT void AERObjectAttachDrawListener( int32_t objIdx, bool (*listener)(AEREvent* event, AERInstance* target, AERInstance* other)) { #define errRet LogInfo("Attaching draw listener to object %i for mod \"%s\"...", objIdx, ModManGetCurrentMod()->name); EnsureStageStrict(STAGE_LISTENER_REG); EnsureArg(listener); HLDObject* obj = HLDObjectLookup(objIdx); EnsureLookup(obj); EventKey key = { .type = HLD_EVENT_DRAW, .num = HLD_EVENT_DRAW_NORMAL, .objIdx = objIdx}; EventManRegisterEventListener(obj, key, listener); LogInfo("Successfully attached draw listener."); Ok(); #undef errRet } AER_EXPORT void AERObjectAttachGUIDrawListener( int32_t objIdx, bool (*listener)(AEREvent* event, AERInstance* target, AERInstance* other)) { #define errRet LogInfo("Attaching GUI-draw listener to object %i for mod \"%s\"...", objIdx, ModManGetCurrentMod()->name); EnsureStageStrict(STAGE_LISTENER_REG); EnsureArg(listener); HLDObject* obj = HLDObjectLookup(objIdx); EnsureLookup(obj); EventKey key = {.type = HLD_EVENT_DRAW, .num = HLD_EVENT_DRAW_GUI_NORMAL, .objIdx = objIdx}; EventManRegisterEventListener(obj, key, listener); LogInfo("Successfully attached GUI-draw listener."); Ok(); #undef errRet }
Foxbud/libaermre
include/public/aer/input.h
<filename>include/public/aer/input.h /** * @file * * @brief Utilities for querying user input. * * @since 1.0.0 * * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef AER_INPUT_H #define AER_INPUT_H #include <stdbool.h> #include <stdint.h> /* ----- PUBLIC TYPES ----- */ /* @deprecated Since 1.3.0. Use ::AER_KEY_ERASE_BEFORE instead. */ #define AER_KEY_ERASE AER_KEY_ERASE __attribute__((deprecated)) /** * @brief Indexes for keypresses in input lookup table. * * @since 1.1.0 */ typedef enum AERInputKey { AER_KEY_INTERRUPT = 0x3, AER_KEY_BACKSPACE = 0x8, AER_KEY_TAB = 0x9, /** * @since 1.3.0 */ AER_KEY_ERASE_AFTER = 0xb, /** * @since 1.3.0 */ AER_KEY_CLEAR = 0xc, AER_KEY_ENTER = 0xd, AER_KEY_CAPSLOCK = 0x14, /** * @deprecated Since 1.3.0. Use ::AER_KEY_ERASE_BEFORE instead. */ AER_KEY_ERASE = 0x15, /** * @since 1.3.0 */ AER_KEY_ERASE_BEFORE = 0x15, AER_KEY_ESCAPE = 0x1b, AER_KEY_SPACE = 0x20, AER_KEY_PAGEUP = 0x21, AER_KEY_EXCLAIM = 0x21, AER_KEY_PAGEDOWN = 0x22, AER_KEY_QUOTE = 0x22, AER_KEY_END = 0x23, AER_KEY_HOME = 0x24, AER_KEY_DOLLAR = 0x24, AER_KEY_LARROW = 0x25, AER_KEY_PERCENT = 0x25, AER_KEY_UARROW = 0x26, AER_KEY_AMP = 0x26, AER_KEY_RARROW = 0x27, AER_KEY_DARROW = 0x28, AER_KEY_LPAREN = 0x28, AER_KEY_RPAREN = 0x29, AER_KEY_ASTERISK = 0x2a, AER_KEY_PLUS = 0x2b, AER_KEY_INSERT = 0x2d, AER_KEY_DELETE = 0x2e, AER_KEY_0 = 0x30, AER_KEY_1 = 0x31, AER_KEY_2 = 0x32, AER_KEY_3 = 0x33, AER_KEY_4 = 0x34, AER_KEY_5 = 0x35, AER_KEY_6 = 0x36, AER_KEY_7 = 0x37, AER_KEY_8 = 0x38, AER_KEY_9 = 0x39, AER_KEY_COLON = 0x3a, AER_KEY_LESS = 0x3c, AER_KEY_GREATER = 0x3e, AER_KEY_QUERY = 0x3f, AER_KEY_AT = 0x40, AER_KEY_A = 0x41, AER_KEY_B = 0x42, AER_KEY_C = 0x43, AER_KEY_D = 0x44, AER_KEY_E = 0x45, AER_KEY_F = 0x46, AER_KEY_G = 0x47, AER_KEY_H = 0x48, AER_KEY_I = 0x49, AER_KEY_J = 0x4a, AER_KEY_K = 0x4b, AER_KEY_L = 0x4c, AER_KEY_M = 0x4d, AER_KEY_N = 0x4e, AER_KEY_O = 0x4f, AER_KEY_P = 0x50, AER_KEY_Q = 0x51, AER_KEY_R = 0x52, AER_KEY_S = 0x53, AER_KEY_T = 0x54, AER_KEY_U = 0x55, AER_KEY_V = 0x56, AER_KEY_W = 0x57, AER_KEY_X = 0x58, AER_KEY_Y = 0x59, AER_KEY_Z = 0x5a, AER_KEY_CARET = 0x5e, AER_KEY_UNDERSCORE = 0x5f, AER_KEY_NUM0 = 0x60, AER_KEY_NUM1 = 0x61, AER_KEY_NUM2 = 0x62, AER_KEY_NUM3 = 0x63, AER_KEY_NUM4 = 0x64, AER_KEY_NUM5 = 0x65, AER_KEY_NUM6 = 0x66, AER_KEY_NUM7 = 0x67, AER_KEY_NUM8 = 0x68, AER_KEY_NUM9 = 0x69, AER_KEY_NUMASTERISK = 0x6a, AER_KEY_NUMPLUS = 0x6b, AER_KEY_NUMMINUS = 0x6d, AER_KEY_NUMPERIOD = 0x6e, AER_KEY_NUMSLASH = 0x6f, AER_KEY_F1 = 0x70, AER_KEY_F2 = 0x71, AER_KEY_F3 = 0x72, AER_KEY_F4 = 0x73, AER_KEY_F5 = 0x74, AER_KEY_F6 = 0x75, AER_KEY_F7 = 0x76, AER_KEY_F8 = 0x77, AER_KEY_F9 = 0x78, AER_KEY_F10 = 0x79, AER_KEY_LCURLY = 0x7b, AER_KEY_VBAR = 0x7c, AER_KEY_RCURLY = 0x7d, AER_KEY_TILDE = 0x7e, AER_KEY_F11 = 0x80, AER_KEY_F12 = 0x81, AER_KEY_LSHIFT = 0xa0, AER_KEY_RSHIFT = 0xa1, AER_KEY_LCTRL = 0xa2, AER_KEY_RCTRL = 0xa3, AER_KEY_LALT = 0xa4, AER_KEY_RALT = 0xa5, AER_KEY_SEMICOLON = 0xba, AER_KEY_EQUALS = 0xbb, AER_KEY_COMMA = 0xbc, AER_KEY_MINUS = 0xbd, AER_KEY_PERIOD = 0xbe, AER_KEY_SLASH = 0xbf, AER_KEY_APOS = 0xc0, AER_KEY_LSQUARE = 0xdb, AER_KEY_BACKSLASH = 0xdc, AER_KEY_RSQUARE = 0xdd, AER_KEY_HASH = 0xde, AER_KEY_BACKTICK = 0xdf } AERInputKey; #undef AER_KEY_ERASE /* ----- PUBLIC CONSTANTS ----- */ /** * @brief Printable characters corresponding to input table indexes. * * @since 1.1.0 */ extern const char AER_DISPLAY_KEYS[]; /* ----- PUBLIC FUNCTIONS ----- */ /** * @brief Query the keyboard key(s) that the user just pressed this step. * * @return Lookup table mapping key-codes to pressed state or `NULL` if * unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * * @since 1.0.0 * * @sa AERInputKey */ const bool* AERInputGetKeysPressed(void); /** * @brief Query the keyboard key(s) that the user has held this step. * * @return Lookup table mapping key-codes to held state or `NULL` if * unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * * @since 1.0.0 * * @sa AERInputKey */ const bool* AERInputGetKeysHeld(void); /** * @brief Query the keyboard key(s) that the user just released this step. * * @return Lookup table mapping key-codes to released state or `NULL` if * unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * * @since 1.0.0 * * @sa AERInputKey */ const bool* AERInputGetKeysReleased(void); /** * @brief Query the mouse button(s) that the user just pressed this step. * * @subsubsection MouseButtonStates Mouse Button States * * The array returned by this function has the following values. * * Array Index | Mouse Button * ----------: | ------------ * `0` | Left * `1` | Right * `2` | Middle * * @return Array of mouse button pressed states or `NULL` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * * @since 1.0.0 */ const bool* AERInputGetMouseButtonsPressed(void); /** * @brief Query the mouse button(s) that the user has held this step. * * For more information about the mouse buttons, see @ref MouseButtonStates. * * @return Array of mouse button held states or `NULL` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * * @since 1.0.0 */ const bool* AERInputGetMouseButtonsHeld(void); /** * @brief Query the mouse button(s) that the user just released this step. * * For more information about the mouse buttons, see @ref MouseButtonStates. * * @return Array of mouse button released states or `NULL` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * * @since 1.0.0 */ const bool* AERInputGetMouseButtonsReleased(void); /** * @brief Query the current position of the mouse cursor in pixels relative to * the game window. * * If only one component of the position is needed, then the argument for the * unneeded component may be `NULL`. * * @param[out] x Horizontal position. * @param[out] y Vertical position. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if both arguments `x` and `y` are `NULL`. * * @since 1.3.0 * * @sa AERInputGetMousePositionVirtual */ void AERInputGetMousePositionRaw(uint32_t* x, uint32_t* y); #define void __attribute__((deprecated)) void /** * @brief This function is a deprecated alias for @ref * AERInputGetMousePositionRaw. * * @deprecated Since 1.3.0. Use @ref AERInputGetMousePositionRaw instead. * * @since 1.0.0 * * @sa AERInputGetMousePositionRaw * @sa AERInputGetMousePositionVirtual */ void AERInputGetMousePosition(uint32_t* x, uint32_t* y); #undef void /** * @brief Query the current position of the mouse cursor in pixels relative to * the current room. * * If only one component of the position is needed, then the argument for the * unneeded component may be `NULL`. * * @param[out] x Horizontal position. * @param[out] y Vertical position. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if both arguments `x` and `y` are `NULL`. * * @since 1.3.0 * * @sa AERInputGetMousePositionRaw */ void AERInputGetMousePositionVirtual(float* x, float* y); #endif /* AER_INPUT_H */
Foxbud/libaermre
src/core.c
<filename>src/core.c /** * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <assert.h> #include <stdio.h> #include "aer/core.h" #include "aer/object.h" #include "internal/conf.h" #include "internal/core.h" #include "internal/err.h" #include "internal/event.h" #include "internal/export.h" #include "internal/hld.h" #include "internal/input.h" #include "internal/instance.h" #include "internal/log.h" #include "internal/mod.h" #include "internal/object.h" #include "internal/option.h" #include "internal/rand.h" #include "internal/room.h" #include "internal/save.h" #include "internal/sprite.h" /* ----- PRIVATE CONSTANTS ----- */ static const char* ABS_ASSET_PATH_FMT = "assets/mod/%s/%s"; /* ----- PRIVATE GLOBALS ----- */ static bool gamePaused = false; static char assetPathBuf[8 * 1024]; /* ----- INTERNAL GLOBALS ----- */ CoreStage stage = STAGE_INIT; /* ----- INTERNAL FUNCTIONS ----- */ const char* CoreGetAbsAssetPath(const char* modName, const char* relAssetPath) { assert(modName); assert(relAssetPath); snprintf(assetPathBuf, sizeof(assetPathBuf), ABS_ASSET_PATH_FMT, modName, relAssetPath); return assetPathBuf; } __attribute__((constructor)) static void CoreConstructor(void) { LogInfo("Action-Event-Response (AER) Mod Runtime Environment (MRE)"); ModManConstructor(); ConfConstructor(); OptionConstructor(); RandConstructor(); EventManConstructor(); SpriteManConstructor(); ObjectManConstructor(); RoomManConstructor(); InstanceManConstructor(); return; } __attribute__((destructor)) static void CoreDestructor(void) { InstanceManDestructor(); SaveManDestructor(); ModManUnloadMods(); RoomManDestructor(); ObjectManDestructor(); SpriteManDestructor(); EventManDestructor(); RandDestructor(); OptionDestructor(); ConfDestructor(); ModManDestructor(); return; } static void RegisterAssets(void) { size_t numMods = ModManGetNumMods(); /* Build sprite name table. */ SpriteManBuildNameTable(); /* Register sprites. */ stage = STAGE_SPRITE_REG; LogInfo("Registering mod sprites..."); /* * Reverse order so that higher-priority mods' sprite replacements take * precedence over those of lower-priority mods. */ for (uint32_t idx = 0; idx < numMods; idx++) { int32_t modIdx = (int32_t)(numMods - idx - 1); Mod* mod = ModManGetMod(modIdx); if (mod->registerSprites) { mod->registerSprites(); } } LogInfo("Done."); /* Register fonts. */ stage = STAGE_FONT_REG; LogInfo("Registering mod fonts..."); for (uint32_t modIdx = 0; modIdx < numMods; modIdx++) { Mod* mod = ModManGetMod(modIdx); if (mod->registerFonts) { mod->registerFonts(); } } LogInfo("Done."); /* Build object name table. */ ObjectManBuildNameTable(); /* Register objects. */ stage = STAGE_OBJECT_REG; LogInfo("Registering mod objects..."); for (uint32_t modIdx = 0; modIdx < numMods; modIdx++) { Mod* mod = ModManGetMod(modIdx); if (mod->registerObjects) { mod->registerObjects(); } } LogInfo("Done."); /* Build object inheritance trees and mask event subscribers. */ ObjectManBuildInheritanceTrees(); EventManMaskSubscriptionArrays(); /* Register listeners. */ stage = STAGE_LISTENER_REG; LogInfo("Registering mod event listeners..."); for (uint32_t modIdx = 0; modIdx < numMods; modIdx++) { Mod* mod = ModManGetMod(modIdx); if (mod->registerObjectListeners) { mod->registerObjectListeners(); } } LogInfo("Done."); /* Sort event subscribers. */ EventManSortSubscriptionArrays(); /* Build room name table. */ RoomManBuildNameTable(); stage = STAGE_ACTION; return; } /* ----- UNLISTED FUNCTIONS ----- */ AER_EXPORT void AERHookInit(HLDVariables vars, HLDFunctions funcs) { HLDRecordEngineRefs(&vars, &funcs); InstanceManRecordHLDLocals(); ModManLoadMods(); SaveManConstructor(); return; } AER_EXPORT void AERHookStep(void) { if (*hldvars.numSteps == 1) RegisterAssets(); /* Record user input. */ InputManRecordUserInput(); /* Check if game pause state changed. */ bool paused = HLDObjectLookup(AER_OBJECT_MENUS)->numInstances > 0; if (paused != gamePaused) { gamePaused = paused; /* Call game pause listeners. */ ModManExecuteGamePauseListeners(paused); } /* Check if room changed. */ int32_t roomIdxCur = *hldvars.roomIndexCurrent; if (roomIdxCur != roomIndexPrevious) { /* Prune orphaned mod instance locals. */ InstanceManPruneModLocals(); /* Call room change listeners. */ ModManExecuteRoomChangeListeners(roomIdxCur, roomIndexPrevious); roomIndexPrevious = roomIdxCur; } /* Call game step listeners. */ ModManExecuteGameStepListeners(); return; } AER_EXPORT void AERHookEvent(HLDObject* targetObject, HLDEventType eventType, int32_t eventNum) { currentEvent = (EventKey){ .type = eventType, .num = eventNum, .objIdx = targetObject->index}; return; } AER_EXPORT void AERHookLoadData(HLDPrimitive* dataMapId) { SaveManLoadData(dataMapId); ModManExecuteGameLoadListeners(SaveManGetCurrentSlot()); return; } AER_EXPORT void AERHookSaveData(HLDPrimitive* dataMapId) { ModManExecuteGameSaveListeners(SaveManGetCurrentSlot()); SaveManSaveData(dataMapId); return; } /* ----- PUBLIC FUNCTIONS ----- */ AER_EXPORT uint32_t AERGetNumSteps(void) { #define errRet 0 EnsureStage(STAGE_ACTION); Ok(*hldvars.numSteps); #undef errRet } AER_EXPORT bool AERGetPaused(void) { #define errRet 0 EnsureStage(STAGE_ACTION); Ok(gamePaused); #undef errRet }
Foxbud/libaermre
include/public/aer/draw.h
<gh_stars>1-10 /** * @file * * @brief Utilities for drawing to the screen. * * The functions in this module should only be called from inside object draw * event listeners. See @ref AERObjectAttachDrawListener for more information. * * @subsubsection DrawColors Colors * * Colors are represented as unsigned 32-bit integers. The least significant * byte is the red component, the next byte is the green component, the second * most significant byte is the blue component and the most significant byte is * unused (it is **not** used for alpha). * * This means that expressing a color in hexadecimal requires writing it in * "BGR" order (i.e. the color red=0x0, green=0x70, blue=0xf0 would be written * as `0xf07000`). * * @since 1.1.0 * * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef AER_DRAW_H #define AER_DRAW_H #include <stdbool.h> #include <stdint.h> /* ----- PUBLIC FUNCTIONS ----- */ /** * @brief Query the current global draw alpha. * * @subsubsection GlobalAlpha Global Alpha * * This value is implicitly blended into the final result of all draw functions. * For functions that take an explicit alpha value, the global alpha is still * factored in. * * @return Global alpha or `-1.0f` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * * @since 1.1.0 */ float AERDrawGetCurrentAlpha(void); /** * @brief Set the current global draw alpha. * * See @ref GlobalAlpha for more information about this value. * * @param[in] alpha Global alpha. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_BAD_VAL if argument `alpha` is less than `0.0f` or greater * than `1.0f`. * * @since 1.1.0 */ void AERDrawSetCurrentAlpha(float alpha); /** * @brief Draw a sprite to the screen. * * @param[in] spriteIdx Sprite to draw. * @param[in] frame Frame of sprite to draw. * @param[in] x Horizontal position at which to draw sprite. * @param[in] y Vertical position at which to draw sprite. * @param[in] scale Horizontal and vertical scale of text. * @param[in] blend Color to blend with sprite. See @ref DrawColors for more * infomation. * * @throw ::AER_SEQ_BREAK if called outside draw stage. * @throw ::AER_FAILED_LOOKUP if argument `spriteIdx` is an invalid sprite. * @throw ::AER_BAD_VAL if argument `frame` is greater than or equal to the * number of frames in sprite. * * @since 1.4.0 * * @sa AERDrawSpriteAdv */ void AERDrawSprite(int32_t spriteIdx, uint32_t frame, float x, float y, float scale, uint32_t blend); /** * @brief Draw a sprite to the screen. * * If more than one blend color is provided, then the engine will render a * smooth gradient. * * @param[in] spriteIdx Sprite to draw. * @param[in] frame Frame of sprite to draw. * @param[in] left Horizontal offset into sprite to draw in pixels. * @param[in] top Vertical offset into sprite to draw in pixels. * @param[in] width Horizontal component of sprite to draw in pixels. * @param[in] height Vertical component of sprite to draw in pixels. * @param[in] x Horizontal position at which to draw sprite. * @param[in] y Vertical position at which to draw sprite. * @param[in] scaleX Horizontal scale of sprite. * @param[in] scaleY Vertical scale of sprite. * @param[in] angle Sprite offset angle in degrees. * @param[in] blendNW Blend color of northwest corner. See @ref DrawColors for * more infomation. * @param[in] blendNE Blend color of northeast corner. See @ref DrawColors for * more infomation. * @param[in] blendSE Blend color of southeast corner. See @ref DrawColors for * more infomation. * @param[in] blendSW Blend color of southwest corner. See @ref DrawColors for * more infomation. * @param[in] alpha Sprite alpha (transparency). * * @throw ::AER_SEQ_BREAK if called outside draw stage. * @throw ::AER_FAILED_LOOKUP if argument `spriteIdx` is an invalid sprite. * @throw ::AER_BAD_VAL if argument `alpha` is less than `0.0f` or greater * than `1.0f` or if argument `frame` is greater than or equal to the * number of frames in sprite. * * @since 1.4.0 * * @sa AERDrawSprite */ void AERDrawSpriteAdv(int32_t spriteIdx, uint32_t frame, int32_t left, int32_t top, int32_t width, int32_t height, float x, float y, float scaleX, float scaleY, float angle, uint32_t blendNW, uint32_t blendNE, uint32_t blendSE, uint32_t blendSW, float alpha); /** * @brief Draw a line to the screen. * * @param[in] x1 Horizontal position of line start. * @param[in] y1 Vertical position of line start. * @param[in] x2 Horizontal position of line end. * @param[in] y2 Vertical position of line end. * @param[in] color Color of the line. See @ref DrawColors for more * infomation. * * @throw ::AER_SEQ_BREAK if called outside draw stage. * * @since 1.3.0 * * @sa AERDrawLineAdv */ void AERDrawLine(float x1, float y1, float x2, float y2, uint32_t color); /** * @brief Draw a line to the screen. * * If more than one color is provided, then the engine will render a smooth * gradient. * * @param[in] x1 Horizontal position of line start. * @param[in] y1 Vertical position of line start. * @param[in] x2 Horizontal position of line end. * @param[in] y2 Vertical position of line end. * @param[in] width Line width in pixels. * @param[in] color1 Color of the start of the line. See @ref DrawColors for * more infomation. * @param[in] color2 Color of the end of the line. See @ref DrawColors for * more infomation. * * @throw ::AER_SEQ_BREAK if called outside draw stage. * * @since 1.3.0 * * @sa AERDrawLine */ void AERDrawLineAdv(float x1, float y1, float x2, float y2, float width, uint32_t color1, uint32_t color2); /** * @brief Draw an ellipse to the screen. * * @param[in] left X-intercept of the left side of ellipse. * @param[in] top Y-intercept of the top side of ellipse. * @param[in] right X-intercept of the right side of ellipse. * @param[in] bottom Y-intercept of the bottom side of ellipse. * @param[in] color Color of the ellipse. See @ref DrawColors for more * infomation. * @param[in] outline Whether to render a solid ellipse (`false`) or a `1` * pixel wide outline of an ellipse (`true`). * * @throw ::AER_SEQ_BREAK if called outside draw stage. * * @since 1.3.0 * * @sa AERDrawEllipseAdv */ void AERDrawEllipse(float left, float top, float right, float bottom, uint32_t color, bool outline); /** * @brief Draw an ellipse to the screen. * * If more than one color is provided, then the engine will render a smooth * gradient. * * @param[in] left X-intercept of the left side of ellipse. * @param[in] top Y-intercept of the top side of ellipse. * @param[in] right X-intercept of the right side of ellipse. * @param[in] bottom Y-intercept of the bottom side of ellipse. * @param[in] colorCenter Color of the center ellipse. See @ref DrawColors for * more infomation. * @param[in] colorEdge Color of the edge ellipse. See @ref DrawColors for more * infomation. * @param[in] outline Whether to render a solid ellipse (`false`) or a `1` * pixel wide outline of an ellipse (`true`). * * @throw ::AER_SEQ_BREAK if called outside draw stage. * * @since 1.3.0 * * @sa AERDrawEllipse */ void AERDrawEllipseAdv(float left, float top, float right, float bottom, uint32_t colorCenter, uint32_t colorEdge, bool outline); /** * @brief Draw a triangle to the screen. * * @param[in] x1 Horizontal position of first vertex. * @param[in] y1 Vertical position of first vertex. * @param[in] x2 Horizontal position of second vertex. * @param[in] y2 Vertical position of second vertex. * @param[in] x3 Horizontal position of third vertex. * @param[in] y3 Vertical position of third vertex. * @param[in] color Color of the triangle. See @ref DrawColors for more * infomation. * @param[in] outline Whether to render a solid triangle (`false`) or a `1` * pixel wide outline of a triangle (`true`). * * @throw ::AER_SEQ_BREAK if called outside draw stage. * * @since 1.1.0 * * @sa AERDrawTriangleAdv */ void AERDrawTriangle(float x1, float y1, float x2, float y2, float x3, float y3, uint32_t color, bool outline); /** * @brief Draw a triangle to the screen. * * If more than one color is provided, then the engine will render a smooth * gradient. * * @param[in] x1 Horizontal position of first vertex. * @param[in] y1 Vertical position of first vertex. * @param[in] x2 Horizontal position of second vertex. * @param[in] y2 Vertical position of second vertex. * @param[in] x3 Horizontal position of third vertex. * @param[in] y3 Vertical position of third vertex. * @param[in] color1 Color of first vertex. See @ref DrawColors for more * infomation. * @param[in] color2 Color of second vertex. See @ref DrawColors for more * infomation. * @param[in] color3 Color of third vertex. See @ref DrawColors for more * infomation. * @param[in] outline Whether to render a solid triangle (`false`) or a `1` * pixel wide outline of a triangle (`true`). * * @throw ::AER_SEQ_BREAK if called outside draw stage. * * @since 1.1.0 * * @sa AERDrawTriangle */ void AERDrawTriangleAdv(float x1, float y1, float x2, float y2, float x3, float y3, uint32_t color1, uint32_t color2, uint32_t color3, bool outline); /** * @brief Draw a rectangle to the screen. * * @param[in] left X-intercept of the left side of rectangle. * @param[in] top Y-intercept of the top side of rectangle. * @param[in] right X-intercept of the right side of rectangle. * @param[in] bottom Y-intercept of the bottom side of rectangle. * @param[in] color Color of the rectangle. See @ref DrawColors for more * infomation. * @param[in] outline Whether to render a solid rectangle (`false`) or a `1` * pixel wide outline of a rectangle (`true`). * * @throw ::AER_SEQ_BREAK if called outside draw stage. * * @since 1.1.0 * * @sa AERDrawRectangleAdv */ void AERDrawRectangle(float left, float top, float right, float bottom, uint32_t color, bool outline); /** * @brief Draw a rectangle to the screen. * * If more than one color is provided, then the engine will render a smooth * gradient. * * @param[in] left X-intercept of the left side of rectangle. * @param[in] top Y-intercept of the top side of rectangle. * @param[in] right X-intercept of the right side of rectangle. * @param[in] bottom Y-intercept of the bottom side of rectangle. * @param[in] colorNW Color of northwest vertex. See @ref DrawColors for more * infomation. * @param[in] colorNE Color of northeast vertex. See @ref DrawColors for more * infomation. * @param[in] colorSE Color of southeast vertex. See @ref DrawColors for more * infomation. * @param[in] colorSW Color of southwest vertex. See @ref DrawColors for more * infomation. * @param[in] outline Whether to render a solid rectangle (`false`) or a `1` * pixel wide outline of a rectangle (`true`). * * @throw ::AER_SEQ_BREAK if called outside draw stage. * * @since 1.1.0 * * @sa AERDrawRectangle */ void AERDrawRectangleAdv(float left, float top, float right, float bottom, uint32_t colorNW, uint32_t colorNE, uint32_t colorSE, uint32_t colorSW, bool outline); /** * @brief Draw text to the screen. * * See @ref DrawTextEscape for more information about text escape sequences. * * @param[in] text String to draw. Maximum size is 8192 characters including * null terminator (will not cause error if larger). * @param[in] x Horizontal position at which to draw text. * @param[in] y Vertical position at which to draw text. * @param[in] width Maximum line width before line break in pixels (not * characters). * @param[in] scale Horizontal and vertical scale of text. * @param[in] color Color of text. See @ref DrawColors for more * infomation. * * @throw ::AER_SEQ_BREAK if called outside draw stage. * @throw ::AER_NULL_ARG if argument `text` is `NULL`. * * @since 1.1.0 * * @sa AERDrawTextAdv */ void AERDrawText(const char* text, float x, float y, uint32_t width, float scale, uint32_t color); /** * @brief Draw text to the screen. * * If more than one color is provided, then the engine will render a smooth * gradient. * * @subsubsection DrawTextEscape Text Escape Sequences * * The game maker engine chose to use the hashtag ('#') character to represent * linebreaks. To display a literal hashtag, preceed it with a backslash. * * @param[in] text String to draw. Maximum size is 8192 characters including * null terminator (will not cause error if larger). * @param[in] x Horizontal position at which to draw text. * @param[in] y Vertical position at which to draw text. * @param[in] height Space between each line of text in pixels. * @param[in] width Maximum line width before line break in pixels (not * characters). * @param[in] scaleX Horizontal scale of text. * @param[in] scaleY Vertical scale of text. * @param[in] angle Text offset angle in degrees. * @param[in] colorNW Color of northwest corner. See @ref DrawColors for more * infomation. * @param[in] colorNE Color of northeast corner. See @ref DrawColors for more * infomation. * @param[in] colorSE Color of southeast corner. See @ref DrawColors for more * infomation. * @param[in] colorSW Color of southwest corner. See @ref DrawColors for more * infomation. * @param[in] alpha Text alpha (transparency). * * @throw ::AER_SEQ_BREAK if called outside draw stage. * @throw ::AER_NULL_ARG if argument `text` is `NULL`. * @throw ::AER_BAD_VAL if argument `alpha` is less than `0.0f` or greater * than `1.0f`. * * @since 1.1.0 * * @sa AERDrawText */ void AERDrawTextAdv(const char* text, float x, float y, int32_t height, uint32_t width, float scaleX, float scaleY, float angle, uint32_t colorNW, uint32_t colorNE, uint32_t colorSE, uint32_t colorSW, float alpha); #endif /* AER_DRAW_H */
Foxbud/libaermre
src/event.c
/** * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <assert.h> #include <stdbool.h> #include <stddef.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #include "foxutils/arraymacs.h" #include "foxutils/mapmacs.h" #include "aer/event.h" #include "internal/core.h" #include "internal/event.h" #include "internal/hld.h" #include "internal/log.h" #include "internal/mod.h" #include "internal/object.h" /* ----- PRIVATE TYPES ----- */ typedef struct EventTrap { FoxArray modListeners; void (*origListener)(HLDInstance* target, HLDInstance* other); HLDEventType eventType; } EventTrap; typedef struct EventTrapIter { AEREvent base; EventTrap* trap; uint32_t nextIdx; } EventTrapIter; /* ----- PRIVATE GLOBALS ----- */ static HLDNamedFunction eventHandler = {0}; static FoxMap eventTraps = {0}; static FoxMap eventSubscribers = {0}; /* ----- INTERNAL GLOBALS ----- */ EventKey currentEvent = {0}; /* ----- PRIVATE FUNCTIONS ----- */ static void EventTrapInit(EventTrap* trap, HLDEventType eventType, void (*origListener)(HLDInstance*, HLDInstance*)) { assert(trap); assert(origListener); trap->eventType = eventType; trap->origListener = origListener; FoxArrayMInitExt(void*, &trap->modListeners, 2); return; } static void EventTrapDeinit(EventTrap* trap) { assert(trap); trap->eventType = 0; trap->origListener = NULL; FoxArrayMDeinit(void*, &trap->modListeners); return; } static void EventTrapAddListener(EventTrap* trap, void* listener) { assert(trap); *FoxArrayMPush(void*, &trap->modListeners) = listener; return; } static bool EventTrapDeinitCallback(EventTrap* trap, void* ctx) { (void)ctx; EventTrapDeinit(trap); return true; } static bool EventTrapIterNext(EventTrapIter* iter, HLDInstance* target, HLDInstance* other) { assert(iter); assert(target); assert(other); bool result = true; EventTrap* trap = iter->trap; FoxArray* modListeners = &trap->modListeners; if (iter->nextIdx < FoxArrayMSize(ModListener, modListeners)) { bool (*listener)(EventTrapIter*, HLDInstance*, HLDInstance*) = *FoxArrayMIndex(void*, modListeners, iter->nextIdx++); result = listener(iter, target, other); } else { trap->origListener(target, other); } return result; } static void EventTrapIterInit(EventTrapIter* iter, EventTrap* trap) { assert(iter); assert(trap); iter->base.handle = ((bool (*)(AEREvent*, AERInstance*, AERInstance*))EventTrapIterNext); iter->base.next = (AEREvent*)iter; iter->trap = trap; iter->nextIdx = 0; return; } static void EventTrapIterDeinit(EventTrapIter* iter) { assert(iter); iter->base.handle = NULL; iter->base.next = NULL; iter->trap = NULL; iter->nextIdx = 0; return; } static int32_t Int32KeyCompare(const int32_t* keyA, const int32_t* keyB) { return *keyA - *keyB; } static void CommonEventListener(HLDInstance* target, HLDInstance* other) { EventTrap* trap = FoxMapMIndex(EventKey, EventTrap, &eventTraps, currentEvent); assert(trap); EventTrapIter iter; EventTrapIterInit(&iter, trap); /* If draw event, set draw stage. */ CoreStage origStage = stage; if (currentEvent.type == HLD_EVENT_DRAW) stage = STAGE_DRAW; /* Execute listeners and check if event was canceled. */ if (!EventTrapIterNext(&iter, target, other)) { switch (currentEvent.type) { case HLD_EVENT_CREATE: hldfuncs.actionInstanceDestroy(target, other, -1, false); break; /* TODO Figure out how to cancel destruction event. */ default: break; } } stage = origStage; EventTrapIterDeinit(&iter); return; } static void PerformDefaultEvent(HLDInstance* target, HLDInstance* other) { switch (currentEvent.type) { case HLD_EVENT_DRAW: { /* Draw self and do NOT perform parent event. */ if (currentEvent.num == HLD_EVENT_DRAW_NORMAL && HLDSpriteLookup(target->spriteIndex)) hldfuncs.actionDrawSelf(target); break; } default: { /* Perform parent event. */ HLDObject* obj = HLDObjectLookup(currentEvent.objIdx); int32_t parentObjIdx = obj->parentIndex; if (parentObjIdx >= 0 && (uint32_t)parentObjIdx < (*hldvars.objectTableHandle)->numItems) hldfuncs.actionEventPerform(target, other, parentObjIdx, currentEvent.type, currentEvent.num); } } return; } static void RegisterEventSubscriber(EventKey key) { size_t* subCount; HLDEventSubscribers subArr; switch (key.type) { case HLD_EVENT_ALARM: subCount = (*hldvars.alarmEventSubscriberCounts) + key.num; subArr = (*hldvars.alarmEventSubscribers)[key.num]; break; case HLD_EVENT_STEP: subCount = (*hldvars.stepEventSubscriberCounts) + key.num; subArr = (*hldvars.stepEventSubscribers)[key.num]; break; default: LogErr("\"%s\" called with unsupported event type %u.", __func__, key.type); abort(); } if (!FoxMapMIndex(EventKey, uint8_t, &eventSubscribers, key)) { uint32_t arrIdx = (*subCount)++; subArr.objects[arrIdx] = key.objIdx; FoxMapMInsert(EventKey, uint8_t, &eventSubscribers, key); FoxArray* allChildren = ObjectManGetAllChildren(key.objIdx); if (allChildren) { size_t numChildren = FoxArrayMSize(int32_t, allChildren); for (uint32_t childIdx = 0; childIdx < numChildren; childIdx++) { key.objIdx = childIdx; if (!FoxMapMIndex(EventKey, uint8_t, &eventSubscribers, key)) { arrIdx = (*subCount)++; subArr.objects[arrIdx] = key.objIdx; FoxMapMInsert(EventKey, uint8_t, &eventSubscribers, key); } } } } return; } static void MaskEventSubscriptionArray(HLDEventType eventType, size_t numEvents, size_t* subCountsArr, HLDEventSubscribers* subArrs) { size_t numObjs = (*hldvars.objectTableHandle)->numItems; for (uint32_t eventNum = 0; eventNum < numEvents; eventNum++) { size_t oldSubCount = subCountsArr[eventNum]; int32_t* oldSubArr = subArrs[eventNum].objects; int32_t* newSubArr = malloc(numObjs * sizeof(int32_t)); assert(newSubArr); subArrs[eventNum].objects = newSubArr; subCountsArr[eventNum] = 0; for (uint32_t subIdx = 0; subIdx < oldSubCount; subIdx++) { EventKey key = {.type = eventType, .num = eventNum, .objIdx = oldSubArr[subIdx]}; RegisterEventSubscriber(key); } } return; } static void SortEventSubscriptionArray(size_t numEvents, size_t* subCountsArr, HLDEventSubscribers* subArrs) { for (uint32_t eventNum = 0; eventNum < numEvents; eventNum++) { qsort(subArrs[eventNum].objects, subCountsArr[eventNum], sizeof(int32_t), (int (*)(const void*, const void*))Int32KeyCompare); } return; } static HLDArrayPreSize ReallocEventArr(HLDArrayPreSize oldArr, size_t newSize) { HLDArrayPreSize newArr; if (oldArr.size < newSize) { newArr = (HLDArrayPreSize){ .size = newSize, .elements = calloc(newSize, sizeof(HLDEventWrapper*))}; assert(newArr.elements); if (oldArr.size > 0) { memcpy(newArr.elements, oldArr.elements, oldArr.size * sizeof(HLDEventWrapper*)); /* TODO Figure out how to safely free oldArr.elements. */ } } else { newArr = oldArr; } return newArr; } static EventTrap EntrapEvent(HLDObject* obj, HLDEventType eventType, int32_t eventNum) { size_t numObjs = (*hldvars.objectTableHandle)->numItems; HLDArrayPreSize oldArr, newArr; /* Get original event array. */ oldArr = obj->eventListeners[eventType]; /* Get new event array. */ uint32_t numSubEvents; switch (eventType) { case HLD_EVENT_CREATE: case HLD_EVENT_DESTROY: numSubEvents = 1; break; case HLD_EVENT_STEP: numSubEvents = 3; break; case HLD_EVENT_ALARM: numSubEvents = 12; break; case HLD_EVENT_COLLISION: numSubEvents = numObjs; break; case HLD_EVENT_OTHER: /* * We don't yet know the maximum number of other events in this * version of the engine, so we're using 128 as a presumably safe * upper bound until we learn the true maximum. */ numSubEvents = 128; break; case HLD_EVENT_DRAW: /* * We don't yet know the maximum number of draw events in this * version of the engine, so we're using 128 as a presumably safe * upper bound until we learn the true maximum. */ numSubEvents = 128; break; default: LogErr("\"%s\" called with unsupported event type %u.", __func__, eventType); abort(); } newArr = ReallocEventArr(oldArr, numSubEvents); /* Update object with new event array. */ obj->eventListeners[eventType] = newArr; /* Get wrapper, event and handler. */ HLDEventWrapper* wrapper = ((HLDEventWrapper**)newArr.elements)[eventNum]; HLDEvent* event; HLDNamedFunction* oldHandler; if (wrapper) { event = wrapper->event; oldHandler = event->handler; event->handler = &eventHandler; } else { oldHandler = NULL; event = HLDEventNew(&eventHandler); wrapper = HLDEventWrapperNew(event); ((HLDEventWrapper**)newArr.elements)[eventNum] = wrapper; } /* Create event trap. */ EventTrap trap; EventTrapInit( &trap, eventType, (oldHandler) ? ((void (*)(HLDInstance*, HLDInstance*))oldHandler->function) : (PerformDefaultEvent)); return trap; } /* ----- INTERNAL FUNCTIONS ----- */ void EventManRegisterEventListener(HLDObject* obj, EventKey key, bool (*listener)(AEREvent*, AERInstance*, AERInstance*)) { /* Register subscription if subscribable event. */ switch (key.type) { case HLD_EVENT_ALARM: case HLD_EVENT_STEP: RegisterEventSubscriber(key); break; default: break; } EventTrap* trap = FoxMapMIndex(EventKey, EventTrap, &eventTraps, key); if (!trap) { trap = FoxMapMInsert(EventKey, EventTrap, &eventTraps, key); *trap = EntrapEvent(obj, key.type, key.num); } EventTrapAddListener(trap, listener); return; } void EventManMaskSubscriptionArrays(void) { MaskEventSubscriptionArray(HLD_EVENT_ALARM, 12, *hldvars.alarmEventSubscriberCounts, *hldvars.alarmEventSubscribers); MaskEventSubscriptionArray(HLD_EVENT_STEP, 3, *hldvars.stepEventSubscriberCounts, *hldvars.stepEventSubscribers); return; } void EventManSortSubscriptionArrays(void) { SortEventSubscriptionArray(12, *hldvars.alarmEventSubscriberCounts, *hldvars.alarmEventSubscribers); SortEventSubscriptionArray(3, *hldvars.stepEventSubscriberCounts, *hldvars.stepEventSubscribers); return; } void EventManConstructor(void) { LogInfo("Initializing event module..."); eventHandler = (HLDNamedFunction){.name = "AEREventHandler", .function = CommonEventListener}; FoxMapMInit(EventKey, EventTrap, &eventTraps); FoxMapMInit(EventKey, uint8_t, &eventSubscribers); LogInfo("Done initializing event module."); return; } void EventManDestructor(void) { LogInfo("Deinitializing event module..."); for (uint32_t idx = 0; idx < 12; idx++) { HLDEventSubscribers* subArr = *hldvars.alarmEventSubscribers + idx; if (subArr->objects) { free(subArr->objects); subArr->objects = NULL; } } for (uint32_t idx = 0; idx < 3; idx++) { HLDEventSubscribers* subArr = *hldvars.stepEventSubscribers + idx; if (subArr->objects) { free(subArr->objects); subArr->objects = NULL; } } FoxMapMDeinit(EventKey, uint8_t, &eventSubscribers); eventSubscribers = (FoxMap){0}; FoxMapMForEachElement(EventKey, EventTrap, &eventTraps, EventTrapDeinitCallback, NULL); FoxMapMDeinit(EventKey, EventTrap, &eventTraps); eventTraps = (FoxMap){0}; eventHandler = (HLDNamedFunction){0}; LogInfo("Done deinitializing event module."); return; }
Foxbud/libaermre
src/log.c
/** * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <assert.h> #include <stdarg.h> #include <stddef.h> #include <stdio.h> #include <time.h> #include "aer/log.h" #include "internal/err.h" #include "internal/export.h" #include "internal/log.h" #include "internal/mod.h" /* ----- PRIVATE MACROS ----- */ #define BuildMsgFromVA(fmt, lastArg) \ ({ \ va_list BuildMsgFromVA_va; \ va_start(BuildMsgFromVA_va, (lastArg)); \ vsnprintf(msgBuf, sizeof(msgBuf), (fmt), BuildMsgFromVA_va); \ va_end(BuildMsgFromVA_va); \ msgBuf; \ }) #define GetCurrentModName() \ ({ \ Mod* GetCurrentModName_mod = ModManGetCurrentMod(); \ GetCurrentModName_mod ? GetCurrentModName_mod->name : "?"; \ }) /* ----- PRIVATE TYPES ----- */ typedef enum LogLevel { LOG_INFO, LOG_WARN, LOG_ERR } LogLevel; /* ----- PRIVATE CONSTANTS ----- */ static const char* MSG_FMT = "[%s][aer][%s] (%s) %s\n"; static const char* LVL_STRS[3] = {"INFO", "WARNING", "ERROR"}; static const char* INTERNAL_MOD_NAME = "mre"; /* ----- PRIVATE GLOBALS ----- */ static char msgBuf[8 * 1024]; /* ----- PRIVATE FUNCTIONS ----- */ static void FmtCurTime(char buf[9]) { assert(buf != NULL); time_t rawtime; time(&rawtime); struct tm* timeinfo = localtime(&rawtime); strftime(buf, 9, "%H:%M:%S", timeinfo); return; } static void Log(FILE* fp, LogLevel logLvl, const char* moduleName, const char* msg) { assert(fp != NULL); assert(logLvl <= LOG_ERR); assert(moduleName != NULL); assert(msg != NULL); /* Get current time. */ char timeBuf[9]; FmtCurTime(timeBuf); /* Print formatted message. */ fprintf(fp, MSG_FMT, timeBuf, moduleName, LVL_STRS[logLvl], msg); return; } /* ----- INTERNAL FUNCTIONS ----- */ void LogInfo(const char* fmt, ...) { assert(fmt); /* Call common log function. */ Log(stdout, LOG_INFO, INTERNAL_MOD_NAME, BuildMsgFromVA(fmt, fmt)); return; } void LogWarn(const char* fmt, ...) { assert(fmt); /* Call common log function. */ Log(stderr, LOG_WARN, INTERNAL_MOD_NAME, BuildMsgFromVA(fmt, fmt)); return; } void LogErr(const char* fmt, ...) { assert(fmt); /* Call common log function. */ Log(stderr, LOG_ERR, INTERNAL_MOD_NAME, BuildMsgFromVA(fmt, fmt)); return; } /* ----- PUBLIC FUNCTIONS ----- */ AER_EXPORT void AERLogInfo(const char* fmt, ...) { #define errRet EnsureArg(fmt); /* Call common log function. */ Log(stdout, LOG_INFO, GetCurrentModName(), BuildMsgFromVA(fmt, fmt)); Ok(); #undef errRet } AER_EXPORT void AERLogWarn(const char* fmt, ...) { #define errRet EnsureArg(fmt); /* Call common log function. */ Log(stdout, LOG_WARN, GetCurrentModName(), BuildMsgFromVA(fmt, fmt)); Ok(); #undef errRet } AER_EXPORT void AERLogErr(const char* fmt, ...) { #define errRet EnsureArg(fmt); /* Call common log function. */ Log(stdout, LOG_ERR, GetCurrentModName(), BuildMsgFromVA(fmt, fmt)); Ok(); #undef errRet }
Foxbud/libaermre
include/private/internal/err.h
/** * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef INTERNAL_ERR_H #define INTERNAL_ERR_H #include <stdlib.h> #include "aer/err.h" #include "internal/core.h" #include "internal/log.h" #include "internal/mod.h" #include "internal/option.h" /* ----- INTERNAL MACROS ----- */ #define Ok(...) \ do { \ aererr = AER_OK; \ return __VA_ARGS__; \ } while (0) #define Ensure(cond, err) \ do { \ if (!(cond)) { \ if (aererr != AER_TRY) { \ Mod* Ensure_mod = ModManGetCurrentMod(); \ if (Ensure_mod) { \ LogWarn( \ "Potentially unhandled error \"%s\" occurred " \ "during call to " \ "function \"%s\" by mod \"%s\".", \ #err, __func__, Ensure_mod->name); \ } else { \ LogWarn( \ "Potentially unhandled error \"%s\" occurred " \ "during internal " \ "call to function \"%s\".", \ #err, __func__); \ } \ if (opts.promoteUnhandledErrors) { \ LogErr("Promoting potentially unhandled error."); \ abort(); \ } \ } \ aererr = (err); \ return errRet; \ } \ } while (0) #define EnsureArg(arg) Ensure((arg), AER_NULL_ARG) #define EnsureArgBuf(buf, size) Ensure(((buf) || (size) == 0), AER_NULL_ARG) #define EnsureLookup(item) Ensure((item), AER_FAILED_LOOKUP) #define EnsureMin(val, min) Ensure(((val) >= (typeof(val))(min)), AER_BAD_VAL) #define EnsureMinExc(val, min) Ensure(((val) > (typeof(val))(min)), AER_BAD_VAL) #define EnsureMax(val, max) Ensure(((val) <= (typeof(val))(max)), AER_BAD_VAL) #define EnsureMaxExc(val, max) Ensure(((val) < (typeof(val))(max)), AER_BAD_VAL) #define EnsureRange(val, min, max) \ do { \ typeof(val) EnsureRange_val = (val); \ Ensure((EnsureRange_val >= (typeof(val))(min) && \ EnsureRange_val <= (typeof(val))(max)), \ AER_BAD_VAL); \ } while (0) #define EnsureRangeExc(val, min, max) \ do { \ typeof(val) EnsureRangeExc_val = (val); \ Ensure((EnsureRangeExc_val > (typeof(val))(min) && \ EnsureRangeExc_val < (typeof(val))(max)), \ AER_BAD_VAL); \ } while (0) #define EnsureProba(val) EnsureRange((val), 0.0f, 1.0f) #define EnsureStage(curStage) Ensure((stage >= (curStage)), AER_SEQ_BREAK) #define EnsureStageStrict(curStage) Ensure((stage == (curStage)), AER_SEQ_BREAK) #define EnsureStagePast(pastStage) Ensure((stage > (pastStage)), AER_SEQ_BREAK) #endif /* INTERNAL_ERR_H */
Foxbud/libaermre
src/hld.c
<reponame>Foxbud/libaermre<gh_stars>1-10 /** * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <assert.h> #include <stdlib.h> #include "internal/hld.h" #include "internal/log.h" /* ----- PRIVATE MACROS ----- */ #define CheckVar(var) \ do { \ if (!(var)) { \ LogErr("Engine variable failed consistency check \"%s\".", #var); \ abort(); \ } \ } while (0) /* ----- INTERNAL GLOBALS ----- */ HLDVariables hldvars = {0}; HLDFunctions hldfuncs = {0}; /* ----- INTERNAL FUNCTIONS ----- */ HLDView* HLDViewLookup(uint32_t viewIdx) { HLDView* result = NULL; if (viewIdx < 8) result = (*hldvars.roomCurrent)->views[viewIdx]; return result; } HLDSprite* HLDSpriteLookup(int32_t spriteIdx) { HLDSprite* result = NULL; if (spriteIdx >= 0 && (uint32_t)spriteIdx < hldvars.spriteTable->size) result = ((HLDSprite**)hldvars.spriteTable->elements)[spriteIdx]; return result; } HLDFont* HLDFontLookup(int32_t fontIdx) { HLDFont* result = NULL; if (fontIdx >= 0 && (uint32_t)fontIdx < hldvars.fontTable->size) result = ((HLDFont**)hldvars.fontTable->elements)[fontIdx]; return result; } HLDRoom* HLDRoomLookup(int32_t roomIdx) { HLDRoom* result = NULL; if (roomIdx >= 0 && (uint32_t)roomIdx < hldvars.roomTable->size) result = ((HLDRoom**)hldvars.roomTable->elements)[roomIdx]; return result; } void* HLDOpenHashTableLookup(HLDOpenHashTable* table, int32_t key) { assert(table != NULL); void* result = NULL; if (key >= 0) { uint32_t idx = key & table->keyMask; HLDOpenHashItem* item = table->slots[idx].first; while (item) { if (item->key == key) { result = item->value; break; } else { item = item->next; } } } return result; } void* HLDClosedHashTableLookup(HLDClosedHashTable* table, int32_t key) { assert(table != NULL); void* result = NULL; uint32_t keyMask = table->keyMask; if (key >= 0) { uint32_t origIdx = key & keyMask; uint32_t idx = origIdx; HLDClosedHashSlot* slot = table->slots + idx; while (slot->value) { if (slot->key == key) { result = slot->value; break; } else { idx = (idx + 1) & keyMask; if (idx == origIdx) break; slot = table->slots + idx; } } } return result; } HLDEvent* HLDEventNew(HLDNamedFunction* handler) { assert(handler); HLDEvent* event = malloc(sizeof(HLDEvent)); assert(event); event->classDef = hldvars.eventClass; event->eventNext = NULL; event->field_8 = 1; event->field_C = 1; event->field_10 = hldvars.unknownEventAddress; event->field_14 = 0; event->field_18 = 0; event->field_1C = 0; event->field_20 = 0; event->field_24 = 0; event->field_28 = 0; event->field_2C = 0; event->field_30 = 0; event->field_34 = 0; event->field_38 = 0; event->field_3C = 0; event->field_40 = 0; event->field_44 = 0; event->field_48 = 0; event->field_4C = 0; event->field_50 = 0; event->field_54 = 0; event->field_58 = hldvars.unknownEventAddress; event->name = handler->name; event->handlerIndex = 0; event->handler = handler; event->field_68 = 0; event->field_6C = 0; event->field_70 = 0; event->field_74 = 0; event->field_78 = 0; event->field_7C = 0x11; return event; } HLDEventWrapper* HLDEventWrapperNew(HLDEvent* event) { assert(event); HLDEventWrapper* wrapper = malloc(sizeof(HLDEventWrapper)); assert(wrapper); wrapper->classDef = hldvars.eventWrapperClass; wrapper->event = event; wrapper->field_08 = hldvars.unknownEventAddress; wrapper->field_0C = 0x81; return wrapper; } void HLDRecordEngineRefs(HLDVariables* vars, HLDFunctions* funcs) { LogInfo("Checking engine variables..."); CheckVar(vars->numSteps); CheckVar(vars->keysPressedTable); CheckVar(vars->keysHeldTable); CheckVar(vars->keysReleasedTable); CheckVar(vars->mouseButtonsPressedTable); CheckVar(vars->mouseButtonsHeldTable); CheckVar(vars->mouseButtonsReleasedTable); CheckVar(vars->mousePosX); CheckVar(vars->mousePosY); CheckVar(vars->roomTable); CheckVar(vars->roomTable->elements); CheckVar(vars->roomTable->size == 0x114); CheckVar(vars->roomIndexCurrent); CheckVar(vars->roomCurrent); CheckVar(*vars->roomCurrent); CheckVar(vars->spriteTable); CheckVar(vars->spriteTable->elements); CheckVar(vars->spriteTable->size == 0xd2b); CheckVar(vars->objectTableHandle); CheckVar(*vars->objectTableHandle); CheckVar((*vars->objectTableHandle)->slots); CheckVar((*vars->objectTableHandle)->numItems == 0x1fe); CheckVar((*vars->objectTableHandle)->keyMask == 0x1ff); CheckVar(vars->instanceTable); CheckVar(vars->instanceTable->slots); CheckVar(vars->instanceLocalTable); CheckVar(vars->instanceLocalTable->elements); CheckVar(vars->instanceLocalTable->size == 0xdf4); CheckVar(vars->alarmEventSubscriberCounts); CheckVar(vars->alarmEventSubscribers); CheckVar(vars->stepEventSubscriberCounts); CheckVar(vars->stepEventSubscribers); CheckVar(vars->eventClass); CheckVar(vars->eventWrapperClass); CheckVar(vars->unknownEventAddress); LogInfo("Done checking engine variables."); LogInfo("Recording engine references..."); hldvars = *vars; hldfuncs = *funcs; LogInfo("Done recording engine references..."); return; }
Foxbud/libaermre
src/rand.c
<filename>src/rand.c /** * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <time.h> #include "foxutils/rand.h" #include "foxutils/xoshiro256ss.h" #include "aer/rand.h" #include "internal/err.h" #include "internal/export.h" #include "internal/rand.h" /* ----- PRIVATE GLOBALS ----- */ static FoxXoshiro256SS randPRNG = {0}; /* ----- PRIVATE FUNCTIONS ----- */ static inline void MemSwap(size_t size, uint8_t* restrict bufA, uint8_t* restrict bufB) { for (size_t idx = 0; idx < size; idx++) { /* * Temporary variable method of swapping is technically faster than XOR * swapping in this situation due to memory accesses. */ uint8_t tmp = bufA[idx]; bufA[idx] = bufB[idx]; bufB[idx] = tmp; } return; } static inline void Shuffle(FoxPRNG* prng, size_t elemSize, size_t bufSize, void* elemBuf) { for (size_t idx = bufSize - 1; idx > 0; idx--) { size_t newIdx = FoxRandUIntRange(prng, 0, idx + 1); if (newIdx != idx) { MemSwap(elemSize, elemBuf + elemSize * idx, elemBuf + elemSize * newIdx); } } return; } /* ----- INTERNAL FUNCTIONS ----- */ void RandConstructor(void) { LogInfo("Initializing random module..."); FoxXoshiro256SSInit(&randPRNG, time(NULL)); LogInfo("Done initializing random module."); return; } void RandDestructor(void) { LogInfo("Deinitializing random module..."); FoxXoshiro256SSDeinit(&randPRNG); LogInfo("Done deinitializing random module."); return; } /* ------ PUBLIC FUNCTIONS ----- */ AER_EXPORT uint64_t AERRandUInt(void) { Ok(FoxRandUInt((FoxPRNG*)&randPRNG)); } AER_EXPORT uint64_t AERRandUIntRange(uint64_t min, uint64_t max) { #define errRet 0 EnsureMaxExc(min, max); Ok(FoxRandUIntRange((FoxPRNG*)&randPRNG, min, max)); #undef errRet } AER_EXPORT int64_t AERRandInt(void) { Ok(FoxRandInt((FoxPRNG*)&randPRNG)); } AER_EXPORT int64_t AERRandIntRange(int64_t min, int64_t max) { #define errRet 0 EnsureMaxExc(min, max); Ok(FoxRandIntRange((FoxPRNG*)&randPRNG, min, max)); #undef errRet } AER_EXPORT float AERRandFloat(void) { Ok(FoxRandFloat((FoxPRNG*)&randPRNG)); } AER_EXPORT float AERRandFloatRange(float min, float max) { #define errRet 0.0f EnsureMaxExc(min, max); Ok(FoxRandFloatRange((FoxPRNG*)&randPRNG, min, max)); #undef errRet } AER_EXPORT double AERRandDouble(void) { Ok(FoxRandDouble((FoxPRNG*)&randPRNG)); } AER_EXPORT double AERRandDoubleRange(double min, double max) { #define errRet 0.0 EnsureMaxExc(min, max); Ok(FoxRandDoubleRange((FoxPRNG*)&randPRNG, min, max)); #undef errRet } AER_EXPORT bool AERRandBool(void) { Ok(FoxRandBool((FoxPRNG*)&randPRNG)); } AER_EXPORT void AERRandShuffle(size_t elemSize, size_t bufSize, void* elemBuf) { #define errRet EnsureArg(elemBuf); EnsureMinExc(elemSize, 0); Shuffle((FoxPRNG*)&randPRNG, elemSize, bufSize, elemBuf); Ok(); #undef errRet } AER_EXPORT AERRandGen* AERRandGenNew(uint64_t seed) { Ok(FoxXoshiro256SSNew(seed)); } AER_EXPORT void AERRandGenFree(AERRandGen* gen) { #define errRet EnsureArg(gen); FoxXoshiro256SSFree(gen); Ok(); #undef errRet } AER_EXPORT void AERRandGenSeed(AERRandGen* gen, uint64_t seed) { #define errRet EnsureArg(gen); FoxXoshiro256SSSeed(gen, seed); Ok(); #undef errRet } AER_EXPORT uint64_t AERRandGenUInt(AERRandGen* gen) { #define errRet 0 EnsureArg(gen); Ok(FoxRandUInt((FoxPRNG*)gen)); #undef errRet } AER_EXPORT uint64_t AERRandGenUIntRange(AERRandGen* gen, uint64_t min, uint64_t max) { #define errRet 0 EnsureArg(gen); EnsureMaxExc(min, max); Ok(FoxRandUIntRange((FoxPRNG*)gen, min, max)); #undef errRet } AER_EXPORT int64_t AERRandGenInt(AERRandGen* gen) { #define errRet 0 EnsureArg(gen); Ok(FoxRandFloat((FoxPRNG*)gen)); #undef errRet } AER_EXPORT int64_t AERRandGenIntRange(AERRandGen* gen, int64_t min, int64_t max) { #define errRet 0 EnsureArg(gen); EnsureMaxExc(min, max); Ok(FoxRandIntRange((FoxPRNG*)gen, min, max)); #undef errRet } AER_EXPORT float AERRandGenFloat(AERRandGen* gen) { #define errRet 0.0f EnsureArg(gen); Ok(FoxRandFloat((FoxPRNG*)gen)); #undef errRet } AER_EXPORT float AERRandGenFloatRange(AERRandGen* gen, float min, float max) { #define errRet 0.0f EnsureArg(gen); EnsureMaxExc(min, max); Ok(FoxRandFloatRange((FoxPRNG*)gen, min, max)); #undef errRet } AER_EXPORT double AERRandGenDouble(AERRandGen* gen) { #define errRet 0.0 EnsureArg(gen); Ok(FoxRandDouble((FoxPRNG*)gen)); #undef errRet } AER_EXPORT double AERRandGenDoubleRange(AERRandGen* gen, double min, double max) { #define errRet 0.0 EnsureArg(gen); EnsureMaxExc(min, max); Ok(FoxRandDoubleRange((FoxPRNG*)gen, min, max)); #undef errRet } AER_EXPORT bool AERRandGenBool(AERRandGen* gen) { #define errRet false EnsureArg(gen); Ok(FoxRandBool((FoxPRNG*)gen)); #undef errRet } AER_EXPORT void AERRandGenShuffle(AERRandGen* gen, size_t elemSize, size_t bufSize, void* elemBuf) { #define errRet EnsureArg(gen); EnsureArg(elemBuf); EnsureMinExc(elemSize, 0); Shuffle((FoxPRNG*)gen, elemSize, bufSize, elemBuf); Ok(); #undef errRet }
Foxbud/libaermre
src/instance.c
/** * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <assert.h> #include "foxutils/arraymacs.h" #include "foxutils/mapmacs.h" #include "foxutils/math.h" #include "foxutils/stringmapmacs.h" #include "aer/instance.h" #include "aer/object.h" #include "aer/sprite.h" #include "internal/core.h" #include "internal/err.h" #include "internal/export.h" #include "internal/hld.h" #include "internal/instance.h" #include "internal/log.h" #include "internal/object.h" /* ----- PRIVATE MACROS ----- */ #define ModLocalValDeinit(val) \ do { \ ModLocalVal* ModLocalValDeinit_val = (val); \ void (*destructor)(AERLocal*); \ if ((destructor = ModLocalValDeinit_val->destructor)) \ destructor(&ModLocalValDeinit_val->local); \ } while (0) /* ----- PRIVATE TYPES ----- */ typedef struct __attribute__((packed)) ModLocalKey { int32_t modIdx; int32_t instId; char name[24]; } ModLocalKey; typedef struct ModLocalVal { AERLocal local; void (*destructor)(AERLocal*); } ModLocalVal; /* ----- PRIVATE GLOBALS ----- */ static FoxMap hldLocals = {0}; static FoxMap modLocals = {0}; /* ----- PRIVATE FUNCTIONS ----- */ static bool ModLocalKeyInit(ModLocalKey* key, int32_t instId, const char* name, int32_t modIdx) { assert(key); assert(name); key->modIdx = modIdx; key->instId = instId; char* keyName = key->name; bool endFound = false; char curChar; for (uint32_t idx = 0; idx < sizeof(key->name); idx++) { if (!endFound && (curChar = name[idx]) == '\0') endFound = true; keyName[idx] = (endFound) ? '\0' : curChar; } return endFound; } static bool ModLocalValDeinitCallback(ModLocalVal* val, void* ctx) { (void)ctx; ModLocalValDeinit(val); return true; } static bool ModLocalKeyGetOrphansCallback(const ModLocalKey* key, FoxArray* orphans) { if (!HLDInstanceLookup(key->instId)) *FoxArrayMPush(const ModLocalKey*, orphans) = key; return true; } /* ----- INTERNAL FUNCTIONS ----- */ void InstanceManPruneModLocals(void) { LogInfo("Pruning mod instance locals..."); FoxArray orphans; FoxArrayMInit(const ModLocalKey*, &orphans); FoxMapMForEachKey(ModLocalKey, ModLocalVal, &modLocals, ModLocalKeyGetOrphansCallback, &orphans); size_t numOrphans = FoxArrayMSize(const ModLocalKey*, &orphans); for (uint32_t idx = 0; idx < numOrphans; idx++) { ModLocalVal val = FoxMapMRemove(ModLocalKey, ModLocalVal, &modLocals, *FoxArrayMPop(const ModLocalKey*, &orphans)); ModLocalValDeinit(&val); } FoxArrayMDeinit(const ModLocalKey*, &orphans); LogInfo("Done. Pruned %zu local(s).", numOrphans); return; } void InstanceManRecordHLDLocals(void) { LogInfo("Recording vanilla instance locals..."); size_t numLocals = hldvars.instanceLocalTable->size; const char** names = hldvars.instanceLocalTable->elements; for (uint32_t idx = 0; idx < numLocals; idx++) { *FoxMapMInsert(const char*, int32_t, &hldLocals, names[idx]) = idx + 1; } LogInfo("Done. Recorded %zu local(s).", numLocals); return; } void InstanceManConstructor(void) { LogInfo("Initializing instance module..."); FoxStringMapMInit(int32_t, &hldLocals); FoxMapMInit(ModLocalKey, ModLocalVal, &modLocals); LogInfo("Done initializing instance module."); return; } void InstanceManDestructor(void) { LogInfo("Deinitializing instance module..."); FoxMapMForEachElement(ModLocalKey, ModLocalVal, &modLocals, ModLocalValDeinitCallback, NULL); FoxMapMDeinit(ModLocalKey, ModLocalVal, &modLocals); modLocals = (FoxMap){0}; FoxMapMDeinit(const char*, int32_t, &hldLocals); hldLocals = (FoxMap){0}; LogInfo("Done deinitializing instance module."); return; } /* ----- PUBLIC FUNCTIONS ----- */ AER_EXPORT size_t AERInstanceGetAll(size_t bufSize, AERInstance** instBuf) { #define errRet 0 EnsureStage(STAGE_ACTION); EnsureArgBuf(instBuf, bufSize); HLDRoom* room = *hldvars.roomCurrent; size_t numInsts = room->numInstances; size_t numToWrite = FoxMin(numInsts, bufSize); HLDInstance* inst = room->instanceFirst; for (uint32_t idx = 0; idx < numToWrite; idx++) { instBuf[idx] = (AERInstance*)inst; inst = inst->instanceNext; } Ok(numInsts); #undef errRet } AER_EXPORT size_t AERInstanceGetByObject(int32_t objIdx, bool recursive, size_t bufSize, AERInstance** instBuf) { #define errRet 0 EnsureStage(STAGE_ACTION); EnsureArgBuf(instBuf, bufSize); HLDObject* obj = HLDObjectLookup(objIdx); EnsureLookup(obj); size_t numInsts = obj->numInstances; uint32_t bufIdx = 0; HLDNodeDLL* node = obj->instanceFirst; while (node && bufIdx < bufSize) { instBuf[bufIdx++] = (AERInstance*)node->item; node = node->next; } if (recursive) { FoxArray* children = ObjectManGetAllChildren(objIdx); if (children) { size_t numChildren = FoxArrayMSize(int32_t, children); for (uint32_t idx = 0; idx < numChildren; idx++) { obj = HLDObjectLookup(*FoxArrayMIndex(int32_t, children, idx)); numInsts += obj->numInstances; node = obj->instanceFirst; while (node && bufIdx < bufSize) { instBuf[bufIdx++] = (AERInstance*)node->item; node = node->next; } } } } Ok(numInsts); #undef errRet } AER_EXPORT AERInstance* AERInstanceGetById(int32_t instId) { #define errRet NULL EnsureStage(STAGE_ACTION); AERInstance* inst = (AERInstance*)HLDInstanceLookup(instId); EnsureLookup(inst); Ok(inst); #undef errRet } AER_EXPORT AERInstance* AERInstanceCreate(int32_t objIdx, float x, float y) { #define errRet NULL EnsureStage(STAGE_ACTION); EnsureLookup(HLDObjectLookup(objIdx)); AERInstance* inst = (AERInstance*)hldfuncs.actionInstanceCreate(objIdx, x, y); assert(inst); Ok(inst); #undef errRet } AER_EXPORT void AERInstanceChange(AERInstance* inst, int32_t newObjIdx, bool doEvents) { #define errRet EnsureStage(STAGE_ACTION); EnsureArg(inst); EnsureLookup(HLDObjectLookup(newObjIdx)); hldfuncs.actionInstanceChange((HLDInstance*)inst, newObjIdx, doEvents); Ok(); #undef errRet } AER_EXPORT void AERInstanceDestroy(AERInstance* inst) { #define errRet EnsureStage(STAGE_ACTION); EnsureArg(inst); hldfuncs.actionInstanceDestroy((HLDInstance*)inst, (HLDInstance*)inst, -1, true); Ok(); #undef errRet } AER_EXPORT void AERInstanceDelete(AERInstance* inst) { #define errRet EnsureStage(STAGE_ACTION); EnsureArg(inst); hldfuncs.actionInstanceDestroy((HLDInstance*)inst, (HLDInstance*)inst, -1, false); Ok(); #undef errRet } AER_EXPORT float AERInstanceGetDepth(AERInstance* inst) { #define errRet 0.0f EnsureStage(STAGE_ACTION); EnsureArg(inst); Ok(((HLDInstance*)inst)->depth); #undef errRet } AER_EXPORT void AERInstanceSetDepth(AERInstance* inst, float depth) { #define errRet EnsureStage(STAGE_ACTION); EnsureArg(inst); ((HLDInstance*)inst)->depth = depth; Ok(); #undef errRet } AER_EXPORT void AERInstanceSyncDepth(AERInstance* inst) { #define errRet EnsureStage(STAGE_ACTION); EnsureArg(inst); HLDScriptCallAdv(hldfuncs.Script_Setdepth, (HLDInstance*)inst, (HLDInstance*)inst); Ok(); #undef errRet } AER_EXPORT int32_t AERInstanceGetId(AERInstance* inst) { #define errRet -1 EnsureStage(STAGE_ACTION); EnsureArg(inst); Ok(((HLDInstance*)inst)->id); #undef errRet } AER_EXPORT int32_t AERInstanceGetObject(AERInstance* inst) { #define errRet AER_OBJECT_NULL EnsureStage(STAGE_ACTION); EnsureArg(inst); Ok(((HLDInstance*)inst)->objectIndex); #undef errRet } AER_EXPORT bool AERInstanceGetDeactivated(AERInstance* inst) { #define errRet false EnsureStage(STAGE_ACTION); EnsureArg(inst); Ok(((HLDInstance*)inst)->deactivated); #undef errRet } AER_EXPORT void AERInstanceSetDeactivated(AERInstance* inst, bool deactivated) { #define errRet EnsureStage(STAGE_ACTION); EnsureArg(inst); ((HLDInstance*)inst)->deactivated = deactivated; Ok(); #undef errRet } AER_EXPORT bool AERInstanceGetPersistent(AERInstance* inst) { #define errRet false EnsureStage(STAGE_ACTION); EnsureArg(inst); Ok(((HLDInstance*)inst)->persistent); #undef errRet } AER_EXPORT void AERInstanceSetPersistent(AERInstance* inst, bool persistent) { #define errRet EnsureStage(STAGE_ACTION); EnsureArg(inst); ((HLDInstance*)inst)->persistent = persistent; Ok(); #undef errRet } AER_EXPORT void AERInstanceGetPosition(AERInstance* inst, float* x, float* y) { #define errRet #define inst ((HLDInstance*)inst) EnsureStage(STAGE_ACTION); EnsureArg(inst); EnsureArg(x || y); HLDVecReal pos = inst->pos; if (x) *x = pos.x; if (y) *y = pos.y; Ok(); #undef inst #undef errRet } AER_EXPORT void AERInstanceSetPosition(AERInstance* inst, float x, float y) { #define errRet #define inst ((HLDInstance*)inst) EnsureStage(STAGE_ACTION); EnsureArg(inst); hldfuncs.Instance_setPosition(inst, x, y); Ok(); #undef inst #undef errRet } AER_EXPORT void AERInstanceAddPosition(AERInstance* inst, float x, float y) { #define errRet #define inst ((HLDInstance*)inst) EnsureStage(STAGE_ACTION); EnsureArg(inst); HLDVecReal pos = inst->pos; hldfuncs.Instance_setPosition(inst, pos.x + x, pos.y + y); Ok(); #undef inst #undef errRet } AER_EXPORT void AERInstanceGetBoundingBox(AERInstance* inst, float* left, float* top, float* right, float* bottom) { #define errRet #define inst ((HLDInstance*)inst) EnsureStage(STAGE_ACTION); EnsureArg(inst); EnsureArg(left || top || right || bottom); HLDBoundingBox bbox = inst->bbox; if (left) *left = (float)bbox.left; if (top) *top = (float)bbox.top; if (right) *right = (float)bbox.right; if (bottom) *bottom = (float)bbox.bottom; Ok(); #undef inst #undef errRet } AER_EXPORT float AERInstanceGetFriction(AERInstance* inst) { #define errRet 0.0f EnsureStage(STAGE_ACTION); EnsureArg(inst); Ok(((HLDInstance*)inst)->friction); #undef errRet } AER_EXPORT void AERInstanceSetFriction(AERInstance* inst, float friction) { #define errRet EnsureStage(STAGE_ACTION); EnsureArg(inst); ((HLDInstance*)inst)->friction = friction; Ok(); #undef errRet } AER_EXPORT void AERInstanceGetMotion(AERInstance* inst, float* x, float* y) { #define errRet #define inst ((HLDInstance*)inst) EnsureStage(STAGE_ACTION); EnsureArg(inst); EnsureArg(x || y); if (x) *x = inst->speedX; if (y) *y = inst->speedY; Ok(); #undef inst #undef errRet } AER_EXPORT void AERInstanceSetMotion(AERInstance* inst, float x, float y) { #define errRet #define inst ((HLDInstance*)inst) EnsureStage(STAGE_ACTION); EnsureArg(inst); inst->speedX = x; inst->speedY = y; hldfuncs.Instance_setMotionPolarFromCartesian(inst); Ok(); #undef inst #undef errRet } AER_EXPORT void AERInstanceAddMotion(AERInstance* inst, float x, float y) { #define errRet #define inst ((HLDInstance*)inst) EnsureStage(STAGE_ACTION); EnsureArg(inst); inst->speedX += x; inst->speedY += y; hldfuncs.Instance_setMotionPolarFromCartesian(inst); Ok(); #undef inst #undef errRet } AER_EXPORT int32_t AERInstanceGetMask(AERInstance* inst) { #define errRet AER_SPRITE_NULL EnsureStage(STAGE_ACTION); EnsureArg(inst); Ok(((HLDInstance*)inst)->maskIndex); #undef errRet } AER_EXPORT void AERInstanceSetMask(AERInstance* inst, int32_t maskIdx) { #define errRet EnsureStage(STAGE_ACTION); EnsureArg(inst); EnsureLookup(maskIdx == AER_SPRITE_NULL || HLDSpriteLookup(maskIdx)); hldfuncs.Instance_setMaskIndex((HLDInstance*)inst, maskIdx); Ok(); #undef errRet } AER_EXPORT bool AERInstanceGetVisible(AERInstance* inst) { #define errRet false EnsureStage(STAGE_ACTION); EnsureArg(inst); Ok(((HLDInstance*)inst)->visible); #undef errRet } AER_EXPORT void AERInstanceSetVisible(AERInstance* inst, bool visible) { #define errRet EnsureStage(STAGE_ACTION); EnsureArg(inst); ((HLDInstance*)inst)->visible = visible; Ok(); #undef errRet } AER_EXPORT int32_t AERInstanceGetSprite(AERInstance* inst) { #define errRet AER_SPRITE_NULL EnsureStage(STAGE_ACTION); EnsureArg(inst); Ok(((HLDInstance*)inst)->spriteIndex); #undef errRet } AER_EXPORT void AERInstanceSetSprite(AERInstance* inst, int32_t spriteIdx) { #define errRet EnsureStage(STAGE_ACTION); EnsureArg(inst); EnsureLookup(spriteIdx == AER_SPRITE_NULL || HLDSpriteLookup(spriteIdx)); ((HLDInstance*)inst)->spriteIndex = spriteIdx; Ok(); #undef errRet } AER_EXPORT float AERInstanceGetSpriteFrame(AERInstance* inst) { #define errRet -1.0f EnsureStage(STAGE_ACTION); EnsureArg(inst); Ok(((HLDInstance*)inst)->imageIndex); #undef errRet } AER_EXPORT void AERInstanceSetSpriteFrame(AERInstance* inst, float frame) { #define errRet EnsureStage(STAGE_ACTION); EnsureArg(inst); ((HLDInstance*)inst)->imageIndex = frame; Ok(); #undef errRet } AER_EXPORT float AERInstanceGetSpriteSpeed(AERInstance* inst) { #define errRet -1.0f EnsureStage(STAGE_ACTION); EnsureArg(inst); Ok(((HLDInstance*)inst)->imageSpeed); #undef errRet } AER_EXPORT void AERInstanceSetSpriteSpeed(AERInstance* inst, float speed) { #define errRet EnsureStage(STAGE_ACTION); EnsureArg(inst); EnsureMin(speed, 0.0f); ((HLDInstance*)inst)->imageSpeed = speed; Ok(); #undef errRet } AER_EXPORT float AERInstanceGetSpriteAlpha(AERInstance* inst) { #define errRet -1.0f EnsureStage(STAGE_ACTION); EnsureArg(inst); Ok(((HLDInstance*)inst)->imageAlpha); #undef errRet } AER_EXPORT void AERInstanceSetSpriteAlpha(AERInstance* inst, float alpha) { #define errRet EnsureStage(STAGE_ACTION); EnsureArg(inst); EnsureProba(alpha); ((HLDInstance*)inst)->imageAlpha = alpha; Ok(); #undef errRet } AER_EXPORT float AERInstanceGetSpriteAngle(AERInstance* inst) { #define errRet 0.0f EnsureStage(STAGE_ACTION); EnsureArg(inst); Ok(((HLDInstance*)inst)->imageAngle); #undef errRet } AER_EXPORT void AERInstanceSetSpriteAngle(AERInstance* inst, float angle) { #define errRet EnsureStage(STAGE_ACTION); EnsureArg(inst); ((HLDInstance*)inst)->imageAngle = angle; Ok(); #undef errRet } AER_EXPORT void AERInstanceGetSpriteScale(AERInstance* inst, float* x, float* y) { #define errRet #define inst ((HLDInstance*)inst) EnsureStage(STAGE_ACTION); EnsureArg(inst); EnsureArg(x || y); if (x) *x = inst->imageScale.x; if (y) *y = inst->imageScale.y; Ok(); #undef inst #undef errRet } AER_EXPORT void AERInstanceSetSpriteScale(AERInstance* inst, float x, float y) { #define errRet #define inst ((HLDInstance*)inst) EnsureStage(STAGE_ACTION); EnsureArg(inst); inst->imageScale.x = x; inst->imageScale.y = y; Ok(); #undef inst #undef errRet } AER_EXPORT uint32_t AERInstanceGetSpriteBlend(AERInstance* inst) { #define errRet 0 EnsureStage(STAGE_ACTION); EnsureArg(inst); Ok(((HLDInstance*)inst)->imageBlend); #undef errRet } AER_EXPORT void AERInstanceSetSpriteBlend(AERInstance* inst, uint32_t color) { #define errRet EnsureStage(STAGE_ACTION); EnsureArg(inst); ((HLDInstance*)inst)->imageBlend = color; Ok(); #undef errRet } AER_EXPORT bool AERInstanceGetTangible(AERInstance* inst) { #define errRet false EnsureStage(STAGE_ACTION); EnsureArg(inst); Ok(((HLDInstance*)inst)->tangible); #undef errRet } AER_EXPORT void AERInstanceSetTangible(AERInstance* inst, bool tangible) { #define errRet EnsureStage(STAGE_ACTION); EnsureArg(inst); ((HLDInstance*)inst)->tangible = tangible; Ok(); #undef errRet } AER_EXPORT int32_t AERInstanceGetAlarm(AERInstance* inst, uint32_t alarmIdx) { #define errRet -1 EnsureStage(STAGE_ACTION); EnsureArg(inst); EnsureMax(alarmIdx, 11); Ok(((HLDInstance*)inst)->alarms[alarmIdx]); #undef errRet } AER_EXPORT void AERInstanceSetAlarm(AERInstance* inst, uint32_t alarmIdx, int32_t numSteps) { #define errRet EnsureStage(STAGE_ACTION); EnsureArg(inst); EnsureMax(alarmIdx, 11); ((HLDInstance*)inst)->alarms[alarmIdx] = numSteps; Ok(); #undef errRet } AER_EXPORT size_t AERInstanceGetHLDLocals(AERInstance* inst, size_t bufSize, const char** nameBuf) { #define errRet 0 EnsureStage(STAGE_ACTION); EnsureArg(inst); EnsureArgBuf(nameBuf, bufSize); const char** names = hldvars.instanceLocalTable->elements; HLDClosedHashTable* locals = ((HLDInstance*)inst)->locals; HLDClosedHashSlot* slots = locals->slots; size_t numLocals = locals->numItems; size_t numToWrite = FoxMin(numLocals, bufSize); size_t numSlots = locals->numSlots; uint32_t bufIdx = 0; for (uint32_t slotIdx = 0; slotIdx < numSlots; slotIdx++) { if (bufIdx == numToWrite) break; HLDClosedHashSlot* slot = slots + slotIdx; if (slot->value) { nameBuf[bufIdx++] = names[slot->nameIdx]; } } Ok(numLocals); #undef errRet } AER_EXPORT AERLocal* AERInstanceGetHLDLocal(AERInstance* inst, const char* name) { #define errRet NULL EnsureStage(STAGE_ACTION); EnsureArg(inst); EnsureArg(name); int32_t* localIdx = FoxMapMIndex(const char*, int32_t, &hldLocals, name); EnsureLookup(localIdx); AERLocal* local = HLDClosedHashTableLookup(((HLDInstance*)inst)->locals, *localIdx); EnsureLookup(local); Ok(local); #undef errRet } AER_EXPORT AERLocal* AERInstanceCreateModLocal( AERInstance* inst, const char* name, bool public, void (*destructor)(AERLocal* local)) { #define errRet NULL EnsureStage(STAGE_ACTION); EnsureArg(inst); EnsureArg(name); ModLocalKey key; Ensure(ModLocalKeyInit(&key, ((HLDInstance*)inst)->id, name, public ? MOD_NULL : ModManGetCurrentMod()->idx), AER_BAD_VAL); EnsureLookup(!FoxMapMIndex(ModLocalKey, ModLocalVal, &modLocals, key)); ModLocalVal* val = FoxMapMInsert(ModLocalKey, ModLocalVal, &modLocals, key); val->destructor = destructor; Ok(&val->local); #undef errRet } AER_EXPORT void AERInstanceDestroyModLocal(AERInstance* inst, const char* name, bool public) { #define errRet EnsureStage(STAGE_ACTION); EnsureArg(inst); EnsureArg(name); ModLocalKey key; Ensure(ModLocalKeyInit(&key, ((HLDInstance*)inst)->id, name, public ? MOD_NULL : ModManGetCurrentMod()->idx), AER_BAD_VAL); ModLocalVal* val = FoxMapMIndex(ModLocalKey, ModLocalVal, &modLocals, key); EnsureLookup(val); ModLocalValDeinit(val); FoxMapMRemove(ModLocalKey, ModLocalVal, &modLocals, key); Ok(); #undef errRet } AER_EXPORT AERLocal AERInstanceDeleteModLocal(AERInstance* inst, const char* name, bool public) { #define errRet (AERLocal){0}; EnsureStage(STAGE_ACTION); EnsureArg(inst); EnsureArg(name); ModLocalKey key; Ensure(ModLocalKeyInit(&key, ((HLDInstance*)inst)->id, name, public ? MOD_NULL : ModManGetCurrentMod()->idx), AER_BAD_VAL); EnsureLookup(FoxMapMIndex(ModLocalKey, ModLocalVal, &modLocals, key)); Ok(FoxMapMRemove(ModLocalKey, ModLocalVal, &modLocals, key).local); #undef errRet } AER_EXPORT AERLocal* AERInstanceGetModLocal(AERInstance* inst, const char* name, bool public) { #define errRet NULL EnsureStage(STAGE_ACTION); EnsureArg(inst); EnsureArg(name); ModLocalKey key; Ensure(ModLocalKeyInit(&key, ((HLDInstance*)inst)->id, name, public ? MOD_NULL : ModManGetCurrentMod()->idx), AER_BAD_VAL); ModLocalVal* val = FoxMapMIndex(ModLocalKey, ModLocalVal, &modLocals, key); EnsureLookup(val); Ok(&val->local); #undef errRet }
Foxbud/libaermre
include/public/aer/event.h
<gh_stars>1-10 /** * @file * * @brief Utilities for querying and manipulating object events. * * @since 1.0.0 * * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef AER_EVENT_H #define AER_EVENT_H #include <stdbool.h> #include "aer/instance.h" /* ----- PUBLIC TYPES ----- */ /** * @brief Semi-opaque type for an object event. * * For more information about how to use this object see @ref ObjListeners. * * @since 1.0.0 */ typedef struct AEREvent { /** * @var handle * * @brief Handle the current event. * * This function represents the next event listener attached to the current * object event. * * @param[in] event `next` event context. * @param[in] target Target instance passed to the currently executing * listener. * @param[in] other Other instance passed to the currently executing * listener. * * @return Whether or not the event was handled. * * @since 1.0.0 * * @memberof AEREvent */ bool (*handle)(struct AEREvent* event, AERInstance* target, AERInstance* other); /** * @var next * * @brief Event context for the `handle` event listener. * * @since 1.4.0 * * @memberof AEREvent */ struct AEREvent* next; } AEREvent; #endif /* AER_EVENT_H */
Foxbud/libaermre
src/save.c
/** * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <assert.h> #include <math.h> #include <stdbool.h> #include <stdlib.h> #include <string.h> #include "foxutils/math.h" #include "foxutils/stringmapmacs.h" #include "aer/object.h" #include "aer/save.h" #include "internal/core.h" #include "internal/err.h" #include "internal/export.h" #include "internal/log.h" #include "internal/mod.h" #include "internal/save.h" /* ----- PRIVATE MACROS ----- */ #define HLD_MAIN_MAP_KEY "mod" #define SaveEntryDeinit(entry) \ do { \ SaveEntry* SaveEntryDeinit_entry = (entry); \ if (SaveEntryDeinit_entry->type == SAVE_STRING) \ free(SaveEntryDeinit_entry->value.s); \ *SaveEntryDeinit_entry = (SaveEntry){0}; \ } while (0) #define EnsureType(entry, expType) \ Ensure(((entry)->type == (expType)), AER_FAILED_PARSE); /* ----- PRIVATE TYPES ----- */ typedef enum SaveType { SAVE_NULL, SAVE_DOUBLE, SAVE_STRING } SaveType; typedef struct SaveEntry { SaveType type; union { double d; char* s; } value; } SaveEntry; typedef struct SaveEntryRecordContext { const char* modName; HLDPrimitive hldModMapId; } SaveEntryRecordContext; typedef struct SaveEntryGetKeysContext { const char** const keyBuf; size_t numToWrite; } SaveEntryGetKeysContext; /* ----- PRIVATE GLOBALS ----- */ static FoxMap* modMaps = NULL; /* ----- PRIVATE FUNCTIONS ----- */ static bool SaveEntryDeinitCallback(SaveEntry* entry, void* ctx) { (void)ctx; SaveEntryDeinit(entry); return true; } static bool SaveEntryRecordCallback(const char** key, SaveEntry* entry, SaveEntryRecordContext* ctx) { /* Copy value to HLD primitive. */ HLDPrimitiveMakeUndefined(hldVal); switch (entry->type) { case SAVE_DOUBLE: { /* Copy double value. */ HLDPrimitiveMakeReal(tmpVal, entry->value.d); hldVal = tmpVal; break; } case SAVE_STRING: { /* Copy string value. */ size_t valLen = strlen(entry->value.s); HLDPrimitiveMakeStringH( tmpVal, memcpy(malloc(valLen + 1), entry->value.s, valLen + 1), valLen); hldVal = tmpVal; break; } default: /* Illegal value. */ LogErr( "Encountered illegal SaveEntry type %i while " "saving key \"%s\" of \"%s\" mod's data!", entry->type, *key, ctx->modName); abort(); } /* Insert value into hld sub-map. */ size_t keyLen = strlen(*key); HLDPrimitiveMakeStringH( hldKey, memcpy(malloc(keyLen + 1), *key, keyLen + 1), keyLen); HLDAPICall(hldfuncs.API_dsMapSet, ctx->hldModMapId, hldKey, hldVal); return true; } static bool SaveEntryGetKeysCallback(const char** key, SaveEntryGetKeysContext* ctx) { if (ctx->numToWrite == 0) return false; ctx->keyBuf[--(ctx->numToWrite)] = *key; return true; } static void ResetModMaps(void) { size_t numMods = ModManGetNumMods(); for (uint32_t modIdx = 0; modIdx < numMods; modIdx++) { FoxMap* map = modMaps + modIdx; FoxMapMForEachElement(const char*, SaveEntry, map, SaveEntryDeinitCallback, NULL); FoxMapMDeinit(const char*, SaveEntry, map); FoxStringMapMInit(SaveEntry, map); } return; } /* ----- INTERNAL FUNCTIONS ----- */ int32_t SaveManGetCurrentSlot(void) { /* Get data instance. */ HLDObject* dataObj = HLDObjectLookup(AER_OBJECT_DATA); assert(dataObj->numInstances == 1); HLDInstance* dataInst = dataObj->instanceFirst->item; /* Get save slot local. */ HLDPrimitive* saveSlotLocal = HLDClosedHashTableLookup( dataInst->locals, 0x4a0 /* "currentSaveFileNo" */); assert(saveSlotLocal); return (int32_t)saveSlotLocal->value.r; } void SaveManLoadData(HLDPrimitive* hldDataMapId) { LogInfo("Loading mod data..."); ResetModMaps(); /* Determine whether any mod data to load. */ HLDPrimitiveMakeStringS(hldMainMapKey, HLD_MAIN_MAP_KEY, sizeof(HLD_MAIN_MAP_KEY) - 1); HLDPrimitive hldMainMapId = HLDAPICall(hldfuncs.API_dsMapFindValue, *hldDataMapId, hldMainMapKey); if (hldMainMapId.type == HLD_PRIMITIVE_UNDEFINED) { LogInfo("Skipping because no mod data to load."); return; } assert(hldMainMapId.type == HLD_PRIMITIVE_REAL); /* Update each mod's map. */ size_t numMods = ModManGetNumMods(); size_t numModsWithData = 0; for (uint32_t modIdx = 0; modIdx < numMods; modIdx++) { const char* modName = ModManGetMod(modIdx)->name; HLDPrimitiveMakeStringS(hldModMapKey, modName, strlen(modName)); HLDPrimitive hldModMapId = HLDAPICall(hldfuncs.API_dsMapFindValue, hldMainMapId, hldModMapKey); /* Skip if no mod data. */ if (hldModMapId.type == HLD_PRIMITIVE_UNDEFINED) continue; numModsWithData++; /* Copy entries from HLD map to our map. */ FoxMap* modMap = modMaps + modIdx; HLDOpenHashTable* hldModMap = *((HLDOpenHashTable***) hldvars.maps->elements)[(int32_t)hldModMapId.value.r]; uint32_t entriesLeft = hldModMap->numItems; HLDOpenHashSlot* curSlot = hldModMap->slots; while (entriesLeft > 0) { HLDOpenHashItem* item = (curSlot++)->first; while (item) { struct { HLDPrimitive key; HLDPrimitive value; }* wrapper = item->value; assert(wrapper->key.type == HLD_PRIMITIVE_STRING); const char* entryKey = ((HLDPrimitiveString*)wrapper->key.value.p)->chars; SaveEntry* entry = FoxMapMInsert(const char*, SaveEntry, modMap, entryKey); switch (wrapper->value.type) { case HLD_PRIMITIVE_REAL: /* Copy double value. */ entry->type = SAVE_DOUBLE; entry->value.d = wrapper->value.value.r; break; case HLD_PRIMITIVE_STRING: /* Copy string value. */ entry->type = SAVE_STRING; HLDPrimitiveString* str = wrapper->value.value.p; entry->value.s = memcpy(malloc(str->length + 1), str->chars, str->length + 1); break; default: /* Illegal value. */ LogErr( "Encountered illegal HLDPrimitive type %i while " "loading key \"%s\" of \"%s\" mod's data!", wrapper->value.type, entryKey, modName); abort(); } if (--entriesLeft == 0) break; item = item->next; } } } LogInfo("Done. Loaded data for %zu of %zu mod(s).", numModsWithData, numMods); return; } void SaveManSaveData(HLDPrimitive* hldDataMapId) { LogInfo("Saving mod data..."); /* Determine whether any mod data to save. */ bool isModData = false; size_t numMods = ModManGetNumMods(); for (uint32_t modIdx = 0; modIdx < numMods; modIdx++) { FoxMap* modMap = modMaps + modIdx; if ((isModData = !FoxMapMEmpty(const char*, SaveEntry, modMap))) break; } if (!isModData) { LogInfo("Skipping because no mod data to save."); return; } /* Create main HLD map for holding HLD sub-maps for each mod's data. */ HLDPrimitive hldMainMapId = HLDAPICall(hldfuncs.API_dsMapCreate); HLDPrimitiveMakeStringH(hldMainMapKey, memcpy(malloc(sizeof(HLD_MAIN_MAP_KEY)), HLD_MAIN_MAP_KEY, sizeof(HLD_MAIN_MAP_KEY)), sizeof(HLD_MAIN_MAP_KEY) - 1); HLDAPICall(hldfuncs.API_dsMapAddMap, *hldDataMapId, hldMainMapKey, hldMainMapId); /* Create HLD sub-maps for each mod's data. */ size_t numModsWithData = 0; for (uint32_t modIdx = 0; modIdx < numMods; modIdx++) { FoxMap* modMap = modMaps + modIdx; /* Skip if no mod data. */ if (FoxMapMEmpty(const char*, SaveEntry, modMap)) continue; numModsWithData++; /* Create HLD sub-map. */ HLDPrimitive hldModMapId = HLDAPICall(hldfuncs.API_dsMapCreate); const char* modName = ModManGetMod(modIdx)->name; size_t modNameLen = strlen(modName); HLDPrimitiveMakeStringH( hldModMapKey, memcpy(malloc(modNameLen + 1), modName, modNameLen + 1), modNameLen); HLDAPICall(hldfuncs.API_dsMapAddMap, hldMainMapId, hldModMapKey, hldModMapId); /* Record values to HLD sub-map. */ SaveEntryRecordContext ctx = {.hldModMapId = hldModMapId, .modName = modName}; FoxMapMForEachPair(const char*, SaveEntry, modMap, SaveEntryRecordCallback, &ctx); } LogInfo("Done. Saved data for %zu of %zu mod(s).", numModsWithData, numMods); return; } void SaveManConstructor(void) { LogInfo("Initializing save module..."); size_t numMods = ModManGetNumMods(); modMaps = malloc(numMods * sizeof(FoxMap)); for (uint32_t modIdx = 0; modIdx < numMods; modIdx++) { FoxStringMapMInit(SaveEntry, modMaps + modIdx); } LogInfo("Done initializing save module."); return; } void SaveManDestructor(void) { LogInfo("Deinitializing save module..."); size_t numMods = ModManGetNumMods(); for (uint32_t modIdx = 0; modIdx < numMods; modIdx++) { FoxMap* map = modMaps + modIdx; FoxMapMForEachElement(const char*, SaveEntry, map, SaveEntryDeinitCallback, NULL); FoxMapMDeinit(const char*, SaveEntry, map); } free(modMaps); LogInfo("Done deinitializing save module."); return; } /* ----- PUBLIC FUNCTIONS ----- */ AER_EXPORT int32_t AERSaveGetCurrentSlot(void) { #define errRet -1 EnsureStage(STAGE_ACTION); Ok(SaveManGetCurrentSlot()); #undef errRet } AER_EXPORT size_t AERSaveGetKeys(size_t bufSize, const char** keyBuf) { #define errRet 0 EnsureStage(STAGE_ACTION); EnsureArgBuf(keyBuf, bufSize); /* Get mod map. */ Mod* mod = ModManGetCurrentMod(); assert(mod); FoxMap* modMap = modMaps + mod->idx; /* Write keys to buffer. */ size_t numKeys = FoxMapMSize(const char*, SaveEntry, modMap); SaveEntryGetKeysContext ctx = {.keyBuf = keyBuf, .numToWrite = FoxMin(numKeys, bufSize)}; FoxMapMForEachKey(const char*, SaveEntry, modMap, SaveEntryGetKeysCallback, &ctx); Ok(numKeys); #undef errRet } AER_EXPORT void AERSaveDestroy(const char* key) { #define errRet EnsureStage(STAGE_ACTION); EnsureArg(key); /* Get entry. */ Mod* mod = ModManGetCurrentMod(); assert(mod); FoxMap* modMap = modMaps + mod->idx; SaveEntry* entry = FoxMapMIndex(const char*, SaveEntry, modMap, key); EnsureLookup(entry); /* Destroy entry. */ SaveEntryDeinit(entry); FoxMapMRemove(const char*, SaveEntry, modMap, key); Ok(); #undef errRet } AER_EXPORT double AERSaveGetDouble(const char* key) { #define errRet 0.0 EnsureStage(STAGE_ACTION); EnsureArg(key); /* Get entry. */ Mod* mod = ModManGetCurrentMod(); assert(mod); FoxMap* modMap = modMaps + mod->idx; SaveEntry* entry = FoxMapMIndex(const char*, SaveEntry, modMap, key); EnsureLookup(entry); EnsureType(entry, SAVE_DOUBLE); /* Get entry value. */ Ok(entry->value.d); #undef errRet } AER_EXPORT void AERSaveSetDouble(const char* key, double value) { #define errRet EnsureStage(STAGE_ACTION); EnsureArg(key); Ensure(isfinite(value), AER_BAD_VAL); /* Get entry. */ Mod* mod = ModManGetCurrentMod(); assert(mod); FoxMap* modMap = modMaps + mod->idx; SaveEntry* entry = FoxMapMIndex(const char*, SaveEntry, modMap, key); if (entry) /* Reset entry. */ SaveEntryDeinit(entry); else /* Create entry. */ entry = FoxMapMInsert(const char*, SaveEntry, modMap, key); /* Set entry value. */ entry->type = SAVE_DOUBLE; entry->value.d = value; Ok(); #undef errRet } AER_EXPORT const char* AERSaveGetString(const char* key) { #define errRet NULL EnsureStage(STAGE_ACTION); EnsureArg(key); /* Get entry. */ Mod* mod = ModManGetCurrentMod(); assert(mod); FoxMap* modMap = modMaps + mod->idx; SaveEntry* entry = FoxMapMIndex(const char*, SaveEntry, modMap, key); EnsureLookup(entry); EnsureType(entry, SAVE_STRING); /* Get entry value. */ Ok(entry->value.s); #undef errRet } AER_EXPORT void AERSaveSetString(const char* key, const char* value) { #define errRet EnsureStage(STAGE_ACTION); EnsureArg(key); EnsureArg(value); /* Get entry. */ Mod* mod = ModManGetCurrentMod(); assert(mod); FoxMap* modMap = modMaps + mod->idx; SaveEntry* entry = FoxMapMIndex(const char*, SaveEntry, modMap, key); if (entry) /* Reset entry. */ SaveEntryDeinit(entry); else /* Create entry. */ entry = FoxMapMInsert(const char*, SaveEntry, modMap, key); /* Set entry value. */ entry->type = SAVE_STRING; size_t valSize = strlen(value) + 1; entry->value.s = memcpy(malloc(valSize), value, valSize); Ok(); #undef errRet }
Foxbud/libaermre
include/public/aer/room.h
/** * @file * * @brief Utilities for querying and manipulating game rooms. * * @since 1.0.0 * * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef AER_ROOM_H #define AER_ROOM_H #include <stddef.h> #include <stdint.h> #include "aer/instance.h" /* ----- PUBLIC TYPES ----- */ /** * @brief Vanilla rooms. * * @since 1.0.0 */ typedef enum AERRoomIndex { /** * @brief Flag which represents either no room or an invalid room depending * on context. */ AER_ROOM_NULL = -1, AER_ROOM__INIT = 0x0, AER_ROOM_FOLDER_MENU = 0x1, AER_ROOM_AUTOSAVEMESSAGE = 0x2, AER_ROOM_CONTROLLER = 0x3, AER_ROOM_HEARTMACHINE = 0x4, AER_ROOM_TITLE = 0x5, AER_ROOM_PAX_CHALLENGERESULTS = 0x6, AER_ROOM_THANKYOU = 0x7, AER_ROOM_CREDITS = 0x8, AER_ROOM_EXITGAME = 0x9, AER_ROOM_WIPWARNING = 0xa, AER_ROOM_FOLDER_ENDMENU = 0xb, AER_ROOM_FOLDER_TEST = 0xc, AER_ROOM_GENERAL_TEST = 0xd, AER_ROOM_0BEAUSPLAYGROUND = 0xe, AER_ROOM_0TEDDYSPLAYGROUND = 0xf, AER_ROOM_0AKASHPLAYGROUND = 0x10, AER_ROOM_0ALXSPLAYGROUND = 0x11, AER_ROOM_0CASEYPLAYGROUND = 0x12, AER_ROOM_LISATEST = 0x13, AER_ROOM_BATTLEROOM02 = 0x14, AER_ROOM_HOARDE = 0x15, AER_ROOM_STAGINGAREA02 = 0x16, AER_ROOM_ZCOLUMNRISE = 0x17, AER_ROOM_ENEMYMUSEUM = 0x18, AER_ROOM_FOLDER_ENDTEST = 0x19, AER_ROOM_FOLDER_CHALLENGES = 0x1a, AER_ROOM_____MISC = 0x1b, AER_ROOM_PREGAUNTLETLUSHBIG02 = 0x1c, AER_ROOM_GAUNTLETLOADOUT = 0x1d, AER_ROOM_CH_GAUNTLETOPENING = 0x1e, AER_ROOM_CH_GAUNTLETEND = 0x1f, AER_ROOM_____GAUNTLETOLD = 0x20, AER_ROOM_CH_A_TESTY = 0x21, AER_ROOM_CH_ASLASHDASH = 0x22, AER_ROOM_CH_BDND = 0x23, AER_ROOM_CH_BPUNCHBAGPANIC = 0x24, AER_ROOM_CH_BTBESTLEVEL = 0x25, AER_ROOM_CH_CSHOOTINGGALLERY = 0x26, AER_ROOM_CH_CTESTING = 0x27, AER_ROOM_CH_TRIFLECIRCUS = 0x28, AER_ROOM_CH_TSUPERCRATEBLOX = 0x29, AER_ROOM_GAUNTLETCOLLECTABLE = 0x2a, AER_ROOM_PREGAUNTLETLUSH = 0x2b, AER_ROOM_FOLDER_ENDCHALLENGES = 0x2c, AER_ROOM_FOLDER_INTRO = 0x2d, AER_ROOM_IN_01_BROKENSHALLOWS = 0x2e, AER_ROOM_IN_02_TUTORIAL = 0x2f, AER_ROOM_IN_03_TUT_COMBAT = 0x30, AER_ROOM_IN_HORIZONCLIFF = 0x31, AER_ROOM_IN_HALUCINATIONDEATH = 0x32, AER_ROOM_IN_DRIFTERFIRE = 0x33, AER_ROOM_IN_BLACKWAITROOM = 0x34, AER_ROOM_IN_BACKERTABLET = 0x35, AER_ROOM_____OLD_INTRO = 0x36, AER_ROOM_INL_SECRETS = 0x37, AER_ROOM_LIN_GAPS = 0x38, AER_ROOM_LIN_COMBAT = 0x39, AER_ROOM_FOLDER_ENDINTRO = 0x3a, AER_ROOM_FOLDER_CENTRAL = 0x3b, AER_ROOM_C_DRIFTERWORKSHOP = 0x3c, AER_ROOM_C_CENTRAL = 0x3d, AER_ROOM_C_DREGS_N = 0x3e, AER_ROOM_C_DREGS_S = 0x3f, AER_ROOM_C_DREGS_E = 0x40, AER_ROOM_C_DREGS_W = 0x41, AER_ROOM_C_VEN_APOTH = 0x42, AER_ROOM_C_VEN_DASH = 0x43, AER_ROOM_C_VEN_GUN = 0x44, AER_ROOM_C_VEN_SPEC = 0x45, AER_ROOM_C_VEN_SDOJO = 0x46, AER_ROOM_CARENA = 0x47, AER_ROOM_PAX_STAGING = 0x48, AER_ROOM_PAX_ARENA1 = 0x49, AER_ROOM_PAX_ARENA2 = 0x4a, AER_ROOM_PAX_ARENAE = 0x4b, AER_ROOM_PAX_ARENAW = 0x4c, AER_ROOM_PAX_ARENAALL = 0x4d, AER_ROOM_C_BACKERTABLETX = 0x4e, AER_ROOM_TELEVATORSHAFT = 0x4f, AER_ROOM______OLD = 0x50, AER_ROOM_Z_FOLDER_ENDCENTRAL = 0x51, AER_ROOM_FOLDER_NORTH = 0x52, AER_ROOM_____WINDING_RIDGE = 0x53, AER_ROOM_NL_ENTRANCEPATH = 0x54, AER_ROOM_NX_TITANVISTA = 0x55, AER_ROOM_NX_NORTHHALL = 0x56, AER_ROOM_NL_CAVEVAULT = 0x57, AER_ROOM_NX_AFTERTITAN = 0x58, AER_ROOM_NC_NPCHATCHERY = 0x59, AER_ROOM_NX_SHRINEPATH = 0x5a, AER_ROOM_NL_SHRINEPATH2VAULT = 0x5b, AER_ROOM_NX_CAVE01 = 0x5c, AER_ROOM_NX_SHRINEPATH_2 = 0x5d, AER_ROOM_NX_MOONCOURTYARD = 0x5e, AER_ROOM_NX_TOWERLOCK = 0x5f, AER_ROOM_NC_CLIFFCAMPFIRE = 0x60, AER_ROOM_NL_TOBROKENSHALLOWS = 0x61, AER_ROOM_NX_STAIRS03 = 0x62, AER_ROOM_____WARP_CRUSH = 0x63, AER_ROOM_NL_WARPROOM = 0x64, AER_ROOM_NL_CRUSHWARPHALL = 0x65, AER_ROOM_NL_CRUSHTRANSITION = 0x66, AER_ROOM_NL_CRUSHBACKLOOP = 0x67, AER_ROOM_NC_CRUSHARENA = 0x68, AER_ROOM_____CULT_DROP = 0x69, AER_ROOM_NL_DROPSPIRALOPEN = 0x6a, AER_ROOM_NL_DROPPITS = 0x6b, AER_ROOM_NL_DROPBLOCKCULTFIGHT = 0x6c, AER_ROOM_NL_DROPARENA = 0x6d, AER_ROOM_____RISING_GAP = 0x6e, AER_ROOM_NL_GAPOPENING = 0x6f, AER_ROOM_NX_GAPWIDE = 0x70, AER_ROOM_NL_GAPHALLWAY = 0x71, AER_ROOM_NL_RISINGARENA = 0x72, AER_ROOM_____POPE_CATHEDRAL = 0x73, AER_ROOM_NX_CATHEDRALENTRANCE = 0x74, AER_ROOM_NX_CATHEDRALHALL = 0x75, AER_ROOM_NL_ALTARTHRONE = 0x76, AER_ROOM_NX_SPIRALSTAIRCASE = 0x77, AER_ROOM_NX_LIBRARIANTABLET = 0x78, AER_ROOM_NX_JERKPOPE = 0x79, AER_ROOM_____OLD_NORTH = 0x7a, AER_ROOM_NL_STAIRASCENT = 0x7b, AER_ROOM_NL_CRUSHARENA = 0x7c, AER_ROOM_FOLDER_ENDNORTH = 0x7d, AER_ROOM_FOLDER_SOUTH = 0x7e, AER_ROOM_____SURFACE_SOUTH = 0x7f, AER_ROOM_SX_SOUTHOPENING = 0x80, AER_ROOM_CH_CTEMPLATE = 0x81, AER_ROOM_SX_TOWERSOUTH = 0x82, AER_ROOM_SX_NPC = 0x83, AER_ROOM_S_GAUNTLET_ELEVATOR = 0x84, AER_ROOM_CH_BGUNPILLARS = 0x85, AER_ROOM_CH_BFINAL = 0x86, AER_ROOM_S_GAUNTLETEND = 0x87, AER_ROOM_____LEFT = 0x88, AER_ROOM_CH_BDIRKDEMOLITION = 0x89, AER_ROOM_____LEFT_PATH_1 = 0x8a, AER_ROOM_CH_TABIGONE = 0x8b, AER_ROOM_CH_CGATEBLOCK = 0x8c, AER_ROOM_CH_BMADDASH = 0x8d, AER_ROOM_CH_TLONGESTROAD = 0x8e, AER_ROOM_S_BULLETBAKER = 0x8f, AER_ROOM_CH_CENDHALL = 0x90, AER_ROOM_____LEFT_PATH_2 = 0x91, AER_ROOM_CH_CTURNHALL = 0x92, AER_ROOM_CH_BFPS = 0x93, AER_ROOM_CH_CBIGGGNS = 0x94, AER_ROOM_CH_CSPAWNGROUND = 0x95, AER_ROOM_S_COUNTACULARD = 0x96, AER_ROOM_____RIGHT = 0x97, AER_ROOM_CH_ACORNER = 0x98, AER_ROOM_____RIGHT_PATH_01 = 0x99, AER_ROOM_CH_BDIRKDELUGE = 0x9a, AER_ROOM_CH_BPODS = 0x9b, AER_ROOM_CH_BGUNDIRKDASH = 0x9c, AER_ROOM_S_MARKSCYTHE = 0x9d, AER_ROOM_S_GAUNTLETLINKUP = 0x9e, AER_ROOM_____RIGHT_PATH_02 = 0x9f, AER_ROOM_CH_APILLARBIRD = 0xa0, AER_ROOM_CH_CSPIRAL = 0xa1, AER_ROOM_CH_TBIRDSTANDOFF = 0xa2, AER_ROOM_CH_BLEAPERFALL = 0xa3, AER_ROOM_S_BENNYARROW = 0xa4, AER_ROOM_S_GAUNTLETTITANFINALE = 0xa5, AER_ROOM_____OLD_SOUTH = 0xa6, AER_ROOM_BOSSSOUTH = 0xa7, AER_ROOM_FOLDER_ENDSOUTH = 0xa8, AER_ROOM_FOLDER_EAST = 0xa9, AER_ROOM______INTRO = 0xaa, AER_ROOM_EA_EASTOPENING = 0xab, AER_ROOM_EC_SWORDBRIDGE = 0xac, AER_ROOM_EL_FLAMEELEVATORENTER = 0xad, AER_ROOM_EA_WATERTUNNELLAB = 0xae, AER_ROOM_EC_THEPLAZA = 0xaf, AER_ROOM_EC_NPCDRUGDEN = 0xb0, AER_ROOM_EX_TOWEREAST = 0xb1, AER_ROOM_EB_BOGSTREET = 0xb2, AER_ROOM_EC_PLAZATOLOOP = 0xb3, AER_ROOM______FLAMEDUNGEON = 0xb4, AER_ROOM_EL_MEGAHUGELAB = 0xb5, AER_ROOM_EB_MELTYMASHARENA = 0xb6, AER_ROOM_EB_FLAMEPITLAB = 0xb7, AER_ROOM_EL_FLAMEELEVATOREXIT = 0xb8, AER_ROOM_EB_DEADOTTERWALK = 0xb9, AER_ROOM______SUNKENDOCKS = 0xba, AER_ROOM_EC_PLAZAACCESSLAB = 0xbb, AER_ROOM_EC_DOCKSLAB = 0xbc, AER_ROOM_EX_DOCKSCAMPFIRE = 0xbd, AER_ROOM_EV_DOCKSBRIDGE = 0xbe, AER_ROOM_EL_FROGARENA = 0xbf, AER_ROOM______FROGBOG = 0xc0, AER_ROOM_EC_BIGBOGLAB = 0xc1, AER_ROOM_EA_BOGTEMPLECAMP = 0xc2, AER_ROOM_EA_FROGBOSS = 0xc3, AER_ROOM_EC_TEMPLEISHVAULT = 0xc4, AER_ROOM______LOOPDELOOP = 0xc5, AER_ROOM_EC_EASTLOOP = 0xc6, AER_ROOM_EC_LOOPLAB = 0xc7, AER_ROOM_EB_MELTYLEAPERARENA = 0xc8, AER_ROOM_____OLD_EAST = 0xc9, AER_ROOM_EC_PLAZATODOCKS = 0xca, AER_ROOM_EA_DOCKFIGHTLAB = 0xcb, AER_ROOM_EB_UNDEROTTERBIGRIFLERUMBLE = 0xcc, AER_ROOM_EB_CLEANERSHOLE = 0xcd, AER_ROOM_FOLDER_ENDEAST = 0xce, AER_ROOM_FOLDER_WEST = 0xcf, AER_ROOM_____ENTRANCE = 0xd0, AER_ROOM_WA_ENTRANCE = 0xd1, AER_ROOM_WL_PRISONHALVAULT = 0xd2, AER_ROOM_WA_DEADWOOD = 0xd3, AER_ROOM_WA_DEADWOODS1 = 0xd4, AER_ROOM_WA_GROTTO_BUFFINTRO = 0xd5, AER_ROOM_WC_WINDINGWOOD = 0xd6, AER_ROOM_WC_GROTTONPC = 0xd7, AER_ROOM_WL_NPCTREEHOUSE = 0xd8, AER_ROOM_WC_MINILAB = 0xd9, AER_ROOM_WT_THEWOOD = 0xda, AER_ROOM_WA_ENTSWITCH = 0xdb, AER_ROOM_WC_MEADOWOODCORNER = 0xdc, AER_ROOM_____TREETRE = 0xdd, AER_ROOM_WB_TREETREACHERY = 0xde, AER_ROOM_WL_WESTDRIFTERVAULT = 0xdf, AER_ROOM_____CRYSTAL_LABS = 0xe0, AER_ROOM_WT_SLOWLAB = 0xe1, AER_ROOM_WC_CLIFFSIDECELLSREDUX = 0xe2, AER_ROOM_WC_PRISONHAL = 0xe3, AER_ROOM_____CRYSTAL_LAKE = 0xe4, AER_ROOM_WC_THINFOREST = 0xe5, AER_ROOM_WC_SIMPLEPATH = 0xe6, AER_ROOM_WC_CRYSTALLAKE = 0xe7, AER_ROOM_WC_CRYSTALLAKEVAULT = 0xe8, AER_ROOM_WC_PRISONHALLEND = 0xe9, AER_ROOM_WC_THINFORESTLOW = 0xea, AER_ROOM_WC_THINFORESTLOWSECRET = 0xeb, AER_ROOM_WA_TITANFALLS = 0xec, AER_ROOM_____FOUNDATIONS = 0xed, AER_ROOM_WA_VALE = 0xee, AER_ROOM_WC_BIGMEADOW = 0xef, AER_ROOM_WC_BIGMEADOWVAULT = 0xf0, AER_ROOM_WC_MEADOWCAVECROSSING = 0xf1, AER_ROOM_WB_BIGBATTLE = 0xf2, AER_ROOM_WB_TANUKITROUBLE = 0xf3, AER_ROOM_WC_RUINCLEARING = 0xf4, AER_ROOM_WX_BOSS = 0xf5, AER_ROOM_WA_TOWERENTER = 0xf6, AER_ROOM_WA_MULTIENTRANCELAB = 0xf7, AER_ROOM_WA_CRSYTALDESCENT = 0xf8, AER_ROOM_____OLD_WEST = 0xf9, AER_ROOM_WA_GROTTOX = 0xfa, AER_ROOM_WB_CRYSTALQUEEN = 0xfb, AER_ROOM_WT_PROTOGRID = 0xfc, AER_ROOM_WB_PUZZLEPALACE = 0xfd, AER_ROOM_FOLDER_ENDWEST = 0xfe, AER_ROOM_FOLDER_ABYSS = 0xff, AER_ROOM_A_ELEVATORSHAFTUPPER = 0x100, AER_ROOM_A_ELEVATORSHAFT = 0x101, AER_ROOM_A_PREDOWNWARD = 0x102, AER_ROOM_A_DOWNWARD = 0x103, AER_ROOM_A_DOWNWARDDEAD = 0x104, AER_ROOM_A_DOWNWARDDEADREVISIT = 0x105, AER_ROOM_A_EMBERROOM = 0x106, AER_ROOM_FOLDER_ENDABYSS = 0x107, AER_ROOM_FOLDER_EXTRA = 0x108, AER_ROOM_BOSSRUSH_HUB = 0x109, AER_ROOM_BOSSRUSH_FROGBOSS = 0x10a, AER_ROOM_BOSSRUSH_JERKPOPE = 0x10b, AER_ROOM_BOSSRUSH_GENERAL = 0x10c, AER_ROOM_BOSSRUSH_BULLETBAKER = 0x10d, AER_ROOM_BOSSRUSH_COUNTACULARD = 0x10e, AER_ROOM_BOSSRUSH_MARKSCYTHE = 0x10f, AER_ROOM_BOSSRUSH_BENNYARROW = 0x110, AER_ROOM_BOSSRUSH_EMBER = 0x111, AER_ROOM_BOSSRUSH_FINALSCREEN = 0x112, AER_ROOM_FOLDER_ENDEXTRA = 0x113 } AERRoomIndex; /* ----- PUBLIC FUNCTIONS ----- */ /** * @brief Query the currently active room. * * @return Index of current room or ::AER_ROOM_NULL if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * * @since 1.0.0 */ int32_t AERRoomGetCurrent(void); /** * @brief Change the currently active room to a new one. * * @param[in] roomIdx Index of new room. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_FAILED_LOOKUP if argument `roomIdx` is an invalid room. * * @since 1.0.0 */ void AERRoomGoto(int32_t roomIdx); /** * @brief Query the room with a specific name. * * @param[in] name Name of room. * * @return Room index or ::AER_ROOM_NULL if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_NULL_ARG if argument `name` is `NULL`. * @throw ::AER_FAILED_LOOKUP if no room with name given by argument `name`. * * @since 1.3.0 */ int32_t AERRoomGetByName(const char* name); /** * @brief Query the name of a room. * * @param[in] roomIdx Room of interest. * * @return Name of room or `NULL` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_FAILED_LOOKUP if argument `roomIdx` is an invalid sprite. * * @since 1.3.0 */ const char* AERRoomGetName(int32_t roomIdx); #endif /* AER_ROOM_H */
Foxbud/libaermre
include/public/aer/mod.h
<reponame>Foxbud/libaermre /** * @file * * @brief Defining and initializing mods. * * When the MRE successfully loads a mod library, it first searches for and * calls the mod's public definition function, which must have the signature: * * @code{.c} * void define_mod(AERModDef *def); * @endcode * * In an attempt to accommodate varied naming conventions, this function may * be named any of the following: * - `define_mod` * - `definemod` * - `defineMod` * - `DefineMod` * * @since 1.0.0 * * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef AER_MOD_H #define AER_MOD_H #include <stdbool.h> #include <stdint.h> /* ----- PUBLIC TYPES ----- */ /** * @brief Definition of a mod. * * @warning As new features get added to the framework, this struct may receive * new fields corresponding to those features **without** resulting in a new * major version number. However, field ordering is guaranteed to remain the * same for all releases with the same major version number. To ensure forward * API compatability, only work with pointers to this struct. * * @since 1.0.0 */ typedef struct AERModDef { /** * @var constructor * * @brief Callback function which constructs a mod. * * @note Prefer using this over `__attribute__((constructor))`. * @note May be `NULL` if mod does not need construction. * * @since 1.0.0 * * @memberof AERModDef */ void (*constructor)(void); /** * @var destructor * * @brief Callback function which destructs a mod. * * @note Prefer using this over `__attribute__((destructor))`. * @note May be `NULL` if mod does not need destruction. * * @since 1.0.0 * * @memberof AERModDef */ void (*destructor)(void); /** * @var registerSprites * * @brief Callback function which registers a mod's sprites. * * @note May be `NULL` if mod does not register/replace any sprites. * * @since 1.0.0 * * @sa AERSpriteRegister * @sa AERSpriteReplace * * @memberof AERModDef */ void (*registerSprites)(void); /** * @var registerObjects * * @brief Callback function which registers a mod's objects. * * @note May be `NULL` if mod does not register any objects. * * @since 1.0.0 * * @sa AERObjectRegister * * @memberof AERModDef */ void (*registerObjects)(void); /** * @var registerObjectListeners * * @brief Callback function which registers a mod's object event listeners. * * @note May be `NULL` if mod does not register any object event listeners. * * @since 1.0.0 * * @sa AERObjectAttachCreateListener * @sa AERObjectAttachDestroyListener * @sa AERObjectAttachAlarmListener * @sa AERObjectAttachStepListener * @sa AERObjectAttachPreStepListener * @sa AERObjectAttachPostStepListener * @sa AERObjectAttachCollisionListener * @sa AERObjectAttachAnimationEndListener * @sa AERObjectAttachDrawListener * @sa AERObjectAttachGUIDrawListener * * @memberof AERModDef */ void (*registerObjectListeners)(void); /** * @var gameStepListener * * @brief Mod's game step pseudo-event listener. * * This is effectively the global "tick" function of a mod. If provided, the * MRE will unconditionally call it at the very start of every in-game * step (before any object event listeners are called, including pre-step * listeners). * * This event does not exist in the GameMaker engine; the MRE * provides it as a convenience to mod developers. * * @note May be `NULL`. * * @since 1.0.0 * * @memberof AERModDef */ void (*gameStepListener)(void); /** * @var gamePauseListener * * @brief Mod's game pause pseudo-event listener. * * If provided and the game is paused or unpaused, the MRE will call this * function at the very start of the first step of the new pause state * (immediately before calling gameStepListener). * * This event does not exist in the GameMaker engine; the MRE * provides it as a convenience to mod developers. * * @note May be `NULL`. * * @param[in] paused Whether game was paused (`true`) or unpaused (`false`). * * @since 1.0.0 * * @sa AERGetPaused * * @memberof AERModDef */ void (*gamePauseListener)(bool paused); /** * @var roomChangeListener * * @brief Mod's room change pseudo-event listener. * * If provided and the active game room changes, the MRE will call this * function at the very start of the new room's first step * (immediately before calling gameStepListener). * * This event does not exist in the GameMaker engine; the MRE * provides it as a convenience to mod developers. * * @warning Will **not** be called if active room is reset. * * @note May be `NULL`. * * @param[in] newRoomIdx Index of new (current) room. * @param[in] prevRoomIdx Index of previous room. * * @since 1.0.0 * * @memberof AERModDef */ void (*roomChangeListener)(int32_t newRoomIdx, int32_t prevRoomIdx); /** * @var registerFonts * * @brief Callback function which registers a mod's fonts. * * @note May be `NULL` if mod does not register any fonts. * * @since 1.1.0 * * @sa AERFontRegister * * @memberof AERModDef */ void (*registerFonts)(void); /** * @var gameSaveListener * * @brief Mod's game save pseudo-event listener. * * If provided and the game data gets saved, the MRE will call this function * immediately after the game has finalized its vanilla save data but * immediately before that data has been written to the savefile. * * This means that any calls to the functions in save.h from within this * listener **will** make it into the savefile. However, this also means * that any changes made to vanilla state (i.e. changing the number of * gearbits that the player has) **will not** make it into the savefile. * * @note The functions in save.h can be called from anywhere within a mod, * not just from within this listener. * * @note May be `NULL`. * * @param[in] curSlotIdx Index of save slot to which the game is saving * data. * * @since 1.2.0 * * @sa save.h * * @memberof AERModDef */ void (*gameSaveListener)(int32_t curSlotIdx); /** * @var gameLoadListener * * @brief Mod's game load pseudo-event listener. * * If provided and the game data gets loaded, the MRE will call this * function immediately after the game reads and parses data from the * savefile but immediately before that gets applied to any in-game state. * * This means that any calls to the functions in save.h from within this * listener **will** be saved at the next save point. However, this also * means that any changes made to vanilla state (i.e. changing the number of * gearbits that the player has) **will** be overwritten and **will not** be * saved at the next save point. * * @note The functions in save.h can be called from anywhere within a mod, * not just from within this listener. * * @note May be `NULL`. * * @param[in] curSlotIdx Index of save slot from which the game is loading * data. * * @since 1.2.0 * * @sa save.h * * @memberof AERModDef */ void (*gameLoadListener)(int32_t curSlotIdx); } AERModDef; #endif /* AER_MOD_H */
Foxbud/libaermre
src/font.c
<reponame>Foxbud/libaermre<gh_stars>1-10 /** * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "aer/font.h" #include "internal/core.h" #include "internal/err.h" #include "internal/export.h" #include "internal/hld.h" /* ----- PUBLIC FUNCTIONS ----- */ AER_EXPORT int32_t AERFontGetCurrent(void) { #define errRet AER_FONT_NULL EnsureStagePast(STAGE_FONT_REG); Ok(*hldvars.fontIndexCurrent); #undef errRet } AER_EXPORT void AERFontSetCurrent(int32_t fontIdx) { #define errRet EnsureStagePast(STAGE_FONT_REG); EnsureLookup(HLDFontLookup(fontIdx)); hldfuncs.actionDrawSetFont(fontIdx); Ok(); #undef errRet } AER_EXPORT int32_t AERFontRegister(const char* filename, size_t size, bool bold, bool italic, int32_t first, int32_t last) { #define errRet AER_FONT_NULL EnsureArg(filename); Mod* curMod = ModManGetCurrentMod(); assert(curMod); LogInfo("Registering font \"%s\" for mod \"%s\"...", filename, curMod->name); EnsureStageStrict(STAGE_FONT_REG); int32_t fontIdx = hldfuncs.actionFontAdd(CoreGetAbsAssetPath(curMod->name, filename), size, bold, italic, first, last); Ensure(HLDFontLookup(fontIdx), AER_BAD_FILE); LogInfo("Successfully registered font to index %i.", fontIdx); Ok(fontIdx); #undef errRet } AER_EXPORT size_t AERFontGetNumRegistered(void) { #define errRet 0 EnsureStage(STAGE_FONT_REG); Ok(hldvars.fontTable->size); #undef errRet } AER_EXPORT const char* AERFontGetName(int32_t fontIdx) { #define errRet NULL EnsureStage(STAGE_FONT_REG); HLDFont* font = HLDFontLookup(fontIdx); EnsureLookup(font); Ok(font->fontname); #undef errRet } AER_EXPORT size_t AERFontGetSize(int32_t fontIdx) { #define errRet 0 EnsureStage(STAGE_FONT_REG); HLDFont* font = HLDFontLookup(fontIdx); EnsureLookup(font); Ok(font->size); #undef errRet } AER_EXPORT bool AERFontGetBold(int32_t fontIdx) { #define errRet false EnsureStage(STAGE_FONT_REG); HLDFont* font = HLDFontLookup(fontIdx); EnsureLookup(font); Ok(font->bold); #undef errRet } AER_EXPORT bool AERFontGetItalic(int32_t fontIdx) { #define errRet false EnsureStage(STAGE_FONT_REG); HLDFont* font = HLDFontLookup(fontIdx); EnsureLookup(font); Ok(font->italic); #undef errRet } AER_EXPORT int32_t AERFontGetFirst(int32_t fontIdx) { #define errRet -1 EnsureStage(STAGE_FONT_REG); HLDFont* font = HLDFontLookup(fontIdx); EnsureLookup(font); Ok(font->first); #undef errRet } AER_EXPORT int32_t AERFontGetLast(int32_t fontIdx) { #define errRet -1 EnsureStage(STAGE_FONT_REG); HLDFont* font = HLDFontLookup(fontIdx); EnsureLookup(font); Ok(font->last); #undef errRet }
Foxbud/libaermre
include/public/aer/font.h
/** * @file * * @brief Utilities for querying and manipulating fonts. * * @since 1.1.0 * * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef AER_FONT_H #define AER_FONT_H #include <stdbool.h> #include <stddef.h> #include <stdint.h> /* ----- PUBLIC TYPES ----- */ /** * @brief Vanilla fonts. * * @since 1.1.0 */ typedef enum AERFontIndex { /** * @brief Flag which represents either no font or an invalid font depending * on context. */ AER_FONT_NULL = -1, AER_FONT_ARIAL = 0x0, AER_FONT_UNI = 0x1, AER_FONT_CYR = 0x2, AER_FONT_JP = 0x3, AER_FONT_EDITORSMALL = 0x4, AER_FONT_EDITOR = 0x5, AER_FONT_IMAGINE = 0x6 } AERFontIndex; /* ----- PUBLIC FUNCTIONS ----- */ /** * @brief Query the currently active font. * * @return Index of current font or @ref ::AER_FONT_NULL if unsuccessful. * * @throw ::AER_SEQ_BREAK if called outside action stage. * * @since 1.1.0 */ int32_t AERFontGetCurrent(void); /** * @brief Change the currently active font to a new one. * * @param[in] fontIdx Index of new font. * * @throw ::AER_SEQ_BREAK if called outside action stage. * @throw ::AER_FAILED_LOOKUP if argument `fontIdx` is an invalid font. * * @since 1.1.0 */ void AERFontSetCurrent(int32_t fontIdx); /** * @brief Register a custom font. * * @note This function only supports the *TrueType* font format (`*.ttf`). * * @param[in] filename Path to font file relative to asset directory. * @param[in] size Pixel size of font. * @param[in] bold Whether font is bold. * @param[in] italic Whether font is italic. * @param[in] first Index of first font character to include. * @param[in] last Index of last font character to include. * * @return Index of new font or ::AER_FONT_NULL if unsuccessful. * * @throw ::AER_NULL_ARG if argument `filename` is `NULL`. * @throw ::AER_SEQ_BREAK if called outside font registration stage. * @throw ::AER_BAD_FILE if argument `filename` does not point to valid file. * * @since 1.1.0 */ int32_t AERFontRegister(const char* filename, size_t size, bool bold, bool italic, int32_t first, int32_t last); /** * @brief Query the total number of vanilla and mod fonts registered. * * @return Number of fonts or `0` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called before start of font registration stage. * * @since 1.1.0 */ size_t AERFontGetNumRegistered(void); /** * @brief Query the name of a font. * * @param[in] fontIdx Font of interest. * * @return Name of font or `NULL` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called before start of font registration stage. * @throw ::AER_FAILED_LOOKUP if argument `fontIdx` is an invalid font. * * @since 1.1.0 */ const char* AERFontGetName(int32_t fontIdx); /** * @brief Query the size of a font in pixels. * * @param[in] fontIdx Font of interest. * * @return Pixel size of font or `0` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called before start of font registration stage. * @throw ::AER_FAILED_LOOKUP if argument `fontIdx` is an invalid font. * * @since 1.1.0 */ size_t AERFontGetSize(int32_t fontIdx); /** * @brief Query whether a font is bold. * * @param[in] fontIdx Font of interest. * * @return Whether font is bold or `false` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called before start of font registration stage. * @throw ::AER_FAILED_LOOKUP if argument `fontIdx` is an invalid font. * * @since 1.1.0 */ bool AERFontGetBold(int32_t fontIdx); /** * @brief Query whether a font is italic. * * @param[in] fontIdx Font of interest. * * @return Whether font is italic or `false` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called before start of font registration stage. * @throw ::AER_FAILED_LOOKUP if argument `fontIdx` is an invalid font. * * @since 1.1.0 */ bool AERFontGetItalic(int32_t fontIdx); /** * @brief Query the index of the first character in a font. * * @param[in] fontIdx Font of interest. * * @return Index of first character or `-1` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called before start of font registration stage. * @throw ::AER_FAILED_LOOKUP if argument `fontIdx` is an invalid font. * * @since 1.1.0 */ int32_t AERFontGetFirst(int32_t fontIdx); /** * @brief Query the index of the last character in a font. * * @param[in] fontIdx Font of interest. * * @return Index of last character or `-1` if unsuccessful. * * @throw ::AER_SEQ_BREAK if called before start of font registration stage. * @throw ::AER_FAILED_LOOKUP if argument `fontIdx` is an invalid font. * * @since 1.1.0 */ int32_t AERFontGetLast(int32_t fontIdx); #endif /* AER_FONT_H */