Loading time

BlitzMax Forums/BlitzMax Programming/Loading time

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Okay so here is what I ended up doing to speed up the loading of huge maps in my editor:

' this is a speed optimization, istead of reading each int one at a time
' we read them in in blocks, much faster but we have to deal with the endian stuff
' ourselves
Local temp:Int[] = New Int[mcw]
Local bptr:Byte Ptr = Varptr temp[0]
' cell tile index data
For Local y:Int=0 Until mch
	FlushMem
	mfs.ReadBytes( bptr,mcw*4 )
	For Local x:Int=0 Until mcw
?BigEndian
		Local t ' only do the byte swapping if on a big endian system, file is little endian
		t=bptr[(x*4)];bptr[(x*4)]=bptr[(x*4)+3];bptr[(x*4)+3]=t
		t=bptr[1];bptr[(x*4)+1]=bptr[(x*4)+2];bptr[(x*4)+2]=t
?
		newmap.layers[l].tiles[x,y]=temp[x]
	Next
Next