int snapper_culc(INPUT *input) { int res, i, k = 0; SNAPPER snap[S_MAX]; for (i = 0; i < S_MAX; i++) { snap[i].OUT = 0; snap[i].STATE = 0; } // Fist snapper is as Power supply. State is Dummy snap[0].OUT = HIGH; for (i = 0; i < input->k; i++) { D_OUT("Snaping!! %d times\n", i); for (k = input->n; k >= 1; k--) { if (snap[k-1].OUT == HIGH) { snap[k].STATE = 1 - snap[k].STATE; } } for (k = 1; k <= input->n; k++) { if (snap[k].STATE == ON && snap[k-1].OUT == HIGH) { snap[k].OUT = HIGH; } else { snap[k].OUT = LOW; } D_OUT("snap[%d] state[%d] out[%d]\n", k, snap[k].STATE, snap[k].OUT); } } res = snap[input->n].OUT; return res; }
int get_token_got_equal(token* save_loc, FILE* strin) { int cc = 0; while (isspace(cc = getc(strin))); D_OUT("Got '=', checking next symbol..."); if (cc == '=') { int drop = CMP_E; D_OUT("Found '==', saving token..."); return token_write(save_loc, TKN_COMP, (void*)(&drop)); } D_OUT1("Found [%c], it's assignition", cc); ungetc(cc, strin); int drop = ASSGN; return token_write(save_loc, TKN_ASSGN, (void*)(&drop)); }
DarkSouls::DarkSouls() { if (fetchProcess(L"DARKSOULS.exe", L"DARK SOULS")) { D_OUT("Process found and opened."); fetchBasePointer(); } else { R_ERR("No process has been found or failed to open the handle."); } initWrappers(); }
Q_INVOKABLE void IObject::setPropertyInitializationValue( std::string propertyName, QVariant value ) { std::unordered_map<std::string, QVariant>::iterator it = _propertyInitializationValue.find(propertyName); if( it == _propertyInitializationValue.end()) { _propertyInitializationValue.insert(std::pair<std::string, QVariant>(propertyName, value)); } else { D_OUT("property initialization value already set. Overriding old value"); it->second = value; } }
int token_construct(token** my_token) { D_OUT("Token constructing...\n"); VERIFY(my_token == NULL, TOKEN_BAD, "TOKEN_CONSTRUCT(): token pointer is NULL"); (*my_token) = (token*) calloc(1, sizeof(token)); assert(*my_token); (*my_token) -> type = 0; (*my_token) -> value = NULL; D_OUT1("done -> %08x\n", *my_token); printf(">>>[%08x]\n", *my_token); return TOKEN_OK; }
int get_token_got_op(token* save_loc, FILE* strin, int c) { assert(save_loc); assert(strin); int drop = 0; int cc = 0; while (isspace(cc = getc(strin))); D_OUT1("Checking next symbol, it's [%c]", cc); if (cc == '=') { D_OUT("It's assignition"); switch (c) { case '+': drop = ASSGN_ADD; return token_write(save_loc, TKN_ASSGN, (void*)(&drop)); break; case '-': drop = ASSGN_SUB; return token_write(save_loc, TKN_ASSGN, (void*)(&drop)); break; case '*': drop = ASSGN_MUL; return token_write(save_loc, TKN_ASSGN, (void*)(&drop)); break; case '/': drop = ASSGN_DIV; return token_write(save_loc, TKN_ASSGN, (void*)(&drop)); break; default: assert(("Unexpected happened", 0)); } } else { ungetc(cc, strin); D_OUT("It's not assignition"); return token_write(save_loc, TKN_OP, (void*)(&c)); } return TOKEN_OK; }
int token_destruct(token* my_token) { D_OUT1("Token [%08x] destructing...\n", my_token); VERIFY( my_token == NULL, TOKEN_BAD, "TOKEN_DESTRUCT(): argumented pointer is null"); my_token -> type = POISON; if (my_token -> value != NULL) { DBG_FREE fprintf(stdout, "[%08x] token.cpp, token_destruct, my_token -> value\n", my_token -> value); free(my_token -> value); } my_token -> value = NULL; DBG_FREE fprintf(stdout, "[%08x] token.cpp, token_destruct, my_token\n", my_token); free(my_token); my_token = NULL; D_OUT("done\n"); return TOKEN_OK; }
void DS2Player::getPlayerPointer() { _ds->readMemory<void*>((char*)_ds->getBaseAddress() + 0x16829A0, &_playerPointer); _ds->readMemory<void*>((char*)_playerPointer+0x20, &_playerPointer); D_OUT("Player pointer is " << _playerPointer << "."); }
int tokenize_stream(FILE* strin, token** token_stream, int* token_count) { D_OUT(">>>>>>>>>>>>>>>>>TOKENIZE START<<<<<<<<<<<<<<<<<<<<<<<"); PRECOND(strin == NULL, CPLR_TOKENIZE_FAULT, "TOKENIZE_STREAM(): Argumented file stream is NULL"); PRECOND(token_stream == NULL, CPLR_TOKENIZE_FAULT, "TOKENIZE_STREAM(): argumented token pointer is NULL"); token* temp_token = (token*) calloc(1, sizeof(token)); assert(temp_token); int ret = token_construct(&temp_token); VERIFY(ret != TOKEN_OK, CPLR_TOKENIZE_FAULT, "TOKENIZE_STREAM(): Temporary token construction fault"); ret = get_token(temp_token, strin); VERIFY(ret != TOKEN_OK, CPLR_TOKENIZE_FAULT, "TOKENIZE_STREAM(): get_token() fail"); int i = 1; while (temp_token -> type != TKN_END) { ret = get_token(temp_token, strin); VERIFY(ret != TOKEN_OK, CPLR_TOKENIZE_FAULT, "TOKENIZE_STREAM(): get_token() fail"); i++; } ret = token_destruct(temp_token); temp_token = NULL; assert(fseek(strin, 0, SEEK_SET) == 0); char temp_word[MAXLINE] = {}; VERIFY(ret != TOKEN_OK, CPLR_TOKENIZE_FAULT, "TOKENIZE_STREAM(): token_destruct() fail"); //ret = fscanf(strin, "%s", temp_word); //assert(ret); (*token_stream) = (token*) calloc(i, sizeof(token)); assert(*token_stream); //printf("[%08x]", (*token_stream)); int i_copy = i; //Verifying, that we're going to get the same ammount of tokens i = 0; while ((*token_stream + i - 1) -> type != TKN_END || i == 0) { ret = get_token((*token_stream + i), strin); print_token(*token_stream + i, stdout); VERIFY(ret != TOKEN_OK, CPLR_TOKENIZE_FAULT, "TOKENIZE_STREAM(): get_token() fail"); i++; } VERIFY2(i != i_copy, CPLR_TOKENIZE_FAULT, "TOKENIZE_STREAM(): i and i_copy don't match, i = %d, i_copy = %d", i , i_copy); D_OUT("LIST OF SCANNED TOKENS BEGIN>>>>>>>>>>>>>>>>>>>>>>\n"); for (i = 0; i < i_copy; i++) { fprintf(strlog, "%d", i); print_token(*token_stream + i, strlog); } D_OUT("LIST OF SCANNED TOKENS FINISH<<<<<<<<<<<<<<<<<<<<<<\n"); D_OUT1(">>>>>>>>>>>>>>>>>TOKENIZE FINISHED, GOT %d TOKENS<<<<<<<<<<<<<<<<<", i); *token_count = i; printf("[%08x]", (*token_stream)); return CPLR_OK; }
int token_write(token* my_token, int type, const void* source) { D_OUT2("Writing to [%08x] token, type = %d\n", my_token, type); int c = 0; int str_len = 0; double temp = 0; switch (type) { case TKN_OP: c = *((int*)source); D_OUT1("Got [%c]", c); VERIFY1((c != '+' && c != '-' && c != '*' && c != '/'), TOKEN_BAD, "TOKEN_WRITE(): Expected +-//*, got [%c]", c); TOKEN_BURN(TKN_OP, int); break; case TKN_COMP: c = *((int*)source); D_OUT1("Got [%d] code", c); VERIFY1( (!(c >= CMP_B && c <= CMP_NE)), TOKEN_BAD, "TOKEN_WRITE(): got [%d]", c); TOKEN_BURN(TKN_COMP, int); break; case TKN_ID: str_len = strlen((char*)source); VERIFY1(str_len > MAXLINE, TOKEN_BAD, "TOKEN_WRITE(): got too big identificator \n%50s", (char*)source); D_OUT1("Got [%s]", (char*)source); VERIFY1(token_word_is_valid((char*)source) == 0, TOKEN_BAD, "TOKEN_WRITE(): got invalid identificator only [-_A-Za-z] allowed, '_' can't be first, got [%s]", (char*)source); VERIFY1(token_word_is_key ((char*)source) != 0, TOKEN_BAD, "TOKEN_WRITE(): inputted identificator is key word, got [%s]", (char*)source); my_token -> type = type; my_token -> value = calloc(str_len + 2, sizeof(char)); assert(my_token -> value); strcpy((char*)my_token -> value, (char*)source); break; case TKN_NUM: D_OUT1("Got [%lg]", *((double*)source)); TOKEN_BURN(TKN_NUM, double); break; case TKN_SEP: c = *((char*)(source)); D_OUT1("Got [%c]", c); VERIFY1((c!= ',' && c != ';' && c != '(' && c != ')' && c != '{' && c != '}'), TOKEN_BAD, "TOKEN_WRITE(): Expected ;{}(), got [%c]", c); TOKEN_BURN(TKN_SEP, int); break; case TKN_ASSGN: c = *((int*)source); D_OUT1("Got [%d] code", c); VERIFY1( (!(ASSGN <= c && c <= ASSGN_DIV)), TOKEN_BAD, "TOKEN_WRITE(): input assign code is wrong [%d]", c); TOKEN_BURN(TKN_ASSGN, int); break; case TKN_STR: str_len = strlen((char*)source); VERIFY1(str_len > MAXLINE, TOKEN_BAD, "TOKEN_WRITE(): got too big string \n%50s", (char*)source); D_OUT1("Got [%s]", (char*)source); my_token -> type = type; my_token -> value = calloc(str_len + 2, sizeof(char)); assert(my_token -> value); strcpy((char*)my_token -> value, (char*)source); break; case TKN_END: c = *((int*)source); D_OUT1("Got [%d]", c); VERIFY1(c != 0, TOKEN_BAD, "TOKEN_WRITE(): strange end [%c]", *(char*)source); TOKEN_BURN(TKN_END, int); break; case TKN_KEY: c = *((int*)source); D_OUT1("Got [%d] code", c);my_token -> type = type; VERIFY1( (!(WORD_if <= c && c <= WORD_print_val)), TOKEN_BAD, "TOKEN_WRITE(): input key code is wrong [%d]", c); TOKEN_BURN(TKN_KEY, int); break; default: VERIFY1(true, TOKEN_BAD, "Invalid type of token type, got [%d]", type); break; } D_OUT("Token written successfully"); return TOKEN_OK; }
GameLua::GameLua(lua_State* l) { D_OUT("Do not manually construct DS2 instances. (It just won't work)"); }