Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * OpenTyrian: A modern cross-platform port of Tyrian
  3.  * Copyright (C) 2007-2009  The OpenTyrian Development Team
  4.  *
  5.  * This program is free software; you can redistribute it and/or
  6.  * modify it under the terms of the GNU General Public License
  7.  * as published by the Free Software Foundation; either version 2
  8.  * of the License, or (at your option) any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  18.  */
  19. #ifndef SPRITE_H
  20. #define SPRITE_H
  21.  
  22. #include "opentyr.h"
  23.  
  24. #include "SDL.h"
  25.  
  26. #include <assert.h>
  27. #include <stdio.h>
  28.  
  29. #define FONT_SHAPES       0
  30. #define SMALL_FONT_SHAPES 1
  31. #define TINY_FONT         2
  32. #define PLANET_SHAPES     3
  33. #define FACE_SHAPES       4
  34. #define OPTION_SHAPES     5 /*Also contains help shapes*/
  35. #define WEAPON_SHAPES     6
  36. #define EXTRA_SHAPES      7 /*Used for Ending pics*/
  37.  
  38. #define SPRITE_TABLES_MAX        8
  39. #define SPRITES_PER_TABLE_MAX  151
  40.  
  41. typedef struct
  42. {
  43.         Uint16 width, height;
  44.         Uint16 size;
  45.         Uint8 *data;
  46. }
  47. Sprite;
  48.  
  49. typedef struct
  50. {
  51.         unsigned int count;
  52.         Sprite sprite[SPRITES_PER_TABLE_MAX];
  53. }
  54. Sprite_array;
  55.  
  56. extern Sprite_array sprite_table[SPRITE_TABLES_MAX];
  57.  
  58. static inline Sprite *sprite( unsigned int table, unsigned int index )
  59. {
  60.         assert(table < COUNTOF(sprite_table));
  61.         assert(index < COUNTOF(sprite_table->sprite));
  62.         return &sprite_table[table].sprite[index];
  63. }
  64.  
  65. static inline bool sprite_exists( unsigned int table, unsigned int index )
  66. {
  67.         return (sprite(table, index)->data != NULL);
  68. }
  69. static inline Uint16 get_sprite_width( unsigned int table, unsigned int index )
  70. {
  71.         return (sprite_exists(table, index) ? sprite(table, index)->width : 0);
  72. }
  73. static inline Uint16 get_sprite_height( unsigned int table, unsigned int index )
  74. {
  75.         return (sprite_exists(table, index) ? sprite(table, index)->height : 0);
  76. }
  77.  
  78. void load_sprites_file( unsigned table, const char *filename );
  79. void load_sprites( unsigned int table, FILE *f );
  80. void free_sprites( unsigned int table );
  81.  
  82. void blit_sprite( SDL_Surface *, int x, int y, unsigned int table, unsigned int index ); // JE_newDrawCShapeNum
  83. void blit_sprite_blend( SDL_Surface *, int x, int y, unsigned int table, unsigned int index ); // JE_newDrawCShapeTrick
  84. void blit_sprite_hv_unsafe( SDL_Surface *, int x, int y, unsigned int table, unsigned int index, Uint8 hue, Sint8 value ); // JE_newDrawCShapeBright
  85. void blit_sprite_hv( SDL_Surface *, int x, int y, unsigned int table, unsigned int index, Uint8 hue, Sint8 value ); // JE_newDrawCShapeAdjust
  86. void blit_sprite_hv_blend( SDL_Surface *, int x, int y, unsigned int table, unsigned int index, Uint8 hue, Sint8 value ); // JE_newDrawCShapeModify
  87. void blit_sprite_dark( SDL_Surface *, int x, int y, unsigned int table, unsigned int index, bool black ); // JE_newDrawCShapeDarken, JE_newDrawCShapeShadow
  88.  
  89. typedef struct
  90. {
  91.         unsigned int size;
  92.         Uint8 *data;
  93. }
  94. Sprite2_array;
  95.  
  96. extern Sprite2_array eShapes[6];
  97. extern Sprite2_array shapesC1, shapes6, shapes9, shapesW2;
  98.  
  99. void JE_loadCompShapes( Sprite2_array *, JE_char s );
  100. void JE_loadCompShapesB( Sprite2_array *, FILE *f );
  101. void free_sprite2s( Sprite2_array * );
  102.  
  103. void blit_sprite2( SDL_Surface *, int x, int y, Sprite2_array, unsigned int index );
  104. void blit_sprite2_blend( SDL_Surface *,  int x, int y, Sprite2_array, unsigned int index );
  105. void blit_sprite2_darken( SDL_Surface *, int x, int y, Sprite2_array, unsigned int index );
  106. void blit_sprite2_filter( SDL_Surface *, int x, int y, Sprite2_array, unsigned int index, Uint8 filter );
  107.  
  108. void blit_sprite2x2( SDL_Surface *, int x, int y, Sprite2_array, unsigned int index );
  109. void blit_sprite2x2_blend( SDL_Surface *, int x, int y, Sprite2_array, unsigned int index );
  110. void blit_sprite2x2_darken( SDL_Surface *, int x, int y, Sprite2_array, unsigned int index );
  111.  
  112. void JE_loadMainShapeTables( const char *shpfile );
  113. void free_main_shape_tables( void );
  114.  
  115. #endif // SPRITE_H
  116.  
  117.