draw_map.h File Reference


Detailed Description

Graphics draw of Dungeon Keeper map.

Purpose:
Header file. Defines exported routines from draw_map.c
Comment:
None.
Author:
Tomasz Lis
Date:
12 Jan 2008 - 22 Jul 2008
Copying and copyrights:
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Definition in file draw_map.h.

#include "globals.h"

Go to the source code of this file.

Data Structures

struct  PALETTE_ENTRY
struct  MAPDRAW_DATA

Defines

#define ERR_DRAW_BADTXTR   -33
#define ERR_DRAW_BADCUBE   -34
#define SIN_ACOS_SIZE   1024

Enumerations

enum  BMFONT_OPTIONS { BMFONT_DONT_LOAD = 0x00, BMFONT_LOAD_SMALL = 0x01, BMFONT_LOAD_LARGE = 0x02 }
enum  TNGFLG_OPTIONS { TNGFLG_NONE = 0x00, TNGFLG_SHOW_CIRCLES = 0x01 }

Functions

DLLIMPORT short generate_map_bitmap (const char *bmpfname, const struct LEVEL *lvl, const struct MAPDRAW_OPTIONS *opts)
 Generates bitmap representing the current map layout.
DLLIMPORT short generate_map_bitmap_mapfname (struct LEVEL *lvl)
 Generates bitmap representing the current map layout.
DLLIMPORT short load_draw_data (struct MAPDRAW_DATA **draw_data, const struct MAPDRAW_OPTIONS *opts, const struct UPOINT_2D *subtl, const struct IPOINT_2D bmp_size, int textr_idx)
 Allocates and fills the MAPDRAW_DATA structure.
DLLIMPORT short free_draw_data (struct MAPDRAW_DATA *draw_data)
 Frees the MAPDRAW_DATA structure.
DLLIMPORT short draw_map_on_buffer (char *dest, const struct LEVEL *lvl, struct MAPDRAW_DATA *draw_datam, unsigned int anim)
 Draws given LEVEL on given buffer, using graphics and options from MAPDRAW_DATA.
DLLIMPORT short draw_map_on_buffer_fast (char *dest, const struct LEVEL *lvl, struct MAPDRAW_DATA *draw_data, unsigned int anim)
 Draws given LEVEL on given buffer, using graphics and options from MAPDRAW_DATA.
DLLIMPORT short draw_things_on_buffer (char *dest, const struct LEVEL *lvl, struct MAPDRAW_DATA *draw_data)
 Draws things from given LEVEL on given buffer, using graphics and options from MAPDRAW_DATA.
DLLIMPORT short draw_text_on_buffer (char *dest, const int px, const int py, const char *text, struct MAPDRAW_DATA *draw_data, short font)
 Draws text on given buffer, using graphics and options from MAPDRAW_DATA.
DLLIMPORT short change_draw_data_texture (struct MAPDRAW_DATA *draw_data, const struct MAPDRAW_OPTIONS *opts, const int textr_idx)
 Changes loaded texture in the MAPDRAW_DATA structure.
DLLIMPORT short set_draw_data_rect (struct MAPDRAW_DATA *draw_data, const int startx, const int starty, const int endx, const int endy, const unsigned int scanline, const short rescale)
 Sets the drawing rectangle in MAPDRAW_DATA structure.
short set_draw_data_rect_ip (struct MAPDRAW_DATA *draw_data, const struct IPOINT_2D start, const struct IPOINT_2D end, const unsigned int scanline, const short rescale)
 Sets the drawing rectangle in MAPDRAW_DATA structure.
short set_draw_data_rect_sl4 (struct MAPDRAW_DATA *draw_data, const int startx, const int starty, const int endx, const int endy, const short dest_sizex, const short rescale)
 Sets the drawing rectangle in MAPDRAW_DATA structure.
DLLIMPORT short get_draw_tile_rect (struct IPOINT_2D *tstart, struct IPOINT_2D *tdim, const struct MAPDRAW_DATA *draw_data, unsigned int tx, unsigned int ty)
 Returns coordinates of a graphics buffer rectangle where specific tile is.
DLLIMPORT short get_draw_subtile_rect (struct IPOINT_2D *sstart, struct IPOINT_2D *sdim, const struct MAPDRAW_DATA *draw_data, unsigned int sx, unsigned int sy)
 Returns coordinates of a graphics buffer rectangle where specific subtile is.
