@@ -189,53 +189,57 @@ public void DrawMetaSprite(SpriteCollection spriteCollection, int x, int y, bool
189189 var total = tmpSpritesData . Count ;
190190 var id = 0 ;
191191
192- // When rendering in Tile Mode, switch to grid layout
193- if ( drawMode == DrawMode . Tile )
194- {
195- // TODO added this so C# code isn't corrupted, need to check performance impact
196- if ( tmpIDs . Length != total ) Array . Resize ( ref tmpIDs , total ) ;
197-
198- var i = 0 ;
199-
200- for ( i = 0 ; i < total ; i ++ )
201- {
202- tmpIDs [ i ] = tmpSpritesData [ i ] . Id ;
203- }
204-
205- var width = ( int ) Math . Ceiling ( ( double ) spriteCollection . Bounds . Width / SpriteChip . DefaultSpriteSize ) ;
206-
207- var height = ( int ) Math . Ceiling ( ( double ) total / width ) ;
208-
209- if ( flipH || flipV ) Utilities . FlipPixelData ( ref tmpIDs , width , height , flipH , flipV ) ;
210-
211- // TODO need to offset the bounds based on the scroll position before testing against it
212- for ( i = 0 ; i < total ; i ++ )
213- {
214- // Set the sprite id
215- id = tmpIDs [ i ] ;
216-
217- // TODO should also test that the sprite is not greater than the total sprites (from a cached value)
218- // Test to see if the sprite is within range
219- if ( id > - 1 )
220- {
221- var pos = CalculatePosition ( i , width ) ;
222-
223- DrawSprite (
224- id ,
225- pos . X + x ,
226- pos . Y + y ,
227- flipH ,
228- flipV ,
229- drawMode ,
230- _currentSpriteData . ColorOffset + colorOffset ) ;
231- }
232- }
233- }
234- else
235- {
192+ // // When rendering in Tile Mode, switch to grid layout
193+ // if (drawMode == DrawMode.Tile)
194+ // {
195+ // // TODO added this so C# code isn't corrupted, need to check performance impact
196+ // if (tmpIDs.Length != total) Array.Resize(ref tmpIDs, total);
197+
198+ // var i = 0;
199+
200+ // for (i = 0; i < total; i++)
201+ // {
202+ // tmpIDs[i] = tmpSpritesData[i].Id;
203+ // }
204+
205+ // var width = (int)Math.Ceiling((double)spriteCollection.Bounds.Width / SpriteChip.DefaultSpriteSize);
206+
207+ // var height = (int)Math.Ceiling((double)total / width);
208+
209+ // if (flipH || flipV) Utilities.FlipPixelData(ref tmpIDs, width, height, flipH, flipV);
210+
211+ // // TODO need to offset the bounds based on the scroll position before testing against it
212+ // for (i = 0; i < total; i++)
213+ // {
214+ // // Set the sprite id
215+ // id = tmpIDs[i];
216+
217+ // // TODO should also test that the sprite is not greater than the total sprites (from a cached value)
218+ // // Test to see if the sprite is within range
219+ // if (id > -1)
220+ // {
221+ // var pos = CalculatePosition(i, width);
222+
223+ // DrawSprite(
224+ // id,
225+ // pos.X + x,
226+ // pos.Y + y,
227+ // flipH,
228+ // flipV,
229+ // drawMode,
230+ // _currentSpriteData.ColorOffset + colorOffset);
231+ // }
232+ // }
233+ // }
234+ // else
235+ // {
236236
237237 int startX , startY ;
238238 bool tmpFlipH , tmpFlipV ;
239+
240+ var spriteSize = SpriteChip . DefaultSpriteSize ;
241+ var width = spriteCollection . Bounds . Width ;
242+ var height = spriteCollection . Bounds . Height ;
239243
240244 // Loop through each of the sprites
241245 for ( var i = 0 ; i < total ; i ++ )
@@ -252,16 +256,24 @@ public void DrawMetaSprite(SpriteCollection spriteCollection, int x, int y, bool
252256
253257 if ( flipH )
254258 {
255- startX = spriteCollection . Bounds . Width - startX - SpriteSize ( ) . X ;
259+ startX = width - startX - spriteSize ;
256260 tmpFlipH = ! tmpFlipH ;
257261 }
258262
259263 if ( flipV )
260264 {
261- startY = spriteCollection . Bounds . Height - startY - SpriteSize ( ) . Y ;
265+ startY = height - startY - spriteSize ;
262266 tmpFlipV = ! tmpFlipV ;
263267 }
264268
269+ if ( drawMode == DrawMode . Tile ) {
270+
271+ // Get sprite values
272+ startX = ( int ) Math . Ceiling ( ( double ) startX / spriteSize ) ;
273+ startY = ( int ) Math . Ceiling ( ( double ) startY / spriteSize ) ;
274+
275+ }
276+
265277 startX += x ;
266278 startY += y ;
267279
@@ -276,7 +288,7 @@ public void DrawMetaSprite(SpriteCollection spriteCollection, int x, int y, bool
276288 ) ;
277289 }
278290 }
279- }
291+ // }
280292 }
281293 }
282294}
0 commit comments