static void update_status_line(struct status_line *status) { int i; for (i = 0; i < status->num; ++i) { const struct block *config_block = status->blocks + i; struct block *updated_block = status->updated_blocks + i; /* Skip static block */ if (!*config_block->command) { bdebug(config_block, "no command, skipping"); continue; } /* If a block needs an update, reset and execute it */ if (need_update(updated_block)) { struct click click; /* save click info and restore config values */ memcpy(&click, &updated_block->click, sizeof(struct click)); memcpy(updated_block, config_block, sizeof(struct block)); memcpy(&updated_block->click, &click, sizeof(struct click)); block_update(updated_block); /* clear click info */ memset(&updated_block->click, 0, sizeof(struct click)); } } if (caughtsig > 0) caughtsig = 0; }
void block_reap(struct block *block) { int status, code; if (block->pid <= 0) { bdebug(block, "not spawned yet"); return; } if (waitpid(block->pid, &status, 0) == -1) { berrorx(block, "waitpid(%d)", block->pid); mark_as_failed(block, strerror(errno)); goto close; } code = WEXITSTATUS(status); bdebug(block, "process %d exited with %d", block->pid, code); /* Process successfully reaped, reset the block PID */ block->pid = 0; block_dump_stderr(block); if (code != 0 && code != EXIT_URGENT) { char reason[32]; if (code == EXIT_ERR_INTERNAL) sprintf(reason, "internal error"); else sprintf(reason, "bad exit code %d", code); berror(block, "%s", reason); mark_as_failed(block, reason); goto close; } /* Do not update unless it was meant to terminate */ if (block->interval == INTER_PERSIST) goto close; block_update(block); /* Exit code takes precedence over the output */ if (code == EXIT_URGENT) strcpy(block->updated_props.urgent, "true"); close: if (close(block->out) == -1) berrorx(block, "close stdout"); if (close(block->err) == -1) berrorx(block, "close stderr"); }
bool map_draw(map *p_map, SDL_Surface *destination) { int i, j; SDL_Rect rect_src; rect_src.h = TILE_SIZE; rect_src.w = TILE_SIZE; for (i=0;i<p_map->height;i++) { for (j=0;j<p_map->width[i];j++) { if (p_map->pp_tile[i][j].key == '_') { image_draw_part(p_map->p_chipset, destination, j*TILE_SIZE, i*TILE_SIZE, 0, 0, rect_src.h, rect_src.w); } else if (p_map->pp_tile[i][j].key == '#') { image_draw_part(p_map->p_chipset, destination, j*TILE_SIZE, i*TILE_SIZE, 32, 0, rect_src.h, rect_src.w); } if(p_map->pp_tile[i][j].type == BLOCK){ block_draw(p_map->pp_tile[i][j].p_block, destination); block_update(&p_map->pp_tile[i][j]); } } } return true; }
/* STHD - Dream Factory .stx [Kakuto Chojin (Xbox)] */ VGMSTREAM * init_vgmstream_sthd(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; off_t start_offset; int loop_flag, channel_count; /* checks */ if (!check_extensions(streamFile, "stx")) goto fail; if (read_32bitBE(0x00,streamFile) != 0x53544844) /* "STHD" */ goto fail; /* first block has special values */ if (read_32bitLE(0x04,streamFile) != 0x0800 && read_32bitLE(0x0c,streamFile) != 0x0001 && read_32bitLE(0x14,streamFile) != 0x0000) goto fail; channel_count = read_16bitLE(0x06,streamFile); loop_flag = read_16bitLE(0x18,streamFile) != -1; start_offset = 0x800; /* build the VGMSTREAM */ vgmstream = allocate_vgmstream(channel_count, loop_flag); if (!vgmstream) goto fail; vgmstream->meta_type = meta_STHD; vgmstream->sample_rate = read_32bitLE(0x20, streamFile); /* repeated ~8 times? */ vgmstream->coding_type = coding_XBOX_IMA_int; vgmstream->layout_type = layout_blocked_sthd; if (!vgmstream_open_stream(vgmstream,streamFile,start_offset)) goto fail; /* calc num_samples manually (blocks data varies in size) */ { /* loop values may change to +1 in first actual block, but this works ok enough */ int loop_start_block = (uint16_t)read_16bitLE(0x1a,streamFile); int loop_end_block = (uint16_t)read_16bitLE(0x1c,streamFile); int block_count = 1; /* header block = 0 */ vgmstream->next_block_offset = start_offset; do { block_update(vgmstream->next_block_offset,vgmstream); if (block_count == loop_start_block) vgmstream->loop_start_sample = vgmstream->num_samples; if (block_count == loop_end_block) vgmstream->loop_end_sample = vgmstream->num_samples; vgmstream->num_samples += xbox_ima_bytes_to_samples(vgmstream->current_block_size, 1); block_count++; } while (vgmstream->next_block_offset < get_streamfile_size(streamFile)); block_update(start_offset, vgmstream); } return vgmstream; fail: close_vgmstream(vgmstream); return NULL; }