DLLIMPORT short get_subtile_from_draw_coords (unsigned int *sx, unsigned int *sy, const struct MAPDRAW_DATA *draw_data, unsigned int px, unsigned int py)
 Returns subtile coordinates for given graphics map position.
DLLIMPORT short get_subtile_from_draw_coords_ip (struct IPOINT_2D *subtl, struct IPOINT_2D *subpos, const struct MAPDRAW_DATA *draw_data, unsigned int px, unsigned int py)
 Returns subtile coordinates for given graphics map position.
DLLIMPORT short get_subtile_from_draw_coords_adv (unsigned int *ssx, unsigned int *ssy, const struct MAPDRAW_DATA *draw_data, unsigned int px, unsigned int py)
 Returns subtile coordinates for given graphics map position.
short get_subtile_from_draw_coords_adv_fast (unsigned int *ssx, unsigned int *ssy, const struct IPOINT_2D scaled_txtr_size, const struct IPOINT_2D start, unsigned int px, unsigned int py)
 Returns subtile coordinates for given graphics map position.
DLLIMPORT short get_full_draw_dimensions (struct IPOINT_2D *gdim, const struct MAPDRAW_DATA *draw_data)
 Returns full dimensions of the level graphics view in current scale.
DLLIMPORT short get_full_draw_dimensions_opt (struct IPOINT_2D *gdim, const struct UPOINT_2D *subtl, const struct MAPDRAW_OPTIONS *opts)
 Returns full dimensions of the level graphics view in current scale.
DLLIMPORT short get_thing_with_circle_at (unsigned int *sx, unsigned int *sy, unsigned int *num, const struct MAPDRAW_DATA *draw_data, const struct LEVEL *lvl, unsigned int px, unsigned int py)
 Returns a thing which is at given position in map image buffer.
DLLIMPORT short get_object_with_circle_at (unsigned int *sx, unsigned int *sy, unsigned int *z, const struct MAPDRAW_DATA *draw_data, const struct LEVEL *lvl, unsigned int px, unsigned int py)
 Returns an object which is at given position in map image buffer.


Define Documentation

#define ERR_DRAW_BADCUBE   -34

Definition at line 24 of file draw_map.h.

Referenced by get_top_texture_pos().

#define ERR_DRAW_BADTXTR   -33

Definition at line 23 of file draw_map.h.

Referenced by texture_index_to_texture_pos().

#define SIN_ACOS_SIZE   1024

Definition at line 41 of file draw_map.h.

Referenced by draw_circle_fill(), draw_circle_mul(), and load_draw_data().


Enumeration Type Documentation

Enumerator:
BMFONT_DONT_LOAD 
BMFONT_LOAD_SMALL 
BMFONT_LOAD_LARGE 

Definition at line 26 of file draw_map.h.

Enumerator:
TNGFLG_NONE 
TNGFLG_SHOW_CIRCLES 

Definition at line 32 of file draw_map.h.


Function Documentation

DLLIMPORT short change_draw_data_texture ( struct MAPDRAW_DATA draw_data,
const struct MAPDRAW_OPTIONS opts,
const int  textr_idx 
)

Changes loaded texture in the MAPDRAW_DATA structure.

Loads the new texture file from disk into draw_data.

Parameters:
draw_data Destination structure.
opts Drawing options.
textr_idx New texture file index.
Returns:
Returns ERR_NONE on success, error code on failure.

Definition at line 2320 of file draw_map.c.

Referenced by load_draw_data().

DLLIMPORT short draw_map_on_buffer ( char *  dest,
const struct LEVEL lvl,
struct MAPDRAW_DATA draw_data,
unsigned int  anim 
)

Draws given LEVEL on given buffer, using graphics and options from MAPDRAW_DATA.

Parameters:
dest The destination buffer.
lvl Source level to draw.
draw_data Graphics textures, sprites and options.
anim Number of the animation frame.
Returns:
Returns ERR_NONE on success, error code on failure.

Definition at line 1505 of file draw_map.c.

Referenced by generate_map_bitmap().

DLLIMPORT short draw_map_on_buffer_fast ( char *  dest,
const struct LEVEL lvl,
struct MAPDRAW_DATA draw_data,
unsigned int  anim 
)

