Dark Bit Factory & Gravity
ARCHIVE => Archive => Cobra => Topic started by: GrahamK on March 13, 2007
-
A new little teaser for you, just to show I'm taking demo coders seriously :||
I've started on a 'bare bones' engine, based around the ptc stuff I've seen in other parts of the forum.. It's pretty basic at the moment, but it runs shocky's raster code reasonably well so far, while still retaining a lot of cobra functionality (as in core functionality, rather than gfx engine functionality).
At present it provides the ability to create frambuffers and read/write to them on a pixel by pixel basis, that's about it at the moment (full keyboard support is in there though).
Here is an example of the raster code:
// RASTER EFFECT BY SHOCKWAVE.
// ---------------------------
// FEBRUARY 2007.
// LAME I KNOW, BUT FROM LITTLE ACORNS ETC....!!!!
// updated to test the use of 'cobramini', a new low level lib for cobra.
//----------------------------------------------------------------------------------------------------------------------------------
PROGRAM USES cobramini, KEYSET
//----------------------------------------------------------------------------------------------------------------------------------
CONST XRES = 640
CONST YRES = 480
VAR
GADD : REAL =0
GADD2: REAL =0
GADD3: REAL =0
v,r,j:integer
//----------------------------------------------------------------------------------------------------------------------------------
PROCEDURE INITIALISE()
BEGIN
OPENSCREEN( XRES , YRES)
END
//----------------------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------------------
// MAIN PROGRAM
//----------------------------------------------------------------------------------------------------------------------------------
VAR
Y : INTEGER
RD,GR,BL : REAL
t1,t2,d:real
frames,fps:integer
ImagePointer:integer
BEGIN
INITIALISE()
frames = 0
t1 = millisecs
WHILE NOT KEYDOWN (VK_ESCAPE)
GADD=GADD+1
GADD2=GADD2+2
GADD3=GADD3+3
if Millisecs-t1< 1000 then
inc(frames)
else
fps = frames
frames = 0
t1 = millisecs
endif
ImagePointer = currentmembuffer
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))
r = ToRGB(rd,gr,bl)
v = ImagePointer + (y*xres*4)
j=xres
asm
@mov eax,[!r]
@mov ecx,[!j]
@mov edi,[!v]
@rep stosd
endasm
NEXT
FLIP
WEND
MessageBox('FPS:'+fps)
END
Nice thing is, it also compiles down much smaller, ok not the 40k you can get with freebasic, 271k which is still a quarter of the usual exe size for cobra.
So, the question is... If I develop this further, what features would you, as demo coders, want in there ? (remembering that I would want to try and keep this as a low level library).
Things on the list so far (note excessive use of the word "simple")
1. Simple sound engine (probably just mod's, maybe wave files)
2. Simple drawing commands (including writing text to a buffer, as that can be a pain)
3. Simple image loader (probably restricted to bmp, or at a push include png)
I've attached the above code as an exe for you to have a look at.
-
That runs at around 540fps here, that's more than acceptable :D
As for what features, I don't just want to spout off a load of things here, I need to think about this, and post back later or tomorrow, but two things that spring to mind immediately are the ability to draw windows fonts and music playability with some way of monitoring the sound levels in the sound channels...
I could see it getting some fans :)
Btw, is this packed already? Upx says it is :)
-
Cobra includes it's own packer as part of it's build.
Working on getting hold of a 'mod' module, not sure on monitoring the sound levels (but I know what you are getting at ;) ) Fonts drawing "shouldn't" be an issue.
But have a good think, I'm not rushing at this, its been more of a diversion at the moment. But I'm willing to put some effort in if it's something people like.
-
Thats way cool, grand job Graham dude.
btw, 413 Fps.
-
Ok, I've included support for XM playback, thanks to the most excellent uFMOD :D
Also added limited text output (no control as yet, just basic text output to screen).
Updated download demo up on the first post....
-
Very cool addition dude, nice going :)
-
That's fantastic!
Nice that the sound and everything is resourced into the exe too :D
Tell me, what are the numbers next to the fps?
There are two in brackets and then a timer..
What are the two numbers in brackets? :)
Thanks!
-
According to the uFmod docs..
The uFMOD_GetStats function returns the current RMS volume coefficients
in L and R channels.
--------------
Return Values:
low-order word : RMS volume in R channel
hi-order word : RMS volume in L channel
Not entirely sure what that means myself, going to have a play around tonight. Kinda looks like its some data that could be used for a vu-meter (or summat!)
-
RMS is sound level then, so ufmod is spitting out a longword with the sound values :D
Sweet. This will make sync very simple with cobra. Nice one Graham.
-
Looks to me like stereo channels, left and right speakers.
-
Yep, that's what Graham said ;)
L + R Channels = Left and Right :)
You'd like this Clyde, you love doing your synced demos, this would be a nice thing for you.
-
Whoah! Now that's faster! :D
Cobra runs most programs very quickly indeed - Shockwave found something it didn't do quite so well. Good idea to try and resolve it Graham - hope the talented guys here can come up with some cool demos and show off what Cobra is capable of - you have to include PNG support though.
-
It should have jpg, png and bmp (fingers crossed), this will also be coming to the sunday cobra patch (in fact, it IS the patch on sunday ;) )
here is another example, using the L-R values...
-
That's almost a cracktro :D
I just noticed that the music isn't resourced inside the exe.. Is it a pain in the arse to one file it?
-
at the moment yeah :(
Saying that, I've been tinkering (again) and I may have an approach soon. Rather than have something 'just' for cobra mini, I want to try and get something more general, as it would be bloody useful for the rest of cobra too :D
I think for demo's it would be a real plus (I guess that is what you are getting at!) so I'll certianly be looking into it.
-
You might want to look at the bin2bas program. It converts a file to a binary representation. You should be able to do something like that in Cobra.
-
I use a version of bin2bas at the moment indeed. It was coded by rbraz and converts a resource file into and array of unsigned bytes. I get along with it just fine, it confuses some people though.
-
it's probably going to end up as
BINARY myfile "filename.something"
with a couple of supporting commands
addr = binaryptr(myfile)
ln = binarylength(myfile)
I'm also thinking about adding "dataptr" to allow access to raw data statements via assembler.
-
I love the sound of this low level stuff. Perhaps Cobra could be 'promoted' to the main set of languages now? ;)
-
I think a few more users are needed first ;)
-
LOL - maybe. But not many developers ask a demo coder what they want - deserves a push in my opinion. Shockwave's decision ofcourse.
-
Ok, last bit of pimpage.... ;)
Here is the latest little demo of the cobramini module..
Added in line drawing, and quad / tri commands from pure2d, allowing some demo's being very easily, while still allowing people to get into the low level stuff.
Now, back to finishing my 20second Intro :D
If I can crack the music, I'll upload it tonight.
-
Nice one GK :)
-
I like :)
-
Codeuerrrr Colourzz! I love that :D I've seen such techniques in 256 byte intros :D
As far as promoting a language here, the main thing that has to govern it is popularity :D If there is enough Cobra interest, we could host the section.. I have a registered copy of Cobra myself so adminning it would not be a problem :)
Graham, I'm looking forward to your entry!
-
On it's way ;)
-
Hehe, looking good :)
-
I've just released this module as part of Cobra's update cycle... So if you've bought a copy of Cobra you will be able to have a mess about with it yourself..
Feel free to suggest updates / new commands. I'm all ears ..
-
I need to have a play with this on the weekend :) Hope I'm not working.