Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

Backgrounds.hpp

00001 /* $Id: Backgrounds.hpp,v 1.1.1.1 2005/04/22 17:18:53 ndsdev Exp $ */
00002 
00003 #ifndef LIBPR_BACKGROUNDS_HPP
00004 #define LIBPR_BACKGROUNDS_HPP
00005 
00006 #ifndef ARM9
00007 #error Video is only available on the ARM9
00008 #endif
00009 
00010 #include <NDS/NDS.h>
00011 
00016 enum TileManagerScreen {
00017   TOP_SCREEN,                   
00018   BOTTOM_SCREEN,                
00019 };
00020 
00025 enum TileManagerColors {
00026   COLORS_16 = BG_16_COLOR,      
00027   COLORS_256 = BG_256_COLOR,    
00028 };
00029 
00037 #define CALCULATE_TILE_MANAGER_COLORS(palette) \
00038 ((sizeof(palette) / sizeof(uint16) > 16) ? COLORS_256 : COLORS_16)
00039 
00044 enum TileErrorCode {
00045   TM_NO_ERROR,                  
00046   TM_TILE_MAP_COLLISION,        
00047   TM_NO_DATA_PREPARED,          
00048   TM_BAD_DATA,                  
00049 };
00050 
00056 class TileManagerBase {
00057 public:
00080   TileManagerBase(TileManagerScreen screen, int tile_index, int map_index,
00081                   TileManagerColors bg_colors, int bg_num);
00082 
00087   virtual ~TileManagerBase();
00088 
00096   virtual uint32 displayCr(void) const;
00097 
00117   virtual TileErrorCode prepare(const uint16* tile_data,
00118                                 uint32 bytes_of_tiles,
00119                                 const uint16* palette_data,
00120                                 uint32 bytes_of_palette);
00134   virtual TileErrorCode load(void);
00135 
00143   uint16* map(void);
00144 
00145 protected:
00159   TileErrorCode loadTileData(const uint16* data, uint32 bytes_of_data);
00160 
00169   TileErrorCode loadPalette(const uint16* data, uint32 bytes_of_data);
00170 
00183   uint16* copy16(uint16* dest, const uint16* src, uint32 bytes_of_data);
00184 
00190   TileManagerScreen _bg_screen;
00191 
00196   int _tile_index;
00197 
00202   int _map_index;
00203 
00208   int _bg_num;
00209 
00216   TileManagerColors _bg_colors;
00217 
00222   uint16* _bg_tiles;
00223 
00229   uint16* _bg_map;
00230 
00236   uint16* _bg_palette;
00237 
00243   const uint16* _bg_tile_data;
00244 
00249   uint32  _bg_tile_data_size;
00250 
00256   const uint16* _bg_palette_data;
00257 
00262   uint32  _bg_palette_data_size;
00263 };
00264 
00283 class BackgroundMap : public TileManagerBase {
00289   typedef TileManagerBase inherited;
00290 public:
00295   BackgroundMap(TileManagerScreen screen, int tile_index, int map_index,
00296                 TileManagerColors bg_colors, int bg_num = 0);
00297 
00310   TileErrorCode load(const uint16* bg_map = 0);
00311 };
00312 
00336 class TileMap : public TileManagerBase {
00342   typedef TileManagerBase inherited;
00343 public:
00348   TileMap(TileManagerScreen screen, int tile_index, int map_index,
00349           TileManagerColors bg_colors, int bg_num = 1);
00350 };
00351 
00357 class TextMap : public TileManagerBase {
00363   typedef TileManagerBase inherited;
00364 public:
00369   TextMap(TileManagerScreen screen, int tile_index, int map_index,
00370           TileManagerColors bg_colors, int bg_num = 2);
00371 
00397   TileErrorCode prepare(const uint16* font_data, uint32 bytes_of_fonts,
00398                         const uint16* font_palette, uint32 bytes_of_palette,
00399                         int font_width, int font_height);
00400 
00415   TileErrorCode load(void);
00416 
00421   void clear(void);
00422 
00429   int screenWidth(void) const;
00430 
00437   int screenHeight(void) const;
00438 
00445   void setForegroundColor(uint16 color);
00446 
00453   void setBackgroundColor(uint16 color);
00454 
00466   TileErrorCode setCursorPosition(int x, int y);
00467 
00472   int xPos(void) const;
00473 
00478   int yPos(void) const;
00479 
00486   TextMap& operator<<(const char* msg);
00487 
00494   TextMap& operator<<(char c);
00495 
00502   TextMap& operator<<(uint32 n);
00503 
00510   TextMap& operator<<(int32 n);
00511 
00512   //protected:
00519   void writeString(const char* text);
00520 
00521   int _font_width;      
00522   int _font_height;     
00523 
00524   int _font_tile_width; 
00525   int _font_tile_height;
00526 
00527   int _font_tiles;      
00528 
00529   int _screen_width;    
00530   int _screen_height;   
00531 
00532   int _cur_x;           
00533   int _cur_y;           
00534 
00535   int _radix;           
00536   bool _showbase;       
00537 
00538   int _tab_size;        
00539 };
00540 
00541 #endif

Generated on Fri Apr 22 13:47:42 2005 for PhoenixRising NDS Library by doxygen 1.3.6