Draws given LEVEL on given buffer, using graphics and options from MAPDRAW_DATA.

Fast version - but a little less quality on rescaling.

Parameters:
dest The destination buffer.
lvl Source level to draw.
draw_data Graphics textures, sprites and options.
anim Number of the animation frame.
Returns:
Returns ERR_NONE on success, error code on failure.

Definition at line 1654 of file draw_map.c.

DLLIMPORT short draw_text_on_buffer ( char *  dest,
const int  px,
const int  py,
const char *  text,
struct MAPDRAW_DATA draw_data,
short  font 
)

Draws text on given buffer, using graphics and options from MAPDRAW_DATA.

Parameters:
dest The destination buffer.
px,py Start point for the dawing in dest buffer.
text Source text message.
draw_data Graphics textures, sprites and options.
font Font selector.
Returns:
Returns ERR_NONE on success, error code on failure.

Definition at line 2002 of file draw_map.c.

DLLIMPORT short draw_things_on_buffer ( char *  dest,
const struct LEVEL lvl,
struct MAPDRAW_DATA draw_data 
)

Draws things from given LEVEL on given buffer, using graphics and options from MAPDRAW_DATA.

Parameters:
dest The destination buffer.
lvl Source level to draw things from.
draw_data Graphics textures, sprites and options.
Returns:
Returns ERR_NONE on success, error code on failure.

Definition at line 1820 of file draw_map.c.

Referenced by generate_map_bitmap().

DLLIMPORT short free_draw_data ( struct MAPDRAW_DATA draw_data  ) 

Frees the MAPDRAW_DATA structure.

Parameters:
draw_data Destination structure.
Returns:
Returns ERR_NONE on success, error code on failure.

Definition at line 2340 of file draw_map.c.

Referenced by generate_map_bitmap(), and load_draw_data().

DLLIMPORT short generate_map_bitmap ( const char *  bmpfname,
const struct LEVEL lvl,
const struct MAPDRAW_OPTIONS opts 
)

Generates bitmap representing the current map layout.

The result is stored into given file name. Loads all data files every time it's executed.

Parameters:
bmpfname Output bitmap file name.
lvl Source level to draw map from.
opts Drawing options.
Returns:
Returns ERR_NONE on success, error code on failure.

Definition at line 2671 of file draw_map.c.

Referenced by generate_map_bitmap_mapfname().

DLLIMPORT short generate_map_bitmap_mapfname ( struct LEVEL lvl  ) 

Generates bitmap representing the current map layout.

Saves it on the filename same as level name, and with BMP extension.

Parameters:
lvl Source level to draw map from.

Definition at line 2726 of file draw_map.c.

DLLIMPORT short get_draw_subtile_rect ( struct IPOINT_2D sstart,
struct IPOINT_2D sdim,
const struct MAPDRAW_DATA draw_data,
unsigned int  sx,
unsigned int  sy 
)

Returns coordinates of a graphics buffer rectangle where specific subtile is.

Parameters:
sstart Subtile start (top left) coordinates.
sdim Subtile dimensions. Adding them to sstart will give you end (bottom right) coordinates.
draw_data The drawing data structure.
sx,sy Coords of the subtile we want to get graphics rectangle for.
Returns:
Returns ERR_NONE on success, error code on failure. On success, returns coordinates in IPOINT_2D structures.

Definition at line 2390 of file draw_map.c.

DLLIMPORT short get_draw_tile_rect ( struct IPOINT_2D tstart,
struct IPOINT_2D tdim,
const struct MAPDRAW_DATA draw_data,
unsigned int  tx,
unsigned int  ty 
)

Returns coordinates of a graphics buffer rectangle where specific tile is.

Parameters:
tstart Tile start (top left) coordinates.
tdim Tile dimensions. Adding them to tstart will give you end (bottom right) coordinates.
draw_data The drawing data structure.
tx,ty Coords of the tile we want to get graphics rectangle for.
Returns:
Returns ERR_NONE on success, error code on failure. On success, returns coordinates in IPOINT_2D structures.

Definition at line 2366 of file draw_map.c.

DLLIMPORT short get_full_draw_dimensions ( struct IPOINT_2D gdim,
const struct MAPDRAW_DATA draw_data 
)

