| 1 | /****************************************************************************** |
| 2 | * Arachnoid Graphics Plugin for Mupen64Plus |
| 3 | * http://bitbucket.org/wahrhaft/mupen64plus-video-arachnoid/ |
| 4 | * |
| 5 | * Copyright (C) 2007 Kristofer Karlsson, Rickard Niklasson |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License |
| 9 | * as published by the Free Software Foundation; either version 2 |
| 10 | * of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 20 | *****************************************************************************/ |
| 21 | |
| 22 | #ifndef TEXTURE_LOADER_H_ |
| 23 | #define TEXTURE_LOADER_H_ |
| 24 | |
| 25 | #include "GBIDefs.h" |
| 26 | |
| 27 | //Forward declarations |
| 28 | class Memory; |
| 29 | class RDP; |
| 30 | |
| 31 | //***************************************************************************** |
| 32 | //* TextureImage |
| 33 | //! Used to store information about texture image |
| 34 | //***************************************************************************** |
| 35 | struct TextureImage |
| 36 | { |
| 37 | unsigned int format; |
| 38 | unsigned int size; |
| 39 | unsigned int width; |
| 40 | unsigned int bpl; |
| 41 | unsigned int address; |
| 42 | |
| 43 | //! Constructor |
| 44 | TextureImage() |
| 45 | { |
| 46 | format = size = width = bpl = 0; |
| 47 | address = 0; |
| 48 | } |
| 49 | }; |
| 50 | |
| 51 | //***************************************************************************** |
| 52 | //* RDP Tile |
| 53 | //! Struct used to store information used then loading textures. |
| 54 | //***************************************************************************** |
| 55 | struct RDPTile |
| 56 | { |
| 57 | unsigned int format, size, line, tmem, palette; |
| 58 | |
| 59 | union |
| 60 | { |
| 61 | struct |
| 62 | { |
| 63 | unsigned int mirrort : 1; |
| 64 | unsigned int clampt : 1; |
| 65 | unsigned int pad0 : 30; |
| 66 | unsigned int mirrors : 1; |
| 67 | unsigned int clamps : 1; |
| 68 | unsigned int pad1 : 30; |
| 69 | }; |
| 70 | struct |
| 71 | { |
| 72 | unsigned int cmt, cms; |
| 73 | }; |
| 74 | }; |
| 75 | |
| 76 | //FrameBuffer *frameBuffer; |
| 77 | unsigned int maskt, masks; |
| 78 | unsigned int shiftt, shifts; |
| 79 | float fuls, fult, flrs, flrt; |
| 80 | unsigned int uls, ult, lrs, lrt; |
| 81 | |
| 82 | unsigned int getWidth() { return lrs - uls + 1; } |
| 83 | unsigned int getHeight() { return lrt - ult + 1; } |
| 84 | |
| 85 | //! Constructor |
| 86 | RDPTile() |
| 87 | { |
| 88 | format = size = line = tmem = palette = 0; |
| 89 | maskt = masks = 0; |
| 90 | shiftt = shifts = 0; |
| 91 | fuls = fult = flrs = flrt = 0; |
| 92 | uls = ult = lrs = lrt = 0; |
| 93 | } |
| 94 | }; |
| 95 | |
| 96 | //***************************************************************************** |
| 97 | //* Texture Loader |
| 98 | //! Class for loading texturs from RDRAM to Texture Memory |
| 99 | //***************************************************************************** |
| 100 | class TextureLoader |
| 101 | { |
| 102 | public: |
| 103 | |
| 104 | //Constructor / Destructor |
| 105 | TextureLoader(); |
| 106 | ~TextureLoader(); |
| 107 | |
| 108 | bool initialize(RDP* rdp, Memory* memory); |
| 109 | |
| 110 | //Set Texture Image |
| 111 | void setTextureImage(unsigned int format, unsigned int size, unsigned int width, unsigned int segmentAddress); |
| 112 | |
| 113 | //Set Tile |
| 114 | void setTile(int format, int size, int line, int tmem, int tile, int palette, |
| 115 | int clampS, int clampT, int mirrorS, int mirrorT, int maskS, |
| 116 | int maskT, int shiftS, int shiftT); |
| 117 | |
| 118 | //Set Tile Size |
| 119 | void setTileSize(int tile, unsigned int s0, unsigned int t0, unsigned int s1, unsigned int t1); |
| 120 | |
| 121 | //Load Tile |
| 122 | void loadTile(int tile, int s0, int t0, int s1, int t1); |
| 123 | |
| 124 | //Load Block |
| 125 | void loadBlock(int tile, int s0, int t0, int s1, int t1); |
| 126 | |
| 127 | //Load Texture Look up table |
| 128 | void loadTLUT(int tile, int s0, int t0, int s1, int t1); |
| 129 | |
| 130 | public: |
| 131 | |
| 132 | //! Returns information about current texture image |
| 133 | TextureImage* getTextureImage() { return &m_textureImage; } |
| 134 | |
| 135 | //! Returns previusly loaded tile |
| 136 | RDPTile* getCurrentTile() { return m_currentTile; } |
| 137 | |
| 138 | //! Returns a tile |
| 139 | //! @param tile which of the eight tiles to return. |
| 140 | RDPTile* getTile(unsigned int tile) { return &m_tiles[tile]; } |
| 141 | |
| 142 | private: |
| 143 | |
| 144 | Memory* m_memory; //!< Pointer to Memory Manager |
| 145 | RDP* m_rdp; //!< Pointer to Reality Signal Processor |
| 146 | |
| 147 | //Tiles |
| 148 | RDPTile m_tiles[8]; //!< Eight tiles |
| 149 | RDPTile* m_currentTile; //!< Previusly loaded tile |
| 150 | TextureImage m_textureImage; //!< Texture Image |
| 151 | |
| 152 | }; |
| 153 | |
| 154 | #endif |