void Sudoku::ReadIn() { //讀檔 for(int i=0; i<SIZE; i++) for(int j=0; j<SIZE; j++) { scanf("%d",&map[i][j]); } //存空格資訊 for(int i=0; i<SIZE; i++) for(int j=0; j<SIZE; j++) { if(map[i][j]==0) save_block(i,j); } // /*if(block_num>64) { printf("2"); exit(1); }*/ /*for(int i = 0 ;i<block_num ;i++) for(int j= 0;j<9 ;j++) if(block[i].num[j]!=0) printf("第%d格可能 = %d\n",i,j+1);*/ }
void SpinBlock::Save (std::ofstream &ofs) { dmrginp.diskio->start(); boost::archive::binary_oarchive save_block(ofs); save_block << *this; dmrginp.diskio->stop(); }
void parse_games(FILE * file, uint32_t start) { uint32_t count = 0; fseek(file, start, SEEK_SET); fread(&count, sizeof(count), 1, file); printf("\tCount = %d\n\n", count); count_games = count; int i; for (i = 0; i < (count); i++) { uint32_t start_script; uint32_t next_script; fseek(file, (start + 4) + 4 * i, SEEK_SET); fread(&start_script, sizeof(start_script), 1, file); if (i < (count - 1)) { fread(&next_script, sizeof(next_script), 1, file); } else { next_script = end_game; } char name[2024]; snprintf(name, 2020, "game%02d", i); save_block(name, start_script, next_script - start_script); printf("Game Header (%2d, 0x%X)\n--------------------------\n", i, start_script); parse_game(file, i, start_script, next_script); } }
void TextMan::draw_window(int x1, int y1, int x2, int y2) { game.window.active = true; game.window.x1 = x1; game.window.y1 = y1; game.window.x2 = x2; game.window.y2 = y2; game.window.buffer = (uint8 *) malloc((x2 - x1 + 1) * (y2 - y1 + 1)); debugC(4, kDebugLevelText, "x1=%d, y1=%d, x2=%d, y2=%d", x1, y1, x2, y2); save_block(x1, y1, x2, y2, game.window.buffer); draw_box(x1, y1, x2, y2, MSG_BOX_COLOUR, MSG_BOX_LINE, 2); }
void SpinBlock::Save (std::ofstream &ofs) { boost::archive::binary_oarchive save_block(ofs); save_block << *this; }
int residos_exec(char *target) { FILE *binfile; /* Read in bin file */ long filesize; long readlen; long table_start; long table_end; long package_id; if ( help ) { return -1; } if ( binname == NULL || crtfile == NULL ) { return -1; } if ( outfile == NULL ) { outfile = binname; } table_start = parameter_search(crtfile,".map","package_call_table"); table_end = parameter_search(crtfile,".map","package_call_end"); package_id = parameter_search(crtfile,".map","residos_package_id"); if ( table_start == -1 ) { myexit("Could not find parameter package_call_table (not a Residos package compile?)\n",1); } if ( table_end == -1 ) { myexit("Could not find parameter package_call_end (not a Residos package compile?)\n",1); } if ( package_id == -1 ) { myexit("Could not find parameter residos_package_id (not a Residos package compile?)\n",1); } if ( ( binfile=fopen(binname, "rb") ) == NULL ) { myexit("Can't open binary file\n",1); } if (fseek(binfile, 0, SEEK_END)) { fclose(binfile); myexit("Couldn't determine the size of the file\n",1); } filesize=ftell(binfile); if (filesize > 0x3fc0 ) { fclose(binfile); myexit("The source binary is over 16,320 bytes in length.\n",1); } if ( ( memory = calloc(16384, 1) ) == NULL ) { myexit("Can't allocate memory\n",1); } /* Basic header size is 16: defm "ZXPKG" ; magic identifier defb TESTPKG_CAPS ; capabilities bitmask defb TESTPKG_ID ; package ID defw TESTPKG_MIN_RESIDOS ; minimum ResiDOS version required defb TESTPKG_MAX_CALL_ID ; highest call ID provided defw TESTPKG_CALL_TABLE ; address of package call table defb 0 ; Hook code terminator defb 0 ; channel name terminator defb 0 ; end of syntax table defb 0 ; end of function table // Binary blob */ strcpy(memory,"ZXPKG"); memory[5] = 0; /* Capabilities */ memory[6] = package_id; memory[7] = 0x23; /* Minimum Residos version is v2.23 */ memory[8] = 0x02; memory[9] = (table_end - table_start) / 2; memory[10] = table_start % 256; memory[11] = table_start / 256; memory[12] = 0; /* Hook code terminator */ memory[13] = 0; /* Channel name terminator */ memory[14] = 0; /* Syntax table terminator */ memory[15] = 0; /* Function table terminator */ fseek(binfile, 0, SEEK_SET); readlen = fread(memory + HEADER_SIZE,1,filesize,binfile); if ( filesize != readlen ) { fclose(binfile); myexit("Couldn't read in binary file\n",1); } fclose(binfile); save_block(filesize + HEADER_SIZE,outfile,".com"); myexit(0,0); return 0; }