コード例 #1
0
ファイル: calc_82.c プロジェクト: Jonimoose/tilp-libticalcs
static int		recv_backup	(CalcHandle* handle, BackupContent* content)
{
  char varname[9] = { 0 };

  g_snprintf(update_->text, sizeof(update_->text), _("Waiting for backup..."));
  update_label();

  content->model = CALC_TI82;
  strcpy(content->comment, tifiles_comment_set_backup());

  TRYF(ti82_recv_VAR(&(content->data_length1), &content->type, varname));
  content->data_length2 = (uint8_t)varname[0] | ((uint8_t)varname[1] << 8);
  content->data_length3 = (uint8_t)varname[2] | ((uint8_t)varname[3] << 8);
  content->mem_address  = (uint8_t)varname[4] | ((uint8_t)varname[5] << 8);
  TRYF(ti82_send_ACK());

  TRYF(ti82_send_CTS());
  TRYF(ti82_recv_ACK(NULL));

  strcpy(update_->text, "");
  update_label();

  update_->cnt2 = 0;
  update_->max2 = 3;
  update_->pbar();

  content->data_part1 = tifiles_ve_alloc_data(65536);
  TRYF(ti82_recv_XDP(&content->data_length1, content->data_part1));
  TRYF(ti82_send_ACK());
  update_->cnt2++;
  update_->pbar();

  content->data_part2 = tifiles_ve_alloc_data(65536);
  TRYF(ti82_recv_XDP(&content->data_length2, content->data_part2));
  TRYF(ti82_send_ACK());
  update_->cnt2++;
  update_->pbar();

  content->data_part3 = tifiles_ve_alloc_data(65536);
  TRYF(ti82_recv_XDP(&content->data_length3, content->data_part3));
  TRYF(ti82_send_ACK());
  update_->cnt2++;
  update_->pbar();

  content->data_part4 = NULL;

  return 0;
}
コード例 #2
0
ファイル: calc_83.c プロジェクト: debrouxl/tilp-libticalcs
static int		recv_backup	(CalcHandle* handle, BackupContent* content)
{
	char varname[9] = { 0 };
	uint16_t unused;

	content->model = CALC_TI83;
	strcpy(content->comment, tifiles_comment_set_backup());

	TRYF(ti82_send_REQ(handle, 0x0000, TI83_BKUP, ""));
	TRYF(ti82_recv_ACK(handle, &unused));

	TRYF(ti82_recv_VAR(handle, &(content->data_length1), &content->type, varname));
	content->data_length2 = (uint16_t)varname[0] | (((uint16_t)(varname[1])) << 8);
	content->data_length3 = (uint16_t)varname[2] | (((uint16_t)(varname[3])) << 8);
	content->mem_address  = (uint16_t)varname[4] | (((uint16_t)(varname[5])) << 8);
	TRYF(ti82_send_ACK(handle));

	TRYF(ti82_send_CTS(handle));
	TRYF(ti82_recv_ACK(handle, NULL));

	update_->cnt2 = 0;
	update_->max2 = 3;

	content->data_part1 = tifiles_ve_alloc_data(65536);
	TRYF(ti82_recv_XDP(handle, &content->data_length1, content->data_part1));
	TRYF(ti82_send_ACK(handle));
	update_->cnt2++;
	update_->pbar();

	content->data_part2 = tifiles_ve_alloc_data(65536);
	TRYF(ti82_recv_XDP(handle, &content->data_length2, content->data_part2));
	TRYF(ti82_send_ACK(handle));
	update_->cnt2++;
	update_->pbar();

	content->data_part3 = tifiles_ve_alloc_data(65536);
	TRYF(ti82_recv_XDP(handle, &content->data_length3, content->data_part3));
	TRYF(ti82_send_ACK(handle));
	update_->cnt2++;
	update_->pbar();

	content->data_part4 = NULL;

	return 0;
}
コード例 #3
0
ファイル: calc_83.c プロジェクト: debrouxl/tilp-libticalcs
static int		get_memfree	(CalcHandle* handle, uint32_t* ram, uint32_t* flash)
{
	uint16_t unused;	
	uint32_t memory;

	TRYF(ti82_send_REQ(handle, 0x0000, TI83_DIR, ""));
	TRYF(ti82_recv_ACK(handle, &unused));

	TRYF(ti82_recv_XDP(handle, &unused, (uint8_t *)&memory));
	fixup(memory);
	TRYF(ti82_send_EOT(handle));
	*ram = memory;
	*flash = -1;

	return 0;
}
コード例 #4
0
ファイル: calc_83.c プロジェクト: debrouxl/tilp-libticalcs
static int		recv_var	(CalcHandle* handle, CalcMode mode, FileContent* content, VarRequest* vr)
{
  uint16_t unused;
  VarEntry *ve;
  char *utf8;
  uint16_t ve_size;

	content->model = CALC_TI83;
	strcpy(content->comment, tifiles_comment_set_single());
	content->num_entries = 1;
	content->entries = tifiles_ve_create_array(1);
	ve = content->entries[0] = tifiles_ve_create();
	memcpy(ve, vr, sizeof(VarEntry));

	utf8 = ticonv_varname_to_utf8(handle->model, ve->name, ve->type);
	g_snprintf(update_->text, sizeof(update_->text), "%s", utf8);
	g_free(utf8);
	update_label();

	// silent request
	TRYF(ti82_send_REQ(handle, (uint16_t)vr->size, vr->type, vr->name));
	TRYF(ti82_recv_ACK(handle, &unused));

	TRYF(ti82_recv_VAR(handle, &ve_size, &ve->type, ve->name));
	ve->size = ve_size;
	TRYF(ti82_send_ACK(handle));

	TRYF(ti82_send_CTS(handle));
	TRYF(ti82_recv_ACK(handle, NULL));

	ve->data = tifiles_ve_alloc_data(ve->size);
	TRYF(ti82_recv_XDP(handle, &ve_size, ve->data));
	ve->size = ve_size;
	TRYF(ti82_send_ACK(handle));

	return 0;
}
コード例 #5
0
ファイル: calc_83.c プロジェクト: debrouxl/tilp-libticalcs
static int		recv_screen	(CalcHandle* handle, CalcScreenCoord* sc, uint8_t** bitmap)
{
	uint16_t max_cnt;
	int err;
	uint8_t buf[TI83_COLS * TI83_ROWS / 8];

	sc->width = TI83_COLS;
	sc->height = TI83_ROWS;
	sc->clipped_width = TI83_COLS;
	sc->clipped_height = TI83_ROWS;

	TRYF(ti82_send_SCR(handle));
	TRYF(ti82_recv_ACK(handle, NULL));

	err = ti82_recv_XDP(handle, &max_cnt, buf);	// pb with checksum
	if (err != ERR_CHECKSUM) { TRYF(err) };
	TRYF(ti82_send_ACK(handle));

	*bitmap = (uint8_t *)g_malloc(TI83_COLS * TI83_ROWS / 8);
	if(*bitmap == NULL) return ERR_MALLOC;
	memcpy(*bitmap, buf, TI83_COLS * TI83_ROWS / 8);

	return 0;
}
コード例 #6
0
ファイル: calc_83.c プロジェクト: debrouxl/tilp-libticalcs
static int		get_dirlist	(CalcHandle* handle, GNode** vars, GNode** apps)
{
	TreeInfo *ti;
	GNode *folder;
	uint16_t unused;
	uint32_t memory;
	char *utf8;

	// get list of folders & FLASH apps
	(*apps) = g_node_new(NULL);
	ti = (TreeInfo *)g_malloc(sizeof(TreeInfo));
	ti->model = handle->model;
	ti->type = APP_NODE_NAME;
	(*apps)->data = ti;

	(*vars) = g_node_new(NULL);
	ti = (TreeInfo *)g_malloc(sizeof(TreeInfo));
	ti->model = handle->model;
	ti->type = VAR_NODE_NAME;
	(*vars)->data = ti;

	TRYF(ti82_send_REQ(handle, 0x0000, TI83_DIR, ""));
	TRYF(ti82_recv_ACK(handle, &unused));

	TRYF(ti82_recv_XDP(handle, &unused, (uint8_t *)&memory));
	fixup(memory);
	TRYF(ti82_send_ACK(handle));
	ti->mem_free = memory;
	
	folder = g_node_new(NULL);
	g_node_append(*vars, folder);

	// Add permanent variables (Window, RclWindow, TblSet aka WINDW, ZSTO, TABLE)
	{
		GNode *node;
		VarEntry *ve;

		ve = tifiles_ve_create();
		ve->type = TI83_WINDW;
		node = g_node_new(ve);
		g_node_append(folder, node);

		ve = tifiles_ve_create();
		ve->type = TI83_ZSTO;
		node = g_node_new(ve);
		g_node_append(folder, node);

		ve = tifiles_ve_create();
		ve->type = TI83_TABLE;
		node = g_node_new(ve);
		g_node_append(folder, node);
	}

	for (;;) 
	{
		VarEntry *ve = tifiles_ve_create();
		GNode *node;
		int err;
		uint16_t ve_size;

		err = ti82_recv_VAR(handle, &ve_size, &ve->type, ve->name);
		ve->size = ve_size;
		TRYF(ti82_send_ACK(handle));
		if (err == ERR_EOT)
			break;
		else if (err != 0)
			return err;

		node = g_node_new(ve);
		g_node_append(folder, node);

		utf8 = ticonv_varname_to_utf8(handle->model, ve->name, ve->type);
		g_snprintf(update_->text, sizeof(update_->text), _("Parsing %s"), utf8);
		g_free(utf8);
		update_label();
	}

	return 0;
}
コード例 #7
0
ファイル: calc_82.c プロジェクト: Jonimoose/tilp-libticalcs
static int		recv_var_ns	(CalcHandle* handle, CalcMode mode, FileContent* content, VarEntry** vr)
{
  int nvar = 0;
  int err = 0;
  char *utf8;
  uint16_t ve_size;

  g_snprintf(update_->text, sizeof(update_->text), _("Waiting for var(s)..."));
  update_label();

  content->model = CALC_TI82;

  for (nvar = 0;; nvar++) 
  {
    VarEntry *ve;

	content->entries = tifiles_ve_resize_array(content->entries, nvar+1);
    ve = content->entries[nvar] = tifiles_ve_create();

    do 
	{
      update_refresh();
      if (update_->cancel)
		return ERR_ABORT;

      err = ti82_recv_VAR(&ve_size, &(ve->type), ve->name);
      ve->size = ve_size;
    }
    while (err == ERROR_READ_TIMEOUT);

    TRYF(ti82_send_ACK());
    if (err == ERR_EOT) 
	  goto exit;
    TRYF(err);

    TRYF(ti82_send_CTS());
    TRYF(ti82_recv_ACK(NULL));

    utf8 = ticonv_varname_to_utf8(handle->model, ve->name, ve->type);
    g_snprintf(update_->text, sizeof(update_->text), "%s", utf8);
	g_free(utf8);
    update_label();

	ve->data = tifiles_ve_alloc_data(ve->size);
    TRYF(ti82_recv_XDP(&ve_size, ve->data));
    ve->size = ve_size;
    TRYF(ti82_send_ACK());
  }

exit:
  content->num_entries = nvar;
  if(nvar == 1)
  {
	strcpy(content->comment, tifiles_comment_set_single());
	*vr = tifiles_ve_dup(content->entries[0]);
  }
  else
  {
	strcpy(content->comment, tifiles_comment_set_group());
	*vr = NULL;
  }

  return 0;
}