/* * Query and display information about the channels. */ void dyio_print_channels(dyio_t *d) { int num_channels, c; uint8_t chan_mode[MAX_CHANNELS], *p; int chan_value[MAX_CHANNELS]; /* Get current channel modes. */ dyio_call(d, PKT_GET, ID_BCS_IO, "gacm", 0, 0); if (d->reply_len < 1) { printf("dyio-info: incorrect gacm reply: length %u bytes\n", d->reply_len); exit(-1); } num_channels = d->reply[0]; memcpy(chan_mode, &d->reply[1], num_channels); /* Get current pin values. */ dyio_call(d, PKT_GET, ID_BCS_IO, "gacv", 0, 0); if (d->reply_len < 1) { printf("dyio-info: incorrect gacv reply: length %u bytes\n", d->reply_len); exit(-1); } for (c=0; c<num_channels; c++) { p = &d->reply[1 + c*4]; chan_value[c] = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; } printf("\nChannel Status:\n"); for (c=0; c<num_channels; c++) { printf(" %2u: %-20s = %u\n", c, mode_name(chan_mode[c]), chan_value[c]); } }
void Keymap_JoystickUpDown(unsigned int button, int pressed) { static unsigned int button_already_pressed; char code; if (button > 16) return; code = JoystickButtonToSTScanCode[current_mode][button]; if (!code) return; if (code == SPECIAL_MOUSE_BTN_LEFT) { if (pressed) Input_MousePress(SDL_BUTTON_LEFT); else Input_MouseRelease(SDL_BUTTON_LEFT); return; } else if (code == SPECIAL_MOUSE_BTN_RIGHT) { if (pressed) Input_MousePress(SDL_BUTTON_RIGHT); else Input_MouseRelease(SDL_BUTTON_RIGHT); return; } else if (code == SPECIAL_MOUSE_BTN_MIDDLE) { if (pressed) Input_MousePress(SDL_BUTTON_MIDDLE); else Input_MouseRelease(SDL_BUTTON_MIDDLE); return; } if (code == SPECIAL_SWITCH_MODE) { if (!pressed) return; if (++current_mode == MODE_LAST) current_mode = 0; printf("Switching to mode %s\n", mode_name()); return; } if (code == SPECIAL_TIME_INCREASE || code == SPECIAL_TIME_DECREASE) { if (pressed) { if (button_already_pressed) return; button_already_pressed = button; } else if (button != button_already_pressed) return; else button_already_pressed = 0; if (pressed && code == SPECIAL_TIME_INCREASE && currentTimeMode < 5) currentTimeMode++; if (pressed && code == SPECIAL_TIME_DECREASE && currentTimeMode) currentTimeMode--; inject_mouse_event(5 + (screen_w >> 5) * currentTimeMode, screen_h * 9 / 10, pressed); } else
const QString& server_info::meta_info_string() const { if (meta_info_string_.isEmpty()) { QStringList pl; foreach (const player_info& pi, players) pl += pi.nick_name(); meta_info_string_ = QString("%1 %2 %3 %4 %5 %6 %7 %8").arg(name) .arg(id.address()).arg(country).arg(map).arg(mode_name()).arg(pl.join(" ")) .arg(status_name()).arg(game_type); }
static void debug_exec(const char *cmd, unsigned *regs) { if (!strcmp(cmd, "pc")) { dprintf(" pc %08x cpsr %08x mode %s\n", regs[15], regs[16], mode_name(regs[16])); } else if (!strcmp(cmd, "regs")) { dprintf(" r0 %08x r1 %08x r2 %08x r3 %08x\n", regs[0], regs[1], regs[2], regs[3]); dprintf(" r4 %08x r5 %08x r6 %08x r7 %08x\n", regs[4], regs[5], regs[6], regs[7]); dprintf(" r8 %08x r9 %08x r10 %08x r11 %08x mode %s\n", regs[8], regs[9], regs[10], regs[11], mode_name(regs[16])); dprintf(" ip %08x sp %08x lr %08x pc %08x cpsr %08x\n", regs[10], regs[13], regs[14], regs[15], regs[16]); } else if (!strcmp(cmd, "reboot")) { if (msm_hw_reset_hook) msm_hw_reset_hook(); } else if (!strcmp(cmd, "irqs")) { dump_irqs(); } else if (!strcmp(cmd, "kmsg")) { dump_kernel_log(); } else if (!strcmp(cmd, "version")) { dprintf("%s\n", linux_banner); } else { if (debug_busy) { dprintf("command processor busy. trying to abort.\n"); debug_abort = -1; } else { strcpy(debug_cmd, cmd); debug_busy = 1; } msm_trigger_irq(debug_signal_irq); return; } debug_prompt(); }
static void dump_regs(unsigned *regs) { dprintf(" r0 %08x r1 %08x r2 %08x r3 %08x\n", regs[0], regs[1], regs[2], regs[3]); dprintf(" r4 %08x r5 %08x r6 %08x r7 %08x\n", regs[4], regs[5], regs[6], regs[7]); dprintf(" r8 %08x r9 %08x r10 %08x r11 %08x mode %s\n", regs[8], regs[9], regs[10], regs[11], mode_name(regs[16])); if ((regs[16] & MODE_MASK) == USR_MODE) dprintf(" ip %08x sp %08x lr %08x pc %08x cpsr %08x\n", regs[12], regs[13], regs[14], regs[15], regs[16]); else dprintf(" ip %08x sp %08x lr %08x pc %08x cpsr %08x " "spsr %08x\n", regs[12], regs[13], regs[14], regs[15], regs[16], regs[17]); }
/* * Query and print a table of channel capabilities. */ void dyio_print_channel_features(dyio_t *d) { int num_channels, c, num_modes, i, m; uint8_t query[1], chan_feature[MAX_CHANNELS][MAX_MODES]; /* Get number of channels. */ dyio_call(d, PKT_GET, ID_BCS_IO, "gchc", 0, 0); if (d->reply_len < 4) { printf("dyio-info: incorrect gchc reply: length %u bytes\n", d->reply_len); exit(-1); } num_channels = d->reply[3]; memset(chan_feature, 0, sizeof(chan_feature)); /* Build a matrix of channel features. */ for (c=0; c<num_channels; c++) { /* Get a list of channel modes. */ query[0] = c; dyio_call(d, PKT_GET, ID_BCS_IO, "gcml", query, 1); if (d->reply_len < 1) { printf("dyio-info: incorrect gcml[%u] reply\n", c); exit(-1); } num_modes = d->reply[0]; for (i=0; i<num_modes; i++) { m = d->reply[1+i]; chan_feature[c][m] = 1; } } printf("\n"); printf("Channel Features: 1 1 1 1 1 1 1 1 1 1 2 2 2 2\n"); printf(" 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3\n"); for (m=MODE_DI; m<MAX_MODES; m++) { if (m == MODE_UNUSED) continue; printf(" %-22s", mode_name(m)); for (c=0; c<num_channels; c++) { printf("%c ", chan_feature[c][m] ? '+' : '.'); } printf("\n"); } }
void fiq_debugger_dump_regs_aarch32(struct fiq_debugger_output *output, const struct pt_regs *regs) { output->printf(output, " r0 %08x r1 %08x r2 %08x r3 %08x\n", regs->compat_usr(0), regs->compat_usr(1), regs->compat_usr(2), regs->compat_usr(3)); output->printf(output, " r4 %08x r5 %08x r6 %08x r7 %08x\n", regs->compat_usr(4), regs->compat_usr(5), regs->compat_usr(6), regs->compat_usr(7)); output->printf(output, " r8 %08x r9 %08x r10 %08x r11 %08x\n", regs->compat_usr(8), regs->compat_usr(9), regs->compat_usr(10), regs->compat_usr(11)); output->printf(output, " ip %08x sp %08x lr %08x pc %08x\n", regs->compat_usr(12), regs->compat_sp, regs->compat_lr, regs->pc); output->printf(output, " cpsr %08x (%s)\n", regs->pstate, mode_name(regs)); }
void fiq_debugger_dump_regs_aarch64(struct fiq_debugger_output *output, const struct pt_regs *regs) { output->printf(output, " x0 %016lx x1 %016lx\n", regs->regs[0], regs->regs[1]); output->printf(output, " x2 %016lx x3 %016lx\n", regs->regs[2], regs->regs[3]); output->printf(output, " x4 %016lx x5 %016lx\n", regs->regs[4], regs->regs[5]); output->printf(output, " x6 %016lx x7 %016lx\n", regs->regs[6], regs->regs[7]); output->printf(output, " x8 %016lx x9 %016lx\n", regs->regs[8], regs->regs[9]); output->printf(output, " x10 %016lx x11 %016lx\n", regs->regs[10], regs->regs[11]); output->printf(output, " x12 %016lx x13 %016lx\n", regs->regs[12], regs->regs[13]); output->printf(output, " x14 %016lx x15 %016lx\n", regs->regs[14], regs->regs[15]); output->printf(output, " x16 %016lx x17 %016lx\n", regs->regs[16], regs->regs[17]); output->printf(output, " x18 %016lx x19 %016lx\n", regs->regs[18], regs->regs[19]); output->printf(output, " x20 %016lx x21 %016lx\n", regs->regs[20], regs->regs[21]); output->printf(output, " x22 %016lx x23 %016lx\n", regs->regs[22], regs->regs[23]); output->printf(output, " x24 %016lx x25 %016lx\n", regs->regs[24], regs->regs[25]); output->printf(output, " x26 %016lx x27 %016lx\n", regs->regs[26], regs->regs[27]); output->printf(output, " x28 %016lx x29 %016lx\n", regs->regs[28], regs->regs[29]); output->printf(output, " x30 %016lx sp %016lx\n", regs->regs[30], regs->sp); output->printf(output, " pc %016lx cpsr %08x (%s)\n", regs->pc, regs->pstate, mode_name(regs)); }
void Nu_DrawScreen () { int y; BuildRGBPalette(MainRGBPalette, MainPalette, len_main_palette); BuildRGBPalette(CtrlRGBPalette, CtrlPalette, 16); y = logscreen2; logscreen2 = physcreen; DrawStr(280, 5, 15, mode_name(), 1); logscreen2 = y; draw_control_panel (); if (mouse_shown && in_mouse_mode()) { SDL_Rect rect = { input.abs_x, input.abs_y, 0, 0 }; SDL_BlitSurface(cursor, NULL, sdlscrn, &rect); mouse_shown = 0; } SDL_Flip(sdlscrn); }
void fiq_debugger_dump_pc(struct fiq_debugger_output *output, const struct pt_regs *regs) { output->printf(output, " pc %016lx cpsr %08lx mode %s\n", regs->pc, regs->pstate, mode_name(regs)); }
bool Replay::LoadReplay(const std::string& name) { #define TEMP_SIZE 256 char temp[TEMP_SIZE]; bool status = false; std::streampos pos; ReplayInfo *info = NULL; GameMode *game_mode = GameMode::GetInstance(); int map_id, val; ASSERT(!is_recorder); old_time = 0; FILE *in = fopen(name.c_str(), "rb"); if (!in) { Error(Format(_("Couldn't open %s\n"), name.c_str())); goto done; } info = ReplayInfo::ReplayInfoFromFile(in); if (!info->IsValid()) goto done; if (info->GetVersion() != Constants::WARMUX_VERSION) { Error(Format(_("Bad version: %s != %s"), info->GetVersion().c_str(), Constants::WARMUX_VERSION.c_str())); goto done; } goto ok; err: Error(Format(_("Warning, malformed replay with data of size %u"), bufsize)); done: fclose(in); if (info) delete info; return status; ok: // duration old_time = info->GetMillisecondsDuration(); // map ID map_id = MapsList::GetInstance()->FindMapById(info->GetMapId()); if (map_id == -1) { Error(Format(_("Couldn't find map %s"), temp)); return false; } MapsList::GetInstance()->SelectMapByIndex(map_id); // Backup playing list TeamsList& teams_list = GetTeamsList(); backup_list = teams_list.playing_list; teams_list.playing_list.clear(); // Teams for (uint i = 0; i<info->GetTeams().size(); i++) { ConfigTeam team_cfg; teams_list.AddTeam(info->GetTeams()[i], true); } // Game mode memcpy(&mode_info, info->GetGameModeInfo(), sizeof(GameModeInfo)); // Set GameMode val = mode_info.allow_character_selection; mode_info.allow_character_selection = game_mode->allow_character_selection; game_mode->allow_character_selection = (GameMode::manual_change_character_t)val; #define SWAP(a, b) val = a; a = b; b = val SWAP(mode_info.turn_duration, game_mode->duration_turn); SWAP(mode_info.duration_before_death_mode, game_mode->duration_before_death_mode); SWAP(mode_info.damage_per_turn_during_death_mode, game_mode->damage_per_turn_during_death_mode); SWAP(mode_info.init_energy, game_mode->character.init_energy); SWAP(mode_info.max_energy, game_mode->character.max_energy); SWAP(mode_info.gravity, game_mode->gravity); MSG_DEBUG("replay", "Game mode: turn=%us move_player=%u max_energy=%u init_energy=%u\n", game_mode->duration_turn, game_mode->duration_move_player, game_mode->character.max_energy, game_mode->character.init_energy); // All of the above could be avoided through a GameMode::Load config_loaded = true; seed = Read32(in); // Get remaining data pos = ftell(in); fseek(in, 0, SEEK_END); uint size = ftell(in)-pos; fseek(in, pos, SEEK_SET); MSG_DEBUG("replay", "Actions found at %u on %uB, seed=%08X\n", (uint)pos, size, seed); // Explicit buffer change to avoid garbage if (buf) free(buf); buf = (uint8_t*)malloc(size); ptr = buf; bufsize = size; if (fread(buf, size, 1, in)!=1 || ferror(in)) goto err; size = SDLNet_Read16(ptr); ptr += 2; std::string mode_name((char*)ptr, size); ptr += size; size = SDLNet_Read16(ptr); ptr += 2; std::string mode((char*)ptr, size); ptr += size; size = SDLNet_Read16(ptr); ptr += 2; std::string mode_objects((char*)ptr, size); ptr += size; game_mode->LoadFromString(mode_name, mode, mode_objects); status = true; goto done; }
static void dump_kernel_log(struct fiq_debugger_state *state) { char buf[512]; size_t len; struct kmsg_dumper dumper = { .active = true }; kmsg_dump_rewind_nolock(&dumper); while (kmsg_dump_get_line_nolock(&dumper, true, buf, sizeof(buf) - 1, &len)) { buf[len] = 0; debug_puts(state, buf); } } static char *mode_name(unsigned cpsr) { switch (cpsr & MODE_MASK) { case USR_MODE: return "USR"; case FIQ_MODE: return "FIQ"; case IRQ_MODE: return "IRQ"; case SVC_MODE: return "SVC"; case ABT_MODE: return "ABT"; case UND_MODE: return "UND"; case SYSTEM_MODE: return "SYS"; default: return "???"; } } static int debug_printf(void *cookie, const char *fmt, ...) { struct fiq_debugger_state *state = cookie; char buf[256]; va_list ap; va_start(ap, fmt); vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); debug_puts(state, buf); return state->debug_abort; } /* Safe outside fiq context */ static int debug_printf_nfiq(void *cookie, const char *fmt, ...) { struct fiq_debugger_state *state = cookie; char buf[256]; va_list ap; unsigned long irq_flags; va_start(ap, fmt); vsnprintf(buf, 128, fmt, ap); va_end(ap); local_irq_save(irq_flags); debug_puts(state, buf); debug_uart_flush(state); local_irq_restore(irq_flags); return state->debug_abort; } static void dump_regs(struct fiq_debugger_state *state, unsigned *regs) { debug_printf(state, " r0 %08x r1 %08x r2 %08x r3 %08x\n", regs[0], regs[1], regs[2], regs[3]); debug_printf(state, " r4 %08x r5 %08x r6 %08x r7 %08x\n", regs[4], regs[5], regs[6], regs[7]); debug_printf(state, " r8 %08x r9 %08x r10 %08x r11 %08x mode %s\n", regs[8], regs[9], regs[10], regs[11], mode_name(regs[16])); if ((regs[16] & MODE_MASK) == USR_MODE) debug_printf(state, " ip %08x sp %08x lr %08x pc %08x " "cpsr %08x\n", regs[12], regs[13], regs[14], regs[15], regs[16]); else debug_printf(state, " ip %08x sp %08x lr %08x pc %08x " "cpsr %08x spsr %08x\n", regs[12], regs[13], regs[14], regs[15], regs[16], regs[17]); }