00001
00002
00003
00004 #include <OVGA.H>
00005 #include <OMOUSE.H>
00006 #include <OMOUSECR.H>
00007 #include <OSYS.H>
00008 #include <OCONFIG.H>
00009 #include <OTERRAIN.H>
00010 #include <OWORLD.H>
00011
00012
00013
00014 World::World() {
00015 loc_matrix = NULL;
00016 }
00017
00018
00019
00020
00021
00022 World::~World() {
00023 deinit();
00024 }
00025
00026
00027
00028
00030
00031
00032
00033 loc_matrix = (Location*) mem_add( sizeof(Location) * MAX_WORLD_X_LOC * MAX_WORLD_Y_LOC );
00034
00035 memset( loc_matrix, 0, sizeof(Location) * MAX_WORLD_X_LOC * MAX_WORLD_Y_LOC );
00036
00037 max_x_loc = MAX_WORLD_X_LOC;
00038 max_y_loc = MAX_WORLD_Y_LOC;
00039
00040
00041
00042 map_matrix.init( MAP_X1, MAP_Y1, MAP_X2, MAP_Y2,
00043 MAP_LOC_WIDTH, MAP_LOC_HEIGHT,
00044
00045 loc_matrix, max_x_loc, max_y_loc, ZOOM_SMALL, 1 );
00046
00047 zoom1_matrix.init( ZOOM_X1, ZOOM_Y1, ZOOM_X2, ZOOM_Y2,
00048 ZOOM1_LOC_WIDTH, ZOOM1_LOC_HEIGHT,
00049 loc_matrix, max_x_loc, max_y_loc, ZOOM_MEDIUM );
00050
00051 zoom2_matrix.init( ZOOM_X1, ZOOM_Y1, ZOOM_X2, ZOOM_Y2,
00052 ZOOM2_LOC_WIDTH, ZOOM2_LOC_HEIGHT,
00053 loc_matrix, max_x_loc, max_y_loc, ZOOM_LARGE );
00054
00055
00056
00057 show_map = 1;
00058
00059 set_zoom_level(1);
00060
00061
00062
00063 init_terrain();
00064 }
00065
00066
00067
00068
00070
00071 if( loc_matrix ) {
00072 mem_del( loc_matrix );
00073 loc_matrix = NULL;
00074 }
00075
00076
00077 }
00078
00079
00080
00081
00083
00084 zoom_level = newZoomLevel;
00085
00086 if( zoom_level==1 )
00087 active_zoom_matrix = &zoom1_matrix;
00088 else
00089 active_zoom_matrix = &zoom2_matrix;
00090
00091 sys.redraw_zoom_flag = 1;
00092 }
00093
00094
00095
00096
00098
00099 show_map = showMapFlag;
00100
00101 sys.redraw_all_flag = 1;
00102 }
00103
00104
00105
00106
00108
00109 int terrainTypeCount = terrain_res.terrain_count;
00110
00111 for( int i=0 ; i<MAX_WORLD_X_LOC*MAX_WORLD_Y_LOC ; i++ ) {
00112 loc_matrix[i].set_terrain(m.random(terrainTypeCount)+1);
00113 }
00114 }
00115
00116
00117
00118
00120
00121 active_zoom_matrix->draw_all();
00122
00123 if( show_map ) {
00124 vga_back.bar( MAP_X1, MAP_Y1, MAP_X2, MAP_Y2, V_WHITE );
00125
00126 vga_back.rect( MAP_X1-MAP_BORDER_WIDTH, MAP_Y1-MAP_BORDER_HEIGHT,
00127 MAP_X2+MAP_BORDER_WIDTH, MAP_Y2+MAP_BORDER_HEIGHT, 2, V_BLACK );
00128
00129 map_matrix.draw_all();
00130 }
00131 }
00132
00133
00134
00135
00137
00138 active_zoom_matrix->draw_update();
00139
00140 if( show_map )
00141 map_matrix.draw_update();
00142 }
00143
00144
00145
00146
00153
00154
00155
00156 if( show_map ) {
00157 if( map_matrix.detect() )
00158 return 1;
00159 }
00160
00161
00162
00163 if( active_zoom_matrix->detect() )
00164 return 1;
00165
00166 return 0;
00167 }
00168
00169
00170
00171
00173
00174 err_when( xLoc<0 || xLoc>=MAX_WORLD_X_LOC );
00175 err_when( yLoc<0 || yLoc>=MAX_WORLD_Y_LOC );
00176
00177 return loc_matrix + MAX_WORLD_X_LOC * yLoc + xLoc;
00178 }
00179
00180
00181
00182
00184
00185 if ( xLoc>=0 && xLoc<MAX_WORLD_X_LOC
00186 && yLoc>=0 && yLoc<MAX_WORLD_Y_LOC) {
00187 return loc_matrix + MAX_WORLD_X_LOC * yLoc + xLoc;
00188 }
00189 else
00190 return NULL;
00191 }
00192
00193