src/spritecache.cpp
changeset 6865 60e668c0ed7c
parent 6856 aa95d0fd29f1
child 6869 cd04f1d7cad7
equal deleted inserted replaced
6864:fc33b39c585f 6865:60e668c0ed7c
   142 		byte *dest = (byte *)AllocSprite(num);
   142 		byte *dest = (byte *)AllocSprite(num);
   143 
   143 
   144 		sc->ptr = dest;
   144 		sc->ptr = dest;
   145 		FioReadBlock(dest, num);
   145 		FioReadBlock(dest, num);
   146 
   146 
   147 		return dest;
   147 		return sc->ptr;
       
   148 	}
       
   149 	/* Ugly hack to work around the problem that the old landscape
       
   150 	 *  generator assumes that those sprites are stored uncompressed in
       
   151 	 *  the memory, and they are only read directly by the code, never
       
   152 	 *  send to the blitter. So do not send it to the blitter (which will
       
   153 	 *  result in a data array in the format the blitter likes most), but
       
   154 	 *  read the data directly from disk and store that as sprite.
       
   155 	 * Ugly: yes. Other solution: no. Blame the original author or
       
   156 	 *  something ;) The image should really have been a data-stream
       
   157 	 *  (so type = 0xFF basicly). */
       
   158 	if (id >= 4845 && id <= 4881) {
       
   159 		uint height = FioReadByte();
       
   160 		uint width  = FioReadWord();
       
   161 		Sprite *sprite;
       
   162 		byte *dest;
       
   163 
       
   164 		num = width * height;
       
   165 		sprite = (Sprite *)AllocSprite(sizeof(*sprite) + num);
       
   166 		sc->ptr = sprite;
       
   167 		sprite->height = height;
       
   168 		sprite->width  = width;
       
   169 		sprite->x_offs = FioReadWord();
       
   170 		sprite->y_offs = FioReadWord();
       
   171 
       
   172 		dest = sprite->data;
       
   173 		while (num > 0) {
       
   174 			int8 i = FioReadByte();
       
   175 			if (i >= 0) {
       
   176 				num -= i;
       
   177 				for (; i > 0; --i) *dest++ = FioReadByte();
       
   178 			} else {
       
   179 				const byte* rel = dest - (((i & 7) << 8) | FioReadByte());
       
   180 				i = -(i >> 3);
       
   181 				num -= i;
       
   182 				for (; i > 0; --i) *dest++ = *rel++;
       
   183 			}
       
   184 		}
       
   185 
       
   186 		return sc->ptr;
   148 	}
   187 	}
   149 
   188 
   150 	SpriteLoaderGrf sprite_loader;
   189 	SpriteLoaderGrf sprite_loader;
   151 	SpriteLoader::Sprite sprite;
   190 	SpriteLoader::Sprite sprite;
   152 
   191