B+, Emulators, and ALPHA Sprites!

BlitzPlus Forums/BlitzPlus Programming/B+, Emulators, and ALPHA Sprites!

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.

Yeah, I think you two are correct. Reading pixels is SLOOW. Hmmm...what do you guys think about doing everything in an array or bank? This would be like using system memory to do complex blits and then copying that to the backbuffer??

I may experiment with that. What do you guys think?

Listen, here is what I think...back years and years ago, I could take my 7.14Mhz Amiga 500, read from video memory, and plot sprites at 60 fps. SURELY our 500+ MHz machines nowadays can do it....lol

cb


********** EDIT ****************

Ok, I just coded a short example for array blitting. I am not too impressed. I haven't tried hard but I don't think it could get much faster. Normally, I get 100 FPS (vsync) with a standard cls/flip loop but using this code, I only get 47 fps. Jeesh.

I might forget the alpha blitting for a while. Or just stick with other people's code for the handful of sprites that I will need alpha-blitted.

-cb

;This is a test of advance blits using system memory
;cbmeeks


Const SCR_WIDTH = 640
Const SCR_HEIGHT = 480
Global Timer, FPS_Real, FPS_Temp,FPS


;screen array
Dim Screen(SCR_WIDTH,SCR_HEIGHT)

;graphics
Graphics SCR_WIDTH,SCR_HEIGHT,16,1
SetBuffer BackBuffer()

;clear arrays
Clear(0,128,0)


;main loop
Repeat

	;copy arrays to backbuffer
	LockBuffer
	For y=0 To SCR_HEIGHT-1
		For x=0 To SCR_WIDTH-1
			WritePixelFast x,y,Screen(x,y)
		Next
	Next
	UnlockBuffer
	
	DisplayFPS(0,0)
	
	Flip
	
Until KeyDown(1)



Function Clear(r,g,b)
	Local x,y
	For y=0 To SCR_HEIGHT-1
		For x=0 To SCR_WIDTH-1
			Screen(x,y)=GetRGB(r,g,b)
		Next
	Next
End Function


Function GetRGB% ( Red% , Green% , Blue% )  ; Combines Red, Green and Blue values into one RGB value
	Return Red Shl 16 + Green Shl 8 + Blue
End Function


Function DisplayFPS(x#,y#)
	Color 255,255,255
	If Timer + 1000 <= MilliSecs() Timer = MilliSecs() : FPS_Real = FPS_Temp : FPS_Temp = 0
	FPS_Temp = FPS_Temp + 1 : Text x#,y#,"FPS: " + FPS_Real
End Function