\r
\r
\r
-/* Dynamically allocate memory for a class data structure, */\r
-/* or cdat, after a class has been identified in a grammar. */\r
-/* We also create a stack of class pointers so that */\r
-/* we can access the cdat during processing of that */\r
-/* cdats sets and elements, a requirement because the */\r
-/* nature of recursive classes prevents us from accessing */\r
-/* the cdat based on the previous index into cdat_buf, */\r
-/* which is a list of all allocated cdats */\r
+\r
/* Cdats: A cdat is a class data structure. Cdats serve as the central */\r
/* data types of the IR. Cdats contain pointers to their subclasses so that the relationship between */\r
/* classes can be determined, but the subclasses are not represented inside */\r
/* incrementing num_classes during parse time. */\r
/* TODO: Should classes point to their parent class? */\r
/* TODO: Talk more about cdat set structure */\r
+\r
struct cdat {\r
struct name name;\r
int idx;\r
};\r
\r
\r
-/* Sets: What is a set? \r
- Instantiation?\r
- Associations? \r
- Containment?\r
- Usage?\r
- The set is populated at parse time AFTER the elements are populated, due to\r
- the nature of bottom up parsing. */\r
struct set {\r
int cdat_idx;\r
int num_sets;\r
struct set* set_list[MAX_SETS];\r
};\r
\r
-/* Refs: Each set/ele has a reference to its object data (odat) through a refid.\r
- refids are unsigned 64 byte integers that map to the hex values RGBA. During\r
- the construction of the directory structure, users can choose a RGBA value for\r
- each object that any other object can refer to via links (see link). If a user\r
- does not choose an RGBA value, then the object is given one from the system space.\r
- We maintain a doubly linked list of refs in the ref_buf at parse time so that\r
- links can be resolved after the parsing of the directory structure is complete.\r
- For every 16th ref, we create a post so that we can reduce on the search time for\r
- a random access. */\r
-\r
struct ref {\r
- int type; //TODO: Is this needed?\r
struct ref* nextref;\r
struct ref* lastref;\r
struct odat* odatp;\r
int refid; //0xFFFFFF->digit\r
};\r
\r
-/* Links: At parse time, a set/ele can include a link in their\r
- grammar representation instead of the actual data and this signifies\r
- to the APC that that set/ele wishes to use the data of another\r
- set/ele, either its video data (vdat) or object data (odat). The link\r
- itself contains the type of link it is, the refid OR name, and\r
- which set/ele created the link. During parse time, links can be made\r
- to o/vdats that have yet to be parsed. In order to accomodate for this,\r
- we resolve all links AFTER parse time by iterating through the link_buf,\r
- finding the refid that was stored for some object (if the refid exists),\r
- and creating a relative pointer from the original object to the data that\r
- was linked */\r
-\r
-/* TODO: Explain links more betta */\r
-\r
struct olink {\r
int src_refid;\r
};\r
};\r
\r
\r
-/* From: src odat ()To: dest odat (refid)*/\r
+/* Links are a mechanism for designers to indicate in the grammar that a odat, vdat, or map \r
+ is defined elsewhere and that the link should be replaced with the specified odat/vdat/map */ \r
struct link {\r
int type; //1 = olink, 2 = vlink, 3 = mlink\r
union link_t link_t;\r
int vdat_idx;\r
struct link* linkp; \r
struct vdat* vdatp;\r
- struct odat* parent_odatp; // odat == set ? null : set refid\r
+ struct odat* parent_odatp; /* null if parent is a cdat */\r
struct ref* refp; /* pointer to it's ref on ref_list */\r
- struct map map; //only valid if odat ismap\r
+ struct map map; /* only valid if odat ismap */\r
\r
};\r
\r
-/* A framesheet is a grouping of animation frames in\r
- a single direction (N,W,S,E) */\r
+/* A framesheet is a grouping of animation frames in a single direction (N,W,S,E, etc.). Framesheets\r
+ also hold the framesheet dimensions and the filepath to the png of the framesheet so the file can be opened\r
+ and the png data can be extracted. */\r
struct framesheet {\r
int width;\r
int height;\r
};\r
\r
/* A model is a collection of framesheets for every\r
- direction (N,W,S,E,NW,NE,SW,SE)*/\r
-/* NAMED spritesheet */\r
+ direction (N,W,S,E,NW,NE,SW,SE). Currently, users can only define\r
+ framesheets in the APC grammar, which are inserted into the current model*/\r
struct model {\r
struct name name;\r
struct framesheet spritesheet[8]; //one for each\r
};\r
\r
-/* Vdat: Vdats are the video data of each object. They can not be\r
- created as a stand alone object (because they consist solely\r
- of animation information and not the map which the\r
- animation manipulates). Vdats have a list of models for every\r
- animation that the vdats odat can do for that vdat*/\r
+/* Vdat: Vdats are the video data of each object. Vdats have a list of models for every\r
+ animation that the vdats odat can do for that vdat. */\r
struct vdat {\r
struct odat* creator; //pointer to odat that made this vdat\r
int num_models;\r
- uint8_t filename[FNAME_MAX];\r
- int height;\r
- int width;\r
- uint8_t filepath[FPATH_MAX];\r
struct model model_list[MAX_MODELS];\r
};\r
\r
+/* An entry on the set_stack that describes the namelist and relevant information for \r
+ the current set that is being processed in the parser. For each set name,\r
+ there is a corresponding set/odat that is created when set names are encountered. */\r
\r
struct set_frame\r
{ struct name namelist[MAX_DEPTH];\r
struct odat* odatp;\r
} ;\r
\r
-\r
-\r
+/* Stores the last defined set at every depth */\r
struct set_stack\r
{ struct set_frame set_frames[MAX_DEPTH];\r
int curr_depth; //used to get most recently created set/odat + to check for undefined parents of namelists\r
int max_dats; //number of dats per chunk for this stack\r
} ocs, vcs, ccs, rcs, lcs, pcs, scs; //odat, vdat, cdat, ref, link, post stacks\r
\r
-\r
-\r
-\r
/* The cdat_stack is a stack pointers to cdat pointers, the top of which is\r
the cdat that is currently being parsed. Whenever a new cdat is recognized\r
by the grammar (CLOPEN), a cdat is pushed onto the cdat_stack, and we refer\r
access to the current cdat so that the elements and sets can populate themselves\r
in the cdat accordingly. */\r
\r
-\r
struct cdat* cdat_stack[MAX_CLASSES];\r
struct cdat** cdat_stackp;\r
\r
+\r
+\r
struct set_stack ss;\r
struct name set_namelist[MAX_DEPTH];\r
int set_numnames = 0;\r
{\r
return CURRENT_VDAT();\r
}\r
-\r
struct set*\r
curr_cdat_set \r
()\r
return CURRENT_SET();\r
}\r
\r
-struct set*\r
-curr_set\r
-()\r
-{ \r
- return CURRENT_SET();\r
-}\r
-\r
struct ref*\r
curr_ref\r
()\r
/* IR.C*/\r
void\r
push_cdat\r
-( name )\r
- struct name* name;\r
+( struct name* name )\r
{\r
struct cdat* curr_cdatp;\r
\r
curr_cdatp->idx = num_cdats;\r
\r
/* Set the cdat as a subclass of the previous cdat */\r
- (*cdat_stackp)->class_list[(*cdat_stackp)->num_classes] = curr_cdatp;\r
+ (*cdat_stackp)->class_list[(*cdat_stackp)->num_classes++] = curr_cdatp;\r
/* Push the cdat onto the cdat_stack */\r
*++cdat_stackp = curr_cdatp;\r
\r
}\r
\r
\r
+\r
void\r
insert_set_name\r
-( name )\r
- struct name* name;\r
+( struct name* name )\r
{ \r
//Push name onto current namelist, set the set_namelist.\r
name_u8_cpy(&set_namelist[set_numnames++], name);\r
\r
- \r
}\r
\r
\r
+/* Called at the last name of a sets namelist. Inserts the set namelist \r
+ onto the set_stack at the appropriate depth i.e. the number of names in\r
+ the namelist. If each name in the namelist at every depth matches, nothing happens. For every\r
+ name on the namelist that doesnt match what is currently on the set_stack,\r
+ a new set/odat is created at the depth that it describes. E.g. a set name\r
+ of A_B_C is a depth of 3 and is represented in the set_stack as A, A_B and A_B_C. \r
+ If a new set namelist is defined, X_Y, the new set_stack will become X, X_Y. */\r
+\r
void\r
insert_set_namelist\r
-( name )\r
- struct name* name;\r
+( struct name* name )\r
{ int depth, nameidx, i;\r
\r
insert_set_name(name);\r
\r
- //Check if entire string matches first? Only possible if namelist is contiguous (uint8_t strings seperated by \0)\r
- //Create odats/sets for each name in namelist where nameidx > ns_depth\r
- //first check if any parts of namelist matches what is currently on namestack\r
- //we can gauruntee that from ns_depth + 1 -> set_numnames namelists dont match. x\r
- \r
-\r
- //if name_list doesnt match, from the first depth at which namelist doesnt match\r
- //remove the nameframes namelist (zero out ones below?) and replace with current namelist,\r
- //then allocate a new odat and set it to the current set_frame.\r
+ \r
for( depth = 0; depth < set_numnames ; depth++ )\r
{ for (nameidx = 0; nameidx <= depth; nameidx++)\r
{ if( name_u8_cmp(&set_namelist[nameidx], &ss.set_frames[depth].namelist[nameidx]) != 0 )\r
\r
ss.set_frames[depth].num_names = set_numnames;\r
ss.curr_depth = depth;\r
+\r
+ /* Every set has a vdat, but some won't be populated because the namelist that instantiated */\r
+ /* the set might not have a SS statement that populates the models of the vdat. This is ok */\r
+ /* because 1) IR is supposed to be bloated so that binary out isnt 2) this functionality */\r
+ /* preserves the assumptions that insert_framesheet() makes when it calls curr_vdat() */\r
+ alloc_vdat();\r
}\r
\r
}\r
\r
}\r
+\r
+ /* Set to 0 to reset for next set_namelist */\r
+ set_numnames = 0;\r
}\r
\r
-/*. We create new odats for each map variant that are children of the current odat/set\r
- , set their name as the map name, and identify them by marking them as a map. This lets\r
- us distinguish between sibling odatsthat have the same name because the map of the parent\r
- odat had the same name as another, regular odat*/\r
+\r
+/* We create new odats for each map variant that are children of the current odat/set\r
+ set their name as the map name, and identify them by marking them as a map. This lets\r
+ us distinguish between sibling odats that have the same name because the map of the parent\r
+ odat had the same name as another, regular odat. */\r
#define CURR_SS_FRAME() (ss.set_frames[ss.curr_depth])\r
#define CURR_SS_SETP() (CURR_SS_FRAME().setp)\r
#define CURR_SS_ODATP() (CURR_SS_FRAME().odatp)\r
void\r
insert_map\r
-( name, direction, height, width, refid, filepath )\r
- struct name* name;\r
- int direction, height, width, refid;\r
- uint8_t* filepath;\r
+( struct name* name, int direction, int height, int width, int refid, uint8_t* filepath )\r
{ int i;\r
- struct odat* curr_mem_odatp; //pointer to odat in odat_buf\r
- struct set* curr_mem_setp; //pointer to set in set_buf\r
+ struct odat* curr_map_odatp; //pointer to odat in odat_buf\r
+ struct set* curr_map_setp; //pointer to set in set_buf\r
struct link* linkp;\r
\r
- curr_mem_odatp = alloc_odat();\r
- curr_mem_setp = alloc_set();\r
- //Create a new odat, make its parent be the set. Make a set for mdat, its name should\r
- //be the name of the odat + name of model. That makes a conflict beween odats that are named\r
- //the same thing as the model of a sibling odat that was created from a map. They can have\r
- //same name if the map odat is marked. So mark the map odat.\r
+ curr_map_odatp = alloc_odat();\r
+ curr_map_setp = alloc_set();\r
+ /* Create a new odat, make its parent be the set. Make a set for mdat, its name should */\r
+ /* be the name of the odat + name of model. That makes a conflict beween odats that are named */\r
+ /* the same thing as the model of a sibling odat that was created from a map. They can have */\r
+ /* same name if the map odat is marked. So mark the map odat. */\r
+\r
+ /* insert parent odat */\r
+ curr_map_odatp->parent_odatp = CURR_SS_ODATP(); \r
\r
- //insert parent odat\r
- curr_mem_odatp->parent_odatp = CURR_SS_ODATP(); \r
- //insert into set_list\r
+ /* insert into set_list */\r
if(CURR_SS_SETP()->num_sets < MAX_SETS)\r
- CURR_SS_SETP()->set_list[CURR_SS_SETP()->num_sets++] = curr_mem_setp;\r
+ CURR_SS_SETP()->set_list[CURR_SS_SETP()->num_sets++] = curr_map_setp;\r
else\r
{ printf("You have allocated to many sets, error in insert_map()\n");\r
//TODO: EXIT()\r
}\r
\r
- //indicate that newly created odat is a map\r
- curr_mem_odatp->ismap = 1;\r
- //set odat and set name\r
- name_u8_cpy(&curr_mem_odatp->name, name);\r
+ /* indicate that newly created odat is a map */\r
+ curr_map_odatp->ismap = 1;\r
+ /* set odat and set name */\r
+ name_u8_cpy(&curr_map_odatp->name, name);\r
\r
/* set cdat idx values for both set and odat */\r
- curr_mem_setp->cdat_idx = num_cdats;\r
+ curr_map_setp->cdat_idx = num_cdats;\r
\r
- /* TODO: INSERT MAP HEIGHT/WIDTH/NAME/FILEPATH INTO ODAT */\r
+ /* Insert map information into the odats map */\r
+ curr_map_odatp->map.height = height;\r
+ curr_map_odatp->map.width = width;\r
+ u8_stpncpy(curr_map_odatp->map.filepath, filepath, FPATH_MAX);\r
\r
\r
/* Generate refid if needed, put into ref_buf */\r
if(!refid)\r
refid = ss_refid++;\r
\r
- insert_ref(curr_mem_odatp, refid);\r
+ insert_ref(curr_map_odatp, refid);\r
\r
/* If current odatp on stack has a link, then we need to make our own link. just set the vdat_idx */\r
if(CURR_SS_ODATP()->vdat_idx == 0)\r
- { //alloc a link\r
- linkp = alloc_link();\r
+ { linkp = alloc_link();\r
linkp->type = CURR_SS_ODATP()->linkp->type;\r
linkp->dest_odatp = CURR_SS_ODATP();\r
linkp->dest_refid = refid;\r
name_u8_cpy(&linkp->link_t.vlink.src_namelist[i], &CURR_SS_ODATP()->linkp->link_t.vlink.src_namelist[i]);\r
}\r
else\r
- curr_mem_odatp->vdat_idx = CURR_SS_ODATP()->vdat_idx;\r
+ curr_map_odatp->vdat_idx = CURR_SS_ODATP()->vdat_idx;\r
\r
- \r
- \r
- \r
}\r
\r
\r
/* 11/22 Each vdat has a multiple models. Each model has 8 framesheets, one in each\r
direction, that create a spritesheet. Inserting framesheets into the correct \r
model is just a matter of checking whether or not the last models name matches\r
-\r
the current one. We can never get a framesheet that is for the same model before \r
AND after some other model, due to alphasorting of the files in each directory */\r
void\r
insert_framesheet\r
-( model_name, direction, height, width, refid, filepath )\r
- struct name* model_name;\r
- int direction, height, width, refid;\r
- uint8_t* filepath;\r
+( struct name* model_name, int direction, int height, int width, int refid, uint8_t* filepath )\r
{ struct vdat* curr_vdatp;\r
struct model* curr_modelp;\r
static struct name last_model_name[32];\r
-\r
\r
curr_vdatp = curr_vdat();\r
\r
if(CURR_SS_ODATP()->refid == 0)\r
{ if(!refid)\r
refid = ss_refid++;\r
- insert_ref(CURR_SS_ODATP(), refid);//given a odatp and a refid, insert the odatp into the ref_buf.\r
- //push ref into ref_buf. \r
+ insert_ref(CURR_SS_ODATP(), refid); /* given a odatp and a refid, insert the odatp into the ref_buf. */\r
} \r
else\r
printf("error: redefining a previously set refid\n");\r
name_u8_cpy(&curr_modelp->name, model_name);\r
curr_modelp->spritesheet[direction].height = height;\r
curr_modelp->spritesheet[direction].width = width;\r
- /* TODO: INSERT FILEPATH INTO VDAT */\r
u8_stpncpy(curr_modelp->spritesheet[direction].filepath, filepath, FPATH_MAX);\r
\r
name_u8_cpy(last_model_name, model_name);\r
-\r
\r
}\r
\r
\r
-\r
-//src_path is stored in link_namelist\r
void\r
insert_mlink\r
-( src_mapname, src_refid)\r
- struct name* src_mapname;\r
- int src_refid;\r
+( struct name* src_mapname, int src_refid)\r
{ struct link* linkp;\r
int i;\r
\r
name_u8_cpy(&linkp->link_t.mlink.src_mapname, src_mapname);\r
/* Set the source ref id of the link */\r
linkp->link_t.mlink.src_refid = src_refid;\r
+ \r
/* Copy the entire namelist of the link, if it exists */\r
- for(i = 0; i < link_numnames; i--) //TODO MAX_DEPTH -> link_namelist_num??\r
+ for(i = 0; i < link_numnames; i--) \r
{ name_u8_cpy(&linkp->link_t.mlink.src_namelist[i], &link_namelist[i]);\r
name_u8_set(&link_namelist[i], (ucs4_t) 0);\r
}\r
\r
}\r
\r
+\r
void\r
insert_link_name\r
-( name )\r
- struct name* name;\r
+( struct name* name )\r
{ \r
//Push name onto current namelist, set the set_namelist.\r
name_u8_cpy(&link_namelist[link_numnames++], name);\r
\r
}\r
\r
+\r
/* Nearly identical to mlink */\r
void\r
insert_vlink\r
-( src_animname, src_refid ) \r
- struct name* src_animname;\r
- int src_refid;\r
+( struct name* src_animname, int src_refid ) \r
{ struct link* linkp;\r
int i;\r
\r
linkp->link_t.mlink.src_refid = src_refid;\r
\r
/* Copy the entire namelist of the link, if it exists */\r
- for(i = 0; i < link_numnames; i++) //TODO MAX_DEPTH -> link_namelist_num??\r
+ for(i = 0; i < link_numnames; i++) \r
{ name_u8_cpy(&linkp->link_t.vlink.src_namelist[i], &link_namelist[i]);\r
name_u8_set(&link_namelist[i], (ucs4_t) 0);//set to null for next link_namelist\r
}\r
+ link_numnames = 0;\r
\r
linkp->dest_odatp = CURR_SS_ODATP();//current odat on set_stack\r
\r
ref_buf could be achieved by iterating until the num_refs anyway. */\r
void\r
insert_ref\r
-( odatp, refid )\r
- struct odat* odatp;\r
- int refid;\r
+( struct odat* odatp, int refid )\r
{ struct ref* curr_refp;\r
struct ref* prev_refp;\r
\r
CURRENT_POST()->refid = refid;\r
CURRENT_POST()->odatp = odatp;\r
}\r
- \r
- \r
- \r
+ \r
}\r
\r
-void\r
-insert_vdat\r
-()\r
-{ struct vdat* curr_vdatp;\r
-\r
- curr_vdatp = curr_vdat();\r
- \r
- curr_vdatp->creator = CURR_SS_ODATP();\r
- CURR_SS_ODATP()->vdat_idx = num_vdats;\r
- CURR_SS_ODATP()->vdatp = curr_vdatp;\r
- alloc_vdat();\r
-}\r
\r
void\r
insert_refid\r
-( refid )\r
- int refid;\r
+( int refid )\r
{ CURR_SS_ODATP()->refid = refid;\r
}\r
-#if 0\r
-\r
-\r
-/* Called in the reduction of a set. While both odats (eles and sets)\r
- have identical label terminals, we are unable to give a single grammatical rule\r
- for both due to how we allocate odats in the odat buf. Due to the\r
- nature of bottom up parsing, the set label is recognized first, and then the\r
- sets elements are recognized. This means that after we have processed the sets elemenets,\r
- the curr_odat is going to be the last element and NOT the set that was first allocated.\r
- To get around this, we create a global variable set_odatp that will store the pointer\r
- to the odat when it is first allocated (in insert_set_label()) so that insert_set() can\r
- have access to it. Curr set points the sets representation in the cdat, curr_set_odatp\r
- points to the sets representation as an odat*/\r
-\r
-//TODO: Add insert_set_ref()\r
-//TODO: Is this the correct allocation scheme? No do the one ken suggested\r
-void\r
-insert_s_name\r
-( struct name* name\r
-)\r
-{\r
-\r
- struct set* curr_setp;\r
-\r
- curr_setp = curr_set();\r
- curr_set_odatp = alloc_odat();\r
\r
- u8_cpy(curr_set_odatp->name, name, 32);\r
- u8_cpy(curr_setp->name, name, 32);\r
- curr_set_odatp->parent_odatp = NULL;\r
- \r
-\r
-}\r
\r
-/* Inserting a olink instead of a set. Set is really just a placeholder\r
- for another set. Allocate the memory for the set so taht it can be populated*/\r
void\r
-insert_set_olink\r
-( int refid\r
-)\r
-{\r
- struct set* curr_setp;\r
-\r
- curr_setp = curr_set();\r
-\r
- curr_setp->refid = refid;\r
-\r
-}\r
-\r
-void\r
-insert_set_vlink\r
-( int refid,\r
- uint8_t* anim_name\r
-)\r
-{\r
- struct cdat* curr_cdatp;\r
- struct odat* curr_odatp;\r
- struct link* curr_linkp;\r
-\r
-\r
- curr_cdatp = curr_cdat();\r
- curr_odatp = curr_odat();\r
- curr_linkp = alloc_link();\r
-\r
- /* Insert vlink into link_stack so that it gets processed at\r
- output time */\r
- curr_linkp->type = 2;\r
- /* Store the target odat information*/\r
- curr_linkp->link_t.vlink.refid = refid;\r
- u8_cpy(curr_linkp->link_t.vlink.anim_name, anim_name, 32);\r
- /* Store the linking odat/cdat information */\r
- curr_linkp->classp = curr_cdatp;\r
- curr_linkp->odatp = curr_odatp;\r
- curr_linkp->set_idx = curr_cdatp->num_sets;\r
- // curr_linkp->ele_idx = -1;\r
-\r
-}\r
-\r
-/* Svlinks dont have animation names */\r
-void\r
-insert_set_svlink\r
-( int refid \r
-)\r
-{\r
- struct cdat* curr_cdatp;\r
- struct link* curr_linkp;\r
-\r
- curr_cdatp = curr_cdat();\r
- curr_linkp = alloc_link();\r
-\r
- /* Insert svlink into link_stack so that it gets processed at\r
- output time */\r
- curr_linkp->type = 3;\r
- curr_linkp->classp = curr_cdatp;\r
- curr_linkp->set_idx = curr_cdatp->num_sets;\r
- // curr_linkp->ele_idx = -1;\r
- curr_linkp->link_t.svlink.refid = refid;\r
-\r
-}\r
-\r
-/* At the point of reducing to a set, most of the\r
- sets odat information has already been populated\r
- during the reduction of its right hand side\r
- non terminals (hitbox, root, quad_list). */\r
-void\r
-insert_set\r
-()\r
-{ int refid;\r
- struct odat* curr_odatp;\r
- struct cdat* curr_cdatp;\r
- struct set* curr_setp;\r
- struct ref* prev_refp;\r
- struct ref* curr_refp;\r
- struct vdat* curr_vdatp;\r
-\r
- curr_odatp = curr_set_odatp; //allocated at insert_set_label\r
- curr_cdatp = curr_cdat();\r
- curr_setp = curr_set();\r
- prev_refp = curr_ref();\r
- curr_refp = alloc_ref();\r
- curr_vdatp = curr_vdat();\r
-\r
- curr_vdatp->creator = curr_set_odatp;\r
-\r
- curr_setp->cdat_idx = curr_cdatp->idx; //does a set need its class idx?\r
- u8_cpy(curr_setp->name, curr_odatp->name, 32);\r
- curr_cdatp->num_sets++;\r
-\r
- curr_odatp->cdat_idx = curr_cdatp->idx;\r
- curr_odatp->refp = curr_refp;\r
-\r
- refid = curr_setp->refid; // refid set by insert_set_label(name, refid)\r
-\r
- curr_refp->refid = refid;\r
- curr_refp->lastref = prev_refp;\r
- curr_refp->odatp = curr_odatp;\r
- prev_refp->nextref = curr_refp;\r
-\r
-\r
-\r
-}\r
-/* Created as a seperate function, instead of setting the ODATS vdat_id and\r
- calling inc_vdat() inside of insert_set(), to account for the set reduction\r
- where a vdat is not created (o/v/svlinks). */\r
-void\r
-insert_set_vdatid\r
+insert_vdat\r
()\r
-{\r
- struct vdat* curr_vdatp;\r
-\r
- curr_vdatp = curr_vdat();\r
-\r
- curr_set_odatp->vdat_id = num_vdats; //no vdat_id for odats that have vlinks/svlinks\r
- curr_set_odatp->vdatp = curr_vdatp;\r
- curr_set_odatp = NULL; //This sets odat shouldnt be modified after populating odats vdat info\r
-}\r
-\r
-/* Populates the odat name and refid for odat, allocate the odat here for the rest of\r
- the functions to use via curr_odat(). */\r
-void\r
-insert_ele_label\r
-( uint8_t* name,\r
- int refid\r
-)\r
-{\r
- struct odat* curr_odatp;\r
-\r
- curr_odatp = alloc_odat();\r
-\r
- u8_cpy(curr_odatp->name, name, 32);\r
- curr_odatp->map[0] = 0;\r
-\r
- if(refid != -1)\r
- curr_odatp->refid = refid;\r
- else\r
- curr_odatp->refid = ss_refid++;\r
-\r
-}\r
-\r
-/* We don't make an odat here, at output time we will resolve\r
- the refid to the corresponding odat. */\r
-void\r
-insert_ele_olink\r
-( int refid\r
-)\r
-{\r
- /* Do nothing because we already know the refid that\r
- the odat needs for this element (in the quad_file) */\r
-}\r
-\r
-void\r
-insert_ele_vlink\r
-( int refid,\r
- uint8_t* anim_name\r
-)\r
-{\r
- struct cdat* curr_cdatp;\r
- struct set* curr_setp;\r
- struct link* curr_linkp;\r
-\r
- curr_cdatp = curr_cdat();\r
- curr_setp = curr_set();\r
- curr_linkp = alloc_link();\r
-\r
- /* Insert vlink into link_stack so that it gets processed at\r
- output time */\r
- curr_linkp->classp = curr_cdatp;\r
- curr_linkp->type = 2;\r
- curr_linkp->set_idx = curr_cdatp->num_sets;\r
- //curr_linkp->ele_idx = curr_setp->num_ele;\r
- curr_linkp->link_t.vlink.refid = refid;\r
- u8_cpy(curr_linkp->link_t.vlink.anim_name, anim_name, 32);\r
-\r
-}\r
-\r
-void\r
-insert_ele_svlink\r
-( int refid\r
-)\r
-{\r
- struct cdat* curr_cdatp;\r
- struct set* curr_setp;\r
- struct link* curr_linkp;\r
-\r
- curr_cdatp = curr_cdat();\r
- curr_setp = curr_set();\r
- curr_linkp = alloc_link();\r
-\r
- curr_linkp->classp = curr_cdatp;\r
- curr_linkp->type = 3;\r
-\r
- //curr_linkp->ele_idx = curr_setp->num_ele;\r
- curr_linkp->link_t.svlink.refid = refid;\r
-\r
-\r
-}\r
-\r
-//Insert element into odat_buf and cdatpages\r
-void\r
-insert_ele()\r
-{\r
- int refid;\r
- struct cdat* curr_cdatp;\r
- struct odat* curr_odatp;\r
- struct vdat* curr_vdatp;\r
- struct set* curr_setp;\r
- struct ele* curr_elep;\r
- struct ref* curr_refp;\r
- struct ref* prev_refp;\r
-\r
+{ struct vdat* curr_vdatp;\r
\r
- curr_odatp = curr_odat(); //malloced @ insert_ele_label\r
curr_vdatp = curr_vdat();\r
- curr_setp = curr_set();\r
- prev_refp = curr_ref();\r
- curr_refp = alloc_ref();\r
-\r
- curr_vdatp->creator = curr_odatp;\r
-\r
- /* Populate odat for ele */\r
- curr_odatp->cdat_idx = curr_cdatp->idx;\r
- curr_odatp->refp = curr_refp;\r
- curr_odatp->parent_odatp = curr_set_odatp;\r
-\r
- refid = curr_odatp->refid;\r
-\r
- curr_refp->refid = refid;\r
- curr_refp->lastref = prev_refp;\r
- curr_refp->odatp = curr_odatp;\r
- prev_refp->nextref = curr_refp;\r
-\r
-}\r
-\r
-void\r
-insert_ele_vdatid\r
-()\r
-{ struct odat* curr_odatp;\r
- curr_odatp = curr_odat();\r
- curr_odatp->vdat_id = num_vdats;\r
-}\r
-\r
-\r
-\r
-#endif\r
-\r
-\r
- \r
-\r
-/* void */\r
-/* insert_quad */\r
-/* ( int x, int y, int z, int refid */\r
-/* ) */\r
-/* { */\r
-/* struct quad* curr_quadp; */\r
-\r
-/* curr_quadp = curr_quad(); */\r
-\r
-/* curr_quadp->x = x; */\r
-/* curr_quadp->y = y; */\r
-/* curr_quadp->z = z; */\r
-/* curr_quadp->refid = refid; */\r
\r
-\r
-\r
-/* } */\r
-\r
-/* /\* serting the hitbox into the set */\r
-/* odat. Elements that don't have */\r
-/* a hitbox will use the sets root. *\/ */\r
-/* void */\r
-/* insert_hitbox */\r
-/* ( int hitbox */\r
-/* ) */\r
-/* { struct odat* curr_odatp; */\r
-\r
-/* curr_odatp = curr_odat(); */\r
-/* curr_odatp->hitbox = hitbox; */\r
-/* } */\r
-\r
-/* /\* Inserting the root into the set */\r
-/* odat. Elements that don't have */\r
-/* a root will use the sets root. *\/ */\r
-/* void */\r
-/* insert_root */\r
-/* ( int x, */\r
-/* int y, */\r
-/* int z */\r
-/* ) */\r
-/* { struct odat* curr_odatp; */\r
-\r
-/* curr_odatp = curr_odat(); */\r
-/* curr_odatp->root.x = x; */\r
-/* curr_odatp->root.y = y; */\r
-/* curr_odatp->root.z = z; */\r
-/* } */\r
-\r
-\r
-\r
-\r
-/* void */\r
-/* insert_frame_pointer */\r
-/* ( uint8_t direction, */\r
-/* void* frame */\r
-/* ) */\r
-/* { struct model* curr_modelp; */\r
-\r
-/* curr_modelp = curr_model(); */\r
-\r
-/* curr_modelp->spritesheet[(int)direction].frames[curr_modelp->spritesheet[(int)direction].num_frames++] = frame; */\r
-/* } */\r
-\r
+ curr_vdatp->creator = CURR_SS_ODATP();\r
+ CURR_SS_ODATP()->vdat_idx = num_vdats;\r
+ CURR_SS_ODATP()->vdatp = curr_vdatp;\r
+ alloc_vdat();\r
+}\r