Пример #1
0
int test_link_assist_rx() {
	asic_t *asic = asic_init(TI83pSE, NULL);
	z80iodevice_t link_assist_rx_read = asic->cpu->devices[0x0A];
	z80iodevice_t link_assist_status = asic->cpu->devices[0x09];
	link_state_t *state = link_assist_rx_read.device;

	if (!link_recv_byte(asic, 0xBE)) {
		asic_free(asic);
		return 1;
	}
	if (link_recv_byte(asic, 0xEF)) {
		asic_free(asic);
		return 2;
	}

	uint8_t status = link_assist_status.read_in(state);
	if (status != state->assist.status.u8 ||
			!state->assist.status.rx_ready ||
			!state->assist.status.int_rx_ready) {
		return 3;
	}

	uint8_t val = link_assist_rx_read.read_in(state);
	if (val != 0xBE) {
		return 4;
	}

	status = link_assist_status.read_in(state);
	if (status != state->assist.status.u8 ||
			state->assist.status.rx_ready ||
			state->assist.status.int_rx_ready) {
		return 5;
	}
	return 0;
}
Пример #2
0
void send_byte_from_input(struct debugger_state *state) {
	if (!link_input) {
		return;
	}
	int c = getc(link_input);
	if (c == EOF) {
		fclose(link_input);
		hook_remove_port_in(state->asic->hook, hook);
		return;
	}
	if (!link_recv_byte(state->asic, (uint8_t)c)) {
		state->print(state, "Warning: link not ready\n");
		ungetc(c, link_input);
	}
}
Пример #3
0
int handle_send(struct debugger_state *state, int argc, char **argv) {
	char *path = strdup(argv[2]);
	wordexp_t p;
	if (wordexp(path, &p, 0) == 0) {
		free(path);
		path = strdup(p.we_wordv[0]);
	}

	link_input = fopen(path, "r");
	if (link_input) {
		state->print(state, "Sending file: %s\n", path);
		hook = hook_add_port_in(state->asic->hook, 0x0A, 0x0A, state, on_link_rx_buffer_read);
		send_byte_from_input(state);
		free(path);
		return 0;
	}
	free(path);

	int strl = 0;
	int i;
	for (i = 1; i < argc - 1; i++) {
		strl += strlen(argv[i + 1]) + 1;
	}

	char *data = malloc(strl);
	char *dpointer = data;
	for (i = 1; i < argc - 1; i++) {
		strcpy(dpointer, argv[i + 1]);
		dpointer += strlen(argv[i + 1]);
		*(dpointer++) = ' ';
	}
	*(dpointer - 1) = 0;

	uint8_t expr = parse_expression_z80e(state, data);

	free(data);

	if (!link_recv_byte(state->asic, expr)) {
		state->print(state, "Calculator is not ready to receive another byte.\n");
	} else {
		state->print(state, "Sent %02X to calculator's link assist.\n", expr);
	}
	return 0;
}