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