int cgl_read_one_cano(struct cannon *cannon, FILE *fp) { int err; uint8_t buf[CANO_HDR_SIZE]; int16_t buf2[CANO_NUM_SHORTS]; size_t nread; nread = fread(buf, sizeof(uint8_t), CANO_HDR_SIZE, fp); if (nread < CANO_HDR_SIZE) return -EBADCANO; err = read_short((int16_t*)buf2, 1, fp); if (err) return -EBADCANO; cannon->fire_rate = buf2[0]; nread = fread(buf, sizeof(uint8_t), 2, fp); if (nread < 2) return -EBADCANO; cannon->speed_x = (int8_t)buf[0]; cannon->speed_y = (int8_t)buf[1]; err = read_short((int16_t*)buf2, CANO_NUM_SHORTS, fp); if (err) return -EBADCANO; cannon->dir = buf[0] & 0x03; parse_point(buf2 + 0x00, &cannon->beg, &cannon->end); parse_tile_minimal(buf2 + 0x04, cannon->beg_base, 24, 24, 512, 188); parse_tile_simple(buf2 + 0x06, cannon->beg_cano, 16, 16); cannon->beg_cano->collision_test = Bitmap; parse_tile_minimal(buf2 + 0x0a, cannon->end_base, 16, 16, 472, 196); parse_tile_normal(buf2 + 0x0c, cannon->end_catch); cannon->end_catch->collision_test = Bitmap; return 0; }
char *parse_etvs_header(char *buf, NIDS_etvss *p) { int i; char *ptr; p->length = GET2(buf); p->num_points = p->length / 4; if (!(p->points = malloc(p->num_points * sizeof(NIDS_point)))) ERROR("parse_etvs_header"); ptr = buf + 2; for (i = 0 ; i < p->num_points ; i++) { ptr = parse_point(ptr, p->points + i); } return ptr; }