00001 /* 00002 Copyright (C) 2003-2004 The Pentagram team 00003 00004 This program is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU General Public License 00006 as published by the Free Software Foundation; either version 2 00007 of the License, or (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License 00015 along with this program; if not, write to the Free Software 00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 */ 00018 00019 #include "pent_include.h" 00020 00021 #include "Palette.h" 00022 #include "IDataSource.h" 00023 #include "Texture.h" 00024 #include <cstring> 00025 00026 namespace Pentagram 00027 { 00028 00029 void Palette::load(IDataSource& ds, IDataSource& xformds) 00030 { 00031 load(ds); 00032 for (int i = 0; i < 256; i++) 00033 xform_untransformed[i] = xformds.read4(); 00034 } 00035 00036 void Palette::load(IDataSource& ds) 00037 { 00038 int i; 00039 ds.read(palette, 768); 00040 00041 // convert from 0-63 to 0-255 palette 00042 for (i = 0; i < 256; i++) 00043 { 00044 palette[i*3] = (palette[i*3]*255)/63; 00045 palette[i*3+1] = (palette[i*3+1]*255)/63; 00046 palette[i*3+2] = (palette[i*3+2]*255)/63; 00047 } 00048 00049 for (i = 0; i < 256; i++) 00050 xform_untransformed[i] = 0; 00051 00052 // Setup the transformation matrix 00053 matrix[0] = 0x800; matrix[1] = 0; matrix[2] = 0; matrix[3] = 0; 00054 matrix[4] = 0; matrix[5] = 0x800; matrix[6] = 0; matrix[7] = 0; 00055 matrix[8] = 0; matrix[9] = 0; matrix[10] = 0x800; matrix[11] = 0; 00056 00057 transform=Transform_None; 00058 } 00059 00060 }