Returns full dimensions of the level graphics view in current scale.

Parameters:
gdim Graphics map dimensions. Substracting draw_data->start will give you dimensions from current start position.
draw_data The drawing data structure.
Returns:
Returns ERR_NONE on success, error code on failure. On success, returns coordinates in IPOINT_2D structures.

Definition at line 2628 of file draw_map.c.

DLLIMPORT short get_full_draw_dimensions_opt ( struct IPOINT_2D gdim,
const struct UPOINT_2D subtl,
const struct MAPDRAW_OPTIONS opts 
)

Returns full dimensions of the level graphics view in current scale.

Requires MAPDRAW_OPTIONS struct and map size instead of MAPDRAW_DATA.

Parameters:
gdim Graphics map dimensions. Substracting draw_data->start will give you dimensions from current start position.
subtl The map size, in subtiles.
opts The drawing options structure.
Returns:
Returns ERR_NONE on success, error code on failure. On success, returns coordinates in IPOINT_2D structures.

Definition at line 2650 of file draw_map.c.

DLLIMPORT short get_object_with_circle_at ( unsigned int *  sx,
unsigned int *  sy,
unsigned int *  z,
const struct MAPDRAW_DATA draw_data,
const struct LEVEL lvl,
unsigned int  px,
unsigned int  py 
)

Returns an object which is at given position in map image buffer.

The (sx,sy,z) indices can be used to get the object data. You can identify the object type by calling get_object_type(lvl,sx,sy,z).

Parameters:
sx,sy,z Destination indices of object.
draw_data The drawing data structure.
lvl Pointer to the level structure.
px,py Coords of the graphics map point at which we want the object.
Returns:
Returns ERR_NONE on success, error code on failure. On success, returns indices in (sx,sy,z).

Definition at line 2572 of file draw_map.c.

DLLIMPORT short get_subtile_from_draw_coords ( unsigned int *  sx,
unsigned int *  sy,
const struct MAPDRAW_DATA draw_data,
unsigned int  px,
unsigned int  py 
)

Returns subtile coordinates for given graphics map position.

Parameters:
sx Destination subtile X coordinate.
sy Destination subtile Y coordinate.
draw_data The drawing data structure.
px,py Coords of the graphics map point at which we want subtile number.
Returns:
Returns ERR_NONE on success, error code on failure. On success, returns coordinates in (sx,sy).

Definition at line 2413 of file draw_map.c.

DLLIMPORT short get_subtile_from_draw_coords_adv ( unsigned int *  ssx,
unsigned int *  ssy,
const struct MAPDRAW_DATA draw_data,
unsigned int  px,
unsigned int  py 
)

Returns subtile coordinates for given graphics map position.

Returns exact coords within a subtile plus subtile number shifted by 8 bits.

Parameters:
ssx,ssy Destination coordinates: subtile<<8+subtile_pos.
draw_data The drawing data structure.
px,py Coords of the graphics map point at which we want subtile number.
Returns:
Returns ERR_NONE on success, error code on failure. On success, returns coordinates in (sx,sy).

Definition at line 2462 of file draw_map.c.

short get_subtile_from_draw_coords_adv_fast ( unsigned int *  ssx,
unsigned int *  ssy,
const struct IPOINT_2D  scaled_txtr_size,
const struct IPOINT_2D  start,
unsigned int  px,
unsigned int  py 
) [inline]

Returns subtile coordinates for given graphics map position.

Returns exact coords within a subtile plus subtile number shifted by 8 bits. Fast version - gets scalet texture as parameter, so it don't have to be recomputed.

Parameters:
ssx,ssy Destination coordinates: subtile<<8+subtile_pos.
scaled_txtr_size The scaled size of texture (subtile size on graphics buffer).
start Map drawing starting coords.
px,py Coords of the graphics map point at which we want subtile number.
Returns:
Returns ERR_NONE on success, error code on failure. On success, returns coordinates in (sx,sy).

Definition at line 2489 of file draw_map.c.

Referenced by get_object_with_circle_at(), and get_thing_with_circle_at().

DLLIMPORT short get_subtile_from_draw_coords_ip ( struct IPOINT_2D subtl,
struct IPOINT_2D subpos,
const struct MAPDRAW_DATA draw_data,
unsigned int  px,
unsigned int  py 
)

