static int recv_screen_80 (CalcHandle* handle, CalcScreenCoord* sc, uint8_t** bitmap) { int ret; uint8_t * buffer; *bitmap = (uint8_t *)ticalcs_alloc_screen(TI80_COLS * TI80_ROWS / 8); if (*bitmap == NULL) { return ERR_MALLOC; } sc->width = TI80_COLS; sc->height = TI80_ROWS; sc->clipped_width = TI80_COLS; sc->clipped_height = TI80_ROWS; sc->pixel_format = CALC_PIXFMT_MONO; ret = ti80_send_SCR(handle); if (!ret) { ret = ti80_recv_ACK(handle, NULL); if (!ret) { uint16_t max_cnt; ret = ti80_recv_XDP(handle, &max_cnt, handle->buffer); if (!ret) { int stripe, row, i = 0; buffer = (uint8_t *)(handle->buffer); for (stripe = 7; stripe >= 0; stripe--) { for (row = 0; row < TI80_ROWS; row++) { (*bitmap)[row * TI80_COLS / 8 + stripe] = buffer[i++]; } } } } } if (ret) { ticalcs_free_screen(*bitmap); *bitmap = NULL; } return ret; }
static int recv_screen (CalcHandle* handle, CalcScreenCoord* sc, uint8_t** bitmap) { uint16_t max_cnt; uint8_t buf[TI80_COLS * TI80_ROWS / 8]; int stripe, row, i = 0; int retval = 0; sc->width = TI80_COLS; sc->height = TI80_ROWS; sc->clipped_width = TI80_COLS; sc->clipped_height = TI80_ROWS; retval = ti80_send_SCR(handle); if (!retval) { retval = ti80_recv_ACK(handle, NULL); if (!retval) { retval = ti80_recv_XDP(handle, &max_cnt, buf); if (!retval) { *bitmap = (uint8_t *)g_malloc(TI80_COLS * TI80_ROWS / 8); if (*bitmap == NULL) { return ERR_MALLOC; } for(stripe = 7; stripe >= 0; stripe--) { for(row = 0; row < TI80_ROWS; row++) { (*bitmap)[row * TI80_COLS / 8 + stripe] = buf[i++]; } } } } } return retval; }