// initialize a custom table, given the no. of absolute scale and table size // the customTable array is (2*absScale+1) groups // and each group has (tableSize) bytes of remapping entries void ColorTable::init(int absScale, int tableSize, WORD *customTable) { deinit(); abs_scale = absScale; table_size = table_size; remap_table = (WORD *)mem_add(table_size * (2*absScale+1) * sizeof(WORD) ); memcpy(remap_table, customTable, tableSize * (2*absScale+1) * sizeof(WORD) ); }
void RegionArray::init_region_stat() { //------ count the no. of regions with statistic -----// // // Only include land regions that are big enough. // //----------------------------------------------------// region_stat_count=0; RegionInfo* regionInfo; int i; for( i=1 ; i<=region_info_count ; i++ ) { regionInfo = region_array[i]; if( regionInfo->region_size >= MIN_STAT_REGION_SIZE && // regions are sorted by their sizes regionInfo->region_type == REGION_LAND ) { region_stat_count++; } } err_when( region_stat_count==0 ); //-------- init the region_stat_array ---------// region_stat_array = (RegionStat*) mem_add( region_stat_count * sizeof(RegionStat) ); memset( region_stat_array, 0, region_stat_count * sizeof(RegionStat) ); int regionStatId=1; for( i=1 ; i<=region_info_count ; i++ ) { regionInfo = get_sorted_region(i); if( regionInfo->region_type != REGION_LAND ) continue; err_when( regionStatId<1 || regionStatId>region_stat_count ); region_stat_array[regionStatId-1].region_id = regionInfo->region_id; regionInfo->region_stat_id = regionStatId; if( ++regionStatId > region_stat_count ) break; } err_when( regionStatId != region_stat_count+1 ); // no all regionStat get their region_id for( i=0 ; i<region_stat_count ; i++ ) region_stat_array[i].init(); update_region_stat(); }
// ------------ begin of function RockRes::load_info -----------// void RockRes::load_info() { RockRec *rockRec; RockInfo *rockInfo; int i; //---- read in rock count and initialize rock info array ----// String rockDbName; rockDbName = DIR_RES; rockDbName += "ROCK"; rockDbName += config.terrain_set; rockDbName += ".RES"; Database rockDbObj(rockDbName, 1); //Database *dbRock = game_set.open_db(ROCK_DB); // only one database can be opened at a time, so we read ROCK.DBF first Database *dbRock = &rockDbObj; rock_info_count = (short) dbRock->rec_count(); rock_info_array = (RockInfo*) mem_add( sizeof(RockInfo)*rock_info_count ); memset( rock_info_array, 0, sizeof(RockInfo) * rock_info_count ); //---------- read in ROCK.DBF ---------// for( i=0 ; i<rock_info_count ; i++ ) { rockRec = (RockRec*) dbRock->read(i+1); rockInfo = rock_info_array+i; misc.rtrim_fld( rockInfo->rock_name, rockRec->rock_id, rockRec->ROCKID_LEN ); rockInfo->rock_type = rockRec->rock_type; rockInfo->loc_width = misc.atoi(rockRec->loc_width, rockRec->LOC_LEN); rockInfo->loc_height = misc.atoi(rockRec->loc_height, rockRec->LOC_LEN); if( rockRec->terrain_1 == 0 || rockRec->terrain_1 == ' ') rockInfo->terrain_1 = 0; else rockInfo->terrain_1 = TerrainRes::terrain_code(rockRec->terrain_1); if( rockRec->terrain_2 == 0 || rockRec->terrain_2 == ' ') rockInfo->terrain_2 = 0; else rockInfo->terrain_2 = TerrainRes::terrain_code(rockRec->terrain_2); rockInfo->first_bitmap_recno = misc.atoi(rockRec->first_bitmap_recno, rockRec->RECNO_LEN); rockInfo->max_frame = misc.atoi(rockRec->max_frame, rockRec->MAX_FRAME_LEN); // if( rockRec->pal_file_name[0] == ' ' || rockRec->pal_file_name[0] == '\0' ) // { rockInfo->palw_ptr = NULL; // } // else // { // long paletteOffset; // memcpy( &paletteOffset, rockRec->pal_offset, sizeof(long) ); // rockInfo->palw_ptr = res_pal.read_imported_pal(paletteOffset); // } } }
// --------- begin of function SERes::load_info ----------// void SERes::load_info() { SERec *seRec; SEInfo *seInfo; int i; Database *dbSE = game_set.open_db(SERES_DB); se_array_count = dbSE->rec_count(); se_array = (SEInfo *)mem_add(sizeof(SEInfo) * se_array_count); memset( se_array, 0, sizeof(SEInfo) * se_array_count ); for( i = 0; i < se_array_count; ++i ) { seRec = (SERec *) dbSE->read(i+1); seInfo = se_array+i; // ------- copy subject ---------// seInfo->subject_type = seRec->subject_type; seInfo->subject_id = m.atoi(seRec->subject_id, seRec->RECNO_LEN); // -------- copy verb ---------// memcpy( seInfo->action, seRec->action, seRec->VERB_LEN ); seInfo->action[seInfo->VERB_LEN] = '\0'; m.rtrim( seInfo->action ); // --------- copy object ---------// if( seRec->object_type == ' ' || seRec->object_type == '\0') { seInfo->object_type = 0; seInfo->object_id = 0; } else if( seRec->object_type == '*' ) { seInfo->object_type = -1; // all object seInfo->object_id = -1; } else { seInfo->object_type = seRec->object_type; if( seRec->object_id[0] != '*' ) seInfo->object_id = m.atoi(seRec->object_id, seRec->RECNO_LEN); else seInfo->object_id = -1; // all of the objectType } // -------- copy out frame ---------// seInfo->out_frame = m.atoi(seRec->out_frame, seRec->OUT_FRAME_LEN); err_when(seInfo->out_frame <= 0); // -------- copy file name --------// memcpy(seInfo->file_name, seRec->file_name, seRec->FILE_NAME_LEN); seInfo->file_name[seInfo->FILE_NAME_LEN] = '\0'; m.rtrim(seInfo->file_name); seInfo->effect_id = 0; } }
//-------- Begin of function Info::disp_panel --------// // void Info::disp_panel() { image_interface.put_to_buf( &vga_back, "MAINSCR" ); //------ keep a copy of bitmap of the panel texture -----// if( !info_background_bitmap ) info_background_bitmap = mem_add( 4 + (INFO_X2-INFO_X1+1)*(INFO_Y2-INFO_Y1+1) ); vga_back.read_bitmap( INFO_X1, INFO_Y1, INFO_X2, INFO_Y2, info_background_bitmap ); }
Jpeg::Jpeg() : cinfo( (jpeg_decompress_struct *) mem_add(sizeof(jpeg_decompress_struct))), jerr((jpeg_error_mgr *) mem_add(sizeof(jpeg_error_mgr))), error_flag(0) { memset( cinfo, 0, sizeof(*cinfo) ); memset( jerr, 0, sizeof(*jerr) ); // We set up the normal JPEG error routines, then override our own routine cinfo->err = jpeg_std_error(jerr); jerr->error_exit = jpeg_error_exit; jerr->output_message = jpeg_output_message; jerr->emit_message = jpeg_emit_message; // Step 1: allocate and initialize JPEG decompression object // Now we can initialize the JPEG decompression object jpeg_create_decompress(cinfo); }
void LargeText::init(int x,int y,char* str) { text_x1=x; text_y1=y; pointer_flag=CHAR_TYPE; char_data_ptr=str; int i; for(i=0;str[i]!=0;i++); disp_string=mem_add(sizeof(char)*i); font_type=&font_charts; }
// ----- begin of function ScenarioEditor::init_monster_mode ------// // void ScenarioEditor::init_monster_mode() { unit_or_struct = 0; // 0 = unit, 1 = structure brush_player_recno = 1; // -------- filter unit_id to display -------// monster_race_filter = 0; // all race monster_unit_id_count = 0; monster_unit_id_browse_recno = 1; monster_unit_id_array = (short *)mem_add( unit_res.unit_info_count * sizeof(short) ); collect_monster_unit(monster_race_filter); // ------- filter firm_build_id to display ------ // monster_firm_group_count = 0; monster_firm_group_browse_recno = 1; monster_firm_group_array = (short *) mem_add( firm_res.firm_group_count * sizeof(short) ); collect_monster_firm(monster_race_filter); spinner_race_group.vbrowse_enable_flag = 0; }
DynArray::DynArray(int eleSize,int blockNum) { ele_size = eleSize; block_num = blockNum; body_buf = mem_add( ele_size*block_num ); cur_pos=0; last_ele=0; ele_num= block_num; sort_offset = -1; }
//------- Begin of function FirmDieRes::load_firm_bitmap -------// // // Read in information of FDBITMAP.DBF into memory array // void FirmDieRes::load_bitmap_info() { FirmBitmapRec *firmBitmapRec; FirmDieBitmap *firmBitmap; int i; // long bitmapOffset; Database *dbFirmBitmap = game_set.open_db(FIRM_BITMAP_DB); firm_bitmap_count = (short) dbFirmBitmap->rec_count(); firm_bitmap_array = (FirmDieBitmap*) mem_add( sizeof(FirmDieBitmap)*firm_bitmap_count ); //------ read in firm bitmap info array -------// memset( firm_bitmap_array, 0, sizeof(FirmDieBitmap) * firm_bitmap_count ); for( i=0 ; i<firm_bitmap_count ; i++ ) { firmBitmapRec = (FirmBitmapRec*) dbFirmBitmap->read(i+1); firmBitmap = firm_bitmap_array+i; memcpy( &firmBitmap->bitmap_ptr, firmBitmapRec->bitmap_ptr, sizeof(uint32_t) ); // memcpy( &bitmapOffset, firmBitmapRec->bitmap_ptr, sizeof(long) ); // firmBitmap->bitmap_ptr = NULL; firmBitmap->width = misc.atoi( firmBitmapRec->width, firmBitmapRec->LOC_LEN ); firmBitmap->height = misc.atoi( firmBitmapRec->height, firmBitmapRec->LOC_LEN ); firmBitmap->offset_x = misc.atoi( firmBitmapRec->offset_x, firmBitmapRec->OFFSET_LEN ); firmBitmap->offset_y = misc.atoi( firmBitmapRec->offset_y, firmBitmapRec->OFFSET_LEN ); firmBitmap->loc_width = misc.atoi( firmBitmapRec->loc_width , firmBitmapRec->LOC_LEN ); firmBitmap->loc_height = misc.atoi( firmBitmapRec->loc_height, firmBitmapRec->LOC_LEN ); firmBitmap->delay = misc.atoi( firmBitmapRec->delay, firmBitmapRec->DELAY_LEN ); firmBitmap->ani_part = misc.atoi( firmBitmapRec->ani_part, firmBitmapRec->FRAME_ID_LEN ); // firmBitmap->random_flag = firmBitmapRec->random_flag[0] == 'R' ? 1 : 0; firmBitmap->random_flag = firmBitmapRec->random_flag[0]; firmBitmap->display_layer = firmBitmapRec->layer - '0'; #ifdef DEBUG if( firmBitmap->loc_width >= 4 || firmBitmap->loc_height >= 4 ) { // break point here int x = 0; } #endif // modify offset_x/y for 7k2 firmBitmap->offset_x += -firmBitmap->loc_width*LOCATE_WIDTH/2 - (-firmBitmap->loc_width*ZOOM_LOC_X_WIDTH/2 + -firmBitmap->loc_height*ZOOM_LOC_Y_WIDTH/2); firmBitmap->offset_y += -firmBitmap->loc_height*LOCATE_HEIGHT/2 - (-firmBitmap->loc_width*ZOOM_LOC_X_HEIGHT/2 + -firmBitmap->loc_height*ZOOM_LOC_Y_HEIGHT/2); } }
//--------- Begin of function FirmBase::disp_god_info ---------// // void FirmBase::disp_god_info(int dispY1, int refreshFlag) { //-------- display the icon of the mythical creature -------// int x=INFO_X1, y=INFO_Y1; if( refreshFlag == INFO_REPAINT ) { invoked_effect_text[0] = '\0'; // clear text not to show invoked effect text } String str; short* hitPointBitmap =NULL; int ratio = (int)pray_points *40 / (int)MAX_PRAY_POINTS; int size = (int)pray_points *76 / (int)MAX_PRAY_POINTS; //106 x 35 --- 15 to 90 ie. 0 to 40 hitPointBitmap = (short *)mem_add( BitmapW::size(15 +size, 35) ); if (ratio <11) vga.active_buf->put_bitmap_trans( INFO_X1 +80 -13, INFO_Y1 +49 +48, image_spict.read("MTR_10")); else if (ratio <40) vga.active_buf->put_bitmap_trans( INFO_X1 +80 -13, INFO_Y1 +49 +48, image_spict.read("MTR_39")); else vga.active_buf->put_bitmap_trans( INFO_X1 +80 -13, INFO_Y1 +49 +48, image_spict.read("MTR_40")); vga.active_buf->read_bitmapW( INFO_X1 +80 -13, INFO_Y1 +49 +48, INFO_X1 +94 +size -13, INFO_Y1 +80 +48, hitPointBitmap ); vga.active_buf->put_bitmap_trans( INFO_X1 +80 -13, INFO_Y1 +49 +48, image_spict.read("MTR_00")); vga.active_buf->put_bitmapW( INFO_X1 +80 -13, INFO_Y1 +49 +48, hitPointBitmap ); mem_del( hitPointBitmap ); /* str = (int)pray_points; str += " / "; str += (int)MAX_PRAY_POINTS; font_snds.center_put( INFO_X1 +80 -13, INFO_Y1 +46 +48, INFO_X1 +187 -13, INFO_Y1 +63 +48, str ); */ const char *baseDesc; if( should_show_info() && invoked_effect_text[0] ) { baseDesc = invoked_effect_text; } else { baseDesc = text_firm.str_base_prayer_effect( god_id ); } font_snds.center_put_paragraph( INFO_X1+33, INFO_Y1, INFO_X2-22, INFO_Y1+115, baseDesc, -2, 0, 0 ); }
//-------- Begin of function Database::open --------// //! //! Database::open( char* fileName ) //! //! <char*> fileName = the name of the DBF file to be opened //! [int] bufferAll = read the whole database into memory or not //! (default : 0) //! //! return 1 : opened successfully //! 0 : opening failure //! void Database::open( char* fileName, int bufferAll ) { close(); // if there is a opened file attached to current database, close it first file_open(fileName); file_read( &dbf_header, sizeof(DbfHeader) ); //..........................................// if( bufferAll ) { // read the whole database into memory or not dbf_buf = mem_add( dbf_header.rec_size * dbf_header.last_rec ); file_seek( 1 + dbf_header.data_offset ); file_read( dbf_buf, dbf_header.rec_size*dbf_header.last_rec ); file_close(); dbf_buf_allocated = 1; // we allocated the buffer } else rec_buf = mem_add( dbf_header.rec_size ); cur_recno = 1; }
// ---------- begin of function ColorTable::ColorTable ----------// ColorTable::ColorTable(const ColorTable& ct) : abs_scale(ct.abs_scale), table_size(ct.table_size) { if( ct.remap_table ) { remap_table = (WORD *)mem_add(table_size * (2*abs_scale+1) * sizeof(WORD) ); memcpy(remap_table, ct.remap_table, table_size * (2*abs_scale+1) * sizeof(WORD) ); } else { remap_table = NULL; } }
// ------------ begin of function RockRes::load_bitmap_info -----------// void RockRes::load_bitmap_info() { RockBitmapRec *rockBitmapRec; RockBitmapInfo *rockBitmapInfo; int i; //---- read in rock count and initialize rock info array ----// String rockDbName; rockDbName = DIR_RES; rockDbName += "ROCKBMP"; rockDbName += config.terrain_set; rockDbName += ".RES"; Database rockDbObj(rockDbName, 1); // Database *dbRock = game_set.open_db(ROCK_BITMAP_DB); // only one database can be opened at a time, so we read ROCK.DBF first Database *dbRock = &rockDbObj; rock_bitmap_count = (short) dbRock->rec_count(); rock_bitmap_array = (RockBitmapInfo*) mem_add( sizeof(RockBitmapInfo)*rock_bitmap_count ); memset( rock_bitmap_array, 0, sizeof(RockBitmapInfo) * rock_bitmap_count ); //---------- read in ROCKBMP.DBF ---------// for( i=0 ; i<rock_bitmap_count ; i++ ) { rockBitmapRec = (RockBitmapRec*) dbRock->read(i+1); rockBitmapInfo = rock_bitmap_array+i; rockBitmapInfo->frame = misc.atoi(rockBitmapRec->frame, rockBitmapRec->FRAME_NO_LEN); rockBitmapInfo->delay = misc.atoi(rockBitmapRec->delay, rockBitmapRec->DELAY_LEN); rockBitmapInfo->next_frame = misc.atoi(rockBitmapRec->next_frame, rockBitmapRec->FRAME_NO_LEN); rockBitmapInfo->alt_next = misc.atoi(rockBitmapRec->alt_next, rockBitmapRec->FRAME_NO_LEN); rockBitmapInfo->offset_x = misc.atoi(rockBitmapRec->offset_x, rockBitmapRec->OFFSET_LEN); rockBitmapInfo->offset_y = misc.atoi(rockBitmapRec->offset_y, rockBitmapRec->OFFSET_LEN); uint32_t bitmapOffset; memcpy( &bitmapOffset, rockBitmapRec->bitmap_ptr, sizeof(uint32_t) ); rockBitmapInfo->bitmap_ptr = res_bitmap.read_imported(bitmapOffset); // modify offset_x/y for 7k2 short width = misc.atoi(rockBitmapRec->loc_width, rockBitmapRec->LOC_LEN); short height = misc.atoi(rockBitmapRec->loc_height, rockBitmapRec->LOC_LEN); rockBitmapInfo->offset_x = rockBitmapInfo->offset_x + width*ZOOM_LOC_X_WIDTH/2 + height*ZOOM_LOC_Y_WIDTH/2 -width*LOCATE_WIDTH/2; rockBitmapInfo->offset_y = rockBitmapInfo->offset_y + width*ZOOM_LOC_X_HEIGHT/2 + height*ZOOM_LOC_Y_HEIGHT/2 -height*LOCATE_HEIGHT/2; } }
void FirmOffensive::disp_main_menu(int refreshFlag) { Firm::put_info(refreshFlag); button_cast.create( INFO_X1 +13, INFO_Y1 +259, 'A', "GBA-1" ); if( !should_show_info() ) return; vga.active_buf->put_bitmap( INFO_X1, INFO_Y1, image_gameif.read("BLDGBASE") ); // display delay if( cast_delay > 0 ) { short* hitPointBitmap =NULL; int ratio = cast_delay *40 / cast_delay_max; int size = cast_delay *76 / cast_delay_max; //106 x 35 --- 15 to 90 ie. 0 to 40 int offsetX = -35; int offsetY = -40; hitPointBitmap = (short *)mem_add( BitmapW::size(15 +size, 35) ); if (ratio <11) vga.active_buf->put_bitmap_trans( INFO_X1 +80 +20 +offsetX, INFO_Y1 +49 +offsetY, image_spict.read("MTR_10")); else if (ratio <40) vga.active_buf->put_bitmap_trans( INFO_X1 +80 +20 +offsetX, INFO_Y1 +49 +offsetY, image_spict.read("MTR_39")); else vga.active_buf->put_bitmap_trans( INFO_X1 +80 +20 +offsetX, INFO_Y1 +49 +offsetY, image_spict.read("MTR_40")); vga.active_buf->read_bitmapW( INFO_X1 +80 +20 +offsetX, INFO_Y1 +49 +offsetY, INFO_X1 +94 +20 +size +offsetX, INFO_Y1 +80 +offsetY, hitPointBitmap ); vga.active_buf->put_bitmap_trans( INFO_X1 +80 +20 +offsetX, INFO_Y1 +49 +offsetY, image_spict.read("MTR_00")); vga.active_buf->put_bitmapW( INFO_X1 +80 +20 +offsetX, INFO_Y1 +49 +offsetY, hitPointBitmap ); mem_del( hitPointBitmap ); } if( !is_own() ) return; char fileName[] = "GBA-1"; if (button_cast.enable_flag) fileName[4] = '1' + (char) (sys.frame_count%3); button_cast.update_bitmap( fileName ); button_cast.enable_flag = can_cast(magic_id_upper_limit); button_cast.paint(); }
//-------- Begin of function FileTxt::FileTxt ----------// // // Initialize this FileTxt structure with a file stream. // // <File*> filePtr = pointer to a file class for reading in the text // <int> dataSize = size of the data. // FileTxt::FileTxt(File* filePtr, int dataSize) { //-----------------------------------// file_length = dataSize; data_buf = mem_add( file_length+1 ); data_buf[file_length] = CHAR_EOF; data_ptr = data_buf; //-----------------------------------// filePtr->file_read( data_buf, file_length ); }
// -------- begin of function ColorTable::read_file ---------// int ColorTable::read_file(File *f) { deinit(); abs_scale = f->file_get_long(); table_size = f->file_get_long(); remap_table = (WORD *)mem_add(table_size * (2*abs_scale+1) * remap_table[0] ); if(! f->file_read(remap_table, table_size * (2*abs_scale+1) * remap_table[0]) ) { mem_del(remap_table); remap_table = 0; return 0; } return 1; }
Blob2D::Blob2D( Blob2D &b ) { left_edge = b.left_edge; top_edge = b.top_edge; width = b.width; height = b.height; alloc_size = b.alloc_size; err_when( width < 0 ); err_when( height < 0 ); ptr = (Bitmap *)mem_add(alloc_size); memcpy(ptr, b.ptr, alloc_size); // ((Bitmap *)ptr)->init(width, height); }
void ExploredMask::init() { // ------- read into exploration remap bitmap ------// String str; long fileSize; str = DIR_RES; str += REMAP_FILENAME; File remapFile; remapFile.file_open(str); fileSize = remapFile.file_size(); remap_bitmap = (char *) mem_add(fileSize); remapFile.file_read(remap_bitmap, fileSize); remapFile.file_close(); }
//------------ Start of MouseSDL::init ------------// // void MouseSDL::init() { update_skey_state(); //------- initialize VGA update buffer -------// vga_update_buf = mem_add( VGA_UPDATE_BUF_SIZE ); // ------ initialize mouse boundary ---------// reset_boundary(); // ------- initialize event queue ---------// head_ptr = tail_ptr = 0; SDL_ShowCursor(SDL_DISABLE); }
//------- Begin of function RaceRes::load_race_info -------// // // Read in information of RACE.DBF into memory array // void RaceRes::load_race_info() { RaceRec *raceRec; RaceInfo *raceInfo; int i, unitId; long bitmapOffset; Database *dbRace = game_set.open_db(RACE_DB); race_count = (short) dbRace->rec_count(); race_info_array = (RaceInfo*) mem_add( sizeof(RaceInfo)*race_count ); //------ read in race information array -------// memset( race_info_array, 0, sizeof(RaceInfo) * race_count ); for( i=0 ; i<race_count ; i++ ) { raceRec = (RaceRec*) dbRace->read(i+1); raceInfo = race_info_array+i; raceInfo->race_id = i+1; m.rtrim_fld( raceInfo->code, raceRec->code, raceRec->CODE_LEN ); m.rtrim_fld( raceInfo->name, raceRec->name, raceRec->NAME_LEN ); m.rtrim_fld( raceInfo->adjective, raceRec->adjective, raceRec->ADJECTIVE_LEN ); #if(defined(GERMAN) || defined(FRENCH) || defined(SPANISH)) translate.multi_to_win(raceInfo->name, raceInfo->NAME_LEN); translate.multi_to_win(raceInfo->adjective, raceInfo->ADJECTIVE_LEN); #endif memcpy( &bitmapOffset, raceRec->icon_bitmap_ptr, sizeof(long) ); raceInfo->icon_bitmap_ptr = res_bitmap.read_imported(bitmapOffset); err_when( !raceInfo->icon_bitmap_ptr ); for( unitId=1 ; unitId<=MAX_UNIT_TYPE ; unitId++ ) { if( unit_res[unitId]->race_id == i+1 ) { raceInfo->basic_unit_id = unitId; break; } } } }
//---------- Begin of function DynArray::bubble_sort -------------// //! //! Perform a bubble sort on the array. //! //! int(*fcmp)(const void*, const void*) cmpFun = the pointer to the comparsion function //! void DynArray::bubble_sort( int(*cmpFun)(const void*, const void*) ) { char *tmp; tmp=mem_add(ele_size); for(int i=0;i<last_ele;i++) for(int j=i+1;j<last_ele;j++) { void *p,*q; //swapping p=get(i+1); q=get(j+1); if(cmpFun(p,q)>0) { memcpy(tmp,p,ele_size); memcpy(p,q,ele_size); memcpy(q,tmp,ele_size); } } mem_del(tmp); }
//-------- begin of function StateArray::init ----------// // void StateArray::init( int w, int h ) { err_when( w > MAX_STATE_MAP_WIDTH ); err_when( h > MAX_STATE_MAP_HEIGHT ); deinit(); max_x_loc = w; max_y_loc = h; loc_matrix = (StateLocation *)mem_add( sizeof(StateLocation) * w * h ); memset( loc_matrix, 0, sizeof(StateLocation) * w * h ); state_count = 0; state_info_array = 0; init_flag = 1; }
//-------------------// int SchoolRes::read_file(File* filePtr) { free_db_info(); School* schoolPtr = desired_school_array; int schoolCount = desired_school_count; //-------------------// if ( !filePtr->file_read(this, sizeof(SchoolRes)) ) return 0; desired_school_array = schoolPtr; desired_school_count = schoolCount; //-------------------// peer_school_array = (PeerSchool *) mem_add(peer_school_count*sizeof(PeerSchool)); if( !filePtr->file_read( peer_school_array, peer_school_count*sizeof(PeerSchool) ) ) return 0; //-------------------// short playerPeerIndex = -1; playerPeerIndex = filePtr->file_get_short(); err_when(playerPeerIndex < 0 || playerPeerIndex >= peer_school_count); player_peer_school = peer_school_array+playerPeerIndex; //-------------------// if( !filePtr->file_read(PeerSchool::pref_vars_average_array, sizeof(PeerSchool::pref_vars_average_array) ) ) return 0; if( !filePtr->file_read(PeerSchool::pref_vars_average_array_last, sizeof(PeerSchool::pref_vars_average_array_last) ) ) return 0; if( !filePtr->file_read(PeerSchool::average_faculty_salary, sizeof(PeerSchool::average_faculty_salary) ) ) return 0; return 1; }
// ---------- begin of function ColorTable::operator= ----------// ColorTable& ColorTable::operator=(const ColorTable& ct) { deinit(); abs_scale = ct.abs_scale; table_size= ct.table_size; if( ct.remap_table ) { remap_table = (WORD *)mem_add(table_size * (2*abs_scale+1) ); memcpy(remap_table, ct.remap_table, table_size * (2*abs_scale+1) * sizeof(WORD) ); } else { remap_table = NULL; } return *this; }
//-------- Begin of function FileTxt::FileTxt ----------// // // <char*> fileName = name of the file // FileTxt::FileTxt(char* fileName) { file_open(fileName); //-----------------------------------// file_length = File::file_size(); data_buf = mem_add( file_length+1 ); data_buf[file_length] = CHAR_EOF; data_ptr = data_buf; //-----------------------------------// file_read( data_buf, file_length ); file_close(); }
//------- Begin of function TownRes::load_town_layout -------// // // Read in information from TOWNLAY.DBF. // void TownRes::load_town_layout() { TownLayoutRec *townLayoutRec; TownLayout *townLayout; TownSlot *townSlot; int i, j; Database *dbTownLayout = game_set.open_db(TOWN_LAYOUT_DB); town_layout_count = (short) dbTownLayout->rec_count(); town_layout_array = (TownLayout*) mem_add( sizeof(TownLayout)*town_layout_count ); //------ read in town layout info array -------// memset( town_layout_array, 0, sizeof(TownLayout) * town_layout_count ); for( i=0 ; i<town_layout_count ; i++ ) { townLayoutRec = (TownLayoutRec*) dbTownLayout->read(i+1); townLayout = town_layout_array+i; townLayout->first_slot_recno = misc.atoi(townLayoutRec->first_slot, TownLayoutRec::FIRST_SLOT_LEN); townLayout->slot_count = misc.atoi(townLayoutRec->slot_count, TownLayoutRec::SLOT_COUNT_LEN); // ###### begin Gilbert 9/9 ########// // townLayout->ground_bitmap_ptr = image_spict.get_ptr( misc.nullify(townLayoutRec->ground_name, TownLayoutRec::GROUND_NAME_LEN) ); townLayout->ground_bitmap_ptr = image_tpict.get_ptr( misc.nullify(townLayoutRec->ground_name, TownLayoutRec::GROUND_NAME_LEN) ); // ###### end Gilbert 9/9 ########// err_if( townLayout->slot_count > MAX_TOWN_LAYOUT_SLOT ) err_now( "Error: MAX_TOWN_LAYOUT_SLOT limit exceeded." ); //----- calculate min_population & max_population -----// townSlot = town_slot_array+townLayout->first_slot_recno-1; for( j=0 ; j<townLayout->slot_count ; j++, townSlot++ ) { if( townSlot->build_type==TOWN_OBJECT_HOUSE ) // if there is a building in this slot townLayout->build_count++; } } }
//----------- Begin of function PlantRes::load_info -------// //! //! Read in information of PLANT.DBF into memory array //! void PlantRes::load_info() { PlantRec *plantRec; PlantInfo *plantInfo; int i; Database *dbPlant = game_set.open_db(PLANT_DB); plant_count = (short) dbPlant->rec_count(); info_array = (PlantInfo*) mem_add( sizeof(PlantInfo)*plant_count ); //------ read in plant bitmap info array -------// memset( info_array, 0, sizeof(PlantInfo) * plant_count ); for( i=0 ; i<plant_count ; i++ ) { plantRec = (PlantRec*) dbPlant->read(i+1); plantInfo = info_array+i; m.rtrim_fld( plantInfo->file_name, plantRec->file_name, plantRec->FILE_NAME_LEN ); } }
int Xmemory(void) { if (cmd.argc >= 2) { int i; /* parse the memory specs */ for (i = 1; i < cmd.argc; i++) { char *p; long long addr, size; p = cmd.argv[i]; size = strtoll(p + 1, &p, 0); if (*p && *p == '@') addr = strtoll(p + 1, NULL, 0); else addr = 0; if (addr == 0 && (*p != '@' || size == 0)) { printf("bad language\n"); return 0; } else { switch (cmd.argv[i][0]) { case '-': mem_delete(addr, addr + size); break; case '+': mem_add(addr, addr + size); break; default : printf("bad OP\n"); return 0; } } } } dump_biosmem(NULL); return 0; }
Remote::Remote() { //--------------------------------------------// packet_send_count = 0; packet_receive_count = 0; //--------------------------------------------// common_msg_buf = mem_add( COMMON_MSG_BUF_SIZE ); mp_ptr = NULL; connectivity_mode = 0; // handle_vga_lock = 1; handle_vga_lock = 0; // lock vga front in MulitPlayerDP process_queue_flag = 0; nation_processing = 0; // ###### patch begin Gilbert 22/1 #######// sync_test_level = 0; // 0=disable, bit0= random seed, bit1=crc, bit7=error encountered // ###### patch end Gilbert 22/1 #######// }