#ifndef __indirected_h
#define __indirected_h

/* store for indirected text/sprite data for pins */
/* note that the data is in a flex store so it may move around */

#define INDIRECT_FREEC ((char *)-1)
#define INDIRECT_FREEI (-1)

typedef struct {
  int length;       // data length
  unsigned char data[]; // may be text, sprite, whatever
} _indirected;

extern char *indirect_store;

void indirected_init(void);
int indirected_add(void *data,int length); // add to end of the pile
int indirected_add_fromflex(flex_ptr block,int length);

int indirected_update(int offset,void *data,int length);

int indirected_remove(int offset);

/* offset to pointer, with cast */
#define indirected(a,b) (b)(((_indirected *)(indirect_store+((int)(a))))->data)

#endif
