예제 #1
0
파일: param.c 프로젝트: doomglue/aleph
const u8* param_unpickle(pnode_t* pnode, const u8* src) {
  u32 val;
  // load idx-
  src = unpickle_32(src, &val);

  // print_dbg("\r\n unpickled param index: ");
  // print_dbg_ulong(val);

  pnode->idx = (u8)val;
  // load value
  
  src = unpickle_32(src, &val);
  pnode->data.value = (ParamValue)val;

  print_dbg(" , val: ");
  print_dbg_ulong(val);
  //  src = unpickle_32(src, &(pnode->data.value.asUint));

  // print_dbg("\r\n unpickled param value: ");
  // print_dbg_ulong(val);

  // load preset-inclusion 
  //  src = unpickle_32(src, &val);

  // print_dbg("\r\n unpickled param preset flag: ");
  // print_dbg_ulong(val);

  //  pnode->preset = (u8)val;
  // load descriptor
  src = pdesc_unpickle(&(pnode->desc), src);
  return src;
}
예제 #2
0
파일: files.c 프로젝트: Someone101/aleph
// search for named .dsc file and load into network param desc memory
extern u8 files_load_desc(const char* name) {
  char path[64] = DSP_PATH;
  void * fp;
  int nparams = -1;
  // word buffer for 4-byte unpickling
  u8 nbuf[4];
  // buffer for binary blob of single descriptor
  u8 dbuf[PARAM_DESC_PICKLE_BYTES];
  // unpacked descriptor
  ParamDesc desc;
  int i;
  u8 ret = 0;

  app_pause();

  strcat(path, name);
  strip_ext(path);
  strcat(path, ".dsc");

  print_dbg("\r\n  opening .dsc file at path: ");
  print_dbg(path);

  fp = fl_fopen(path, "r");
  if(fp == NULL) {
    print_dbg("... error opening .dsc file.");
    print_dbg(path);
    ret = 1;
  } else {

    // get number of parameters
    fake_fread(nbuf, 4, fp);
    unpickle_32(nbuf, (u32*)&nparams); 

    /// loop over params
    if(nparams > 0) {
      net_clear_params();
      //    net->numParams = nparams;

      for(i=0; i<nparams; i++) {
	//  FIXME: a little gross,
	// to be interleaving network and file manipulation like this...
	///....
	// read into desc buffer
	fake_fread(dbuf, PARAM_DESC_PICKLE_BYTES, fp);
	// unpickle directly into network descriptor memory
	pdesc_unpickle( &desc, dbuf );
	// copy descriptor to network and increment count
	net_add_param(i, (const ParamDesc*)(&desc));     
 
      }
    } else {
      print_dbg("\r\n error: crazy parameter count from descriptor file.");
      ret = 1;
    }
  }
  fl_fclose(fp);
  app_resume();
  return ret;
}
예제 #3
0
파일: files.c 프로젝트: bbnickell/aleph
// search for specified dsp file and load it
u8 files_load_dsp_name(const char* name) {
  // don't need .ldr, but we do need .dsc...
  char descname[128];
  u8 nbuf[4];
  // buffer for binary blob of single descriptor
  u8 dbuf[PARAM_DESC_PICKLE_BYTES];
  // unpacked descriptor
  ParamDesc desc;
  u32 nparams;
  u8 ret = 0;
  FILE* fp;
  int i;
  strcpy(descname, workingDir);
  strcat(descname, name);
  strip_ext(descname);
  strcat(descname, ".dsc");

  fp = fopen(descname, "r");
  
  if(fp == NULL) {
    printf("\r\n module descriptor not found; path: %s", descname);
    ret = 1;
    return ret;
  }
  
  // get count of params
  fread(nbuf, 1, 4, fp);
  unpickle_32(nbuf, (u32*)&nparams); 

  /// loop over params
  if(nparams > 0) {
    printf("\r\n loading param descriptor; count: %d", nparams);
    net_clear_params();
    for(i=0; i<nparams; i++) {
      // read into desc buffer
      fread(dbuf, 1, PARAM_DESC_PICKLE_BYTES, fp);
      // unpickle directly into network descriptor memory
      pdesc_unpickle( &desc, dbuf );
      // copy descriptor to network and increment count
      net_add_param(i, (const ParamDesc*)(&desc));     
    }
  } else {
    ret = 1;
  }

  fclose(fp);

  scene_set_module_name(name);
  return ret;
}
예제 #4
0
파일: param.c 프로젝트: Someone101/aleph
const u8* param_unpickle(pnode_t* pnode, const u8* src) {
  u32 val;
  // load idx 
  // TEST: keep as dummy for compatibility
  src = unpickle_32(src, &val);

  // print_dbg("\r\n unpickled param index: ");
  // print_dbg_ulong(val);


  ///// TEST: don't
  //  pnode->idx = (u8)val;
  ////



  // load value  
  src = unpickle_32(src, &val);
  pnode->data.value = (ParamValue)val;

  print_dbg("\r\n unpickling param, val: 0x"); 
  print_dbg_hex(val);

  //  print_dbg(" , val: ");
  //  print_dbg_ulong(val);
  //  src = unpickle_32(src, &(pnode->data.value.asUint));

  // print_dbg("\r\n unpickled param value: ");
  // print_dbg_ulong(val);

  // load play-inclusion 
  src = unpickle_32(src, &val);
  pnode->play = (u8)val;


  print_dbg(" , play: 0x"); 
  print_dbg_hex(val);


  // print_dbg("\r\n unpickled param preset flag: ");
  // print_dbg_ulong(val);

  // load descriptor
  src = pdesc_unpickle(&(pnode->desc), src);
  return src;
}