D:/WorkAround/prequengine/trunk/src/grid.c File Reference

This file contains grid manipulation routines. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "grid.h"
#include "resources.h"
#include "lbaengine.h"
#include "scene.h"
#include "sdlengine.h"
#include "interface.h"
#include "images.h"
#include "actor.h"

Include dependency graph for grid.c:

Go to the source code of this file.

Data Structures

struct  BlockEntry
struct  BrickEntry

Defines

#define GRID_SIZE_X   64
#define GRID_SIZE_Y   25
#define GRID_SIZE_Z   GRID_SIZE_X
#define NUM_BRICKS   9000
#define CELLING_GRIDS_START_INDEX   120

Typedefs

typedef struct BlockEntry blockMap [64][64][25]

Functions

void copy_grid_mask (int spriteNum, int x, int y, unsigned char *buffer)
void draw_over_sprite_actor (int X, int Y, int Z)
int process_grid_mask (int var, unsigned char *buffer, unsigned char *ptr)
void create_grid_mask ()
void get_sprite_size (int offset, int *width, int *height, unsigned char *spritePtr)
int load_grid_bricks (int gridSize)
void create_grid_column (unsigned char *gridEntry, unsigned char *dest)
void create_celling_grid_column (unsigned char *gridEntry, unsigned char *dest)
void create_grid_map ()
void create_celling_grid_map (unsigned char *gridPtr)
int init_grid (int index)
int init_celling_grid (int index)
void draw_brick (int index, int posX, int posY)
void draw_sprite (int index, int posX, int posY, unsigned char *ptr)
void draw_brick_sprite (int index, int posX, int posY, unsigned char *ptr, int isSprite)
unsigned char * get_block_library (int index)
void get_brick_pos (int x, int y, int z)
void draw_column_grid (int blockIdx, int brickBlockIdx, int x, int y, int z)
void redraw_grid ()

Variables

unsigned char * brickTable [NUM_BRICKS]
unsigned char * brickMaskTable [NUM_BRICKS]
unsigned int brickSizeTable [NUM_BRICKS]
unsigned char brickUsageTable [NUM_BRICKS]
unsigned char * currentGrid
unsigned char * currentBll
int numberOfBll
BrickEntry bricksDataBuffer [28][150]
short int brickInfoBuffer [28]
int brickPixelPosX
int brickPixelPosY


Detailed Description

This file contains grid manipulation routines.

Prequengine: a Little Big Adventure engine

Copyright (C) 2008 Prequengine team
Copyright (C) 2002-2007 The TwinEngine team

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.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

Definition in file grid.c.


Define Documentation

#define CELLING_GRIDS_START_INDEX   120

Total number of bricks allowed in the game

Definition at line 49 of file grid.c.

Referenced by init_celling_grid().

#define GRID_SIZE_X   64

Grip X size

Definition at line 39 of file grid.c.

Referenced by create_celling_grid_map(), create_grid_map(), and redraw_grid().

#define GRID_SIZE_Y   25

Grip Y size

Definition at line 41 of file grid.c.

Referenced by redraw_grid().

#define GRID_SIZE_Z   GRID_SIZE_X

Grip Z size

Definition at line 43 of file grid.c.

Referenced by create_celling_grid_map(), create_grid_map(), and redraw_grid().

#define NUM_BRICKS   9000

Total number of bricks allowed in the game

Definition at line 46 of file grid.c.

Referenced by create_grid_mask().


Typedef Documentation

typedef struct BlockEntry blockMap[64][64][25]

Grid block entry types

Definition at line 76 of file grid.c.


Function Documentation

void copy_grid_mask ( int  spriteNum,
int  x,
int  y,
unsigned char *  buffer 
)

void create_celling_grid_column ( unsigned char *  gridEntry,
unsigned char *  dest 
)

Create grid Y column in block buffer

Parameters:
gridEntry current grid index
dest destination block buffer

Definition at line 496 of file grid.c.

Referenced by create_celling_grid_map().

void create_celling_grid_map ( unsigned char *  gridPtr  ) 

Create celling grid map from celling grid to block library buffer

Parameters:
gridPtr celling grid buffer pointer

Definition at line 565 of file grid.c.

References blockBuffer, create_celling_grid_column(), GRID_SIZE_X, and GRID_SIZE_Z.

Referenced by init_celling_grid().

void create_grid_column ( unsigned char *  gridEntry,
unsigned char *  dest 
)

Create grid Y column in block buffer

Parameters:
gridEntry current grid index
dest destination block buffer

Definition at line 449 of file grid.c.

Referenced by create_grid_map().

void create_grid_map (  ) 

Create grid map from current grid to block library buffer

Definition at line 541 of file grid.c.

References blockBuffer, create_grid_column(), currentGrid, GRID_SIZE_X, and GRID_SIZE_Z.

Referenced by apply_celling_grid(), and init_grid().

void create_grid_mask (  ) 

Definition at line 341 of file grid.c.

References brickMaskTable, brickSizeTable, brickTable, brickUsageTable, NUM_BRICKS, and process_grid_mask().

Referenced by init_grid().

void draw_brick ( int  index,
int  posX,
int  posY 
)

Definition at line 659 of file grid.c.

References brickTable, and draw_brick_sprite().