Returns subtile coordinates for given graphics map position.

Returns exact coords within a subtile.

Parameters:
subtl Destination subtile coordinates.
subpos Destination position within the subtile.
draw_data The drawing data structure.
px,py Coords of the graphics map point at which we want subtile number.
Returns:
Returns ERR_NONE on success, error code on failure. On success, returns coordinates in (sx,sy).

Definition at line 2436 of file draw_map.c.

DLLIMPORT short get_thing_with_circle_at ( unsigned int *  sx,
unsigned int *  sy,
unsigned int *  num,
const struct MAPDRAW_DATA draw_data,
const struct LEVEL lvl,
unsigned int  px,
unsigned int  py 
)

Returns a thing which is at given position in map image buffer.

The (sx,sy,num) indices can be used to get the thing data like this: get_thing(lvl,sx,sy,num).

Parameters:
sx,sy,num Destination indices of thing.
draw_data The drawing data structure.
lvl Pointer to the level structure.
px,py Coords of the graphics map point at which we want the thing.
Returns:
Returns ERR_NONE on success, error code on failure. On success, returns indices in (sx,sy,num).

Definition at line 2513 of file draw_map.c.

DLLIMPORT short load_draw_data ( struct MAPDRAW_DATA **  draw_data,
const struct MAPDRAW_OPTIONS opts,
const struct UPOINT_2D subtl,
const struct IPOINT_2D  bmp_size,
int  textr_idx 
)

Allocates and fills the MAPDRAW_DATA structure.

Loads all data files needed to draw the map. Sets drawing rectangle from (0,0) to bmp_size.

Parameters:
draw_data Destination structure.
opts Drawing options.
subtl Size of the map, in subtiles.
bmp_size Ending coords of the drawing rectangle.
textr_idx Texture file index.
Returns:
Returns ERR_NONE on success, error code on failure.

Definition at line 2151 of file draw_map.c.

Referenced by generate_map_bitmap().

DLLIMPORT short set_draw_data_rect ( struct MAPDRAW_DATA draw_data,
const int  startx,
const int  starty,
const int  endx,
const int  endy,
const unsigned int  scanline,
const short  rescale 
)

Sets the drawing rectangle in MAPDRAW_DATA structure.

See also:
set_draw_data_rect_ip
Parameters:
draw_data Destination structure.
startx Starting coordinate.
starty Starting coordinate.
endx Ending coordinate.
endy Ending coordinate.
scanline Destination buffer scanline length.
rescale Scale factor.
Returns:
Returns ERR_NONE on success, error code on failure.

Definition at line 2073 of file draw_map.c.

Referenced by load_draw_data(), set_draw_data_rect_ip(), and set_draw_data_rect_sl4().

short set_draw_data_rect_ip ( struct MAPDRAW_DATA draw_data,
const struct IPOINT_2D  start,
const struct IPOINT_2D  end,
const unsigned int  scanline,
const short  rescale 
) [inline]

Sets the drawing rectangle in MAPDRAW_DATA structure.

Uses IPOINT_2D structs instead of single points.

See also:
set_draw_data_rect
Parameters:
draw_data Destination structure.
start Starting coordinates.
end Ending coordinates.
scanline Destination buffer scanline length.
rescale Scale factor.
Returns:
Returns ERR_NONE on success, error code on failure.

Definition at line 2111 of file draw_map.c.

short set_draw_data_rect_sl4 ( struct MAPDRAW_DATA draw_data,
const int  startx,
const int  starty,
const int  endx,
const int  endy,
const short  dest_sizex,
const short  rescale 
) [inline]

Sets the drawing rectangle in MAPDRAW_DATA structure.

Sets a scanline length to be multiplication of 4 - needed in some cases.

See also:
set_draw_data_rect
Parameters:
draw_data Destination structure.
startx Starting coordinate.
starty Starting coordinate.
endx Ending coordinate.
endy Ending coordinate.
dest_sizex Destination buffer line size, in pixels.
rescale Scale factor.
Returns:
Returns ERR_NONE on success, error code on failure.

Definition at line 2131 of file draw_map.c.


Generated on Tue Sep 2 18:51:48 2008 for libAdikted by  doxygen 1.5.6