X-Git-Url: https://www.kengrimes.com/gitweb/?p=henge%2Fwebcc.git;a=blobdiff_plain;f=src%2Fapc%2Fir-mem.c;fp=src%2Fapc%2Fir.c;h=8b64101b73e755f9e406acc5267a2d1baba1e03a;hp=4a8486f582ca52f0fb089b6f3b4a39c1fc1ff0c6;hb=f0fe047bf6596784aae8c56310f9dec35a09dbec;hpb=243efa00e6ec5b35d76db02d1c2c9240e76d2637 diff --git a/src/apc/ir.c b/src/apc/ir-mem.c similarity index 89% rename from src/apc/ir.c rename to src/apc/ir-mem.c index 4a8486f..8b64101 100644 --- a/src/apc/ir.c +++ b/src/apc/ir-mem.c @@ -3,7 +3,7 @@ #include //uint64_t #include //memmove #include //malloc -#include "ir.h" +#include #define CURR_CDAT (*cdat_stackp) #define CURR_SET set_list[CURR_CDAT->num_sets] @@ -16,7 +16,27 @@ #define PREV_VDAT (vdat_buf[num_vdats-1]) #define CURR_MODEL model_list[CURR_VDAT->num_models] #define CURR_LINK (link_buf[num_links]) +#define CURR_POST (post_buf[num_posts]) +int num_cdats = 0; +int curr_max_cdats = PTRS_IN_PAGE; + +int num_odats = 0; +int curr_max_odats = PTRS_IN_PAGE; + + +int num_vdats = 0; +int curr_max_vdats = PTRS_IN_PAGE; + +int num_refs = 0; +int curr_max_refs = PTRS_IN_PAGE; +uint64_t ss_ref_id = 0x00FFFFFF; /* system space for ref_ids */ + +int num_links = 0; +int curr_max_links = PTRS_IN_PAGE; + +int num_posts = 0; +int curr_max_posts = PTRS_IN_PAGE; void ir_init() @@ -46,6 +66,10 @@ ir_init() /* Init first link */ if( (CURR_LINK = (struct link*) malloc(sizeof(struct link))) == NULL) perror("malloc first link failed"); + + /* Init first post */ + if( (CURR_POST = (struct ref*) malloc(sizeof(struct ref))) == NULL) + perror("malloc first post failed"); } //TODO: FREE MEMORY! @@ -99,6 +123,22 @@ pop_cdat() cdat_stackp--; } +void +inc_posts() +{ + num_posts++; + if(num_posts >= curr_max_posts) + { + if( (realloc((void*) post_buf, PTRS_IN_PAGE * 4)) == NULL) + perror("realloc post_buf failed"); + curr_max_posts += PTRS_IN_PAGE; + } + if( (CURR_POST = (struct ref*) malloc(sizeof (struct ref))) == NULL) + { + perror("malloc post failed"); + } + +} void inc_odat() { @@ -155,7 +195,8 @@ inc_ref() if(num_refs % 16 == 0) { - posts[num_posts++] = *CURR_REF; + CURR_POST = CURR_REF; + inc_posts(); } num_refs++; @@ -344,7 +385,7 @@ insert_ele() } void -insert_framesheets(char direction, char* name, uint64_t ref_id, int height , int width, int num_frames) +insert_framesheet(char direction, char* name, uint64_t ref_id, int height , int width, int num_frames) { CURR_VDAT->CURR_MODEL.spritesheet[(int)direction].height = height; CURR_VDAT->CURR_MODEL.spritesheet[(int)direction].width = width;