Referenced by draw_column_grid().

void draw_brick_sprite ( int  index,
int  posX,
int  posY,
unsigned char *  ptr,
int  isSprite 
)

void draw_column_grid ( int  blockIdx,
int  brickBlockIdx,
int  x,
int  y,
int  z 
)

Draw a specific brick in the grid column according with the block index

Parameters:
blockIdx block library index
brickBlockIdx brick index inside the block
x column x position
y column y position
z column z position

Definition at line 785 of file grid.c.

References brickInfoBuffer, brickPixelPosX, brickPixelPosY, draw_brick(), get_block_library(), get_brick_pos(), BrickEntry::index, newCameraX, newCameraY, newCameraZ, BrickEntry::posX, BrickEntry::posY, SCREEN_HEIGHT, SCREEN_WIDTH, BrickEntry::shape, BrickEntry::sound, BrickEntry::x, BrickEntry::y, and BrickEntry::z.

Referenced by redraw_grid().

void draw_over_sprite_actor ( int  X,
int  Y,
int  Z 
)

void draw_sprite ( int  index,
int  posX,
int  posY,
unsigned char *  ptr 
)

Definition at line 664 of file grid.c.

References draw_brick_sprite().

Referenced by process_drawing().

unsigned char* get_block_library ( int  index  ) 

Get block library

Parameters:
index block library index
Returns:
pointer to the current block index

Definition at line 763 of file grid.c.

References currentBll.

Referenced by draw_column_grid().

void get_brick_pos ( int  x,
int  y,
int  z 
)

Get brick position in the screen

Parameters:
x column x position in the current camera
y column y position in the current camera
z column z position in the current camera

Definition at line 773 of file grid.c.

References brickPixelPosX, and brickPixelPosY.

Referenced by draw_column_grid().

void get_sprite_size ( int  offset,
int *  width,
int *  height,
unsigned char *  spritePtr 
)

Definition at line 357 of file grid.c.

Referenced by process_drawing().

int init_celling_grid ( int  index  ) 

Initialize celling grid (background scenearios)

Parameters:
index grid index number

Definition at line 634 of file grid.c.

References CELLING_GRIDS_START_INDEX, create_celling_grid_map(), hqr_entry_size(), hqr_get_entry(), HQR_LBA_GRI_FILE, and reqBgRedraw.

Referenced by apply_celling_grid().

int init_grid ( int  index  ) 

Initialize grid (background scenearios)

Parameters:
index grid index number

Definition at line 591 of file grid.c.

References create_grid_map(), create_grid_mask(), currentBll, currentGrid, hqr_entry_size(), hqr_get_entry(), HQR_LBA_BLL_FILE, HQR_LBA_GRI_FILE, load_grid_bricks(), and numberOfBll.

Referenced by change_scene().

int load_grid_bricks ( int  gridSize  ) 

Load grid bricks according with block librarie usage

Parameters:
gridSize size of the current grid
Returns:
true if everything went ok

Definition at line 368 of file grid.c.

References brickSizeTable, brickTable, brickUsageTable, currentBll, currentGrid, hqr_entry_size(), hqr_get_entry(), and HQR_LBA_BRK_FILE.

Referenced by init_grid().

int process_grid_mask ( int  var,
unsigned char *  buffer,
unsigned char *  ptr 
)

Definition at line 258 of file grid.c.

Referenced by create_grid_mask().

void redraw_grid (  ) 


Variable Documentation

short int brickInfoBuffer[28]

Brick info buffer

Definition at line 102 of file grid.c.

Referenced by draw_column_grid(), draw_over_sprite_actor(), and redraw_grid().

unsigned char* brickMaskTable[NUM_BRICKS]

Table with all loaded bricks masks

Definition at line 54 of file grid.c.

Referenced by copy_grid_mask(), and create_grid_mask().

Current brick pixel X position

Definition at line 105 of file grid.c.

Referenced by draw_column_grid(), and get_brick_pos().

Current brick pixel Y position

Definition at line 107 of file grid.c.

Referenced by draw_column_grid(), and get_brick_pos().

Brick data buffer

Definition at line 100 of file grid.c.

unsigned int brickSizeTable[NUM_BRICKS]

Table with all loaded bricks sizes

Definition at line 56 of file grid.c.

Referenced by create_grid_mask(), and load_grid_bricks().

unsigned char* brickTable[NUM_BRICKS]

Table with all loaded bricks

Definition at line 52 of file grid.c.

Referenced by create_grid_mask(), draw_brick(), and load_grid_bricks().

unsigned char brickUsageTable[NUM_BRICKS]

Table with all loaded bricks usage

Definition at line 58 of file grid.c.

Referenced by create_grid_mask(), and load_grid_bricks().

unsigned char* currentBll

Current block library pointer

Definition at line 63 of file grid.c.

Referenced by get_block_library(), init_grid(), and load_grid_bricks().

unsigned char* currentGrid

Current grid pointer

Definition at line 61 of file grid.c.

Referenced by create_grid_map(), init_grid(), and load_grid_bricks().

Number of block libraries

Definition at line 65 of file grid.c.

Referenced by init_grid().


Generated on Thu Sep 18 14:14:48 2008 for Prequengine by  doxygen 1.5.5