function room = rok_room_create (config, compatMode)
    % room = ROK_ROOM_CREATE (config, compatMode)
    %
    % Creates room configuration structure.
    %
    % Input:
    %  - config = filename of configuration ini file, or an already-parsed
    %    configuration structure, obtained from configuration ini file 
    %    by ROK_PARSE_CONFIG_INI
    %  - compatMode = compatibility mode for old configurations (emulates
    %    a minor bug in cell configuration...)
    %
    % Output:
    %  - room = room configuration structure, which can be used in
    %    functions such as ROK_ROOM_CELL_TO_XY and ROK_ROOM_XY_TO_CELL
    %
    % See also: ROK_ROOM_CELL_TO_XY, ROK_ROOM_XY_TO_CELL
    %
    % Copyright (C) 2011-2012, Rok Mandeljc <rok.mandeljc@fe.uni-lj.si>
    
    if ~exist('compatMode', 'var') || isempty(compatMode),
        compatMode = false;
    end
    
    if ischar(config),
        config = rok_parse_config_ini(config);
    end
        
    %% Create grid
    % At least the following fields should be present in config strucure:
    %  - area = array of room dimensions (x1, y1, x2, y2)
    %  - cell_size = cell size (w, h)
    %  - cell_stride = cell stride (x, y)
    room.area = config.area;
    room.cell_size = config.cell_size;
    room.cell_stride = config.cell_stride;
    
    if ~compatMode,
        % The new, and proper way
        room.xVals = (room.area(1) + room.cell_size(1)/2):room.cell_stride(1):(room.area(3) - room.cell_size(1)/2);
        room.yVals = (room.area(2) + room.cell_size(2)/2):room.cell_stride(2):(room.area(4) - room.cell_size(2)/2);
    else
        % Compatibility mode
        room.xVals = (room.area(1) + room.cell_stride(1)/2):room.cell_stride(1):(room.area(3) - room.cell_stride(1)/2);
        room.yVals = (room.area(2) + room.cell_stride(2)/2):room.cell_stride(2):(room.area(4) - room.cell_stride(2)/2);
    end
    
    room.nx = numel(room.xVals);
    room.ny = numel(room.yVals);
end
