ARCHIVE > Cobra
Crappy RGB rasters
Shockwave:
Sorry about this, knocked up quick as a test, but for some reason it runs fucking slow!
I must have done something to screw this up...
--- Code: ---// RASTER EFFECT BY SHOCKWAVE.
// ---------------------------
// FEBRUARY 2007.
// LAME I KNOW, BUT FROM LITTLE ACORNS ETC....!!!! 11
//----------------------------------------------------------------------------------------------------------------------------------
PROGRAM USES PURE2D, KEYSET
//----------------------------------------------------------------------------------------------------------------------------------
CONST XRES = 800
CONST YRES = 600
VAR
GADD : REAL =0
GADD2: REAL =0
GADD3: REAL =0
//----------------------------------------------------------------------------------------------------------------------------------
PROCEDURE INITIALISE()
BEGIN
OPENSCREEN( XRES , YRES)
END
//----------------------------------------------------------------------------------------------------------------------------------
PROCEDURE RASTERS()
VAR
Y : INTEGER
RD,GR,BL : REAL
BEGIN
FOR Y=0 TO YRES-1
RD = 125+((SIN(Y+GADD3)*50)+(COS(Y+GADD2)*50)-(SIN(Y+GADD)*24))
GR = 125+((SIN(Y+GADD2)*50)+(COS(Y+GADD)*50)+(SIN(Y+GADD3)*24))
BL = 125+((SIN(Y+GADD)*50)-(COS(Y+GADD3)*50)-(SIN(Y+GADD2)*24))
LINE (0,Y,XRES,Y,TORGBA(RD,GR,BL,255))
NEXT
END
//----------------------------------------------------------------------------------------------------------------------------------
// MAIN PROGRAM
//----------------------------------------------------------------------------------------------------------------------------------
BEGIN
INITIALISE()
WHILE NOT KEYDOWN (VK_ESCAPE)
GADD=GADD+1
GADD2=GADD2+2
GADD3=GADD3+3
RASTERS()
FLIP
WEND
END
//----------------------------------------------------------------------------------------------------------------------------------
--- End code ---
GrahamK:
150fps here.
Out of interest, what sort of speed would you expect for a routine like this ?
for comparison, A raw loop with just 'cls' under software in cobra will run around 150fps (on this machine)
*Edit* just ported this to be 'cobra2d' friendly (IE. use code which works in software and 2d in 3d mode) Same size, runs at aprox 3000fps using hardware on this machine.
Shockwave:
In software I was looking for somewhere around 500 - 800fps. As they are horizontal lines I was expecting more speed.
Shockwave:
Here is the FB software rendered version, running at about 880 fps.
--- Code: ---' THIS IS WHY COBRA NEEDS >>REAL AND **NOT** FAKE ASM << ALSO TO SHOW HOW FAST
' HORIZONTAL LINES SHOULD BE IN SOFTWARE.
'-------------------------------------------------------------------------------
' REMOVE COMMENT ON LINE BELOW FOR WINDOWED MODE
#DEFINE PTC_WIN
#INCLUDE "TINYPTC.BI"
' ALL VARIABLES MUST BE DECLARED.
' -------------------------------
OPTION STATIC
OPTION EXPLICIT
CONST PI AS DOUBLE = 3.1415926535897932
' SCREEN DIMENSIONS.
' ------------------
CONST XRES = 640:' WIDTH
CONST YRES = 480:' HEIGHT
DECLARE SUB COPERASE()
DIM SHARED AS DOUBLE OLDTIME
DIM SHARED AS INTEGER TICKS
DIM SHARED AS INTEGER FPS
DIM SHARED AS UINTEGER BUFFER ( XRES * YRES )
If( PTC_OPEN( "S!P", XRES, YRES ) = 0 ) Then
End -1
End If
OLDTIME=TIMER
'-------------------------------------------------------------------------------
' THE MAIN LOOP;
'-------------------------------------------------------------------------------
DIM SHARED GADD AS DOUBLE
DIM SHARED GADD2 AS DOUBLE
oldtime = timer
while (1)
gadd=gadd+1
gadd2=gadd2+3
PTC_UPDATE @ BUFFER (0)
COPERASE()
TICKS=TICKS+1
IF TIMER-OLDTIME>=1 THEN
FPS = TICKS
print str(FPS)
TICKS=0
OLDTIME=TIMER
END IF
wend
'-------------------------------------------------------------------------------
' THE MAIN LOOP ENDS HERE.
'-------------------------------------------------------------------------------
SUB COPERASE()
DIM Y AS UINTEGER
DIM PP AS UINTEGER PTR
DIM TCR AS UINTEGER
DIM TCG AS UINTEGER
DIM TCB AS UINTEGER
DIM TC AS INTEGER
DIM SLICE AS UINTEGER
FOR Y=0 TO YRES-1
SLICE=XRES
TCR=160+(45*SIN((y+GADD2)/143)+15*COS((y+GADD)/13)-8*COS((y+GADD2)/29))
TCG=160+(45*SIN((y+GADD2)/133)+15*COS((y+GADD)/13)-8*COS((y+GADD2)/29))
TCB=160+(45*SIN((y+GADD2)/123)+15*COS((y+GADD)/13)-8*COS((y+GADD2)/29))
TC=RGB(TCR,TCG,TCB)
PP = @BUFFER(Y*XRES)
asm
mov eax,dword ptr[TC]
mov ecx, [slice]
mov edi, [PP]
rep stosd
end asm
NEXT
END SUB
--- End code ---
This is why you need to include pointers and asm into cobra.
GrahamK:
Nice, thanks.
And yes, message received and understood.
I'll do some further tuning, and see if / when I can open up the asm side of things.
The main reason for delaying it, is that the current method I have dumps the assembler code right into the stream with the generated assembler, I want to make it a little more 'part' of the language so that it will syntax check it, rather than relying on the final assembler (which doesn't link back to a line number etc.
If you want to have a go 'as it is, warts and all' I'll try and open that functionality in a patch or so's time (won't be this weekend, as I try and code freeze on a thursday for testing).
Navigation
[0] Message Index
[#] Next page
Go to full version