void SetupMenu() // Set up menu { uint8 i; while(1) { i = GetMenuItem("TERMINAL SETUP","WiFi Setup","ESPUSB Fudge","Scan WiFi","Test Wifi","Exit"); if(i==1) SetupWIFI(); if(i==2) // Open USB in CDC Mode passthough to ESP-01 { SerialPurge(WIFI_UART); CLS(); LCDWriteStrAt(0,4, " USB <-> ESP01 "); LCDWriteStrAt(0,6, " PROGRAMMIING "); LCDWriteStrAt(0,10," PRESS KEY TO "); LCDWriteStrAt(0,12," CONTINUE "); PORTSetPinsDigitalIn(IOPORT_C, BIT_2 ); PPSUnLock; // Unlock PPS (Peripheral Pin Select) to allow PIN Mapping PPSOutput(4,RPC2,NULL); PPSLock; // lock PPS ESP_PGM(0); WIFI_PWR(1); i = WaitEvent(9999); CLS(); WIFI_PWR(0); ESP_PGM(1); DelayMs(500); WIFI_PWR(1); LCDWriteStrAt(0,4, " USB <-> ESP01 "); LCDWriteStrAt(0,6, " PASSTHROUGH "); LCDWriteStrAt(0,10," POWER OFF TO "); LCDWriteStrAt(0,12," RESUME "); while(1); } if(i==4) { if(CheckWIFI()) LCDInform("SUCCESS","Connection OK"); } if(i==3) { LCDInform("WARNING","Not Implemented"); } if(i==0 ||i==5) return; } }
void app_keytest() { for (;;) { CLS(ux_state()); FLUSH(); // WAIT(10); } int flg = 0; for (;;) { if (ux_btn()) flg = !flg; CLS(flg); FLUSH(); // WAIT(1000); // 1,000sec WAIT(1000); } }
void medit_disp_pos_menu(struct descriptor_data *d) { int c; CLS(CH); for (c = 1; c < 9; c++) send_to_char(CH, "%2d) %-20s\r\n", c, position_types[c]); }
int check() { int i; CLS(v); dfs(1); for(i = 1;i <= n; i++) if(v[i] == 0) return 0; return 1; }
void medit_disp_attack_menu(struct descriptor_data *d) { int c; CLS(CH); for (c = 0; c < (NUM_ATTACK_TYPES - 1); c+= 2) send_to_char(CH, "%2d) %-20s %2d) %-20s\r\n", c+1 , attack_types[c], c+2, c+1 < (NUM_ATTACK_TYPES - 1) ? attack_types[c+1] : ""); send_to_char("Enter attack type: ", CH); }
void medit_disp_class_menu(struct descriptor_data *d) { int c; CLS(CH); for (c = 0; c < NUM_MOB_CLASSES; c++) { send_to_char(CH, "%2d) %-20s\r\n", c + 1, npc_classes[c]); } sprinttype(GET_RACE(MOB), npc_classes, buf1); send_to_char(CH, "Mob class: %s%s%s\r\n" "Enter mob class, 0 to quit: ", CCCYN(CH, C_CMP), buf1, CCNRM(CH, C_CMP)); }
void zedit_disp_wear_menu(struct descriptor_data *d) { CLS(CH); int counter; for (counter = 0; counter < (NUM_WEARS - 1); counter += 2) send_to_char(CH, "^G%2d^Y) ^W%-20s ^G%2d^Y) ^W%-20s\r\n", counter + 1, short_where[counter], counter + 2, counter + 1 < (NUM_WEARS - 1) ? short_where[counter + 1] : ""); send_to_char("^wEnter wear position ^Y(^G0 ^Wto quit^Y)^w: ", CH); }
void init() { CLS(parent); CLS(color); CLS(rank); CLS(tree); CLS(num); CLS(q); }
void zedit_disp_direction_menu(struct descriptor_data *d) { CLS(CH); send_to_char("^G 1^Y) ^Wnorth\r\n" "^G 2^Y) ^Wnortheast\r\n" "^G 3^Y) ^Weast\r\n" "^G 4^Y) ^Wsoutheast\r\n" "^G 5^Y) ^Wsouth\r\n" "^G 6^Y) ^Wsouthwest\r\n" "^G 7^Y) ^Wwest\r\n" "^G 8^Y) ^Wnorthwest\r\n" "^G 9^Y) ^Wup\r\n" "^G10^Y) ^Wdown\r\n" "^wEnter selection: ", CH); }
void init() { int i, j; for(i = 1;i <= n; i++) scanf("%lf %lf", &x[i], &y[i]); CLS(adj); tot = 0; while(m--) { scanf("%d %d", &i, &j); adj[i][j] = 1; e[tot].u = i; e[tot].v = j; e[tot].w = sqrt(SQR(x[i] - x[j]) + SQR(y[i] - y[j])); tot++; } }
void medit_disp_att_menu(struct descriptor_data *d) { CLS(CH); send_to_char(CH, "1) Body: %s%d%s\r\n", CCCYN(CH, C_CMP), GET_REAL_BOD(MOB), CCNRM(CH, C_CMP)); send_to_char(CH, "2) Quickness: %s%d%s\r\n", CCCYN(CH, C_CMP), GET_REAL_QUI(MOB), CCNRM(CH, C_CMP)); send_to_char(CH, "3) Strength: %s%d%s\r\n", CCCYN(CH, C_CMP), GET_REAL_STR(MOB), CCNRM(CH, C_CMP)); send_to_char(CH, "4) Charisma: %s%d%s\r\n", CCCYN(CH, C_CMP), GET_REAL_CHA(MOB), CCNRM(CH, C_CMP)); send_to_char(CH, "5) Intel.: %s%d%s\r\n", CCCYN(CH, C_CMP), GET_REAL_INT(MOB), CCNRM(CH, C_CMP)); send_to_char(CH, "6) Willpower: %s%d%s\r\n", CCCYN(CH, C_CMP), GET_REAL_WIL(MOB), CCNRM(CH, C_CMP)); send_to_char(CH, "7) Magic: %s%d%s\r\n", CCCYN(CH, C_CMP), MOB->real_abils.mag / 100, CCNRM(CH, C_CMP)); send_to_char(CH, "q) Quit\r\n"); send_to_char("\r\nEnter your choice:\r\n", CH); d->edit_mode = MEDIT_ATTRIBUTES; }
void medit_disp_affected_menu(struct descriptor_data *d) { int c; CLS(CH); for (c = 0; c < AFF_MAX; c += 2) { send_to_char(CH, "%2d) %-20s %2d) %-20s\r\n", c + 1, affected_bits[c], c + 2, c + 1 < AFF_MAX ? affected_bits[c + 1] : ""); } AFF_FLAGS(MOB).PrintBits(buf1, MAX_STRING_LENGTH, affected_bits, AFF_MAX); send_to_char(CH, "Affected flags: %s%s%s\r\n" "Enter affected flag, 0 to quit:", CCCYN(CH, C_CMP), buf1, CCNRM(CH, C_CMP)); }
void medit_disp_mobflags_menu(struct descriptor_data *d) { int c; CLS(CH); for (c = 0; c < MOB_MAX; c += 2) { send_to_char(CH, "%2d) %-20s %2d) %-20s\r\n", c + 1, action_bits[c], c + 2, c + 1 < MOB_MAX ? action_bits[c + 1] : ""); } MOB_FLAGS(MOB).PrintBits(buf1, MAX_STRING_LENGTH, action_bits, MOB_MAX); send_to_char(CH, "Mob flags: %s%s%s\r\n" "Enter mob flag, 0 to quit:", CCCYN(CH, C_CMP), buf1, CCNRM(CH, C_CMP)); }
void zedit_disp_type_cmd(struct descriptor_data *d) { CLS(CH); send_to_char("^G1^Y) ^WMOB\r\n" "^G2^Y) ^WOBJECT\r\n" "^G3^Y) ^WPUT\r\n" "^G4^Y) ^WEQUIP\r\n" "^G5^Y) ^WGIVE\r\n" "^G6^Y) ^WREMOVE\r\n" "^G7^Y) ^WDOOR\r\n" "^G8^Y) ^WGIVE NUMBER\r\n" "^G9^Y) ^WCYBER/BIOWARE\r\n" "^G0^Y) ^WVEHICLE\r\n" "^GA^Y) ^WDRIVER\r\n" "^GB^Y) ^WUPGRADE\r\n" "^GC^Y) ^WCARRIED\r\n" "^GD^Y) ^WHOST\r\n" "^Rn^Y) ^WNOTHING\r\n" "^wEnter command type: ", CH); }
boolean animate(char* data, int len) { for (int loop = 0; loop < 10; loop++) { for (int i = 0; i < len - 8; i++) { timenobtn = 0; // setMatrix2(data + i); CLS(1); for (int k = 0; k < 8; k++) buf[k] = data[k + i]; FLUSH(); // if (uart0_test()) for (int j = 0; j < 90; j++) { WAIT(1); if (ux_btn()) { return 1; } } } // break; } deepPowerDown(); return 1; }
void zedit_disp_data_menu(struct descriptor_data *d) { CLS(CH); send_to_char(CH, "^WZone: ^c%d^n\r\n", ZON->number ); send_to_char(CH, "^G1^Y) ^WName: ^c%s^n\r\n", ZON->name ); send_to_char(CH, "^G2^Y) ^WTop of zone: ^c%d^n\r\n", ZON->top ); send_to_char(CH, "^G3^Y) ^WLifespan: ^c%d^n\r\n", ZON->lifespan ); send_to_char(CH, "^G4^Y) ^WReset mode: ^c%s^n\r\n", reset_mode[ZON->reset_mode] ); send_to_char(CH, "^G5^Y) ^WSecurity level: ^c%d^n\r\n", ZON->security ); send_to_char(CH, "^G6^Y) ^WJuridiction: ^c%s^n\r\n", jurid[ZON->juridiction]); if (access_level(CH, LVL_VICEPRES)) { send_to_char(CH, "^G7^Y) ^WEditor's ID Numbers: ^c%d^w, ^c%d^w, ^c%d^w, ^c%d^w, ^c%d^n\r\n", ZON->editor_ids[0], ZON->editor_ids[1], ZON->editor_ids[2], ZON->editor_ids[3], ZON->editor_ids[4]); send_to_char(CH, "^G8^Y) ^WConnected: ^c%d^n\r\n", ZON->connected); } send_to_char("^Gq^Y) ^WQuit\r\n^wEnter selection: ", CH); d->edit_mode = ZEDIT_DATA_MENU; }
void medit_disp_skill_menu(struct descriptor_data *d) { CLS(CH); send_to_char(CH, "1) Skill: %s%s%s (%s%d%s)\r\n", CCCYN(CH, C_CMP), skills[MOB->mob_specials.mob_skills[0]].name, CCNRM(CH, C_CMP), CCCYN(CH, C_CMP), MOB->mob_specials.mob_skills[1], CCNRM(CH, C_CMP)); send_to_char(CH, "2) Skill: %s%s%s (%s%d%s)\r\n", CCCYN(CH, C_CMP), skills[MOB->mob_specials.mob_skills[2]].name, CCNRM(CH, C_CMP), CCCYN(CH, C_CMP), MOB->mob_specials.mob_skills[3], CCNRM(CH, C_CMP)); send_to_char(CH, "3) Skill: %s%s%s (%s%d%s)\r\n", CCCYN(CH, C_CMP), skills[MOB->mob_specials.mob_skills[4]].name, CCNRM(CH, C_CMP), CCCYN(CH, C_CMP), MOB->mob_specials.mob_skills[5], CCNRM(CH, C_CMP)); send_to_char(CH, "4) Skill: %s%s%s (%s%d%s)\r\n", CCCYN(CH, C_CMP), skills[MOB->mob_specials.mob_skills[6]].name, CCNRM(CH, C_CMP), CCCYN(CH, C_CMP), MOB->mob_specials.mob_skills[7], CCNRM(CH, C_CMP)); send_to_char(CH, "5) Skill: %s%s%s (%s%d%s)\r\n", CCCYN(CH, C_CMP), skills[MOB->mob_specials.mob_skills[8]].name, CCNRM(CH, C_CMP), CCCYN(CH, C_CMP), MOB->mob_specials.mob_skills[9], CCNRM(CH, C_CMP)); send_to_char("0) Quit\r\n", CH); send_to_char("Enter your choice: ", CH); }
void medit_disp_skills(struct descriptor_data *d) { int c, line = 0; CLS(CH); for (c = 0; c < MAX_SKILLS; c++) { line++; if ((line % 3) == 1) sprintf(buf, "%2d) %-20s ", c+1, skills[c].name); else sprintf(buf, "%s%2d) %-20s ", buf, c+1, skills[c].name); if (!(line % 3)) { sprintf(buf, "%s\r\n", buf); send_to_char(buf, CH); } } if ((line % 3) != 0) { sprintf(buf, "%s\r\nEnter a skill (0 to quit): ", buf); send_to_char(buf, CH); } }
// MAIN LOOP! void zedit_parse(struct descriptor_data *d, char *arg) { int number, i = 0, zone; switch (d->edit_mode) { case ZEDIT_CONFIRM_EDIT_DATA: switch (*arg) { case 'y': case 'Y': d->edit_zon = new zone_data; // we do need to zero it out since we are accessing its elements memset((char *) ZON, 0, sizeof(struct zone_data)); *d->edit_zon = zone_table[d->edit_number]; if (zone_table[d->edit_number].name) d->edit_zon->name = str_dup(zone_table[d->edit_number].name); zedit_disp_data_menu(d); break; case 'n': case 'N': STATE(d) = CON_PLAYING; PLR_FLAGS(d->character).RemoveBit(PLR_EDITING); break; default: send_to_char("That's not a valid choice!\r\n", d->character); send_to_char("Do you wish to edit the data?\r\n", d->character); break; } break; case ZEDIT_CONFIRM_CREATE_DATA: switch (*arg) { case 'y': case 'Y': d->edit_zon = new zone_data; // we do need to zero it out since we are accessing its elements memset((char *) ZON, 0, sizeof(struct zone_data)); // set a few vars ZON->name = str_dup("an unfinished zone"); ZON->number = CH->player_specials->saved.zonenum; ZON->top = ZON->number * 100 + 99; zedit_disp_data_menu(d); break; case 'n': case 'N': STATE(d) = CON_PLAYING; PLR_FLAGS(d->character).RemoveBit(PLR_EDITING); break; default: send_to_char("That's not a valid choice!\r\n", d->character); send_to_char("Do you wish to edit the data?\r\n", d->character); break; } break; case ZEDIT_CONFIRM_SAVEDATA: switch (*arg) { int zone_num; case 'y': case 'Y': zone_num = real_zone(ZON->number); sprintf(buf,"%s wrote new zcmd %ld in zone %d", GET_CHAR_NAME(d->character), d->edit_number, zone_table[zone_num].number); mudlog(buf, d->character, LOG_WIZLOG, TRUE); // first we insert into memory if (zone_num > -1) { // ie, it already exists ZON->cmd = zone_table[zone_num].cmd; delete [] zone_table[zone_num].name; zone_table[zone_num] = *ZON; } else { // here we got to add a new spot int counter; int found = 0; struct zone_data *new_z_table; // create new table + 2 new_z_table = new struct zone_data[top_of_zone_table + 2]; for (counter = 0; counter < top_of_zone_table + 1; counter++) { if (!found) { if (zone_table[counter].number > CH->player_specials->saved.zonenum) { new_z_table[counter] = *(ZON); found = 1; new_z_table[counter + 1] = zone_table[counter]; } else new_z_table[counter] = zone_table[counter]; } else new_z_table[counter + 1] = zone_table[counter]; } if (!found) new_z_table[top_of_zone_table + 1] = *(ZON); top_of_zone_table++; delete [] zone_table; zone_table = new_z_table; } write_zone_to_disk(ZONENUM); write_index_file("zon"); d->edit_mode = 0; delete ZON; ZON = NULL; PLR_FLAGS(d->character).RemoveBit(PLR_EDITING); STATE(d) = CON_PLAYING; send_to_char("Done.\r\n", d->character); break; // end of 'y' case in confirm savestring case 'n': case 'N': if (ZON) { if (ZON->name) delete [] ZON->name; delete ZON; } STATE(d) = CON_PLAYING; ZON = NULL; d->edit_number = 0; PLR_FLAGS(CH).RemoveBit(PLR_EDITING); break; // end of 'n' case in confirm savestring default: send_to_char("Please enter yes or no.\r\n" "Do you wish to save this zone internally?\r\n", CH); break; } break; // end of confirm savestring case ZEDIT_CONFIRM_ADD_CMD: switch (*arg) { case 'y': case 'Y': COM = new reset_com; COM->command = '*'; zedit_disp_command_menu(d); break; case 'n': case 'N': STATE(d) = CON_PLAYING; PLR_FLAGS(d->character).RemoveBit(PLR_EDITING); break; default: send_to_char("That's not a valid choice!\r\n", CH); send_to_char("Do you wish to add a command?\r\n", CH); break; } break; case ZEDIT_CONFIRM_INSERT_CMD: switch (*arg) { case 'y': case 'Y': COM = new reset_com; COM->command = '*'; // so it knows to insert if they decide to save d->edit_number2 = TRUE; zedit_disp_command_menu(d); break; case 'n': case 'N': STATE(d) = CON_PLAYING; PLR_FLAGS(d->character).RemoveBit(PLR_EDITING); break; default: send_to_char("That's not a valid choice!\r\n", CH); send_to_char("Do you wish to insert a command?\r\n", CH); break; } break; case ZEDIT_CONFIRM_EDIT_CMD: switch (*arg) { case 'y': case 'Y': COM = new reset_com; *COM = zone_table[real_zone(ZONENUM)].cmd[d->edit_number]; zedit_disp_command_menu(d); break; case 'n': case 'N': STATE(d) = CON_PLAYING; PLR_FLAGS(d->character).RemoveBit(PLR_EDITING); break; default: send_to_char("That's not a valid choice!\r\n", CH); send_to_char("Do you wish to edit the command?\r\n", CH); break; } break; case ZEDIT_DATA_MENU: switch (*arg) { case 'q': case 'Q': send_to_char("Do you wish to save this zone internally?\r\n", CH); d->edit_mode = ZEDIT_CONFIRM_SAVEDATA; break; case '1': send_to_char("Enter zone name: ", CH); d->edit_mode = ZEDIT_ZONE_NAME; break; case '2': send_to_char("Enter top of zone: ", CH); d->edit_mode = ZEDIT_TOP_OF_ZONE; break; case '3': send_to_char("Lifespan (in ticks between resets): ", CH); d->edit_mode = ZEDIT_LIFESPAN; break; case '4': CLS(CH); send_to_char("1) Don't reset\r\n" "2) Reset only if no PCs are in the zone\r\n" "3) Always reset\r\n" "0) Quit\r\n" "Enter reset mode: ", CH); d->edit_mode = ZEDIT_RESET_MODE; break; case '5': send_to_char("Zone security (1 (none) - 15 (paranoid)):\r\n", CH); d->edit_mode = ZEDIT_SECURITY; break; case '6': send_to_char("0) Seattle\r\n" "1) Portland\r\n" "Enter juridiction: ", CH); d->edit_mode = ZEDIT_JURID; break; case '7': if (!access_level(CH, LVL_VICEPRES)) { send_to_char("That's not a valid choice.\r\n", CH); return; } send_to_char("Enter ID list seperated by spaces:\r\n", CH); d->edit_mode = ZEDIT_ID_LIST; break; case '8': if (!access_level(CH, LVL_VICEPRES)) { send_to_char("That's not a valid choice.\r\n", CH); return; } send_to_char("Zone is connected (1 - yes, 0 - no)? ", CH); d->edit_mode = ZEDIT_CONNECTED; break; default: send_to_char("That's not a valid choice.\r\n", CH); zedit_disp_data_menu(d); break; } break; case ZEDIT_COMMAND_MENU: switch (*arg) { case 'q': case 'Q': send_to_char("Do you wish to save this zone command internally?\r\n", CH); d->edit_mode = ZEDIT_CONFIRM_SAVECMDS; break; case '1': zedit_disp_type_cmd(d); d->edit_mode = ZEDIT_CMD_TYPE; break; case '2': send_to_char("\r\n1) Always\r\n2) If last\r\nEnter your selection: ", CH); d->edit_mode = ZEDIT_IF_FLAG_CMD; break; case '3': switch (COM->command) { case 'M': case 'S': send_to_char("\r\nEnter virtual number of mob: ", CH); d->edit_mode = ZEDIT_ARG1; break; case 'H': case 'U': case 'I': case 'O': case 'P': case 'E': case 'G': case 'R': case 'N': case 'C': send_to_char("\r\nEnter virtual number of obj: ", CH); d->edit_mode = ZEDIT_ARG1; break; case 'D': zedit_disp_direction_menu(d); d->edit_mode = ZEDIT_DIRECTION_OF_DOOR; break; case 'V': send_to_char("\r\nEnter virtual number of vehicle: ", CH); d->edit_mode = ZEDIT_ARG1; break; default: zedit_disp_command_menu(d); break; } break; case '4': switch (COM->command) { case 'M': case 'S': case 'U': case 'I': case 'O': case 'P': case 'E': case 'N': case 'G': case 'H': case 'V': send_to_char("Enter max allowed to exist in game: ", CH); d->edit_mode = ZEDIT_ARG2; break; case 'R': case 'D': send_to_char("Enter the room number: ", CH); d->edit_mode = ZEDIT_REMOVE_ROOM; break; case 'C': send_to_char(" 0) Cyberware\r\n 1) Bioware\r\nEnter location to place obj: ", CH); d->edit_mode = ZEDIT_ARG2; break; default: zedit_disp_command_menu(d); break; } break; case '5': switch (COM->command) { case 'M': case 'O': case 'V': send_to_char("Enter the room number: ", CH); d->edit_mode = ZEDIT_ARG3; break; case 'H': send_to_char("Enter the host number: ", CH); d->edit_mode = ZEDIT_ARG3; break; case 'P': send_to_char("Enter the object number: ", CH); d->edit_mode = ZEDIT_ARG3; break; case 'E': zedit_disp_wear_menu(d); d->edit_mode = ZEDIT_WEAR; break; case 'D': zedit_disp_state_menu(d); d->edit_mode = ZEDIT_DOOR_STATE; break; case 'N': send_to_char("Enter total number to give mob: ", CH); d->edit_mode = ZEDIT_ARG3; break; default: zedit_disp_command_menu(d); break; } break; } break; case ZEDIT_CONFIRM_SAVECMDS: int zone_num, top_of_cmds; switch (*arg) { case 'y': case 'Y': zone_num = real_zone(ZONENUM); top_of_cmds = zone_table[zone_num].num_cmds; sprintf(buf,"%s wrote new zcmd %ld in zone %d", GET_CHAR_NAME(d->character), d->edit_number, zone_table[zone_num].number); mudlog(buf, d->character, LOG_WIZLOG, TRUE); // first, determine if you are adding or replacing if (d->edit_number < top_of_cmds) { if (!d->edit_number2) zone_table[zone_num].cmd[d->edit_number] = *(COM); else { int counter; struct reset_com *new_cmds; new_cmds = new struct reset_com[top_of_cmds + 1]; if (top_of_cmds > 1) { // first count your way up for (counter = 0; counter < d->edit_number; counter++) new_cmds[counter] = zone_table[zone_num].cmd[counter]; for (counter = top_of_cmds; counter > d->edit_number; counter--) new_cmds[counter] = zone_table[zone_num].cmd[counter-1]; new_cmds[d->edit_number] = *(COM); zone_table[zone_num].num_cmds++; delete [] zone_table[zone_num].cmd; zone_table[zone_num].cmd = new_cmds; } else { new_cmds[1] = zone_table[zone_num].cmd[0]; new_cmds[0] = *(COM); zone_table[zone_num].num_cmds++; if (zone_table[zone_num].cmd) delete [] zone_table[zone_num].cmd; zone_table[zone_num].cmd = new_cmds; } } } else { int counter; struct reset_com *new_cmds; // create a new set of commands, with 1 extra spot new_cmds = new struct reset_com[top_of_cmds + 1]; // we know it is always going in at the end, so we copy the old 1st if (top_of_cmds > 0) { // you have to do this in case there are 0 cmds for (counter = 0; counter < top_of_cmds; counter++) new_cmds[counter] = zone_table[zone_num].cmd[counter]; // tada, here it goes now, do not increase counter, for loop new_cmds[counter] = *(COM); // already did! zone_table[zone_num].num_cmds++; delete [] zone_table[zone_num].cmd; zone_table[zone_num].cmd = new_cmds; } else { new_cmds[0] = *(COM); zone_table[zone_num].num_cmds++; if (zone_table[zone_num].cmd) delete [] zone_table[zone_num].cmd; zone_table[zone_num].cmd = new_cmds; } } // end else write_zone_to_disk(ZONENUM); d->edit_mode = 0; delete COM; COM = NULL; PLR_FLAGS(d->character).RemoveBit(PLR_EDITING); STATE(d) = CON_PLAYING; send_to_char("Done.\r\n", d->character); break; // for 'y' case case 'n': case 'N': if (COM) delete COM; STATE(d) = CON_PLAYING; COM = NULL; d->edit_number = 0; PLR_FLAGS(CH).RemoveBit(PLR_EDITING); break; // for 'n' case default: send_to_char("That's not a valid choice.\r\n", CH); send_to_char("Do you wish to save this zone command internally?\r\n", CH); break; } // for switch in confirm save cmds break; // for ZEDIT_CONFIRM_SAVECMDS case ZEDIT_ARG3: number = atoi(arg); switch (COM->command) { case 'H': COM->arg3 = MAX(0, real_host(number)); break; case 'M': case 'V': case 'O': COM->arg3 = MAX(0, real_room(number)); if (!access_level(CH, LVL_ADMIN) && !(number >= (ZONENUM * 100) && number <= zone_table[real_zone(ZONENUM)].top)) COM->arg3 = 0; break; case 'P': COM->arg3 = MAX(0, real_object(number)); if (!access_level(CH, LVL_ADMIN) && (number < 600 || number > 699)) { for (zone = 0; zone <= top_of_zone_table; zone++) if (number >= (zone_table[zone].number * 100) && number <= zone_table[zone].top) break; if (zone <= top_of_zone_table) { for (i = 0; i < 5; i++) if (zone_table[zone].editor_ids[i] == GET_IDNUM(CH)) break; } else i = 5; } if (i >= 5) COM->arg3 = 0; break; case 'N': COM->arg3 = MIN(25, MAX(0, number)); break; } zedit_disp_command_menu(d); break; case ZEDIT_DOOR_STATE: number = atoi(arg); if ((number < 0) || (number > 3)) { zedit_disp_state_menu(d); return; } else if (number != 0) COM->arg3 = number - 1; zedit_disp_command_menu(d); break; case ZEDIT_WEAR: number = atoi(arg); if ((number < 0) || (number > (NUM_WEARS - 1))) { zedit_disp_wear_menu(d); return; } else if (number != 0) COM->arg3 = number - 1; zedit_disp_command_menu(d); break; case ZEDIT_REMOVE_ROOM: number = atoi(arg); COM->arg1 = MAX(0, real_room(number)); if (!access_level(CH, LVL_ADMIN) && !(number >= (ZONENUM * 100) && number <= zone_table[real_zone(ZONENUM)].top)) COM->arg1 = 0; zedit_disp_command_menu(d); break; case ZEDIT_ARG2: number = atoi(arg); if (COM->command == 'C' && (number < 0 || number > 1)) { send_to_char("Value must be either 0 (cyberware) or 1 (bioware).\r\n" "Enter location to place obj: ", CH); return; } else if ((number < -1) || (number > 1000)) { send_to_char("Value must be between -1 and 1000.\r\n" "Enter max allowed to exist in game: ", CH); return; } COM->arg2 = number; zedit_disp_command_menu(d); break; case ZEDIT_DIRECTION_OF_DOOR: number = atoi(arg); if (number < 0 || number > 10) { zedit_disp_direction_menu(d); return; } else if (number != 0) COM->arg2 = number - 1; zedit_disp_command_menu(d); break; case ZEDIT_ARG1: number = atoi(arg); if (COM->command == 'V') { COM->arg1 = MAX(0, real_vehicle(number)); } else { if (COM->command == 'M' || COM->command == 'S') { COM->arg1 = MAX(0, real_mobile(number)); if (!access_level(CH, LVL_ADMIN)) { for (zone = 0; zone <= top_of_zone_table; zone++) if (number >= (zone_table[zone].number * 100) && number <= zone_table[zone].top) break; if (zone <= top_of_zone_table) { for (i = 0; i < 5; i++) if (zone_table[zone].editor_ids[i] == GET_IDNUM(CH)) break; } else i = 5; } if (i >= 5) COM->arg1 = 0; } else { if (COM->command == 'R') COM->arg2 = MAX(0, real_object(number)); else COM->arg1 = MAX(0, real_object(number)); if (!access_level(CH, LVL_ADMIN) && (number < 300 || number > 699 || (number > 499 && number < 600))) { for (zone = 0; zone <= top_of_zone_table; zone++) if (number >= (zone_table[zone].number * 100) && number <= zone_table[zone].top) break; if (zone <= top_of_zone_table) { for (i = 0; i < 5; i++) if (zone_table[zone].editor_ids[i] == GET_IDNUM(CH)) break; } else i = 5; } if (i >= 5) { if (COM->command == 'R') COM->arg2 = 0; else COM->arg1 = 0; } } } zedit_disp_command_menu(d); break; case ZEDIT_CMD_TYPE: number = atoi(arg); if ((number < 0) || (number > 9) && *arg != 'n') { zedit_disp_type_cmd(d); send_to_char("\r\nInvalid selection. Please try again: ", CH); return; } else { COM->command = get_real_type(arg); if ((COM->command == 'E') || (COM->command == 'G') || (COM->command == 'P') || (COM->command == 'N') || (COM->command == 'C')) COM->if_flag = 1; else COM->if_flag = 0; COM->arg1 = 0; COM->arg2 = 0; COM->arg3 = 0; } zedit_disp_command_menu(d); break; case ZEDIT_IF_FLAG_CMD: number = atoi(arg); if ((number < 1) || (number > 2)) { send_to_char("Invalid selection.\r\n1) Always\r\n2) If last\r\n" "Enter your selection: ", CH); } else { COM->if_flag = COM->if_flag; zedit_disp_command_menu(d); } break; case ZEDIT_ZONE_NAME: if (ZON->name) delete [] ZON->name; ZON->name = str_dup(arg); zedit_disp_data_menu(d); break; case ZEDIT_SECURITY: number = atoi(arg); if (number < 1 || number > 15) { send_to_char("Security rating must range from 1 to 15.\r\nZone security: ", CH); return; } ZON->security = number; zedit_disp_data_menu(d); break; case ZEDIT_ID_LIST: { int t[5] = {0, 0, 0, 0, 0}; if (sscanf(arg, "%d %d %d %d %d\n", &t[0], &t[1], &t[2], &t[3], &t[4]) == 5) { ZON->editor_ids[0] = t[0]; ZON->editor_ids[1] = t[1]; ZON->editor_ids[2] = t[2]; ZON->editor_ids[3] = t[3]; ZON->editor_ids[4] = t[4]; } zedit_disp_data_menu(d); } break; case ZEDIT_CONNECTED: number = atoi(arg); if (number != 0 && number != 1) { send_to_char("Value must be 0 or 1! Zone is connected? ", CH); return; } sprintf(arg, "%s set zone %d to connected %d (was %d)", GET_CHAR_NAME( CH ), ZON->number, number, ZON->connected ); mudlog(arg, CH, LOG_WIZLOG, TRUE); ZON->connected = number; zedit_disp_data_menu(d); break; case ZEDIT_TOP_OF_ZONE: number = atoi(arg); if ((d->edit_number == top_of_zone_table) || (d->edit_number == -1)) if ((number < ZON->number * 100) || (number > (ZON->number * 100 + 499))) { send_to_char(CH, "Value must range from %d to %d\r\n", ZON->number * 100, (ZON->number * 100 + 499)); send_to_char("Enter top of zone: ", CH); return; } else ZON->top = number; else if ((number < ZON->number * 100) || (number > zone_table[d->edit_number + 1].number * 100 - 1)) { send_to_char(CH, "Value must range from %d to %d\r\n", ZON->number * 100, zone_table[d->edit_number + 1].number * 100 - 1); send_to_char("Enter top of zone: ", CH); return; } else ZON->top = number; zedit_disp_data_menu(d); break; case ZEDIT_LIFESPAN: number = atoi(arg); if ((number < 0) || (number > 1440)) { send_to_char("Value must range from 0 to 1440\r\n", CH); send_to_char("Lifespan (in ticks between resets): ", CH); } else { ZON->lifespan = number; zedit_disp_data_menu(d); } break; case ZEDIT_RESET_MODE: number = atoi(arg); if ((number < 0) || (number > 3)) { send_to_char("Invalid choice. Please enter from 0 to 3.\r\n", CH); send_to_char("Enter reset mode: ", CH); return; } else if (number != 0) ZON->reset_mode = number - 1; zedit_disp_data_menu(d); break; case ZEDIT_JURID: number = atoi(arg); if (number < 0 || number > 3) { send_to_char("Invalid choice. Please enter from 0 to 1.\r\n", CH); send_to_char("Enter Juridiction: ", CH); return; } else ZON->juridiction = number; zedit_disp_data_menu(d); break; } }
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // Initialization //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= void oled_init(void) { /* Set the data/command pin to be a GPIO */ gpio_set_mode(PIN_MAP[LCD_DC_GPIO].gpio_device, PIN_MAP[LCD_DC_GPIO].gpio_bit, GPIO_OUTPUT_PP); gpio_write_bit(PIN_MAP[LCD_DC_GPIO].gpio_device, PIN_MAP[LCD_DC_GPIO].gpio_bit, 0); /* Set chip-select to be a GPIO */ gpio_set_mode(PIN_MAP[LCD_CS_GPIO].gpio_device, PIN_MAP[LCD_CS_GPIO].gpio_bit, GPIO_OUTPUT_PP); gpio_write_bit(PIN_MAP[LCD_CS_GPIO].gpio_device, PIN_MAP[LCD_CS_GPIO].gpio_bit, 0); /* Turn the display on */ gpio_set_mode(PIN_MAP[LCD_PWR_GPIO].gpio_device, PIN_MAP[LCD_PWR_GPIO].gpio_bit, GPIO_OUTPUT_PP); gpio_write_bit(PIN_MAP[LCD_PWR_GPIO].gpio_device, PIN_MAP[LCD_PWR_GPIO].gpio_bit, 1); delay_us(2000); /* Documentation says at least 1ms */ /* Reset the display */ gpio_set_mode(PIN_MAP[LCD_RES_GPIO].gpio_device, PIN_MAP[LCD_RES_GPIO].gpio_bit, GPIO_OUTPUT_PP); gpio_write_bit(PIN_MAP[LCD_RES_GPIO].gpio_device, PIN_MAP[LCD_RES_GPIO].gpio_bit, 0); delay_us(20); /* Documentation says at least 2us */ gpio_write_bit(PIN_MAP[LCD_RES_GPIO].gpio_device, PIN_MAP[LCD_RES_GPIO].gpio_bit, 1); //============================== Set_Command_Lock(0x12); // Unlock Driver IC (0x12/0x16/0xB0/0xB1) Set_Command_Lock(0xB1); // Unlock All Commands (0x12/0x16/0xB0/0xB1) Set_Display_Off(); Set_Display_Clock(0xF1); // Set Clock as 90 Frames/Sec Set_Multiplex_Ratio(0x7F); // 1/128 Duty (0x0F~0x7F)// 7F Set_Display_Offset(0x00); // Shift Mapping RAM Counter (0x00~0x7F) Set_Start_Line(0x00); // Set Mapping RAM Display Start Line (0x00~0x7F) Set_Remap_Format(0x74); // Set Horizontal Address Increment // Column Address 0 Mapped to SEG0 // Color Sequence D[15:0]=[RRRRR:GGGGGG:BBBBB] // Scan from COM127 to COM0 // Enable COM Split Odd Even // 65,536 Colors Mode (0x74) // * 262,144 Colors Mode (0xB4) Set_GPIO(0x00); // Disable GPIO Pins Input Set_Function_Selection(0x01); // Disable Internal VDD Regulator // Select 8-bit Parallel Interface Set_VSL(0x01); // Enable External VSL //Set_Contrast_Color(0x80,0x80,0x80); // Set Contrast of Color A (Red) Set_Contrast_Color(0xC8,0x80,0xC8); // Set Contrast of Color A (Red) // Set Contrast of Color B (Green) // Set Contrast of Color C (Blue) Set_Master_Current(Brightness); // Set Scale Factor of Segment Output Current Control Set_Gray_Scale_Table(); // Set Pulse Width for Gray Scale Table Set_Phase_Length(0x32); // Set Phase 1 as 5 Clocks & Phase 2 as 3 Clocks Set_Display_Enhancement(0xA4); // Enhance Display Performance Set_Precharge_Voltage(0x17); // Set Pre-Charge Voltage Level as 0.50*VCC Set_Precharge_Period(0x08); // Set Second Pre-Charge Period as 1 Clock Set_Master_Current(Brightness); // Set Scale Factor of Segment Output Current Control Set_Gray_Scale_Table(); // Set Pulse Width for Gray Scale Table Set_Phase_Length(0x32); // Set Phase 1 as 5 Clocks & Phase 2 as 3 Clocks Set_Display_Enhancement(0xA4); // Enhance Display Performance Set_Precharge_Voltage(0x17); // Set Pre-Charge Voltage Level as 0.50*VCC Set_Precharge_Period(0x08); // Set Second Pre-Charge Period as 1 Clock Set_VCOMH(0x05); // Set Common Pins Deselect Voltage Level as 0.82*VCC Set_Display_Mode(0x02); // Normal Display Mode (0x00/0x01/0x02/0x03) CLS(0); // Clear Screen delay_us(1000); Set_Display_On(); }
void *snake_thread(void *dummy) { while(1) { // first advance snake parts, delete tail, add head if (!got_apple) { snake_part *tail = (snake_part *)list_front(&snake); free(tail); } got_apple = 0; snake_direction = next_snake_direction; snake_part *head = (snake_part *)snake.lastNode->data; snake_part *new_head = (snake_part *)malloc(sizeof(snake_part)); switch (snake_direction) { case DIR_UP: new_head->x = head->x; new_head->y = head->y-1; break; case DIR_DOWN: new_head->x = head->x; new_head->y = head->y+1; break; case DIR_LEFT: new_head->x = head->x-1; new_head->y = head->y; break; case DIR_RIGHT: new_head->x = head->x+1; new_head->y = head->y; break; } list_append(&snake, new_head); head = new_head; // check new head doesnt hit any walls if (head->x < 1 || head->x >= BOARD_WIDTH || head->y < 1 || head->y >= BOARD_HEIGHT) { end_game(); } // check if we hit ourself... list_map(&snake, collision_check); // apple logic if (head->x == apple_x && head->y == apple_y) { got_apple = 1; score++; put_apple(); } // then draw CLS(); draw_board(); list_map(&snake, draw_part); GOTO(apple_x+1, apple_y+1); printf("0"); GOTO(0, BOARD_HEIGHT+2); printf("Score: %d", score); HOME(); fflush(stdout); usleep(100000); } }
void CLightShadows::render () { // Gain access to collision-DB CDB::MODEL* DB = g_pGameLevel->ObjectSpace.GetStaticModel(); CDB::TRI* TRIS = DB->get_tris(); Fvector* VERTS = DB->get_verts(); int slot_line = S_rt_size/S_size; // Projection and xform float _43 = Device.mProject._43; Device.mProject._43 -= 0.002f; RCache.set_xform_world (Fidentity); RCache.set_xform_project (Device.mProject); Fvector View = Device.vCameraPosition; // Render shadows RCache.set_Shader (sh_World); RCache.set_Geometry (geom_World); int batch = 0; u32 Offset = 0; FVF::LIT* pv = (FVF::LIT*) RCache.Vertex.Lock (batch_size*3,geom_World->vb_stride,Offset); for (u32 s_it=0; s_it<shadows.size(); s_it++) { Device.Statistic->RenderDUMP_Srender.Begin (); shadow& S = shadows[s_it]; float Le = S.L->color.intensity()*S.E; int s_x = S.slot%slot_line; int s_y = S.slot/slot_line; Fvector2 t_scale, t_offset; t_scale.set (float(S_size)/float(S_rt_size),float(S_size)/float(S_rt_size)); t_scale.mul (.5f); t_offset.set(float(s_x)/float(slot_line),float(s_y)/float(slot_line)); t_offset.x += .5f/S_rt_size; t_offset.y += .5f/S_rt_size; // Search the cache cache_item* CI = 0; BOOL bValid = FALSE; cache_item CI_what; CI_what.O = S.O; CI_what.L = S.L; CI_what.tris=0; xr_vector<cache_item>::iterator CI_ptr = std::lower_bound(cache.begin(),cache.end(),CI_what,cache_search); if (CI_ptr==cache.end()) { // empty ? CI_ptr = cache.insert (CI_ptr,CI_what); CI = &*CI_ptr; bValid = FALSE; } else { if (CI_ptr->O != CI_what.O || CI_ptr->L != CI_what.L) { // we found something different CI_ptr = cache.insert (CI_ptr,CI_what); CI = &*CI_ptr; bValid = FALSE; } else { // Everything, OK. Check if info is still relevant... CI = &*CI_ptr; bValid = TRUE; if (!CI->Op.similar(CI->O->renderable.xform.c)) bValid = FALSE; else if (!CI->Lp.similar(CI->L->position)) bValid = FALSE; } } CI->time = Device.dwTimeGlobal; // acess time if (!bValid) { // Frustum CFrustum F; F.CreateFromMatrix (S.M,FRUSTUM_P_ALL); // Query xrc.frustum_options (0); xrc.frustum_query (DB,F); if (0==xrc.r_count()) continue; // Clip polys by frustum tess.clear (); for (CDB::RESULT* p = xrc.r_begin(); p!=xrc.r_end(); p++) { VERIFY((p->id>=0)&&(p->id<DB->get_tris_count())); // CDB::TRI& t = TRIS[p->id]; if (t.suppress_shadows) continue; sPoly A,B; A.push_back (VERTS[t.verts[0]]); A.push_back (VERTS[t.verts[1]]); A.push_back (VERTS[t.verts[2]]); // Calc plane, throw away degenerate tris and invisible to light polygons Fplane P; float mag = 0; Fvector t1,t2,n; t1.sub (A[0],A[1]); t2.sub (A[0],A[2]); n.crossproduct (t1,t2); mag = n.square_magnitude(); if (mag<EPS_S) continue; n.mul (1.f/_sqrt(mag)); P.build_unit_normal (A[0],n); float DOT_Fade = P.classify(S.L->position); if (DOT_Fade<0) continue; // Clip polygon sPoly* clip = F.ClipPoly (A,B); if (0==clip) continue; // Triangulate poly for (u32 v=2; v<clip->size(); v++) { tess.push_back (tess_tri()); tess_tri& T = tess.back(); T.v[0] = (*clip)[0]; T.v[1] = (*clip)[v-1]; T.v[2] = (*clip)[v]; T.N = P.n; } } // Remember params which builded cache item CI->O = S.O; CI->Op = CI->O->renderable.xform.c; CI->L = S.L; CI->Lp = CI->L->position; CI->tcnt = tess.size(); //Msg ("---free--- %x",u32(CI->tris)); xr_free (CI->tris); VERIFY(0==CI->tris); if (tess.size()) { CI->tris = xr_alloc<tess_tri>(CI->tcnt); //Msg ("---alloc--- %x",u32(CI->tris)); CopyMemory (CI->tris,&*tess.begin(),CI->tcnt * sizeof(tess_tri)); } } // Fill VB for (u32 tid=0; tid<CI->tcnt; tid++) { tess_tri& TT = CI->tris[tid]; Fvector* v = TT.v; Fvector T; Fplane ttp; ttp.build_unit_normal(v[0],TT.N); if (ttp.classify(View)<0) continue; int c0 = PLC_calc(v[0],TT.N,S.L,Le,S.C); int c1 = PLC_calc(v[1],TT.N,S.L,Le,S.C); int c2 = PLC_calc(v[2],TT.N,S.L,Le,S.C); if (c0>S_clip && c1>S_clip && c2>S_clip) continue; clamp (c0,S_ambient,255); clamp (c1,S_ambient,255); clamp (c2,S_ambient,255); S.M.transform(T,v[0]); pv->set(v[0],CLS(c0),(T.x+1)*t_scale.x+t_offset.x,(1-T.y)*t_scale.y+t_offset.y); pv++; S.M.transform(T,v[1]); pv->set(v[1],CLS(c1),(T.x+1)*t_scale.x+t_offset.x,(1-T.y)*t_scale.y+t_offset.y); pv++; S.M.transform(T,v[2]); pv->set(v[2],CLS(c2),(T.x+1)*t_scale.x+t_offset.x,(1-T.y)*t_scale.y+t_offset.y); pv++; batch++; if (batch==batch_size) { // Flush RCache.Vertex.Unlock (batch*3,geom_World->vb_stride); RCache.Render (D3DPT_TRIANGLELIST,Offset,batch); pv = (FVF::LIT*) RCache.Vertex.Lock(batch_size*3,geom_World->vb_stride,Offset); batch = 0; } } Device.Statistic->RenderDUMP_Srender.End (); } // Flush if nessesary RCache.Vertex.Unlock (batch*3,geom_World->vb_stride); if (batch) { RCache.Render (D3DPT_TRIANGLELIST,Offset,batch); } // Clear all shadows and free old entries in the cache shadows.clear (); for (int cit=0; cit<int(cache.size()); cit++) { cache_item& ci = cache[cit]; u32 time = Device.dwTimeGlobal - ci.time; if (time > cache_old) { //Msg ("---free--- %x",u32(ci.tris)); xr_free (ci.tris); VERIFY(0==ci.tris); cache.erase (cache.begin()+cit); cit --; } } // Projection Device.mProject._43 = _43; RCache.set_xform_project (Device.mProject); }
void oled_reinit(uint8_t clock,uint8_t multiplex,uint8_t functionselect,uint8_t vsl,uint8_t phaselen,uint8_t prechargevolt,uint8_t prechargeperiod,uint8_t vcomh) { Set_Display_Off(); // cuts power to the display gpio_write_bit(PIN_MAP[LCD_PWR_GPIO].gpio_device, PIN_MAP[LCD_PWR_GPIO].gpio_bit, 0); delay_us(250000); // give it 250ms to discharge, hard wait; prevent issues with switch bounce /* Set the data/command pin to be a GPIO */ gpio_set_mode(PIN_MAP[LCD_DC_GPIO].gpio_device, PIN_MAP[LCD_DC_GPIO].gpio_bit, GPIO_OUTPUT_PP); gpio_write_bit(PIN_MAP[LCD_DC_GPIO].gpio_device, PIN_MAP[LCD_DC_GPIO].gpio_bit, 0); /* Set chip-select to be a GPIO */ gpio_set_mode(PIN_MAP[LCD_CS_GPIO].gpio_device, PIN_MAP[LCD_CS_GPIO].gpio_bit, GPIO_OUTPUT_PP); gpio_write_bit(PIN_MAP[LCD_CS_GPIO].gpio_device, PIN_MAP[LCD_CS_GPIO].gpio_bit, 0); /* Turn the display on */ gpio_set_mode(PIN_MAP[LCD_PWR_GPIO].gpio_device, PIN_MAP[LCD_PWR_GPIO].gpio_bit, GPIO_OUTPUT_PP); gpio_write_bit(PIN_MAP[LCD_PWR_GPIO].gpio_device, PIN_MAP[LCD_PWR_GPIO].gpio_bit, 1); delay_us(2000); /* Documentation says at least 1ms */ /* Reset the display */ gpio_set_mode(PIN_MAP[LCD_RES_GPIO].gpio_device, PIN_MAP[LCD_RES_GPIO].gpio_bit, GPIO_OUTPUT_PP); gpio_write_bit(PIN_MAP[LCD_RES_GPIO].gpio_device, PIN_MAP[LCD_RES_GPIO].gpio_bit, 0); delay_us(20); /* Documentation says at least 2us */ gpio_write_bit(PIN_MAP[LCD_RES_GPIO].gpio_device, PIN_MAP[LCD_RES_GPIO].gpio_bit, 1); //============================== Set_Command_Lock(0x12); // Unlock Driver IC (0x12/0x16/0xB0/0xB1) Set_Command_Lock(0xB1); // Unlock All Commands (0x12/0x16/0xB0/0xB1) Set_Display_Off(); Set_Display_Clock(clock); // Set Clock as 90 Frames/Sec Set_Multiplex_Ratio(multiplex); // 1/128 Duty (0x0F~0x7F)// 7F Set_Display_Offset(0x00); // Shift Mapping RAM Counter (0x00~0x7F) Set_Start_Line(0x00); // Set Mapping RAM Display Start Line (0x00~0x7F) Set_Remap_Format(0x74); // Set Horizontal Address Increment // Column Address 0 Mapped to SEG0 // Color Sequence D[15:0]=[RRRRR:GGGGGG:BBBBB] // Scan from COM127 to COM0 // Enable COM Split Odd Even // 65,536 Colors Mode (0x74) // * 262,144 Colors Mode (0xB4) Set_GPIO(0x00); // Disable GPIO Pins Input Set_Function_Selection(functionselect); // Disable Internal VDD Regulator // Select 8-bit Parallel Interface Set_VSL(vsl); // Enable External VSL Set_Gray_Scale_Table(); // Set Pulse Width for Gray Scale Table Set_Phase_Length(0x32); // Set Phase 1 as 5 Clocks & Phase 2 as 3 Clocks Set_Display_Enhancement(0xA4); // Enhance Display Performance Set_Precharge_Voltage(prechargevolt); // Set Pre-Charge Voltage Level as 0.50*VCC, 1c in 4D Set_Precharge_Period(prechargeperiod); // Set Second Pre-Charge Period as 1 Clock, Set_VCOMH(vcomh); // Set Common Pins Deselect Voltage Level as 0.82*VCC. 1F in 4D Set_Display_Mode(0x02); // Normal Display Mode (0x00/0x01/0x02/0x03) CLS(0); // Clear Screen delay_us(1000); Set_Display_On(); }
void app_renda() { // 連打ゲーム for (;;) { playMML("L8EGG"); ux_btn(); for (;;) { FILL("8aa2cc006595f010"); // title // FILL("8aa2cc006a953060"); // title FLUSH(); if (ux_btn()) break; } systick = 0; for (;;) { WAIT(10); if (!ux_state()) break; if (systick > 10000) return; } playMML("C"); FILL(PTN_3); FLUSH(); WAIT(1000); playMML("C"); FILL(PTN_2); FLUSH(); WAIT(1000); playMML("C"); FILL(PTN_1); FLUSH(); WAIT(1000); playMML("G2"); FILL(PTN_GO); FLUSH(); WAIT(1000); CLS(1); FLUSH(); systick = 0; int cnt = 0; int bkbtn = 0; ux_btn(); for (;;) { int btn = ux_btn(); if (btn) { playMML("A16"); PRESET(cnt % 8, cnt / 8); FLUSH(); cnt++; if (cnt == 64) break; } // bkbtn = btn; } playMML("L8CEG"); FILL("00c9aaacacaaaa69"); // ok xprintf("%d\n", systick); unsigned int score = 100000 / (systick / 64); xprintf("%d\n", score); /* for (int i = 0;; i++) { int n = time % 10; time /= 10; if (time == 0) break; FILL(PTN_NUM[n]); FLUSH(); WAIT(500); } */ if (score > 250) score = 250; FILL(PTN_NUM[score / 10]); PSET(6, 6); FLUSH(); WAIT(1000); FILL(PTN_NUM[score % 10]); FLUSH(); WAIT(1000); FLUSH(); WAIT(1000); } }
void app_mikuji() { // おみくじ for (;;) { playMML("C8G8C8>G4"); ux_btn(); for (;;) { FILL("c152f4d2014a4530"); // title FLUSH(); if (ux_btn()) break; rnd(); } systick = 0; for (;;) { WAIT(10); if (!ux_state()) break; if (systick > 10000) return; } // 00494bef4da9af00 大凶 int btn = 0; systick = 0; // 大中小末 char* PTN_UP[] = { "00494bef4da9af00", // 大 "0049ebefed494f00", // 中 "00464f46ef594f00", // 小 "00e64fe64fe9df00", // 末 }; char* PTN_DOWN[] = { "0060f060f090f000", // 吉 "0090b0f0d090f000", // 凶 }; playMML("G8"); for (int k = 0; k < 8; k++) { CLS(0); matrix_put("c152f4d2014a4530", 0, -k, 8, 8); matrix_put("00494bef4da9af00", 0, -k + 8, 8, 8); FLUSH(); WAIT(2000 - k * 20); } int view = 0; int next = rnd() % 4; int view2 = 0; int next2 = rnd() % 2; int state = 0; int wcnt = 15; int wcnt2 = 15; int i = 0; int j = 0; int ccnt = 0; int ccnt2 = 0; ux_btn(); for (;;) { CLS(0); matrix_put(PTN_UP[view], 0, -(i % 8), 4, 8); // 大 matrix_put(PTN_UP[next], 0, 8 - i % 8, 4, 8); // 中 matrix_put(PTN_DOWN[view2], 4, -(j % 8), 4, 8); // 吉 matrix_put(PTN_DOWN[next2], 4, 8 - j % 8, 4, 8); // 吉 FLUSH(); WAIT(1); if (!btn) { // if (systick > 10000 && ux_btn()) // btn = 1; if (ux_btn()) { playMML("A8"); btn = 1; } } if (state == 0) { ccnt++; if (ccnt == wcnt) { i++; ccnt = 0; if (i % 8 == 0) { playMML("C16"); view = next; int n = rnd() % 6; next = n > 3 ? 0 : n; if (btn) { wcnt += wcnt; if (wcnt > 100) { state++; btn = 0; } } } } } ccnt2++; if (ccnt2 == wcnt2) { j++; ccnt2 = 0; if (j % 8 == 0) { if (state == 1) playMML("C16"); view2 = next2; next2 = rnd() % 4 == 0 ? 1 : 0; if (state == 1) { if (btn) { wcnt2 += wcnt2; if (wcnt2 > 100) break; } } } } } if (view == 0 && view2 == 0) { playMML("G16R8G2"); } else if (view2 == 1) { playMML("C2C8C8"); } else { playMML("C8E8G8"); } ux_btn(); for (;;) { matrix_put(PTN_UP[view], 0, -(i % 8), 4, 8); // 大 matrix_put(PTN_DOWN[view2], 4, 0, 4, 8); // 吉 FLUSH(); WAIT(10); if (ux_btn()) break; } /* for (;;) { WAIT(100); if (!ux_btn()) break; } */ } }
void zedit_disp_command_menu(struct descriptor_data *d) { CLS(CH); send_to_char(CH, "^WCommand: ^c%d^n\r\n", d->edit_number ); send_to_char(CH, "^G1^Y) ^WType: ^c%s^n\r\n", get_type(COM->command) ); send_to_char(CH, "^G2^Y) ^WConditional: ^c%s^n\r\n", (!COM->if_flag ? "Always" : "If Last") ); switch (COM->command) { case 'M': send_to_char(CH, "^G3^Y) ^WLoad mob: ^c%s ^y(^B%d)^n\r\n", GET_NAME(mob_proto+COM->arg1), MOB(COM->arg1) ); send_to_char(CH, "^G4^Y) ^WMaximum number in game: ^c%d^n\r\n", COM->arg2 ); send_to_char(CH, "^G5^Y) ^WLoad in room: ^c%s ^y(^B%d^y)^n\r\n", world[COM->arg3].name, ROOM(COM->arg3) ); break; case 'S': send_to_char(CH, "^G3^Y) ^WLoad mob: ^c%s ^y(^B%d)^n\r\n", GET_NAME(mob_proto+COM->arg1), MOB(COM->arg1) ); send_to_char(CH, "^G4^Y) ^WMaximum number in game: ^c%d^n\r\n", COM->arg2 ); break; case 'U': send_to_char(CH, "^G3^Y) ^WAttach obj: ^c%s ^y(^B%d^y)^n\r\n", obj_proto[COM->arg1].text.name, OBJ(COM->arg1) ); send_to_char(CH, "^G4^Y) ^WMaximum number in game: ^c%d^n\r\n", COM->arg2 ); break; case 'I': send_to_char(CH, "^G3^Y) ^WCarry obj: ^c%s ^y(^B%d^y)^n\r\n", obj_proto[COM->arg1].text.name, OBJ(COM->arg1) ); send_to_char(CH, "^G4^Y) ^WMaximum number in game: ^c%d^n\r\n", COM->arg2 ); break; case 'O': send_to_char(CH, "^G3^Y) ^WLoad obj: ^c%s ^y(^B%d^y)^n\r\n", obj_proto[COM->arg1].text.name, OBJ(COM->arg1) ); send_to_char(CH, "^G4^Y) ^WMaximum number in game: ^c%d^n\r\n", COM->arg2 ); send_to_char(CH, "^G5^Y) ^WLoad in room: ^c%s ^y(^B%d^y)^n\r\n", world[COM->arg3].name, ROOM(COM->arg3) ); break; case 'H': send_to_char(CH, "^G3^Y) ^WLoad obj: ^c%s ^y(^B%d^y)^n\r\n", obj_proto[COM->arg1].text.name, OBJ(COM->arg1) ); send_to_char(CH, "^G4^Y) ^WMaximum number in game: ^c%d^n\r\n", COM->arg2 ); send_to_char(CH, "^G5^Y) ^WLoad in host: ^c%s ^y(^B%d^y)^n\r\n", matrix[COM->arg3].name, HOST(COM->arg3) ); break; case 'V': send_to_char(CH, "^G3^Y) ^WLoad Veh: ^c%s ^y(^B%d^y)^n\r\n", veh_proto[COM->arg1].short_description, VEH(COM->arg1)); send_to_char(CH, "^G4^Y) ^WMaximum number in game: ^c%d^n\r\n", COM->arg2 ); send_to_char(CH, "^G5^Y) ^WLoad in room: ^c%s ^y(^B%d^y)^n\r\n", world[COM->arg3].name, ROOM(COM->arg3) ); break; case 'P': send_to_char(CH, "^G3^Y) ^WPut obj: ^c%s ^y(^B%d^y)^n\r\n", obj_proto[COM->arg1].text.name, OBJ(COM->arg1) ); send_to_char(CH, "^G4^Y) ^WMaximum number in game: ^c%d^n\r\n", COM->arg2 ); send_to_char(CH, "^G5^Y) ^WInto obj: ^c%s ^y(^B%d^y)^n\r\n", obj_proto[COM->arg3].text.name, OBJ(COM->arg3) ); break; case 'G': send_to_char(CH, "^G3^Y) ^WGive obj: ^c%s ^y(^B%d^y)^n\r\n", obj_proto[COM->arg1].text.name, OBJ(COM->arg1) ); send_to_char(CH, "^G4^Y) ^WMaximum number in game: ^c%d^n\r\n", COM->arg2 ); break; case 'E': send_to_char(CH, "^G3^Y) ^WEquip obj: ^c%s (%d)^n\r\n", obj_proto[COM->arg1].text.name, OBJ(COM->arg1)); send_to_char(CH, "^G4^Y) ^WMaximum number in game: ^c%d^n\r\n", COM->arg2 ); send_to_char(CH, "^G5^Y) ^WAt ^c%s^W position\r\n", short_where[COM->arg3] ); break; case 'N': send_to_char(CH, "^G3^Y) ^WGive obj: ^c%s (%d)^n\r\n", obj_proto[COM->arg1].text.name, OBJ(COM->arg1)); send_to_char(CH, "^G4^Y) ^WMaximum number in game: ^c%d^n\r\n", COM->arg2); send_to_char(CH, "^G5^Y) ^WTotal number to give: ^c%d^n\r\n", COM->arg3); break; case 'R': send_to_char(CH, "^G3^Y) ^WRemove obj: ^c%s ^y(^B%d^y)^n\r\n", obj_proto[COM->arg2].text.name, OBJ(COM->arg2) ); send_to_char(CH, "^G4^Y) ^WFrom room: ^c%s ^y(^B%d^y)^n\r\n", world[COM->arg1].name, ROOM(COM->arg1) ); break; case 'D': send_to_char(CH, "^G3^Y) ^WSet door: ^c%s^n\r\n", dirs[COM->arg2] ); send_to_char(CH, "^G4^Y) ^WIn room: ^c%s ^y(^B%d^y)^n\r\n", world[COM->arg1].name, ROOM(COM->arg1) ); send_to_char(CH, "^G5^Y) ^WTo state: ^c%s^n\r\n", (COM->arg3 == 0 ? "open" : (COM->arg3 == 1 ? "closed" : "closed and locked")) ); break; case 'C': send_to_char(CH, "^G3^Y) ^WObj: ^c%s ^y(^B%d^y)^n\r\n", obj_proto[COM->arg1].text.name, OBJ(COM->arg1) ); send_to_char(CH, "^G4^Y) ^WTo: ^c%s^n\r\n", (COM->arg2 == 1 ? "bioware" : "cyberware") ); break; } send_to_char("^Gq^Y) ^WQuit\r\n^wEnter your selection: ", CH); d->edit_mode = ZEDIT_COMMAND_MENU; }
int main() // MAIN PROGRAM AND First Level Menu { uint8 c,MenuSel; // local var to hold result of which menu item we selected InitPIC32(); // initialise MPU CloseWiFi(); // Wifi powered Off CloseBarcode(); // Barcode powered Off PeripheralReset(); InitLCD(); // initialise LCD CloseRFID(); // RFID off / sleep if(BrownOutReset()) // if the system crapped out previously, then just warn the user to charge the device and power off { LCDInform(" POWER! ","Please Charge!"); PWR_HOLD(0); // turn off power when above message acknowleged } while(1) // main program loop (do this until powered off or sleep) { MenuSel = GetMenuItem("READY","Scan Barcode","Scan RFID","Setup","Shutdown",""); if(MenuSel==1) // SCAN barcode { if(ReadBarcode()>1) // we got a barcode! Barcodes are encoded with the first letter designating the barcode type (or obviously the system wont have a clue!) { if(BarcodeData[0]=='J') OldJobMenu(BarcodeData); else if(BarcodeData[0]=='X') NewJobMenu(BarcodeData); else if(BarcodeData[0]=='S' && BarcodeData[1]=='M') StockMenu(BarcodeData); else if(BarcodeData[0]=='A') AssetMenu(BarcodeData); else if(BarcodeData[0]=='L') LabMenu(BarcodeData); else LCDInform("UID",BarcodeData); } } if(MenuSel==2) // scan RFID tag { CLS(); LCDWriteStrAt(1,6,"SCAN RFID TAG"); if (ReadRFIDUID()) // get UID { LCDInform("UID",uid.SerialNo); ReadRFIDBlock(1); } } if(MenuSel==3) // setup menu { SetupMenu(); } if(MenuSel==4) // power off { PWR_HOLD(0); // remove power to CPU - if on battery power this will turn off power to CPU and effectively end the program here! CLS(); if(ReadFloatAt(0,8,500,7)) LCDInform("Number was",KeypadData); } } }
void medit_disp_menu(struct descriptor_data *d) { int base = calc_karma(NULL, MOB); CLS(CH); send_to_char(CH, "Mob number: %s%d%s\r\n", CCCYN(CH, C_CMP), d->edit_number, CCNRM(CH, C_CMP)); send_to_char(CH, "1) Keywords: %s%s%s\r\n", CCCYN(CH, C_CMP), MOB->player.physical_text.keywords, CCNRM(CH, C_CMP)); send_to_char(CH, "2) Name: %s%s%s\r\n", CCCYN(CH, C_CMP), MOB->player.physical_text.name, CCNRM(CH, C_CMP)); send_to_char(CH, "3) Room description:\r\n%s%s%s\r\n", CCCYN(CH, C_CMP), MOB->player.physical_text.room_desc,CCNRM(CH, C_CMP)); send_to_char(CH, "4) Look description:\r\n%s\r\n", MOB->player.physical_text.look_desc); MOB_FLAGS(MOB).PrintBits(buf1, MAX_STRING_LENGTH, action_bits, MOB_MAX); send_to_char(CH, "5) Mob Flags: %s%s%s\r\n", CCCYN(CH, C_CMP), buf1, CCNRM(CH, C_CMP)); MOB->char_specials.saved.affected_by.PrintBits(buf1, MAX_STRING_LENGTH, affected_bits, AFF_MAX); send_to_char(CH, "6) Affected Flags: %s%s%s\r\n", CCCYN(CH, C_CMP), buf1, CCNRM(CH, C_CMP)); send_to_char(CH, "8) Avg. nuyen: %s%6d%s Avg. credstick value: %s%6d%s\r\n", CCCYN(CH, C_CMP), GET_NUYEN(MOB), CCNRM(CH, C_CMP), CCCYN(CH, C_CMP), GET_BANK(MOB), CCNRM(CH, C_CMP)); send_to_char(CH, "9) Bonus karma points: %s%d%s (Total karma points: %s%d%s)\r\n", CCCYN(CH, C_CMP), GET_KARMA(MOB), CCNRM(CH, C_CMP), CCCYN(CH, C_CMP), base, CCNRM(CH, C_CMP)); send_to_char(CH, "a) Attributes: B(%s%d%s), Q(%s%d%s), S(%s%d%s), C(%s%d%s), " "I(%s%d%s), W(%s%d%s), M(%s%d%s), R(%s%d%s)\r\n", CCCYN(CH, C_CMP), GET_REAL_BOD(MOB), CCNRM(CH, C_CMP), CCCYN(CH, C_CMP), GET_REAL_QUI(MOB), CCNRM(CH, C_CMP), CCCYN(CH, C_CMP), GET_REAL_STR(MOB), CCNRM(CH, C_CMP), CCCYN(CH, C_CMP), GET_REAL_CHA(MOB), CCNRM(CH, C_CMP), CCCYN(CH, C_CMP), GET_REAL_INT(MOB), CCNRM(CH, C_CMP), CCCYN(CH, C_CMP), GET_REAL_WIL(MOB), CCNRM(CH, C_CMP), CCCYN(CH, C_CMP), MOB->real_abils.mag / 100, CCNRM(CH, C_CMP), CCCYN(CH, C_CMP), GET_REAL_REA(MOB), CCNRM(CH, C_CMP)); send_to_char(CH, "b) Level: %s%d%s\r\n", CCCYN(CH, C_CMP), GET_LEVEL(MOB), CCNRM(CH, C_CMP)); send_to_char(CH, "c) Ballistic: %s%d%s, ", CCCYN(CH, C_CMP), GET_BALLISTIC(MOB), CCNRM(CH, C_CMP)); send_to_char(CH, "d) Impact: %s%d%s\r\n", CCCYN(CH, C_CMP), GET_IMPACT(MOB), CCNRM(CH, C_CMP)); send_to_char(CH, "e) Max physical points: %s%d%s, f) Max mental points: %s%d%s\r\n", CCCYN(CH, C_CMP), (int)(GET_MAX_PHYSICAL(MOB) / 100), CCNRM(CH, C_CMP), CCCYN(CH, C_CMP), (int)(GET_MAX_MENTAL(MOB) / 100), CCNRM(CH, C_CMP)); sprinttype(GET_POS(MOB), position_types, buf1); send_to_char(CH, "g) Position: %s%s%s, ", CCCYN(CH, C_CMP), buf1, CCNRM(CH, C_CMP)); sprinttype(GET_DEFAULT_POS(MOB), position_types, buf1); send_to_char(CH, "h) Default Position: %s%s%s\r\n", CCCYN(CH, C_CMP), buf1, CCNRM(CH, C_CMP)); sprinttype(GET_SEX(MOB), genders, buf1); // strcpy(buf1, genders[GET_SEX(d->edit_mob)]); send_to_char(CH, "i) Gender: %s%s%s, ", CCCYN(CH, C_CMP), buf1, CCNRM(CH, C_CMP)); send_to_char(CH, "j) Weight: %s%d%s, ", CCCYN(CH, C_CMP), GET_WEIGHT(MOB), CCNRM(CH, C_CMP)); send_to_char(CH, "k) Height: %s%d%s\r\n", CCCYN(CH, C_CMP), GET_HEIGHT(MOB), CCNRM(CH, C_CMP)); sprinttype(GET_RACE(MOB), npc_classes, buf1); send_to_char(CH, "l) Mob class: %s%s%s\r\n", CCCYN(CH, C_CMP), buf1, CCNRM(CH, C_CMP)); // gotta subtract TYPE_HIT to make it work properly sprinttype(!(MOB->mob_specials.attack_type) ? 0 : (MOB->mob_specials.attack_type - TYPE_HIT), attack_types, buf1); send_to_char(CH, "m) Attack Type: %s%s%s\r\n", CCCYN(CH, C_CMP), buf1, CCNRM(CH, C_CMP)); send_to_char("n) Skill menu.\r\n", CH); send_to_char(CH, "o) Arrive text: ^c%s^n, p) Leave text: ^c%s^n\r\n", MOB->mob_specials.arrive, MOB->mob_specials.leave); send_to_char("q) Quit and save\r\n", CH); send_to_char("x) Exit and abort\r\n", CH); send_to_char("Enter your choice:\r\n", CH); d->edit_mode = MEDIT_MAIN_MENU; }
void app_hit10() { // 10秒あてゲーム for (;;) { playMML("L8ER8EG16E16"); ux_btn(); for (;;) { FILL("afeaaa0067252577"); // title FLUSH(); if (ux_btn()) break; } playMML("C"); FILL(PTN_3); FLUSH(); WAIT(1000); playMML("C"); FILL(PTN_2); FLUSH(); WAIT(1000); playMML("C"); FILL(PTN_1); FLUSH(); WAIT(1000); playMML("G2"); FILL(PTN_GO); FLUSH(); WAIT(1000); CLS(1); systick = 0; int cnt = 0; int bkbtn = 0; for (;;) { int btn = ux_btn(); if (btn && !bkbtn) { playMML("A4"); CLS(0); break; } bkbtn = btn; setMatrix2(buf); wait(10); } unsigned int score = (10 * 100000 - systick) / 1000; if (score < 0) score = -score; playMML("L8CEG"); FILL("00c9aaacacaaaa69"); // ok xprintf("%d\n", systick); xprintf("%d\n", score); /* for (int i = 0;; i++) { int n = time % 10; time /= 10; if (time == 0) break; FILL(PTN_NUM[n]); FLUSH(); WAIT(500); } */ FILL(PTN_NUM[score / 10]); PSET(6, 6); FLUSH(); WAIT(1000); FILL(PTN_NUM[score % 10]); FLUSH(); WAIT(1000); FLUSH(); WAIT(1000); } }